16 #ifndef INCLUDE_NN_NLIB_CSTRING_H_ 17 #define INCLUDE_NN_NLIB_CSTRING_H_ 53 return strcmp(s1, s2);
56 return wcscmp(s1, s2);
59 for (; *s1 == *s2; ++s1, ++s2) {
62 return *s1 < *s2 ? -1 : 1;
65 for (; *s1 == *s2; ++s1, ++s2) {
68 return *s1 < *s2 ? -1 : 1;
74 return strncmp(s1, s2, n);
79 return wcsncmp(s1, s2, n);
84 for (; n > 0; ++s1, ++s2, --n) {
86 return *s1 < *s2 ? -1 : 1;
96 for (; n > 0; ++s1, ++s2, --n) {
98 return *s1 < *s2 ? -1 : 1;
127 template<
class T,
size_t N>
130 return StrCpy(&dest[0], N, src);
158 template<
class T,
size_t N>
162 return StrNcpy(&dest[0], N, src, n);
165 template<
class T,
size_t N>
168 return StrCat(&dest[0], N, src);
171 template<
class T,
size_t N>
175 return StrNcat(&dest[0], N, src, n);
182 _Printf_format_string_
const char* fmt,
188 _Printf_format_string_
const char* fmt,
189 va_list args) NLIB_NOEXCEPT {
192 if (e != 0) errno = e;
193 return (e == 0) ?
static_cast<int>(count) : -1;
199 _Printf_format_string_
const char* fmt,
200 va_list args) NLIB_NOEXCEPT {
207 _Printf_format_string_
const char* fmt,
211 int rval =
VsnPrintf(buf, size, fmt, args);
219 _Printf_format_string_
const char* fmt,
232 _Printf_format_string_
const char* fmt,
233 va_list args) NLIB_NOEXCEPT {
237 inline int SnPrintfFallback(
240 _Printf_format_string_
const char* fmt,
252 _Printf_format_string_
const char* fmt,
264 _Printf_format_string_
const wchar_t* fmt,
270 _Printf_format_string_
const wchar_t* fmt,
271 va_list args) NLIB_NOEXCEPT {
274 if (e != 0) errno = e;
275 return (e == 0) ?
static_cast<int>(count) : -1;
281 _Printf_format_string_
const wchar_t* fmt,
282 va_list args) NLIB_NOEXCEPT {
289 _Printf_format_string_
const wchar_t* fmt,
293 int rval =
VsnPrintf(buf, size, fmt, args);
301 _Printf_format_string_
const wchar_t* fmt,
313 _Printf_format_string_
const wchar_t* fmt,
314 va_list args) NLIB_NOEXCEPT {
318 inline int SnPrintfFallback(
321 _Printf_format_string_
const wchar_t* fmt,
333 _Printf_format_string_
const wchar_t* fmt,
344 #endif // INCLUDE_NN_NLIB_CSTRING_H_ int VsnPrintf(wchar_t(&buf)[N], const wchar_t *fmt, va_list args) noexcept
Internally runs VsnPrintf(buf, N, fmt, args).
errno_t StrCpy(T(&dest)[N], const T *src) noexcept
Makes a call to StrCpy(&dest[0], N, src).
int SnPrintf(wchar_t(&buf)[N], const wchar_t *fmt,...) noexcept
Internally runs the VsnPrintf function.
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.
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.
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.
#define NLIB_NOEXCEPT
Defines noexcept geared to the environment, or the equivalent.
A file that contains the configuration information for each development environment.
errno_t CodePointCount(const wchar_t *str, size_t *count) noexcept
Wraps the nlib_wcscplen function.
errno_t StrNcat(T(&dest)[N], const T *src, size_t n) noexcept
Makes an internal call to StrNcat(&dest[0], N, src, n).
size_t StrLen(const wchar_t *str) noexcept
Wraps the nlib_wcslen function.
errno_t StrNcpy(T(&dest)[N], const T *src, size_t n) noexcept
Makes an internal call to StrNcpy(&dest[0], N, src, n).
errno_t StrCat(T(&dest)[N], const T *src) noexcept
Makes a call to StrCat(&dest[0], N, src).