aboutsummaryrefslogtreecommitdiff
path: root/devel/sfml/files/patch-include_SFML_System_String.hpp
blob: ae79639bd4a20509aa83162179e2d25d415d5359 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
--- include/SFML/System/String.hpp.orig	2023-10-30 00:03:26 UTC
+++ include/SFML/System/String.hpp
@@ -35,6 +35,131 @@
 #include <string>
 
 
+namespace std
+{
+
+namespace // anonymous
+{
+
+template<class CharType, class IntType, IntType EOFVal>
+struct char_traits_base
+{
+    using char_type  = CharType;
+    using int_type   = IntType;
+    using off_type   = streamoff;
+    using pos_type   = fpos<mbstate_t>;
+    using state_type = mbstate_t;
+
+    static inline constexpr void assign(char_type& c1, const char_type& c2) noexcept
+    {
+        c1 = c2;
+    }
+
+    static inline constexpr bool eq(char_type c1, char_type c2) noexcept
+    {
+        return c1 == c2;
+    }
+
+    static inline constexpr bool lt(char_type c1, char_type c2) noexcept
+    {
+        return c1 < c2;
+    }
+
+    static constexpr int compare(const char_type* lhs, const char_type* rhs, size_t count) noexcept
+    {
+        for (; count; --count, ++lhs, ++rhs)
+        {
+            if (lt(*lhs, *rhs))
+                return -1;
+            if (lt(*rhs, *lhs))
+                return 1;
+        }
+        return 0;
+    }
+
+    static inline size_t constexpr length(const char_type* s) noexcept
+    {
+        size_t i = 0;
+        for (; s[i] != '\0'; ++i)
+        {
+        }
+        return i;
+    }
+
+    static constexpr const char_type* find(const char_type* s, size_t n, const char_type& a) noexcept
+    {
+        for (; n; --n)
+        {
+            if (*s == a)
+                return s;
+            ++s;
+        }
+        return nullptr;
+    }
+
+    static inline char_type* move(char_type* s1, const char_type* s2, size_t n) noexcept
+    {
+        return reinterpret_cast<char_type*>(__builtin_memmove(s1, s2, n * sizeof(char_type)));
+    }
+
+    static inline char_type* copy(char_type* s1, const char_type* s2, size_t n) noexcept
+    {
+        __builtin_memmove(s1, s2, n * sizeof(char_type));
+        return s1;
+    }
+
+    static inline char_type* assign(char_type* s, size_t n, char_type a) noexcept
+    {
+        std::fill_n(s, n, a);
+        return s;
+    }
+
+    static inline constexpr int_type not_eof(int_type c) noexcept
+    {
+        return eq_int_type(c, eof()) ? ~eof() : c;
+    }
+
+    static inline constexpr char_type to_char_type(int_type c) noexcept
+    {
+        return char_type(c);
+    }
+
+    static inline constexpr int_type to_int_type(char_type c) noexcept
+    {
+        return int_type(c);
+    }
+
+    static inline constexpr bool eq_int_type(int_type c1, int_type c2) noexcept
+    {
+        return c1 == c2;
+    }
+
+    static inline constexpr int_type eof() noexcept
+    {
+        return int_type(EOF);
+    }
+};
+
+} // namespace anonymous
+
+template<>
+struct char_traits<unsigned char> : char_traits_base<unsigned char, unsigned int, static_cast<unsigned int>(EOF)>
+{
+};
+
+template<>
+struct char_traits<unsigned short> : char_traits_base<unsigned short, unsigned int, static_cast<unsigned int>(0xFFFF)>
+{
+};
+
+template<>
+struct char_traits<unsigned int> : char_traits_base<unsigned int, unsigned int, static_cast<unsigned int>(0xFFFFFFFF)>
+{
+};
+
+} // namespace std
+
+
 namespace sf
 {
 ////////////////////////////////////////////////////////////