LeviLamina
Loading...
Searching...
No Matches
Serializer.h
1
#pragma once
2
#include "ll/api/reflection/ReflectionError.h"
3
#include "ll/api/utils/StringUtils.h"
4
#include <type_traits>
5
6
namespace
ll::reflection {
7
8
template
<
typename
T,
typename
J =
void
>
9
struct
Serializer
{};
10
11
template
<>
12
struct
Serializer
<bool> {
13
static
std::string to_string(
bool
t) {
return
t ?
"true"
:
"false"
; }
14
static
ll::Expected<bool> from_string(std::string_view s) {
return
ll::string_utils::svtobool(s); }
15
};
16
17
template
<
typename
T>
18
requires
(std::is_arithmetic_v<T> && !std::is_same_v<T, bool> && !traits::is_char_v<T>)
19
struct
Serializer<T>
{
20
static
std::string to_string(T t) {
return
fmt::to_string(t); }
21
static
ll::Expected<T> from_string(std::string_view s) {
return
ll::string_utils::svtonum<T>(s); }
22
};
23
24
}
// namespace ll::reflection
ll::reflection::Serializer
Definition
Serializer.h:9
src
ll
api
reflection
Serializer.h
Generated on
for LeviLamina by
1.16.1