52 lines
1.8 KiB
C++
52 lines
1.8 KiB
C++
#pragma once
|
|
#include "adminive/value.hpp"
|
|
#include <concepts>
|
|
#include <optional>
|
|
#include <string>
|
|
#include <string_view>
|
|
#include <type_traits>
|
|
namespace adminive {
|
|
template <class T>
|
|
concept String_Type = std::same_as<std::remove_cvref_t<T>, std::string>;
|
|
template <class T>
|
|
concept String_View_Type = std::same_as<std::remove_cvref_t<T>, std::string_view>;
|
|
template <class T>
|
|
struct Is_Optional : std::false_type {};
|
|
template <class T>
|
|
struct Is_Optional<std::optional<T>> : std::true_type {
|
|
using value_type = T;
|
|
};
|
|
template <class T>
|
|
concept Optional_Type = Is_Optional<std::remove_cvref_t<T>>::value;
|
|
template <Optional_Type T>
|
|
using Optional_Value_Type = typename Is_Optional<std::remove_cvref_t<T>>::value_type;
|
|
template <class T>
|
|
struct Optional_Unwrapped {
|
|
using type = std::remove_cvref_t<T>;
|
|
};
|
|
template <class T>
|
|
struct Optional_Unwrapped<std::optional<T>> {
|
|
using type = T;
|
|
};
|
|
template <class T>
|
|
using Optional_Unwrapped_Type = typename Optional_Unwrapped<std::remove_cvref_t<T>>::type;
|
|
template <class T>
|
|
concept Container_Like_Type = requires(T value) {
|
|
typename std::remove_cvref_t<T>::value_type;
|
|
value.begin();
|
|
value.end();
|
|
} && !String_Type<T> && !String_View_Type<T> && !Optional_Type<T>;
|
|
template <class T>
|
|
concept Json_Scalar_Type = std::same_as<Unwrapped_Value_Type<T>, bool> || std::integral<Unwrapped_Value_Type<T>> || std::floating_point<Unwrapped_Value_Type<T>> || String_Type<Unwrapped_Value_Type<T>> || String_View_Type<Unwrapped_Value_Type<T>> || std::is_enum_v<Unwrapped_Value_Type<T>>;
|
|
template <class Validator>
|
|
concept Multiple_Of_Validator = requires {
|
|
{ Validator::multiple_of };
|
|
};
|
|
template <class Validator>
|
|
concept Validator_With_Message = requires {
|
|
{ Validator::message } -> std::convertible_to<std::string_view>;
|
|
};
|
|
template <class>
|
|
inline constexpr bool Always_False = false;
|
|
}
|