3 #ifndef INCLUDE_NN_NLIB_CSTRING_H_ 4 #define INCLUDE_NN_NLIB_CSTRING_H_ 40 return strcmp(s1, s2);
43 return wcscmp(s1, s2);
46 for (; *s1 == *s2; ++s1, ++s2) {
49 return *s1 < *s2 ? -1 : 1;
52 for (; *s1 == *s2; ++s1, ++s2) {
55 return *s1 < *s2 ? -1 : 1;
61 return strncmp(s1, s2, n);
66 return wcsncmp(s1, s2, n);
71 for (; n > 0; ++s1, ++s2, --n) {
73 return *s1 < *s2 ? -1 : 1;
83 for (; n > 0; ++s1, ++s2, --n) {
85 return *s1 < *s2 ? -1 : 1;
114 template<
class T,
size_t N>
117 return StrCpy(&dest[0], N, src);
145 template<
class T,
size_t N>
149 return StrNcpy(&dest[0], N, src, n);
152 template<
class T,
size_t N>
155 return StrCat(&dest[0], N, src);
158 template<
class T,
size_t N>
162 return StrNcat(&dest[0], N, src, n);
169 _Printf_format_string_
const char* fmt,
175 _Printf_format_string_
const char* fmt,
176 va_list args) NLIB_NOEXCEPT {
179 if (e != 0) errno = e;
180 return (e == 0) ?
static_cast<int>(count) : -1;
186 _Printf_format_string_
const char* fmt,
187 va_list args) NLIB_NOEXCEPT {
194 _Printf_format_string_
const char* fmt,
198 int rval =
VsnPrintf(buf, size, fmt, args);
206 _Printf_format_string_
const char* fmt,
219 _Printf_format_string_
const char* fmt,
220 va_list args) NLIB_NOEXCEPT {
224 inline int SnPrintfFallback(
227 _Printf_format_string_
const char* fmt,
239 _Printf_format_string_
const char* fmt,
251 _Printf_format_string_
const wchar_t* fmt,
257 _Printf_format_string_
const wchar_t* fmt,
258 va_list args) NLIB_NOEXCEPT {
261 if (e != 0) errno = e;
262 return (e == 0) ?
static_cast<int>(count) : -1;
268 _Printf_format_string_
const wchar_t* fmt,
269 va_list args) NLIB_NOEXCEPT {
276 _Printf_format_string_
const wchar_t* fmt,
280 int rval =
VsnPrintf(buf, size, fmt, args);
288 _Printf_format_string_
const wchar_t* fmt,
300 _Printf_format_string_
const wchar_t* fmt,
301 va_list args) NLIB_NOEXCEPT {
305 inline int SnPrintfFallback(
308 _Printf_format_string_
const wchar_t* fmt,
320 _Printf_format_string_
const wchar_t* fmt,
331 #endif // INCLUDE_NN_NLIB_CSTRING_H_ int VsnPrintf(wchar_t(&buf)[N], const wchar_t *fmt, va_list args) noexcept
内部でVsnPrintf(buf, N, fmt, args)を実行します。
errno_t StrCpy(T(&dest)[N], const T *src) noexcept
内部でStrCpy(&dest[0], N, src)を呼び出します。
int SnPrintf(wchar_t(&buf)[N], const wchar_t *fmt,...) noexcept
内部でVsnPrintf()を実行します。
int VsnPrintfFallback(char *buf, size_t size, const char *fmt, va_list args) noexcept
VsnPrintfのフォールバックです。ワイド文字版も実装されています。
int StrCmp(const nlib_utf32_t *s1, const nlib_utf32_t *s2) noexcept
UTF-32文字列をstrcmp()と同様に比較します。
int StrNcmp(const nlib_utf32_t *s1, const nlib_utf32_t *s2, size_t n) noexcept
UTF-32文字列をstrncmp()と同様に比較します。
#define NLIB_NOEXCEPT
環境に合わせてnoexcept 又は同等の定義がされます。
errno_t CodePointCount(const wchar_t *str, size_t *count) noexcept
nlib_wcscplen()をラップします。
errno_t StrNcat(T(&dest)[N], const T *src, size_t n) noexcept
内部でStrNcat(&dest[0], N, src, n)を呼び出します。
size_t StrLen(const wchar_t *str) noexcept
nlib_wcslen()をラップします。
errno_t StrNcpy(T(&dest)[N], const T *src, size_t n) noexcept
内部でStrNcpy(&dest[0], N, src, n)を呼び出します。
errno_t StrCat(T(&dest)[N], const T *src) noexcept
内部でStrCat(&dest[0], N, src)を呼び出します。