nlib
Cstring.h
Go to the documentation of this file.
1 
2 #pragma once
3 #ifndef INCLUDE_NN_NLIB_CSTRING_H_
4 #define INCLUDE_NN_NLIB_CSTRING_H_
5 
6 #include <stdarg.h>
7 #include <string.h>
8 #ifndef NLIB_ISDIGIT_USE_FALLBACK
9 #include <ctype.h>
10 #endif
11 
12 #include "nn/nlib/Config.h"
13 
14 // functions below may be deprecated ....
15 NLIB_NAMESPACE_BEGIN
16 
17 inline size_t StrLen(const char* str) NLIB_NOEXCEPT { return nlib_strlen(str); }
18 inline size_t StrLen(const nlib_utf16_t* str) NLIB_NOEXCEPT { return nlib_utf16len(str); }
19 inline size_t StrLen(const nlib_utf32_t* str) NLIB_NOEXCEPT { return nlib_utf32len(str); }
20 inline size_t StrLen(const wchar_t* str) NLIB_NOEXCEPT { return nlib_wcslen(str); }
21 
22 inline errno_t CodePointCount(const char* str, size_t* count) NLIB_NOEXCEPT {
23  return nlib_strcplen(count, str);
24 }
25 inline errno_t CodePointCount(const nlib_utf16_t* str, size_t* count) NLIB_NOEXCEPT {
26  return nlib_utf16cplen(count, str);
27 }
28 inline errno_t CodePointCount(const nlib_utf32_t* str, size_t* count) NLIB_NOEXCEPT {
29  return nlib_utf32cplen(count, str);
30 }
31 inline errno_t CodePointCount(const wchar_t* str, size_t* count) NLIB_NOEXCEPT {
32  return nlib_wcscplen(count, str);
33 }
34 
35 NLIB_VIS_PUBLIC int StrCmpFallback(const wchar_t* s1, const wchar_t* s2) NLIB_NOEXCEPT;
36 NLIB_VIS_PUBLIC int StrCmpFallback(const nlib_utf16_t* s1, const nlib_utf16_t* s2) NLIB_NOEXCEPT;
37 NLIB_VIS_PUBLIC int StrCmpFallback(const nlib_utf32_t* s1, const nlib_utf32_t* s2) NLIB_NOEXCEPT;
38 
39 inline int StrCmp(const char* s1, const char* s2) NLIB_NOEXCEPT { return strcmp(s1, s2); }
40 inline int StrCmp(const wchar_t* s1, const wchar_t* s2) NLIB_NOEXCEPT {
41 #ifndef NLIB_WCSCMP_USE_FALLBACK
42  return wcscmp(s1, s2);
43 #else
44  return StrCmpFallback(s1, s2);
45 #endif
46 }
47 inline int StrCmp(const nlib_utf16_t* s1, const nlib_utf16_t* s2) NLIB_NOEXCEPT {
48  return StrCmpFallback(s1, s2);
49 }
50 inline int StrCmp(const nlib_utf32_t* s1, const nlib_utf32_t* s2) NLIB_NOEXCEPT {
51  return StrCmpFallback(s1, s2);
52 }
53 
54 NLIB_VIS_PUBLIC int StrNcmpFallback(const char* s1, const char* s2, size_t n) NLIB_NOEXCEPT;
55 NLIB_VIS_PUBLIC int StrNcmpFallback(const wchar_t* s1, const wchar_t* s2, size_t n) NLIB_NOEXCEPT;
56 NLIB_VIS_PUBLIC int StrNcmpFallback(const nlib_utf16_t* s1,
57  const nlib_utf16_t* s2, size_t n) NLIB_NOEXCEPT;
58 NLIB_VIS_PUBLIC int StrNcmpFallback(const nlib_utf32_t* s1,
59  const nlib_utf32_t* s2, size_t n) NLIB_NOEXCEPT;
60 
61 inline int StrNcmp(const char* s1, const char* s2, size_t n) NLIB_NOEXCEPT {
62 #ifndef NLIB_STRNCMP_USE_FALLBACK
63  return strncmp(s1, s2, n);
64 #else
65  return StrNcmpFallback(s1, s2, n);
66 #endif
67 }
68 inline int StrNcmp(const wchar_t* s1, const wchar_t* s2, size_t n) NLIB_NOEXCEPT {
69 #ifndef NLIB_WCSNCMP_USE_FALLBACK
70  return wcsncmp(s1, s2, n);
71 #else
72  return StrNcmpFallback(s1, s2, n);
73 #endif
74 }
75 inline int StrNcmp(const nlib_utf16_t* s1, const nlib_utf16_t* s2, size_t n) NLIB_NOEXCEPT {
76  return StrNcmpFallback(s1, s2, n);
77 }
78 inline int StrNcmp(const nlib_utf32_t* s1, const nlib_utf32_t* s2, size_t n) NLIB_NOEXCEPT {
79  return StrNcmpFallback(s1, s2, n);
80 }
81 
82 // StrEqual to be deprecated
83 inline bool StrEqual(const char* s1, const char* s2) NLIB_NOEXCEPT {
84  return s1[0] == s2[0] && StrCmp(s1, s2) == 0;
85 }
86 inline bool StrEqual(const nlib_utf16_t* s1, const nlib_utf16_t* s2) NLIB_NOEXCEPT {
87  return s1[0] == s2[0] && StrCmp(s1, s2) == 0;
88 }
89 inline bool StrEqual(const nlib_utf32_t* s1, const nlib_utf32_t* s2) NLIB_NOEXCEPT {
90  return s1[0] == s2[0] && StrCmp(s1, s2) == 0;
91 }
92 inline bool StrEqual(const wchar_t* s1, const wchar_t* s2) NLIB_NOEXCEPT {
93  return s1[0] == s2[0] && StrCmp(s1, s2) == 0;
94 }
95 
96 // StrNequal to be deprecated
97 inline bool StrNequal(const char* s1, const char* s2, size_t n) NLIB_NOEXCEPT {
98  return StrNcmp(s1, s2, n) == 0;
99 }
100 inline bool StrNequal(const nlib_utf16_t* s1, const nlib_utf16_t* s2, size_t n) NLIB_NOEXCEPT {
101  return StrNcmp(s1, s2, n) == 0;
102 }
103 inline bool StrNequal(const nlib_utf32_t* s1, const nlib_utf32_t* s2, size_t n) NLIB_NOEXCEPT {
104  return StrNcmp(s1, s2, n) == 0;
105 }
106 inline bool StrNequal(const wchar_t* s1, const wchar_t* s2, size_t n) NLIB_NOEXCEPT {
107  return StrNcmp(s1, s2, n) == 0;
108 }
109 
110 inline errno_t StrCpy(char* dest, size_t destSize, const char* src) NLIB_NOEXCEPT {
111  return nlib_strcpy(dest, destSize, src);
112 }
113 inline errno_t StrCpy(nlib_utf16_t* dest, size_t destSize, const nlib_utf16_t* src) NLIB_NOEXCEPT {
114  return nlib_utf16cpy(dest, destSize, src);
115 }
116 inline errno_t StrCpy(nlib_utf32_t* dest, size_t destSize, const nlib_utf32_t* src) NLIB_NOEXCEPT {
117  return nlib_utf32cpy(dest, destSize, src);
118 }
119 inline errno_t StrCpy(wchar_t* dest, size_t destSize, const wchar_t* src) NLIB_NOEXCEPT {
120  return nlib_wcscpy(dest, destSize, src);
121 }
122 
123 template<class T, size_t N>
124 NLIB_ALWAYS_INLINE errno_t StrCpy(T (&dest)[N], const T* src) NLIB_NOEXCEPT {
125  return StrCpy(&dest[0], N, src);
126 }
127 
128 inline errno_t StrNcpy(char* dest, size_t destSize, const char* src,
129  size_t maxNumCopyWithoutNull) NLIB_NOEXCEPT {
130  return nlib_strncpy(dest, destSize, src, maxNumCopyWithoutNull);
131 }
132 inline errno_t StrNcpy(nlib_utf16_t* dest, size_t destSize, const nlib_utf16_t* src,
133  size_t maxNumCopyWithoutNull) NLIB_NOEXCEPT {
134  return nlib_utf16ncpy(dest, destSize, src, maxNumCopyWithoutNull);
135 }
136 inline errno_t StrNcpy(nlib_utf32_t* dest, size_t destSize, const nlib_utf32_t* src,
137  size_t maxNumCopyWithoutNull) NLIB_NOEXCEPT {
138  return nlib_utf32ncpy(dest, destSize, src, maxNumCopyWithoutNull);
139 }
140 inline errno_t StrNcpy(wchar_t* dest, size_t destSize, const wchar_t* src,
141  size_t maxNumCopyWithoutNull) NLIB_NOEXCEPT {
142  return nlib_wcsncpy(dest, destSize, src, maxNumCopyWithoutNull);
143 }
144 
145 template<class T, size_t N>
146 NLIB_ALWAYS_INLINE errno_t StrNcpy(T(&dest)[N], const T* src,
147  size_t maxNumCopyWithoutNull) NLIB_NOEXCEPT {
148  return StrNcpy(&dest[0], N, src, maxNumCopyWithoutNull);
149 }
150 
151 inline errno_t MemCpy(void* dest, size_t destSize, const void* src, size_t srcSize) NLIB_NOEXCEPT {
152  return nlib_memcpy(dest, destSize, src, srcSize);
153 }
154 
155 inline errno_t MemMove(void* dest, size_t destSize, const void* src, size_t srcSize) NLIB_NOEXCEPT {
156  return nlib_memmove(dest, destSize, src, srcSize);
157 }
158 
159 inline errno_t StrCat(char* dest, size_t destSize, const char* src) NLIB_NOEXCEPT {
160  return nlib_strcat(dest, destSize, src);
161 }
162 
163 inline errno_t StrCat(wchar_t* dest, size_t destSize, const wchar_t* src) NLIB_NOEXCEPT {
164  return nlib_wcscat(dest, destSize, src);
165 }
166 
167 template<class T, size_t N>
168 NLIB_ALWAYS_INLINE errno_t StrCat(T(&dest)[N], const T* src) NLIB_NOEXCEPT {
169  return StrCat(&dest[0], N, src);
170 }
171 
172 inline errno_t StrNcat(char* dest, size_t destSize, const char* src,
173  size_t maxNumCopyWithoutNull) NLIB_NOEXCEPT {
174  return nlib_strncat(dest, destSize, src, maxNumCopyWithoutNull);
175 }
176 
177 inline errno_t StrNcat(wchar_t* dest, size_t destSize, const wchar_t* src,
178  size_t maxNumCopyWithoutNull) NLIB_NOEXCEPT {
179  return nlib_wcsncat(dest, destSize, src, maxNumCopyWithoutNull);
180 }
181 
182 template<class T, size_t N>
183 NLIB_ALWAYS_INLINE errno_t StrNcat(T (&dest)[N], const T* src,
184  size_t maxNumCopyWithoutNull) NLIB_NOEXCEPT {
185  return StrNcat(&dest[0], N, src, maxNumCopyWithoutNull);
186 }
187 
188 /*
189  STR37-C
190  isalnum, isalpha, isascii, isblank,
191  iscntrl, isdigit, isgraph, islower,
192  isprint, ispunct, isspace, isupper,
193  isxdigit, toascii, toupper, tolower
194 */
195 
196 #ifndef NLIB_ISDIGIT_USE_FALLBACK
197 inline int IsAlnum(int c) NLIB_NOEXCEPT { return isalnum(static_cast<unsigned char>(c)); }
198 inline int IsAlpha(int c) NLIB_NOEXCEPT { return isalpha(static_cast<unsigned char>(c)); }
199 // isascii
200 // isblank
201 inline int IsCntrl(int c) NLIB_NOEXCEPT { return iscntrl(static_cast<unsigned char>(c)); }
202 inline int IsDigit(int c) NLIB_NOEXCEPT { return isdigit(static_cast<unsigned char>(c)); }
203 inline int IsGraph(int c) NLIB_NOEXCEPT { return isgraph(static_cast<unsigned char>(c)); }
204 inline int IsLower(int c) NLIB_NOEXCEPT { return islower(static_cast<unsigned char>(c)); }
205 
206 inline int IsPrint(int c) NLIB_NOEXCEPT { return isprint(static_cast<unsigned char>(c)); }
207 inline int IsPunct(int c) NLIB_NOEXCEPT { return ispunct(static_cast<unsigned char>(c)); }
208 inline int IsSpace(int c) NLIB_NOEXCEPT { return isspace(static_cast<unsigned char>(c)); }
209 inline int IsUpper(int c) NLIB_NOEXCEPT { return isupper(static_cast<unsigned char>(c)); }
210 
211 inline int IsXdigit(int c) NLIB_NOEXCEPT { return isxdigit(static_cast<unsigned char>(c)); }
212 // toascii
213 inline int ToUpper(int c) NLIB_NOEXCEPT { return toupper(static_cast<unsigned char>(c)); }
214 inline int ToLower(int c) NLIB_NOEXCEPT { return tolower(static_cast<unsigned char>(c)); }
215 
216 #else
217 inline int IsAlnum(int ch) NLIB_NOEXCEPT {
218  return ('0' <= ch && ch <= '9') || ('A' <= ch && ch <= 'Z') || ('a' <= ch && ch <= 'z');
219 }
220 inline int IsAlpha(int ch) NLIB_NOEXCEPT {
221  return ('A' <= ch && ch <= 'Z') || ('a' <= ch && ch <= 'z');
222 }
223 // isascii
224 // isblank
225 inline int IsCntrl(int ch) NLIB_NOEXCEPT { return (ch >= 0 && ch <= 0x1F) || ch == 0x7F; }
226 inline int IsDigit(int ch) NLIB_NOEXCEPT { return ('0' <= ch && ch <= '9'); }
227 inline int IsGrpah(int ch) NLIB_NOEXCEPT { return ch >= 0x21 && ch <= 0x7E; }
228 inline int IsLower(int ch) NLIB_NOEXCEPT { return (ch >= 'a' && ch <= 'z'); }
229 
230 inline int IsPrint(int ch) NLIB_NOEXCEPT { return ch >= 0x20 && ch <= 0x7E; }
231 inline int IsPunct(int ch) NLIB_NOEXCEPT { return (ch >= 0x00 && ch <= 0x20) || ch == 0x7F; }
232 inline int IsSpace(int c) NLIB_NOEXCEPT { return ((c) == ' ' || (c) == '\t' || (c) == '\n'); }
233 inline int IsUpper(int ch) NLIB_NOEXCEPT { return (ch >= 'A' && ch <= 'Z'); }
234 
235 inline int IsXdigit(int ch) NLIB_NOEXCEPT {
236  return static_cast<unsigned int>(ch - '0') < 10u ||
237  static_cast<unsigned int>((ch | 0x20) - 'a') < 6u;
238 }
239 // toascii
240 inline int ToLower(int ch) NLIB_NOEXCEPT {
241  return (ch >= 'A' && ch <= 'Z') ? ch + ('a' - 'A') : ch;
242 }
243 inline int ToUpper(int ch) NLIB_NOEXCEPT {
244  return (ch >= 'a' && ch <= 'z') ? ch - ('a' - 'A') : ch;
245 }
246 #endif
247 
248 // NOTE: It is possible that NLIB_VSNPRINTF is VsnPrintfFallback.
249 NLIB_VIS_PUBLIC int VsnPrintfFallback(char* buf, size_t size, const char* fmt,
250  va_list args) NLIB_NOEXCEPT;
251 
252 inline int VsnPrintf(char* buf, size_t size, const char* fmt, va_list args) NLIB_NOEXCEPT {
253  size_t count;
254  errno_t e = nlib_vsnprintf(&count, buf, size, fmt, args);
255 #ifndef NLIB_NO_ERRNO
256  if (e != 0) errno = e;
257 #endif
258  return (e == 0) ? static_cast<int>(count) : -1;
259 }
260 
261 template <size_t N>
262 NLIB_ALWAYS_INLINE int VsnPrintf(char (&buf)[N], const char* fmt, va_list args) NLIB_NOEXCEPT {
263  return VsnPrintf(buf, N, fmt, args);
264 }
265 
266 inline int SnPrintf(char* buf, size_t size, const char* fmt, ...) NLIB_NOEXCEPT {
267  va_list args;
268  va_start(args, fmt);
269  int rval = VsnPrintf(buf, size, fmt, args);
270  va_end(args);
271  return rval;
272 }
273 
274 template <size_t N>
275 inline NLIB_VIS_HIDDEN int SnPrintf(char (&buf)[N], const char* fmt, ...) NLIB_NOEXCEPT {
276  // gcc cannot inline vaargs functions
277  va_list args;
278  va_start(args, fmt);
279  int rval = VsnPrintf(buf, N, fmt, args);
280  va_end(args);
281  return rval;
282 }
283 
284 template <size_t N>
285 NLIB_ALWAYS_INLINE int VsnPrintfFallback(char (&buf)[N], const char* fmt,
286  va_list args) NLIB_NOEXCEPT {
287  return VsnPrintfFallback(buf, N, fmt, args);
288 }
289 
290 inline int SnPrintfFallback(char* buf, size_t size, const char* fmt, ...) NLIB_NOEXCEPT {
291  va_list args;
292  va_start(args, fmt);
293  int rval = VsnPrintfFallback(buf, size, fmt, args);
294  va_end(args);
295  return rval;
296 }
297 
298 template <size_t N>
299 inline NLIB_VIS_HIDDEN int SnPrintfFallback(char (&buf)[N],
300  const char* fmt, ...) NLIB_NOEXCEPT {
301  va_list args;
302  va_start(args, fmt);
303  int rval = VsnPrintfFallback(buf, N, fmt, args);
304  va_end(args);
305  return rval;
306 }
307 
308 NLIB_VIS_PUBLIC int VsnPrintfFallback(wchar_t* buf, size_t size, const wchar_t* fmt,
309  va_list args) NLIB_NOEXCEPT;
310 
311 inline int VsnPrintf(wchar_t* buf, size_t size, const wchar_t* fmt, va_list args) NLIB_NOEXCEPT {
312  size_t count;
313  errno_t e = nlib_vsnwprintf(&count, buf, size, fmt, args);
314 #ifndef NLIB_NO_ERRNO
315  if (e != 0) errno = e;
316 #endif
317  return (e == 0) ? static_cast<int>(count) : -1;
318 }
319 
320 template <size_t N>
321 NLIB_ALWAYS_INLINE int VsnPrintf(wchar_t(&buf)[N], const wchar_t* fmt, va_list args) NLIB_NOEXCEPT {
322  return VsnPrintf(buf, N, fmt, args);
323 }
324 
325 inline int SnPrintf(wchar_t* buf, size_t size, const wchar_t* fmt, ...) NLIB_NOEXCEPT {
326  va_list args;
327  va_start(args, fmt);
328  int rval = VsnPrintf(buf, size, fmt, args);
329  va_end(args);
330  return rval;
331 }
332 
333 template <size_t N>
334 inline NLIB_VIS_HIDDEN int SnPrintf(wchar_t(&buf)[N], const wchar_t* fmt, ...) NLIB_NOEXCEPT {
335  va_list args;
336  va_start(args, fmt);
337  int rval = VsnPrintf(buf, N, fmt, args);
338  va_end(args);
339  return rval;
340 }
341 
342 template <size_t N>
343 NLIB_ALWAYS_INLINE int VsnPrintfFallback(wchar_t(&buf)[N], const wchar_t* fmt,
344  va_list args) NLIB_NOEXCEPT {
345  return VsnPrintfFallback(buf, N, fmt, args);
346 }
347 
348 inline int SnPrintfFallback(wchar_t* buf, size_t size, const wchar_t* fmt, ...) NLIB_NOEXCEPT {
349  va_list args;
350  va_start(args, fmt);
351  int rval = VsnPrintfFallback(buf, size, fmt, args);
352  va_end(args);
353  return rval;
354 }
355 
356 template <size_t N>
357 inline NLIB_VIS_HIDDEN int SnPrintfFallback(wchar_t(&buf)[N],
358  const wchar_t* fmt, ...) NLIB_NOEXCEPT {
359  va_list args;
360  va_start(args, fmt);
361  int rval = VsnPrintfFallback(buf, N, fmt, args);
362  va_end(args);
363  return rval;
364 }
365 
366 NLIB_NAMESPACE_END
367 
368 #endif // INCLUDE_NN_NLIB_CSTRING_H_
#define NLIB_NOEXCEPT
Defines noexcept geared to the environment, or the equivalent.
Definition: Platform.h:2151
int VsnPrintf(wchar_t(&buf)[N], const wchar_t *fmt, va_list args) noexcept
Internally runs VsnPrintf(buf, N, fmt, args).
Definition: Cstring.h:321
int IsCntrl(int c) noexcept
Returns std::iscntrl(static_cast(c)).
Definition: Cstring.h:201
NLIB_CHECK_RESULT errno_t nlib_wcscplen(size_t *count, const wchar_t *str)
Gets the number of code points in the string.
errno_t StrCpy(T(&dest)[N], const T *src) noexcept
Makes a call to StrCpy(&dest[0], N, src).
Definition: Cstring.h:124
errno_t nlib_wcsncat(wchar_t *s1, size_t s1max, const wchar_t *s2, size_t n)
An implementation corresponding to N1078 wcsncat_s.
errno_t nlib_strncat(char *s1, size_t s1max, const char *s2, size_t n)
An implementation corresponding to N1078 strncat_s.
errno_t nlib_vsnprintf(size_t *count, char *buf, size_t size, const char *fmt, va_list args)
A safer form of vsnprintf, with some differences from standard vsnprintf behavior.
errno_t nlib_wcscpy(wchar_t *s1, size_t s1max, const wchar_t *s2)
An implementation corresponding to N1078 wcscpy_s.
int IsPunct(int c) noexcept
Returns std::ispunct(static_cast(c)).
Definition: Cstring.h:207
int SnPrintf(wchar_t(&buf)[N], const wchar_t *fmt,...) noexcept
Internally runs the VsnPrintf function.
Definition: Cstring.h:334
#define NLIB_VIS_HIDDEN
Symbols for functions and classes are not made available outside of the library.
Definition: Platform_unix.h:50
int IsDigit(int c) noexcept
Returns std::isdigit(static_cast(c)).
Definition: Cstring.h:202
NLIB_CHECK_RESULT errno_t nlib_strcplen(size_t *count, const char *str)
Gets the number of code points in the string.
int ToUpper(int c) noexcept
Returns std::toupper(static_cast(c)).
Definition: Cstring.h:213
int IsAlnum(int c) noexcept
Returns std::isalnum(static_cast(c)).
Definition: Cstring.h:197
errno_t MemCpy(void *dest, size_t destSize, const void *src, size_t srcSize) noexcept
Wraps the nlib_memcpy function.
Definition: Cstring.h:151
errno_t StrNcpy(T(&dest)[N], const T *src, size_t maxNumCopyWithoutNull) noexcept
Makes a call to StrNcpy(&dest[0], N, src, maxNumCopyWithoutNull).
Definition: Cstring.h:146
int VsnPrintfFallback(char *buf, size_t size, const char *fmt, va_list args) noexcept
The fallback for VsnPrintf. Also implemented in a wide-character version.
errno_t StrNcat(T(&dest)[N], const T *src, size_t maxNumCopyWithoutNull) noexcept
Makes a call to StrNcat(&dest[0], N, src, maxNumCopyWithoutNull).
Definition: Cstring.h:183
errno_t nlib_strncpy(char *s1, size_t s1max, const char *s2, size_t n)
An implementation corresponding to N1078 strncpy_s.
int IsAlpha(int c) noexcept
Returns std::isalpha(static_cast(c)).
Definition: Cstring.h:198
int StrCmp(const nlib_utf32_t *s1, const nlib_utf32_t *s2) noexcept
Compares UTF-32 strings in the same way as the strcmp function.
Definition: Cstring.h:50
int IsGraph(int c) noexcept
Returns std::isgraph(static_cast(c)).
Definition: Cstring.h:203
uint32_t nlib_utf32_t
Uses typedef to define as char32_t if that can be used. If not, it uses typedef to define as uint32_t...
Definition: Platform.h:2161
int StrNcmp(const nlib_utf32_t *s1, const nlib_utf32_t *s2, size_t n) noexcept
Compares UTF-32 strings in the same way as the strncmp function.
Definition: Cstring.h:78
errno_t nlib_utf16ncpy(nlib_utf16_t *s1, size_t s1max, const nlib_utf16_t *s2, size_t n) noexcept
The UTF-16 version of the nlib_strcpy function.
Definition: Platform.h:2206
uint16_t nlib_utf16_t
Uses typedef to define as char16_t if that can be used. If not, it uses typedef to define as uint16_t...
Definition: Platform.h:2160
errno_t nlib_utf16cplen(size_t *count, const nlib_utf16_t *str) noexcept
Gets the number of code points in the string.
Definition: Platform.h:2240
errno_t nlib_memmove(void *s1, size_t s1max, const void *s2, size_t n)
An implementation corresponding to N1078 memmove_s.
Definition: Platform.h:2108
int IsPrint(int c) noexcept
Returns std::isprint(static_cast(c)).
Definition: Cstring.h:206
size_t nlib_wcslen(const wchar_t *s)
Makes a call to thewcslen function. In some cases, it may operate as an independent implementation...
A file that contains the configuration information for each development environment.
errno_t nlib_utf32ncpy(nlib_utf32_t *s1, size_t s1max, const nlib_utf32_t *s2, size_t n) noexcept
The UTF-32 version of the nlib_strcpy function.
Definition: Platform.h:2231
errno_t nlib_wcsncpy(wchar_t *s1, size_t s1max, const wchar_t *s2, size_t n)
An implementation corresponding to N1078 wcsncpy_s.
int IsLower(int c) noexcept
Returns std::islower(static_cast(c)).
Definition: Cstring.h:204
errno_t nlib_strcat(char *s1, size_t s1max, const char *s2)
An implementation corresponding to N1078 strcat_s.
errno_t CodePointCount(const wchar_t *str, size_t *count) noexcept
Wraps the nlib_wcscplen function.
Definition: Cstring.h:31
errno_t MemMove(void *dest, size_t destSize, const void *src, size_t srcSize) noexcept
Wraps the nlib_memmove function.
Definition: Cstring.h:155
size_t nlib_strlen(const char *s)
Internally calls strlen(). In some cases, it may operate as an independent implementation.
errno_t nlib_utf16cpy(nlib_utf16_t *s1, size_t s1max, const nlib_utf16_t *s2) noexcept
The UTF-16 version of the nlib_strcpy function.
Definition: Platform.h:2201
int IsUpper(int c) noexcept
Returns std::isupper(static_cast(c)).
Definition: Cstring.h:209
#define NLIB_ALWAYS_INLINE
Indicates that the compiler is forced to perform inline expansion of functions.
Definition: Platform_unix.h:59
#define NLIB_VIS_PUBLIC
Symbols for functions and classes are made available outside of the library.
Definition: Platform_unix.h:51
NLIB_CHECK_RESULT size_t nlib_utf16len(const nlib_utf16_t *str) noexcept
Counts the number of nlib_utf16_t-type characters, not including the null character.
Definition: Platform.h:2194
errno_t nlib_vsnwprintf(size_t *count, wchar_t *buf, size_t size, const wchar_t *fmt, va_list args)
A safer form of vswprintf, with some differences from standard vswprintf behavior.
size_t StrLen(const wchar_t *str) noexcept
Wraps the nlib_wcslen function.
Definition: Cstring.h:20
int IsSpace(int c) noexcept
Returns std::isspace(static_cast(c)).
Definition: Cstring.h:208
NLIB_CHECK_RESULT size_t nlib_utf32len(const nlib_utf32_t *str) noexcept
Counts the number of nlib_utf32_t-type characters, not including the null character.
Definition: Platform.h:2219
errno_t nlib_utf32cpy(nlib_utf32_t *s1, size_t s1max, const nlib_utf32_t *s2) noexcept
The UTF-32 version of the nlib_strcpy function.
Definition: Platform.h:2226
int ToLower(int c) noexcept
Returns std::tolower(static_cast(c)).
Definition: Cstring.h:214
errno_t nlib_wcscat(wchar_t *s1, size_t s1max, const wchar_t *s2)
An implementation corresponding to N1078 wcscat_s.
errno_t nlib_strcpy(char *s1, size_t s1max, const char *s2)
An implementation corresponding to N1078 strcpy_s.
int IsXdigit(int c) noexcept
Returns std::isxdigit(static_cast(c)).
Definition: Cstring.h:211
errno_t nlib_memcpy(void *s1, size_t s1max, const void *s2, size_t n)
An implementation corresponding to N1078 memcpy_s.
Definition: Platform.h:2095
NLIB_CHECK_RESULT errno_t nlib_utf32cplen(size_t *count, const nlib_utf32_t *str) noexcept
Gets the number of code points in the string.
errno_t StrCat(T(&dest)[N], const T *src) noexcept
Makes a call to StrCat(&dest[0], N, src).
Definition: Cstring.h:168
int errno_t
Indicates with an int-type typedef that a POSIX error value is returned as the return value...
Definition: NMalloc.h:24