acme
Foundational cross-platform layer of the ca2 framework
Loading...
Searching...
No Matches
__begin.h
1#pragma once
2
3
4#include "c/_.h"
5#include "sz/_.h"
6//#include <assert.h>
7
8namespace comparison
9{
10
11
12 template < typename TYPE >
14 {
15 public:
16
17
18 using EQUALITY = for_type < TYPE >;
19 using ORDERING = for_type < TYPE >;
20
21 constexpr bool equals(const TYPE & a, const TYPE & b) const { return a.case_insensitive_equals(b); }
22 constexpr ::std::strong_ordering order(const TYPE & a, const TYPE & b) const { return a.case_insensitive_order(b); }
23
24
25 };
26
27
28 template < prototype_character CHARACTER >
30 {
31 public:
32
33
34 using EQUALITY = for_type < CHARACTER >;
35 using ORDERING = for_type < CHARACTER >;
36
37 constexpr bool equals(CHARACTER a, CHARACTER b) const { return character_tolower(a) == character_tolower(b); }
38 constexpr ::std::strong_ordering order(CHARACTER a, CHARACTER b) const { return character_tolower(a) <=> character_tolower(b); }
39
40
41 };
42
43
44} // namespace comparison
45
46
47
48//template < prototype_character CHARACTER >
49//constexpr bool ::comparison::comparison(CHARACTER a, CHARACTER b)
50//{
51//
52// return a == b;
53//
54//}
55
56
57
58//template < prototype_character CHARACTER >
59//constexpr ::std::strong_ordering compare_character(CHARACTER a, CHARACTER b)
60//{
61//
62// return a <=> b;
63//
64//}
65
66//
67//template < prototype_character CHARACTER >
68//constexpr bool case_insensitive_equals_character(CHARACTER a, CHARACTER b)
69//{
70//
71// return character_tolower(a) == character_tolower(b);
72//
73//}
74//
75//
76//
77//template < prototype_character CHARACTER >
78//constexpr ::std::strong_ordering case_insensitive_compare_character(CHARACTER a, CHARACTER b)
79//{
80//
81// return character_tolower(a) <=> character_tolower(b);
82//
83//}
84
85
86
87constexpr ::i8 __digit(::i32 digit)
88{
89
90 return "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"[digit];
91
92}
93
94
95constexpr ::i32_bool utf16_is_1st_surrogate(::wd16_character _1stSurrogateCandidate) { return (_1stSurrogateCandidate & 0xfc00) == 0xd800; } // Sober Surrogay (Told Hi)
96constexpr ::i32_bool utf16_is_2nd_surrogate(::wd16_character _2ndSurrogateCandidate) { return (_2ndSurrogateCandidate & 0xfc00) == 0xdc00; } // Marginal Surro-G (Told Lo, but much more drunk)
97constexpr ::i32_bool utf16_is_surrogate(::wd16_character uc) { return utf16_is_1st_surrogate(uc) || utf16_is_2nd_surrogate(uc); }
98constexpr ::i32_bool utf32_is_surrogated(::u32 character) { return 0x10000 <= character && character <= 0x10FFFF; }
99constexpr ::u32 decode_utf16_pair(::u16* units)
100{
101 ::u32 code;
102 ASSERT(utf16_is_1st_surrogate(units[0]));
103 ASSERT(utf16_is_2nd_surrogate(units[1]));
104 code = 0x10000;
105 code += (units[0] & 0x03FF) << 10;
106 code += (units[1] & 0x03FF);
107 return code;
108}
109constexpr ::wd32_character utf16_surrogate_to_utf32(::wd16_character _1stSurrogateCandidate, ::wd16_character _2ndSurrogateCandidate) { return (_1stSurrogateCandidate << 10) + _2ndSurrogateCandidate - 0x35fdc00; }
110
111
112
113
114
Definition aaa_character.h:10
Definition __begin.h:14