From 7a34f2b93dcf5791e5e9c090f4e4778fa43d2314 Mon Sep 17 00:00:00 2001 From: Igor Zarzycki Date: Thu, 22 Aug 2024 01:06:14 +0200 Subject: [PATCH] Add suppert for ISO/IEC 8859-1 encoding in isupper function acting on values. --- include/crap/locale.d/isuppervalue.h | 151 +++++++++++++++++++++++++++ 1 file changed, 151 insertions(+) diff --git a/include/crap/locale.d/isuppervalue.h b/include/crap/locale.d/isuppervalue.h index 0f6f79c..f859f80 100644 --- a/include/crap/locale.d/isuppervalue.h +++ b/include/crap/locale.d/isuppervalue.h @@ -7,6 +7,7 @@ #include "locale.h" #include "../utility.d/cmpgreaterequalvalue.h" #include "../utility.d/cmplessequalvalue.h" +#include "../version.d/libintegralconstantcallable.h" namespace crap { @@ -16,6 +17,156 @@ namespace crap : std :: integral_constant :: value) && (cmpLessEqualValue :: value)> {}; + + template struct isupperValue + { + private: + //Encoding detectors. + template struct encoding; + template struct encoding : std :: integral_constant {}; + template struct encoding : std :: integral_constant {}; + template struct encoding : std :: integral_constant {}; + template struct encoding : std :: integral_constant {}; + template struct encoding : std :: integral_constant {}; + template struct encoding : std :: integral_constant {}; + template struct encoding : std :: integral_constant {}; + template struct encoding : std :: integral_constant {}; + template struct encoding : std :: integral_constant {}; + template struct encoding : std :: integral_constant {}; + template struct encoding : std :: integral_constant {}; + template struct encoding : std :: integral_constant {}; + template struct encoding : std :: integral_constant {}; + template struct encoding : std :: integral_constant {}; + template struct encoding : std :: integral_constant {}; + template struct encoding : std :: integral_constant {}; + template struct encoding : std :: integral_constant {}; + template struct encoding : std :: integral_constant {}; + template struct encoding : std :: integral_constant {}; + template struct encoding : std :: integral_constant {}; + template struct encoding : std :: integral_constant {}; + template struct encoding : std :: integral_constant {}; + template struct encoding : std :: integral_constant {}; + template struct encoding : std :: integral_constant {}; + template struct encoding : std :: integral_constant {}; + template struct encoding : std :: integral_constant {}; + template struct encoding : std :: integral_constant {}; + template struct encoding : std :: integral_constant {}; + template struct encoding : std :: integral_constant {}; + template struct encoding : std :: integral_constant {}; + template struct encoding : std :: integral_constant {}; + template struct encoding : std :: integral_constant {}; + template struct encoding : std :: integral_constant {}; + template struct encoding : std :: integral_constant {}; + template struct encoding : std :: integral_constant {}; + template struct encoding : std :: integral_constant {}; + template struct encoding : std :: integral_constant {}; + template struct encoding : std :: integral_constant {}; + template struct encoding : std :: integral_constant {}; + template struct encoding : std :: integral_constant {}; + template struct encoding : std :: integral_constant {}; + template struct encoding : std :: integral_constant {}; + template struct encoding : std :: integral_constant {}; + template struct encoding : std :: integral_constant {}; + template struct encoding : std :: integral_constant {}; + template struct encoding : std :: integral_constant {}; + template struct encoding : std :: integral_constant {}; + template struct encoding : std :: integral_constant {}; + template struct encoding : std :: integral_constant {}; + template struct encoding : std :: integral_constant {}; + template struct encoding : std :: integral_constant {}; + template struct encoding : std :: integral_constant {}; + template struct encoding : std :: integral_constant {}; + template struct encoding : std :: integral_constant {}; + template struct encoding : std :: integral_constant {}; + template struct encoding : std :: integral_constant {}; + template struct encoding : std :: integral_constant {}; + template struct encoding : std :: integral_constant {}; + template struct encoding : std :: integral_constant {}; + template struct encoding : std :: integral_constant {}; + template struct encoding : std :: integral_constant {}; + template struct encoding : std :: integral_constant {}; + template struct encoding : std :: integral_constant {}; + template struct encoding : std :: integral_constant {}; + template struct encoding : std :: integral_constant {}; + template struct encoding : std :: integral_constant {}; + template struct encoding : std :: integral_constant {}; + template struct encoding : std :: integral_constant {}; + template struct encoding : std :: integral_constant {}; + template struct encoding : std :: integral_constant {}; + template struct encoding : std :: integral_constant {}; + template struct encoding : std :: integral_constant {}; + template struct encoding : std :: integral_constant {}; + template struct encoding : std :: integral_constant {}; + template struct encoding : std :: integral_constant {}; + template struct encoding : std :: integral_constant {}; + template struct encoding : std :: integral_constant {}; + template struct encoding : std :: integral_constant {}; + template struct encoding : std :: integral_constant {}; + template struct encoding : std :: integral_constant {}; + template struct encoding : std :: integral_constant {}; + template struct encoding : std :: integral_constant {}; + template struct encoding : std :: integral_constant {}; + template struct encoding : std :: integral_constant {}; + template struct encoding : std :: integral_constant {}; + template struct encoding : std :: integral_constant {}; + template struct encoding : std :: integral_constant {}; + template struct encoding : std :: integral_constant {}; + template struct encoding : std :: integral_constant {}; + template struct encoding : std :: integral_constant {}; + template struct encoding : std :: integral_constant {}; + template struct encoding : std :: integral_constant {}; + template struct encoding : std :: integral_constant {}; + template struct encoding : std :: integral_constant {}; + template struct encoding : std :: integral_constant {}; + //Implementations based on detected encoding. + template struct Implementation; + template struct Implementation<0/*ASCII*/, Empty...>; + template struct Implementation<1/*ISO/IEC 8859-1*/, Empty...>; + public: + constexpr const static bool value = Implementation :: value> :: value; + using value_type = decltype(value); + constexpr operator value_type () const noexcept; +#if (crap_lib_integral_constant_callable >= 201304L) + constexpr value_type operator () () const noexcept; +#endif + }; + + template template + struct isupperValue :: Implementation<0 /*ASCII*/, Empty...> + { + constexpr const static bool value = + (cmpGreaterEqualValue :: value) + && (cmpLessEqualValue :: value); + }; + + template template + struct isupperValue :: Implementation<1 /*ISO/IEC 8859-1*/, Empty...> + { + constexpr const static bool value = + ((cmpGreaterEqualValue :: value) + && (cmpLessEqualValue :: value)) + || + ((cmpGreaterEqualValue :: value) + && (cmpLessEqualValue :: value)) + || + ((cmpGreaterEqualValue :: value) + && (cmpLessEqualValue :: value)); + }; +} +template +inline constexpr crap :: isupperValue :: operator +typename crap :: isupperValue :: value_type () const noexcept +{ + return crap :: isupperValue :: value; } +#if (crap_lib_integral_constant_callable >= 201304L) + +template +inline constexpr typename crap :: isupperValue :: value_type +crap :: isupperValue :: operator () () const noexcept +{ + return crap :: isupperValue :: value; +} +#endif #endif