67 #pragma warning(disable : 4996)
69 #define strtoll _strtoi64
70 #define strtoull _strtoui64
74#define STRTO_CAST (int)
77#define orxSTRING_KC_VECTOR_START '('
78#define orxSTRING_KC_VECTOR_START_ALT '{'
79#define orxSTRING_KC_VECTOR_SEPARATOR ','
80#define orxSTRING_KC_VECTOR_END ')'
81#define orxSTRING_KC_VECTOR_END_ALT '}'
86#define orxString_ToCRC orxString_Hash
98 const orxSTRING zResult;
101 if(_zString != orxNULL)
104 for(zResult = _zString; (*zResult ==
' ') || (*zResult ==
'\t') || (*zResult ==
orxCHAR_CR) || (*zResult ==
orxCHAR_LF); zResult++)
130 const orxSTRING zResult;
133 if(_zString != orxNULL)
146 orxCHAR cNextChar = *(pc + 1);
177 return((orxU32)strlen(_zString));
197 return(((_u32CharacterCodePoint >=
'a') && (_u32CharacterCodePoint <=
'z'))
198 || ((_u32CharacterCodePoint >=
'A') && (_u32CharacterCodePoint <=
'Z'))
199 || ((_u32CharacterCodePoint >=
'0') && (_u32CharacterCodePoint <=
'9'))) ?
orxTRUE :
orxFALSE;
211 if(_u32CharacterCodePoint < 0x80)
216 else if(_u32CharacterCodePoint < 0x0800)
221 else if(_u32CharacterCodePoint < 0x00010000)
226 else if(_u32CharacterCodePoint < 0x00110000)
255 if(u32Result <= _u32Size)
263 *_zDstString = (orxCHAR)_u32CharacterCodePoint;
271 *_zDstString++ = (orxCHAR)(0xC0 | ((_u32CharacterCodePoint & 0x07C0) >> 6));
274 *_zDstString = (orxCHAR)(0x80 | (_u32CharacterCodePoint & 0x3F));
282 *_zDstString++ = (orxCHAR)(0xE0 | ((_u32CharacterCodePoint & 0xF000) >> 12));
285 *_zDstString++ = (orxCHAR)(0x80 | ((_u32CharacterCodePoint & 0x0FC0) >> 6));
288 *_zDstString = (orxCHAR)(0x80 | (_u32CharacterCodePoint & 0x3F));
296 *_zDstString++ = (orxCHAR)(0xF0 | ((_u32CharacterCodePoint & 0x001C0000) >> 18));
299 *_zDstString++ = (orxCHAR)(0x80 | ((_u32CharacterCodePoint & 0x0003F000) >> 12));
302 *_zDstString++ = (orxCHAR)(0x80 | ((_u32CharacterCodePoint & 0x00000FC0) >> 6));
305 *_zDstString = (orxCHAR)(0x80 | (_u32CharacterCodePoint & 0x3F));
342 const orxU8 *pu8Byte;
349 pu8Byte = (
const orxU8 *)_zString;
355 u32Result = *pu8Byte;
358 else if(*pu8Byte < 0xC0)
361 orxDEBUG_PRINT(
orxDEBUG_LEVEL_SYSTEM,
"Invalid or non-UTF-8 string at <0x%X>: multi-byte sequence non-leading byte '%c' (0x%2X) at index %d.", _zString, *pu8Byte, *pu8Byte, pu8Byte - (orxU8 *)_zString);
367 else if(*pu8Byte < 0xC2)
370 orxDEBUG_PRINT(
orxDEBUG_LEVEL_SYSTEM,
"Invalid or non-UTF-8 string at <0x%X>: overlong 2-byte sequence starting with byte '%c' (0x%2X) at index %d.", _zString, *pu8Byte, *pu8Byte, pu8Byte - (orxU8 *)_zString);
376 else if(*pu8Byte < 0xE0)
379 u32Result = *pu8Byte++ & 0x1F;
382 if((*pu8Byte & 0xC0) == 0x80)
385 u32Result = (u32Result << 6) | (*pu8Byte & 0x3F);
390 orxDEBUG_PRINT(
orxDEBUG_LEVEL_SYSTEM,
"Invalid or non-UTF-8 string at <0x%X>: 2-byte sequence non-trailing byte '%c' (0x%2X) at index %d.", _zString, *pu8Byte, *pu8Byte, pu8Byte - (orxU8 *)_zString);
397 else if(*pu8Byte < 0xF0)
400 u32Result = *pu8Byte++ & 0x0F;
403 if((*pu8Byte & 0xC0) == 0x80)
406 u32Result = (u32Result << 6) | (*pu8Byte++ & 0x3F);
409 if((*pu8Byte & 0xC0) == 0x80)
412 u32Result = (u32Result << 6) | (*pu8Byte & 0x3F);
417 orxDEBUG_PRINT(
orxDEBUG_LEVEL_SYSTEM,
"Invalid or non-UTF-8 string at <0x%X>: 3-byte sequence non-trailing byte '%c' (0x%2X) at index %d.", _zString, *pu8Byte, *pu8Byte, pu8Byte - (orxU8 *)_zString);
426 orxDEBUG_PRINT(
orxDEBUG_LEVEL_SYSTEM,
"Invalid or non-UTF-8 string at <0x%X>: 3-byte sequence non-trailing byte '%c' (0x%2X) at index %d.", _zString, *pu8Byte, *pu8Byte, pu8Byte - (orxU8 *)_zString);
433 else if(*pu8Byte < 0xF5)
436 u32Result = *pu8Byte++ & 0x07;
439 if((*pu8Byte & 0xC0) == 0x80)
442 u32Result = (u32Result << 6) | (*pu8Byte++ & 0x3F);
445 if((*pu8Byte & 0xC0) == 0x80)
448 u32Result = (u32Result << 6) | (*pu8Byte++ & 0x3F);
451 if((*pu8Byte & 0xC0) == 0x80)
454 u32Result = (u32Result << 6) | (*pu8Byte & 0x3F);
459 orxDEBUG_PRINT(
orxDEBUG_LEVEL_SYSTEM,
"Invalid or non-UTF-8 string at <0x%X>: 4-byte sequence non-trailing byte '%c' (0x%2X) at index %d.", _zString, *pu8Byte, *pu8Byte, pu8Byte - (orxU8 *)_zString);
468 orxDEBUG_PRINT(
orxDEBUG_LEVEL_SYSTEM,
"Invalid or non-UTF-8 string at <0x%X>: 4-byte sequence non-trailing byte '%c' (0x%2X) at index %d.", _zString, *pu8Byte, *pu8Byte, pu8Byte - (orxU8 *)_zString);
477 orxDEBUG_PRINT(
orxDEBUG_LEVEL_SYSTEM,
"Invalid or non-UTF-8 string at <0x%X>: 4-byte sequence non-trailing byte '%c' (0x%2X) at index %d.", _zString, *pu8Byte, *pu8Byte, pu8Byte - (orxU8 *)_zString);
486 orxDEBUG_PRINT(
orxDEBUG_LEVEL_SYSTEM,
"Invalid or non-UTF-8 string at <0x%X>: invalid out-of-bound byte '%c' (0x%2X) at index %d.", _zString, *pu8Byte, *pu8Byte, pu8Byte - (orxU8 *)_zString);
493 if(_pzRemaining != orxNULL)
496 *_pzRemaining = (*pu8Byte ==
orxCHAR_NULL) ? orxNULL : (orxSTRING)(pu8Byte + 1);
516 for(pc = _zString, u32Result = 0; *pc !=
orxCHAR_NULL; u32Result++)
541static orxINLINE orxSTRING
orxString_NCopy(orxSTRING _zDstString,
const orxSTRING _zSrcString, orxU32 _u32CharNumber)
549 return(strncpy(_zDstString, _zSrcString, (
size_t)_u32CharNumber));
571 if(zResult != orxNULL)
610 return(strcmp(_zString1, _zString2));
620static orxINLINE orxS32
orxString_NCompare(
const orxSTRING _zString1,
const orxSTRING _zString2, orxU32 _u32CharNumber)
627 return(strncmp(_zString1, _zString2, (
size_t)_u32CharNumber));
644 return(stricmp(_zString1, _zString2));
649 return(strcasecmp(_zString1, _zString2));
660static orxINLINE orxS32
orxString_NICompare(
const orxSTRING _zString1,
const orxSTRING _zString2, orxU32 _u32CharNumber)
669 return(strnicmp(_zString1, _zString2, (
size_t)_u32CharNumber));
674 return(strncasecmp(_zString1, _zString2, _u32CharNumber));
686 orxU32 u32Length1, u32Length2, u32Result;
697 if((u32Length1 > 0) && (u32Length2 > 0))
705 orxMemory_Zero(au32PreviousRow, (u32Length2 + 1) *
sizeof(orxU32));
706 for(i = 0; i <= u32Length2; i++)
708 au32CurrentRow[i] = i;
712 for(i = 0; i < u32Length1; i++)
717 au32NextRow[0] = i + 1;
720 for(j = 0; j < u32Length2; j++)
723 au32NextRow[j + 1] = au32CurrentRow[j] + ((_zString1[i] != _zString2[j]) ? 1 : 0);
726 au32NextRow[j + 1] =
orxMIN(au32NextRow[j + 1], au32CurrentRow[j + 1] + 1);
729 au32NextRow[j + 1] =
orxMIN(au32NextRow[j + 1], au32NextRow[j] + 1);
734 && (_zString1[i - 1] == _zString2[j])
735 && (_zString1[i] == _zString2[j - 1]))
737 au32NextRow[j + 1] =
orxMIN(au32NextRow[j + 1], au32PreviousRow[j - 1] + 1);
742 pu32dummy = au32PreviousRow;
743 au32PreviousRow = au32CurrentRow;
744 au32CurrentRow = au32NextRow;
745 au32NextRow = pu32dummy;
749 u32Result = au32CurrentRow[u32Length2];
754 u32Result = u32Length1 + u32Length2;
768 const orxSTRING zString;
769 orxU32 u32Result, u32Offset;
787 switch(zString[1] | 0x20)
810 if((zString[1] >=
'0')
811 && (zString[1] <=
'9'))
841 if(_pzRemaining != orxNULL)
844 *_pzRemaining = zString + u32Offset;
868 *_ps32OutValue = (orxS32)strtol(_zString, &pcEnd,
STRTO_CAST _u32Base);
871 if((pcEnd != _zString) && (_zString[0] !=
orxCHAR_NULL))
883 if(_pzRemaining != orxNULL)
886 *_pzRemaining = pcEnd;
901 const orxSTRING zValue;
936 *_pu32OutValue = (orxU32)strtoul(_zString, &pcEnd,
STRTO_CAST _u32Base);
939 if((pcEnd != _zString) && (_zString[0] !=
orxCHAR_NULL))
951 if(_pzRemaining != orxNULL)
954 *_pzRemaining = pcEnd;
969 const orxSTRING zValue;
1004 *_ps64OutValue = (orxS64)strtoll(_zString, &pcEnd,
STRTO_CAST _u32Base);
1007 if((pcEnd != _zString) && (_zString[0] !=
orxCHAR_NULL))
1019 if(_pzRemaining != orxNULL)
1022 *_pzRemaining = pcEnd;
1037 const orxSTRING zValue;
1072 *_pu64OutValue = (orxU64)strtoull(_zString, &pcEnd,
STRTO_CAST _u32Base);
1075 if((pcEnd != _zString) && (_zString[0] !=
orxCHAR_NULL))
1087 if(_pzRemaining != orxNULL)
1090 *_pzRemaining = pcEnd;
1105 const orxSTRING zValue;
1139#if defined(__orxLINUX__) || defined(__orxMAC__) || defined (__orxIOS__) || defined(__orxMSVC__) || defined(__orxANDROID__)
1142 *_pfOutValue = (orxFLOAT)strtod(_zString, &pcEnd);
1147 *_pfOutValue = strtof(_zString, &pcEnd);
1152 if((pcEnd != _zString) && (_zString[0] !=
orxCHAR_NULL))
1164 if(_pzRemaining != orxNULL)
1167 *_pzRemaining = pcEnd;
1183 const orxSTRING zString;
1236 if(*zString == cEndMarker)
1244 else if(*zString == cEndMarker)
1264 if(_pzRemaining != orxNULL)
1267 *_pzRemaining = zString + 1;
1313 if(_pzRemaining != orxNULL)
1316 *_pzRemaining += u32Length;
1334 if(_pzRemaining != orxNULL)
1337 *_pzRemaining += u32Length;
1365 if((*pc >=
'A') && (*pc <=
'Z'))
1391 if((*pc >=
'a') && (*pc <=
'z'))
1414 return(strstr(_zString1, _zString2));
1428 return(strchr(_zString, _cChar));
1439 orxS32 s32Index, s32Result = -1;
1447 for(s32Index = _s32Position, pc = _zString + s32Index; *pc !=
orxCHAR_NULL; pc++, s32Index++)
1453 s32Result = s32Index;
1469static orxINLINE orxS32 orxCDECL
orxString_NPrint(orxSTRING _zDstString, orxU32 _u32CharNumber,
const orxSTRING _zSrcString, ...)
1480 va_start(stArgs, _zSrcString);
1481 s32Result = vsnprintf(_zDstString, (
size_t)_u32CharNumber, _zSrcString, stArgs);
1488 s32Result = (orxS32)_u32CharNumber - 1;
1493 s32Result =
orxCLAMP(s32Result, 0, (orxS32)_u32CharNumber - 1);
1508static orxINLINE orxS32 orxCDECL
orxString_Scan(
const orxSTRING _zString,
const orxSTRING _zFormat, ...)
1517 va_start(stArgs, _zFormat);
1518 s32Result = vsscanf(_zString, _zFormat, stArgs);
1522 s32Result =
orxMAX(s32Result, 0);
1534 orxS32 s32Index, s32NextIndex;
1535 const orxSTRING zResult;
1543 s32Index = s32NextIndex);
1546 zResult = (s32Index >= 0) ? _zFileName + s32Index + 1 :
orxSTRING_EMPTY;
1608 #pragma warning(pop)
#define orxASSERT(TEST,...)
#define orxDEBUG_PRINT(LEVEL, STRING,...)
#define orxCLAMP(V, MIN, MAX)
orxDLLAPI void orxFASTCALL orxMemory_Free(void *_pMem)
#define orxMemory_StackAllocate(x)
static orxINLINE void * orxMemory_Zero(void *_pDest, orxU32 _u32Size)
static orxINLINE void * orxMemory_Copy(void *_pDest, const void *_pSrc, orxU32 _u32Size)
orxDLLAPI void *orxFASTCALL orxMemory_Allocate(orxU32 _u32Size, orxMEMORY_TYPE _eMemType)
static orxINLINE orxSTRING orxString_UpperCase(orxSTRING _zString)
orxDLLAPI orxSTRINGID orxFASTCALL orxString_Hash(const orxSTRING _zString)
static orxINLINE orxSTATUS orxString_ToS64Base(const orxSTRING _zString, orxU32 _u32Base, orxS64 *_ps64OutValue, const orxSTRING *_pzRemaining)
static orxINLINE orxSTATUS orxString_ToS32(const orxSTRING _zString, orxS32 *_ps32OutValue, const orxSTRING *_pzRemaining)
static orxINLINE orxBOOL orxString_IsCharacterAlphaNumeric(orxU32 _u32CharacterCodePoint)
static orxINLINE orxSTATUS orxString_Delete(orxSTRING _zString)
static orxINLINE orxS32 orxString_SearchCharIndex(const orxSTRING _zString, orxCHAR _cChar, orxS32 _s32Position)
static orxINLINE const orxSTRING orxString_GetExtension(const orxSTRING _zFileName)
orxDLLAPI orxSTRINGID orxFASTCALL orxString_GetID(const orxSTRING _zString)
static orxINLINE orxSTATUS orxString_ToS32Base(const orxSTRING _zString, orxU32 _u32Base, orxS32 *_ps32OutValue, const orxSTRING *_pzRemaining)
orxDLLAPI void orxFASTCALL orxString_Exit()
static orxINLINE orxU32 orxString_GetLength(const orxSTRING _zString)
static orxINLINE orxSTATUS orxString_ToFloat(const orxSTRING _zString, orxFLOAT *_pfOutValue, const orxSTRING *_pzRemaining)
orxDLLAPI void orxFASTCALL orxString_Setup()
#define orxSTRING_KC_VECTOR_START
static orxINLINE orxU32 orxString_ExtractBase(const orxSTRING _zString, const orxSTRING *_pzRemaining)
static orxINLINE orxSTATUS orxString_ToBool(const orxSTRING _zString, orxBOOL *_pbOutValue, const orxSTRING *_pzRemaining)
static orxINLINE orxSTRING orxString_LowerCase(orxSTRING _zString)
#define orxSTRING_KC_VECTOR_SEPARATOR
orxDLLAPI const orxSTRING orxFASTCALL orxString_GetFromID(orxSTRINGID _stID)
orxDLLAPI orxSTATUS orxFASTCALL orxString_Init()
static orxU32 orxFASTCALL orxString_PrintUTF8Character(orxSTRING _zDstString, orxU32 _u32Size, orxU32 _u32CharacterCodePoint)
static orxU32 orxFASTCALL orxString_GetFirstCharacterCodePoint(const orxSTRING _zString, const orxSTRING *_pzRemaining)
static orxINLINE orxSTRING orxString_NCopy(orxSTRING _zDstString, const orxSTRING _zSrcString, orxU32 _u32CharNumber)
static orxINLINE orxS32 orxString_NICompare(const orxSTRING _zString1, const orxSTRING _zString2, orxU32 _u32CharNumber)
static orxINLINE orxU32 orxString_GetCharacterCount(const orxSTRING _zString)
static orxINLINE orxSTATUS orxString_ToS64(const orxSTRING _zString, orxS64 *_ps64OutValue, const orxSTRING *_pzRemaining)
orxDLLAPI orxSTATUS orxFASTCALL orxString_Erase(orxSTRINGID _stID)
static orxINLINE orxS32 orxCDECL orxString_NPrint(orxSTRING _zDstString, orxU32 _u32CharNumber, const orxSTRING _zSrcString,...)
static orxINLINE orxSTATUS orxString_ToU32Base(const orxSTRING _zString, orxU32 _u32Base, orxU32 *_pu32OutValue, const orxSTRING *_pzRemaining)
static orxINLINE const orxSTRING orxString_SkipWhiteSpaces(const orxSTRING _zString)
static orxINLINE orxU32 orxString_GetEditDistance(const orxSTRING _zString1, const orxSTRING _zString2)
orxDLLAPI const orxSTRING orxFASTCALL orxString_Store(const orxSTRING _zString)
static orxINLINE orxS32 orxString_ICompare(const orxSTRING _zString1, const orxSTRING _zString2)
orxDLLAPI orxSTRINGID orxFASTCALL orxString_NHash(const orxSTRING _zString, orxU32 _u32CharNumber)
#define orxSTRING_KC_VECTOR_END_ALT
static orxINLINE orxU32 orxString_GetUTF8CharacterLength(orxU32 _u32CharacterCodePoint)
static orxINLINE orxSTATUS orxString_ToU32(const orxSTRING _zString, orxU32 *_pu32OutValue, const orxSTRING *_pzRemaining)
#define orxSTRING_KC_VECTOR_START_ALT
static orxINLINE orxSTRING orxString_Duplicate(const orxSTRING _zSrcString)
#define orxSTRING_KC_VECTOR_END
static orxINLINE orxSTATUS orxString_ToVector(const orxSTRING _zString, orxVECTOR *_pvOutValue, const orxSTRING *_pzRemaining)
static orxINLINE const orxSTRING orxString_SearchChar(const orxSTRING _zString, orxCHAR _cChar)
static orxINLINE orxS32 orxString_NCompare(const orxSTRING _zString1, const orxSTRING _zString2, orxU32 _u32CharNumber)
static orxINLINE const orxSTRING orxString_SearchString(const orxSTRING _zString1, const orxSTRING _zString2)
static orxINLINE const orxSTRING orxString_SkipPath(const orxSTRING _zString)
static orxINLINE orxS32 orxCDECL orxString_Scan(const orxSTRING _zString, const orxSTRING _zFormat,...)
static orxINLINE orxBOOL orxString_IsCharacterASCII(orxU32 _u32CharacterCodePoint)
static orxINLINE orxS32 orxString_Compare(const orxSTRING _zString1, const orxSTRING _zString2)
static orxINLINE orxSTATUS orxString_ToU64Base(const orxSTRING _zString, orxU32 _u32Base, orxU64 *_pu64OutValue, const orxSTRING *_pzRemaining)
static orxINLINE orxSTATUS orxString_ToU64(const orxSTRING _zString, orxU64 *_pu64OutValue, const orxSTRING *_pzRemaining)
orxDLLAPI const orxSTRING orxSTRING_TRUE
#define orxCHAR_DIRECTORY_SEPARATOR_WINDOWS
orxDLLAPI const orxSTRING orxSTRING_FALSE
static const orxFLOAT orxFLOAT_0
orxDLLAPI const orxSTRING orxSTRING_EMPTY
#define orxCHAR_DIRECTORY_SEPARATOR_LINUX
static const orxU32 orxU32_UNDEFINED
static orxINLINE orxVECTOR * orxVector_Copy(orxVECTOR *_pvDst, const orxVECTOR *_pvSrc)