6 #ifndef PDFTRON_H_CPPCommonCharTraits
7 #define PDFTRON_H_CPPCommonCharTraits
9 #if defined(__apple_build_version__) && __apple_build_version__ >= 17000013
21 struct char_traits<pdftron::
UInt32>
24 using int_type =
unsigned int;
25 using off_type = std::streamoff;
26 using pos_type = std::fpos<std::mbstate_t>;
27 using state_type = std::mbstate_t;
29 #if __cplusplus >= 201703L
30 static constexpr
void assign(char_type& left,
const char_type& right) noexcept
31 #elif __cplusplus >= 201103L
32 static void assign(char_type& left,
const char_type& right) noexcept
34 static void assign(char_type& left,
const char_type& right)
40 #if __cplusplus >= 202002L
41 static constexpr char_type* assign(char_type*
const first, std::size_t count,
const char_type c)
43 static char_type* assign(char_type*
const first, std::size_t count,
const char_type c)
46 for (char_type* next = first; count > 0; --count, ++next)
54 #if __cplusplus >= 201103L
55 static constexpr
bool eq(
const char_type left,
const char_type right) noexcept
57 static bool eq(
const char_type left,
const char_type right)
63 #if __cplusplus >= 201103L
64 static constexpr
bool lt(
const char_type left,
const char_type right) noexcept
66 static bool lt(
const char_type left,
const char_type right)
72 #if __cplusplus >= 202002L
73 static constexpr char_type* move(char_type*
const dst,
const char_type*
const src,
const std::size_t count)
75 static char_type* move(char_type*
const dst,
const char_type*
const src,
const std::size_t count)
78 ::memmove(dst, src, count *
sizeof(char_type));
82 #if __cplusplus >= 202002L
83 static constexpr char_type* copy(char_type*
const dst,
const char_type*
const src,
const std::size_t count)
85 static char_type* copy(char_type*
const dst,
const char_type*
const src,
const std::size_t count)
88 ::memcpy(dst, src, count *
sizeof(char_type));
92 #if __cplusplus >= 201703L
93 static constexpr
int compare(
const char_type* left,
const char_type* right, std::size_t count)
95 static int compare(
const char_type* left,
const char_type* right, std::size_t count)
98 for (; count > 0; --count, ++left, ++right)
100 if (!eq(*left, *right))
102 return lt(*left, *right) ? -1 : 1;
109 #if __cplusplus >= 201703L
110 static constexpr std::size_t length(
const char_type* str)
112 static std::size_t length(
const char_type* str)
115 std::size_t count = 0;
125 #if __cplusplus >= 201703L
126 static constexpr
const char_type* find(
const char_type* str, std::size_t count,
const char_type& c)
128 static const char_type* find(
const char_type* str, std::size_t count,
const char_type& c)
131 for (; count > 0; --count, ++str)
142 #if __cplusplus >= 201103L
143 static constexpr char_type to_char_type(
const int_type i) noexcept
145 static char_type to_char_type(
const int_type i)
148 return static_cast<char_type
>(i);
151 #if __cplusplus >= 201103L
152 static constexpr int_type to_int_type(
const char_type c) noexcept
154 static int_type to_int_type(
const char_type c)
157 return static_cast<int_type
>(c);
160 #if __cplusplus >= 201103L
161 static constexpr
bool eq_int_type(
const int_type left,
const int_type right) noexcept
163 static bool eq_int_type(
const int_type left,
const int_type right)
166 return left == right;
169 #if __cplusplus >= 201103L
170 static constexpr int_type eof() noexcept
172 static int_type eof()
175 return static_cast<int_type
>(EOF);
178 #if __cplusplus >= 201103L
179 static constexpr int_type not_eof(
const int_type i) noexcept
181 static int_type not_eof(
const int_type i)
184 return i != eof() ? i : !eof();
192 #endif // PDFTRON_H_CPPCommonCharTraits