19#pragma comment(user,"T-Coverage Disable")
54 ASSERTLIB(r == strlen(lpsz));
76 ASSERTLIB(r == wcslen(lpsz));
89 inline void Copy(LPSTR _dst, LPCSTR src)
91 ASSERT(! ::IsBadWritePtr(_dst,
GetLen(src)));
96 while ( *_dst++ != 0 );
107 inline void Copy(LPWSTR _dst, LPCWSTR src)
109 ASSERT(! ::IsBadWritePtr(_dst,
GetLen(src) *
sizeof(WCHAR)));
114 while ( *_dst++ != 0 );
135 inline int Compare(LPCSTR P1, LPCSTR P2, INT_PTR len = -1, DWORD dwCmpFlags = 0)
137 if ( P2 == NULL ){ P2 =
""; }
140 return ::CompareStringA(LOCALE_USER_DEFAULT, dwCmpFlags, P1, l, P2, l) - CSTR_EQUAL;
142 DWORD f = NORM_IGNOREKANATYPE | NORM_IGNORENONSPACE | NORM_IGNORESYMBOLS;
143 if ( (dwCmpFlags & f) != 0 )
145 ASSERT0(
false,
"STRLIB::Compare()",
"一部のフラグは無視されます");
147 if ( (dwCmpFlags & NORM_IGNORECASE) != 0 )
149 return (l < 0) ? ::_stricmp(P1, P2) : ::_strnicmp(P1, P2, l);
151 return (l < 0) ? ::strcmp(P1, P2) : ::strncmp(P1, P2, l);
167 inline int Compare(LPCWSTR P1, LPCWSTR P2, INT_PTR len = -1, DWORD dwCmpFlags = 0)
169 if ( P2 == NULL ){ P2 = L
""; }
171 return ::CompareStringW(LOCALE_USER_DEFAULT, dwCmpFlags, P1, l, P2, l) - CSTR_EQUAL;
184 inline INT_PTR
IndexOf(LPCSTR lpszText,
char c, INDEX iFromIndex = 0)
186 LPCSTR P = ::strchr(&lpszText[iFromIndex], c);
187 return (P == NULL) ? (-1) : (P - lpszText);
200 inline INT_PTR
IndexOf(LPCWSTR lpszText, WCHAR c, INDEX iFromIndex = 0)
202 LPCWSTR P = ::wcschr(&lpszText[iFromIndex], c);
203 return (P == NULL) ? (-1) : (P - lpszText);
216 inline INT_PTR
IndexOneOf(LPCSTR lpszText, LPCSTR lpszMark, INDEX iFromIndex = 0)
218 size_t l =
GetLen(&lpszText[iFromIndex]);
219 size_t r = ::strcspn(&lpszText[iFromIndex], lpszMark);
220 return (r >= l) ? -1 : r + iFromIndex;
233 inline INT_PTR
IndexOneOf(LPCWSTR lpszText, LPCWSTR lpszMark, INDEX iFromIndex = 0)
235 size_t l =
GetLen(&lpszText[iFromIndex]);
236 size_t r = ::wcscspn(&lpszText[iFromIndex], lpszMark);
237 return (r >= l) ? -1 : r + iFromIndex;
251 LPCSTR P = ::strrchr(lpszText, c);
252 return (P == NULL) ? (-1) : (P - lpszText);
266 LPCWSTR P = ::wcsrchr(lpszText, c);
267 return (P == NULL) ? (-1) : (P - lpszText);
280 inline INT_PTR
IndexOf(LPCSTR lpszText, LPCSTR lpszWord, INDEX iFromIndex = 0)
282 LPCSTR P = strstr(&lpszText[iFromIndex], lpszWord);
283 return (P == NULL) ? (-1) : (P - lpszText);
296 inline INT_PTR
IndexOf(LPCWSTR lpszText, LPCWSTR lpszWord, INDEX iFromIndex = 0)
298 LPCWSTR P = wcsstr(&lpszText[iFromIndex], lpszWord);
299 return (P == NULL) ? (-1) : (P - lpszText);
314 return (p1 < p2) ? p2 : p1;
329 return (p1 < p2) ? p2 : p1;
343 return ::IsDBCSLeadByte(c) ? 2 : 1;
367 inline int ToInt(LPCSTR lpsz,
int iBase = 10)
369 return strtol(lpsz, NULL, iBase);
381 inline int ToInt(LPCWSTR lpsz,
int iBase = 10)
383 return wcstol(lpsz, NULL, iBase);
395 inline DWORD
ToDword(LPCSTR lpsz,
int iBase = 10)
397 return strtoul(lpsz, NULL, iBase);
409 inline DWORD
ToDword(LPCWSTR lpsz,
int iBase = 10)
411 return wcstoul(lpsz, NULL, iBase);
423 return strtod(lpsz, NULL);
435 return wcstod(lpsz, NULL);
447 return _atoi64(lpsz);
459 return _wtoi64(lpsz);
495 if ( c >=
'a' && c <=
'f' )
499 else if ( c >=
'A' && c <=
'F' )
503 else if ( c >=
'0' && c <=
'9' )
520 return "0123456789ABCDEF"[c & 0x000F];
532 template<
typename TYP>
535 if ( *_lpsz !=
'\\' ){
return -1; }
537 const TYP* P = _lpsz;
559 loop( i, (c ==
'x') ? 2 : 4 )
562 if ( c < 0 ) {
break; }
563 if ( r < 0 ) { r = 0; }
570 if ( *P >=
'0' && *P <=
'9' )
574 if ( *P < '0' || *P >
'7' ) {
break; }
575 if ( r < 0 ) { r = 0; }
601#pragma comment(user,"T-Coverage Enable")
#define loop(VAR, CNT)
loop構文.
int GetCharSize(char c)
[取得] 文字のサイズ(ASCII/SJIS用)
int Compare(LPCSTR P1, LPCSTR P2, INT_PTR len=-1, DWORD dwCmpFlags=0)
[比較] 文字列比較(ASCII/SJIS用)
INT_PTR IndexOf(LPCSTR lpszText, char c, INDEX iFromIndex=0)
[検索] 文字検索(ASCII/SJIS用)
size_t GetLen(LPCSTR lpsz)
[計算] 文字列長計算(ASCII/SJIS用)
LONGLONG ToLonglong(LPCSTR lpsz)
[変換] LONGLONG変換(ASCII/SJIS用)
char IntToHexChar(int c)
[変換] 数値HEX文字変換
int HexCharToInt(int c)
[変換] HEX文字数値変換
INT_PTR PathIndexOf(LPCSTR lpszText)
[検索] パス区切り検索(ASCII/SJIS用)
INT_PTR IndexOneOf(LPCSTR lpszText, LPCSTR lpszMark, INDEX iFromIndex=0)
[検索] 文字セット検索(ASCII/SJIS用)
DWORD ToDword(LPCSTR lpsz, int iBase=10)
[変換] INT変換(ASCII/SJIS用).
void Copy(LPSTR _dst, LPCSTR src)
[複製] 文字列コピー(ASCII/SJIS用)
int EscCharToInt(const TYP *&_lpsz)
[変換] エスケープ文字表記変換
int ToInt(LPCSTR lpsz, int iBase=10)
[変換] INT変換(ASCII/SJIS用).
INT_PTR ReverseIndexOf(LPCSTR lpszText, char c)
[検索] 降順文字検索(ASCII/SJIS用)
bool IsAsciiOnly(LPCSTR lpsz)
[判断] ASCIIオンリー判断
double ToDouble(LPCSTR lpsz)
[変換] double変換(ASCII/SJIS用)