60 while (pString[result] != 0)
75 static int find(T* pString, T pCharSearch,
int begin = 0)
79 while (pString[index] != 0)
81 if (pString[index] == pCharSearch)
99 static int find(T* pString, T* pKeySearch,
int begin = 0)
104 while (pString[index] != 0)
106 if (memcmp(&pString[index], pKeySearch, size) == 0)
127 while (pString[0] != 0 && (pString[0] ==
' ' || pString[0] ==
'\r' || pString[0] ==
'\n' || pString[0] ==
'\t'))
133 memmove((
void*)&pString[0], (
void*)&pString[1], len *
sizeof(T));
149 for (; len >= 0; len--)
151 if (pString[len] ==
' ' || pString[len] ==
'\r' || pString[len] ==
'\n' || pString[len] ==
'\t')
171 while (pString[0] != 0 && pString[0] == delChar)
177 memmove((
void*)&pString[0], (
void*)&pString[1], len *
sizeof(T));
194 for (; len >= 0; len--)
196 if (pString[len] == delChar)
222 static void trim(T* pString, T delChar)
242 while (pString[index] != 0)
244 if (pString[index] == entry)
261 template <
class T1,
class T2>
262 static int copy(T1* pStringDst, T2* pStringSrc)
272 while (pStringSrc[index] != 0)
274 pStringDst[index] = (T1)(pStringSrc[index]);
277 pStringDst[index] = 0;
285 template <
class T1,
class T2>
286 static int copyAt(T1* pStringDst, T2* pStringSrc,
int at)
294 if (
length(pStringDst) < at || at < 0)
297 while (pStringSrc[i] != 0)
299 pStringDst[index] = (T1)(pStringSrc[i]);
302 pStringDst[index] = 0;
310 template <
class T1,
class T2>
311 static int cat(T1* pStringDst, T2* pStringSrc)
319 while (pStringSrc[i] != 0)
321 pStringDst[index] = (T1)(pStringSrc[i]);
324 pStringDst[index] = 0;
333 static int comp(T* pString1, T* pString2)
337 int len = len1 < len2 ? len1 : len2;
339 int r = memcmp(pString1, pString2, len);
359 static int comp(T* pString1, T* pString2,
int len)
361 return memcmp(pString1, pString2, len *
sizeof(T));
372 template <
class T1,
class T2>
373 static int mid(T1* pStringDst, T2* pStringSrc,
int begin,
int end)
376 for (index = begin; index < end; index++)
378 pStringDst[i] = (T1)pStringSrc[index];
391 template <
class T1,
class T2>
392 static int getBlock(T1* pStringDst, T2* pStringSrc, T2* pBlock,
int begin = 0)
411 template <
class T1,
class T2>
412 static int findBlock(T1* pStringDst, T2* pStringSrc, T2* pBlock,
int begin = 0)
421 while (pStringSrc[i] != 0)
423 if (pStringSrc[i] == pBlock[0])
431 if (pStringSrc[i] == pBlock[1])
434 if (block == 0 && midBegin != -1)
453 template <
class T1,
class T2>
454 static int findBlockString(T1* pStringDst, T2* pStringSrc, T2* pBlock1, T2* pBlock2,
int begin = 0)
458 int len = blockLen1 > blockLen2 ? blockLen1 : blockLen2;
464 while (pStringSrc[i + len - 1] != 0)
480 if (block == 0 && midBegin != -1)
503 while (pString[i] != 0)
505 if (pString[i] == charLoop)
507 while (pString[i + 1] == charLoop && pString[i + 1] != 0)
510 memmove(&pString[i], &pString[i + 1], len);
527 static bool split(T* lpStrResult,
const T* lpStringSearch,
const T* lpStrSplit,
int* pos)
530 if (*pos >= nLenSearch)
540 for (i = 0; i < nLen; i++)
559 for (; i < nLen; i++)
565 if (minPos > tempPos)
582 static int splitString(
const char* stringSplit,
const char* search, std::vector<std::string>& result);
591 static std::string
replaceAll(std::string&
string,
const std::string& from,
const std::string& to);
600 static int splitString(
const wchar_t* stringSplit,
const wchar_t* search, std::vector<std::wstring>& result);
608 static bool format(
char* lpString,
const char* lpStringFormat, ...);
617 wchar_t lpAString[400];
620 if (swscanf(lpAString, L
"%d", result) == -1)
633 wchar_t lpAString[400];
636 if (swscanf(lpAString, L
"%f", result) == -1)
649 wchar_t lpAString[400];
652 if (swscanf(lpAString, L
"%u", result) == -1)
665 wchar_t lpAString[400];
668 if (swscanf(lpAString, L
"%X", result) == -1)
681 while (lpString[i] != 0)
683 lpString[i] = (int)towlower(lpString[i]);
695 while (lpString[i] != 0)
697 lpString[i] = (int)towupper(lpString[i]);
707 template<
class T1,
class T2>
713 if (lpString[i] ==
'\\' || lpString[i] ==
'/')
728 template<
class T1,
class T2>
734 if (lpString[i] ==
'\\' || lpString[i] ==
'/')
749 template<
class T1,
class T2>
753 bool haveExt =
false;
757 if (lpString[i] ==
'.')
763 if (lpString[i] ==
'\\' || lpString[i] ==
'/')
770 if (i == 0 || !haveExt)
781 template<
class T1,
class T2>
789 if (lpString[i] ==
'.' && dotPos == -1)
791 else if (lpString[i] ==
'\\' || lpString[i] ==
'/')
800 dstString[dotPos] = 0;
806 dstString[dotPos - i - 1] = 0;
816 static void shortName(T* dest,
const T* name,
int maxchar)
826 for (
int i = 0; i < maxchar; i++)
832 dest[maxchar - 1] = (T)
'.';
835 dest[maxchar - 2] = (T)
'.';
849 static void replaceText(T* result,
const T*
string,
const T* search,
const T* replace)
858 for (
int i = 0, n = lenString; i < n; i++)
860 if (i <= lenString - lenSearch && memcmp(
string + i, search, lenSearch *
sizeof(T)) == 0)
872 result[j] =
string[i];
950 static void replaceString(std::string& subject,
const std::string& search,
const std::string& replace);
971 static const std::string&
toLower(
const std::string& s);
978 static const std::wstring&
toLower(
const std::wstring& s);
985 static const std::string&
toUpper(
const std::string& s);
992 static const std::wstring&
toUpper(
const std::wstring& s);
Low-level string helper functions used by engine utilities.
Definition CStringImp.h:48
static void toLower(T *lpString)
Convert a mutable string to lowercase in place.
Definition CStringImp.h:678
static const std::string & toLower(const std::string &s)
Return a lowercase copy of a narrow string.
static const std::string & convertUnicodeToUTF8(const wchar_t *src)
Convert wide-character text to UTF-8 using shared temporary storage.
static int findBlockString(T1 *pStringDst, T2 *pStringSrc, T2 *pBlock1, T2 *pBlock2, int begin=0)
Extract text from a balanced block with string begin/end markers.
Definition CStringImp.h:454
static bool parseToInt(T *lpString, int *result)
Parse a signed integer from a string.
Definition CStringImp.h:615
static int getBlock(T1 *pStringDst, T2 *pStringSrc, T2 *pBlock, int begin=0)
Extract text between two occurrences of the same delimiter.
Definition CStringImp.h:392
static int findBlock(T1 *pStringDst, T2 *pStringSrc, T2 *pBlock, int begin=0)
Extract text from a balanced block such as {} or [].
Definition CStringImp.h:412
static void getFolderPath(T1 *dstString, T2 *lpString)
Extract the folder path from a file path.
Definition CStringImp.h:708
static void trimright(T *pString)
Remove trailing whitespace characters from a mutable string.
Definition CStringImp.h:144
static void getFileNameNoExt(T1 *dstString, T2 *lpString)
Extract the file name without extension from a path.
Definition CStringImp.h:782
static int getUnicodeStringSize(const char *src)
Calculate the wide-character length required for a UTF-8 string.
static const std::wstring & toLower(const std::wstring &s)
Return a lowercase copy of a wide string.
static void convertUTF8ToUnicode(const char *src, wchar_t *dst)
Convert UTF-8 text to a wide-character buffer.
static void trimleft(T *pString)
Remove leading whitespace characters from a mutable string.
Definition CStringImp.h:121
static int find(T *pString, T pCharSearch, int begin=0)
Find a character in a null-terminated string.
Definition CStringImp.h:75
static void trimright(T *pString, T delChar)
Remove trailing occurrences of a character.
Definition CStringImp.h:189
static int splitString(const wchar_t *stringSplit, const wchar_t *search, std::vector< std::wstring > &result)
Split a wide string into a vector.
static int comp(T *pString1, T *pString2)
Compare two null-terminated strings by raw character bytes.
Definition CStringImp.h:333
static const std::wstring & toUpper(const std::wstring &s)
Return an uppercase copy of a wide string.
static void toUpper(T *lpString)
Convert a mutable string to uppercase in place.
Definition CStringImp.h:692
static void replaceString(std::string &subject, const std::string &search, const std::string &replace)
Replace all occurrences of a substring in a std::string.
static void trimleft(T *pString, T delChar)
Remove leading occurrences of a character.
Definition CStringImp.h:165
static bool parseToUInt(T *lpString, int *result)
Parse an unsigned integer from a string.
Definition CStringImp.h:647
static void replaceText(T *result, const T *string, const T *search, const T *replace)
Replace all occurrences of text in a source buffer.
Definition CStringImp.h:849
static int findStringInList(std::vector< std::string > &listString, const char *find)
Find a string in a vector.
static int getUTF8StringSize(const wchar_t *src)
Calculate the UTF-8 byte length required for a wide string.
static int copy(T1 *pStringDst, T2 *pStringSrc)
Copy a null-terminated string while converting character type.
Definition CStringImp.h:262
static wchar_t utf8Char2Unicode(const char *&str)
Decode one UTF-8 character and advance the source pointer.
static int cat(T1 *pStringDst, T2 *pStringSrc)
Append a source string to a destination string.
Definition CStringImp.h:311
static bool split(T *lpStrResult, const T *lpStringSearch, const T *lpStrSplit, int *pos)
Split a string incrementally using any character from a delimiter set.
Definition CStringImp.h:527
static void trim(T *pString, T delChar)
Remove leading and trailing occurrences of a character.
Definition CStringImp.h:222
static const std::string & toUpper(const std::string &s)
Return an uppercase copy of a narrow string.
static bool format(char *lpString, const char *lpStringFormat,...)
Format text into a caller-provided buffer.
static void convertUnicodeToUTF8(const wchar_t *src, char *dst)
Convert wide-character text to UTF-8.
static bool parseToFloat(T *lpString, float *result)
Parse a floating-point value from a string.
Definition CStringImp.h:631
static int find(T *pString, T *pKeySearch, int begin=0)
Find a substring in a null-terminated string.
Definition CStringImp.h:99
static const std::string & formatThousand(int n, bool useK, bool useM)
Format a number with thousand separators or compact suffixes.
static int splitString(const char *stringSplit, const char *search, std::vector< std::string > &result)
Split a narrow string into a vector.
static int countEntry(T *pString, T entry, int begin=0)
Count occurrences of a character.
Definition CStringImp.h:237
static int length(T *pString)
Count characters before the null terminator.
Definition CStringImp.h:57
static unsigned short * getUnicodeString(const wchar_t *src)
Convert a wide string to an unsigned 16-bit Unicode buffer.
static void getFileName(T1 *dstString, T2 *lpString)
Extract the file name from a path.
Definition CStringImp.h:729
static void replaceExt(char *lpPath, const char *lpExt)
Replace the extension portion of a file name in place.
static void getFileNameExt(T1 *dstString, T2 *lpString)
Extract the file extension from a path.
Definition CStringImp.h:750
static const std::wstring & convertUTF8ToUnicode(const char *src)
Convert UTF-8 text to wide-character text using shared temporary storage.
static void shortName(T *dest, const T *name, int maxchar)
Shorten a name to a maximum character count.
Definition CStringImp.h:816
static int mid(T1 *pStringDst, T2 *pStringSrc, int begin, int end)
Copy a substring range.
Definition CStringImp.h:373
static int copyAt(T1 *pStringDst, T2 *pStringSrc, int at)
Copy a source string into a destination string at an index.
Definition CStringImp.h:286
static int comp(T *pString1, T *pString2, int len)
Compare a fixed number of characters by raw character bytes.
Definition CStringImp.h:359
static void inorgeLoopChar(T *pString, T charLoop)
Collapse repeated occurrences of a character to a single occurrence.
Definition CStringImp.h:500
static void replacePathExt(char *lpPath, const char *lpExt)
Replace the extension portion of a full path in place.
static std::string replaceAll(std::string &string, const std::string &from, const std::string &to)
Replace every occurrence of a substring.
static bool parseFromHex(T *lpString, int *result)
Parse a hexadecimal integer from a string.
Definition CStringImp.h:663
static void trim(T *pString)
Remove leading and trailing whitespace characters.
Definition CStringImp.h:209
Everything in the Skylicht Engine. You can start by looking at the topics.
Definition AudioDebugLog.h:29