diff --git a/include/ss/converter.hpp b/include/ss/converter.hpp index 9adc536..f2e0433 100644 --- a/include/ss/converter.hpp +++ b/include/ss/converter.hpp @@ -1,17 +1,4 @@ #pragma once - -// TODO remove -#include -#ifndef DBG -void log(const std::string& log) { - std::cout << log << std::endl; -} -#else -void log(const std::string&) { -} -#endif -// -// #include "extract.hpp" #include "function_traits.hpp" #include "restrictions.hpp" @@ -20,10 +7,6 @@ void log(const std::string&) { #include #include -constexpr auto space = '_'; -constexpr auto escaping = true; -constexpr auto quote = '"'; - namespace ss { INIT_HAS_METHOD(tied); INIT_HAS_METHOD(ss_valid); @@ -122,29 +105,368 @@ constexpr bool tied_class_v = tied_class::value; // the error can be set inside a string, or a bool enum class error_mode { error_string, error_bool }; +//////////////////////////////////////////////////////// +//////////////////////////////////////////////////////// +//////////////////////////////////////////////////////// +//////////////////////////////////////////////////////// + +/////////////////////////////////////////////////////////////////////////////// +template +struct matcher { +private: + template + static bool match_impl(char c) { + if constexpr (sizeof...(Xs) != 0) { + return (c == X) || match_impl(c); + } + return (c == X); + } + +public: + static bool match(char c) { + return match_impl(c); + } + constexpr static bool enabled = true; +}; + +template <> +class matcher<'\0'> { +public: + constexpr static bool enabled = false; + static bool match(char c) = delete; +}; + +//////////////// +// is instance of +//////////////// + +template class Template> +struct is_instance_of_char { + constexpr static bool value = false; +}; + +template class Template> +struct is_instance_of_char, Template> { + constexpr static bool value = true; +}; + +/////////////////////////////////////////////////// + +template +struct quote : matcher {}; + +template +struct trim : matcher {}; + +template +struct escape : matcher {}; + +///////////////////////////////////////////////// +// -> type traits +template +struct if_then_else; + +template +struct if_then_else { + using type = T; +}; + +template +struct if_then_else { + using type = U; +}; + +////////////////////////////////////////////// +template