8template <
typename Type>
9concept IntegerT = std::same_as<Type, std::int64_t> || std::same_as<Type, std::int32_t>;
11template <
typename Type>
12concept UnsignedT = std::same_as<Type, std::uint64_t> || std::same_as<Type, std::uint32_t>;
14template <
typename Type>
15concept FloatT = std::same_as<Type, float> || std::same_as<Type, double>;
17template <
typename Type>
21template <
typename Type>
26 [[nodiscard]]
static constexpr auto type_name() -> std::string_view {
return "bool"; }
27 [[nodiscard]]
static auto parse(std::string_view in,
bool& out) -> bool;
28 [[nodiscard]]
static auto to_string(
bool const value) -> std::string {
return value ?
"true" :
"false"; }
33 [[nodiscard]]
static constexpr auto type_name() -> std::string_view {
return "string"; }
34 [[nodiscard]]
static auto parse(std::string_view in, std::string& out) -> bool;
35 [[nodiscard]]
static auto to_string(std::string_view
const value) -> std::string {
return std::string{value}; }
38template <NumberT Type>
40 [[nodiscard]]
static constexpr auto type_name() -> std::string_view {
50 [[nodiscard]]
static auto parse(std::string_view
const in, Type& out) ->
bool {
51 char const* end = in.data() + in.size();
52 auto const [ptr, ec] = std::from_chars(in.data(), end, out);
53 return ec == std::errc{} && ptr == end;
56 [[nodiscard]]
static auto to_string(Type
const value) -> std::string {
return std::format(
"{}", value); }
59template <NumberT Type>
61 [[nodiscard]]
static constexpr auto type_name() -> std::string_view {
71 [[nodiscard]]
static auto parse(std::string_view
const in, glm::tvec2<Type>& out) ->
bool {
72 auto const i = in.find(
'x');
73 if (i == std::string_view::npos) {
return false; }
79 [[nodiscard]]
static auto to_string(glm::tvec2<Type>
const value) -> std::string {
return std::format(
"{}x{}", value.x, value.y); }
static auto to_string(Type const value) -> std::string
Definition parser.hpp:56
static constexpr auto type_name() -> std::string_view
Definition parser.hpp:40
static auto parse(std::string_view const in, Type &out) -> bool
Definition parser.hpp:50
static constexpr auto type_name() -> std::string_view
Definition parser.hpp:26
static auto to_string(bool const value) -> std::string
Definition parser.hpp:28
static auto parse(std::string_view in, bool &out) -> bool
static auto to_string(glm::tvec2< Type > const value) -> std::string
Definition parser.hpp:79
static auto parse(std::string_view const in, glm::tvec2< Type > &out) -> bool
Definition parser.hpp:71
static constexpr auto type_name() -> std::string_view
Definition parser.hpp:61
static auto parse(std::string_view in, std::string &out) -> bool
static auto to_string(std::string_view const value) -> std::string
Definition parser.hpp:35
static constexpr auto type_name() -> std::string_view
Definition parser.hpp:33
Customization point. Specialize this type for custom Tweakable template types.
Definition parser.hpp:22