55 #pragma warning(disable : 4996) 57 #define strtoll _strtoi64 58 #define strtoull _strtoui64 62 #define STRTO_CAST (int) 69 #ifndef __orxWINDOWS__ 76 #define orxSTRING_KC_VECTOR_START '(' 77 #define orxSTRING_KC_VECTOR_START_ALT '{' 78 #define orxSTRING_KC_VECTOR_SEPARATOR ',' 79 #define orxSTRING_KC_VECTOR_END ')' 80 #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++);
129 const orxSTRING zResult;
132 if(_zString != orxNULL)
145 orxCHAR cNextChar = *(pc + 1);
176 return((orxU32)strlen(_zString));
196 return(((_u32CharacterCodePoint >=
'a') && (_u32CharacterCodePoint <=
'z'))
197 || ((_u32CharacterCodePoint >=
'A') && (_u32CharacterCodePoint <=
'Z'))
198 || ((_u32CharacterCodePoint >=
'0') && (_u32CharacterCodePoint <=
'9'))) ?
orxTRUE :
orxFALSE;
210 if(_u32CharacterCodePoint < 0x80)
215 else if(_u32CharacterCodePoint < 0x0800)
220 else if(_u32CharacterCodePoint < 0x00010000)
225 else if(_u32CharacterCodePoint < 0x00110000)
254 if(u32Result <= _u32Size)
262 *_zDstString = (orxCHAR)_u32CharacterCodePoint;
270 *_zDstString++ = (orxCHAR)(0xC0 | ((_u32CharacterCodePoint & 0x07C0) >> 6));
273 *_zDstString = (orxCHAR)(0x80 | (_u32CharacterCodePoint & 0x3F));
281 *_zDstString++ = (orxCHAR)(0xE0 | ((_u32CharacterCodePoint & 0xF000) >> 12));
284 *_zDstString++ = (orxCHAR)(0x80 | ((_u32CharacterCodePoint & 0x0FC0) >> 6));
287 *_zDstString = (orxCHAR)(0x80 | (_u32CharacterCodePoint & 0x3F));
295 *_zDstString++ = (orxCHAR)(0xF0 | ((_u32CharacterCodePoint & 0x001C0000) >> 18));
298 *_zDstString++ = (orxCHAR)(0x80 | ((_u32CharacterCodePoint & 0x0003F000) >> 12));
301 *_zDstString++ = (orxCHAR)(0x80 | ((_u32CharacterCodePoint & 0x00000FC0) >> 6));
304 *_zDstString = (orxCHAR)(0x80 | (_u32CharacterCodePoint & 0x3F));
341 const orxU8 *pu8Byte;
348 pu8Byte = (
const orxU8 *)_zString;
354 u32Result = *pu8Byte;
357 else if(*pu8Byte < 0xC0)
360 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);
366 else if(*pu8Byte < 0xC2)
369 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);
375 else if(*pu8Byte < 0xE0)
378 u32Result = *pu8Byte++ & 0x1F;
381 if((*pu8Byte & 0xC0) == 0x80)
384 u32Result = (u32Result << 6) | (*pu8Byte & 0x3F);
389 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);
396 else if(*pu8Byte < 0xF0)
399 u32Result = *pu8Byte++ & 0x0F;
402 if((*pu8Byte & 0xC0) == 0x80)
405 u32Result = (u32Result << 6) | (*pu8Byte++ & 0x3F);
408 if((*pu8Byte & 0xC0) == 0x80)
411 u32Result = (u32Result << 6) | (*pu8Byte & 0x3F);
416 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);
425 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);
432 else if(*pu8Byte < 0xF5)
435 u32Result = *pu8Byte++ & 0x07;
438 if((*pu8Byte & 0xC0) == 0x80)
441 u32Result = (u32Result << 6) | (*pu8Byte++ & 0x3F);
444 if((*pu8Byte & 0xC0) == 0x80)
447 u32Result = (u32Result << 6) | (*pu8Byte++ & 0x3F);
450 if((*pu8Byte & 0xC0) == 0x80)
453 u32Result = (u32Result << 6) | (*pu8Byte & 0x3F);
458 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);
467 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);
476 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);
485 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);
492 if(_pzRemaining != orxNULL)
495 *_pzRemaining = (orxSTRING)(pu8Byte + 1);
515 for(pc = _zString, u32Result = 0; *pc !=
orxCHAR_NULL; u32Result++)
540 static orxINLINE orxSTRING
orxString_NCopy(orxSTRING _zDstString,
const orxSTRING _zSrcString, orxU32 _u32CharNumber)
548 return(strncpy(_zDstString, _zSrcString, (
size_t)_u32CharNumber));
570 if(zResult != orxNULL)
609 return(strcmp(_zString1, _zString2));
620 static orxINLINE orxS32
orxString_NCompare(
const orxSTRING _zString1,
const orxSTRING _zString2, orxU32 _u32CharNumber)
627 return(strncmp(_zString1, _zString2, (
size_t)_u32CharNumber));
642 #ifdef __orxWINDOWS__ 645 return(stricmp(_zString1, _zString2));
650 return(strcasecmp(_zString1, _zString2));
663 static orxINLINE orxS32
orxString_NICompare(
const orxSTRING _zString1,
const orxSTRING _zString2, orxU32 _u32CharNumber)
669 #ifdef __orxWINDOWS__ 672 return(strnicmp(_zString1, _zString2, (
size_t)_u32CharNumber));
677 return(strncasecmp(_zString1, _zString2, _u32CharNumber));
689 const orxSTRING zString;
690 orxU32 u32Result, u32Offset;
708 switch(zString[1] | 0x20)
731 if((zString[1] >=
'0')
732 && (zString[1] <=
'9'))
762 if(_pzRemaining != orxNULL)
765 *_pzRemaining = zString + u32Offset;
789 *_ps32OutValue = (orxS32)strtol(_zString, &pcEnd,
STRTO_CAST _u32Base);
792 if((pcEnd != _zString) && (_zString[0] !=
orxCHAR_NULL))
804 if(_pzRemaining != orxNULL)
807 *_pzRemaining = pcEnd;
822 const orxSTRING zValue;
857 *_pu32OutValue = (orxU32)strtoul(_zString, &pcEnd,
STRTO_CAST _u32Base);
860 if((pcEnd != _zString) && (_zString[0] !=
orxCHAR_NULL))
872 if(_pzRemaining != orxNULL)
875 *_pzRemaining = pcEnd;
890 const orxSTRING zValue;
925 *_ps64OutValue = (orxS64)strtoll(_zString, &pcEnd,
STRTO_CAST _u32Base);
928 if((pcEnd != _zString) && (_zString[0] !=
orxCHAR_NULL))
940 if(_pzRemaining != orxNULL)
943 *_pzRemaining = pcEnd;
958 const orxSTRING zValue;
993 *_pu64OutValue = (orxU64)strtoull(_zString, &pcEnd,
STRTO_CAST _u32Base);
996 if((pcEnd != _zString) && (_zString[0] !=
orxCHAR_NULL))
1008 if(_pzRemaining != orxNULL)
1011 *_pzRemaining = pcEnd;
1026 const orxSTRING zValue;
1060 #if defined(__orxLINUX__) || defined(__orxMAC__) || defined (__orxIOS__) || defined(__orxMSVC__) || defined(__orxANDROID__) 1063 *_pfOutValue = (orxFLOAT)strtod(_zString, &pcEnd);
1068 *_pfOutValue = strtof(_zString, &pcEnd);
1073 if((pcEnd != _zString) && (_zString[0] !=
orxCHAR_NULL))
1085 if(_pzRemaining != orxNULL)
1088 *_pzRemaining = pcEnd;
1104 const orxSTRING zString;
1157 if(*zString == cEndMarker)
1165 else if(*zString == cEndMarker)
1185 if(_pzRemaining != orxNULL)
1188 *_pzRemaining = zString + 1;
1234 if(_pzRemaining != orxNULL)
1237 *_pzRemaining += u32Length;
1255 if(_pzRemaining != orxNULL)
1258 *_pzRemaining += u32Length;
1286 if((*pc >=
'A') && (*pc <=
'Z'))
1311 if((*pc >=
'a') && (*pc <=
'z'))
1333 return(strstr(_zString1, _zString2));
1347 return(strchr(_zString, _cChar));
1358 orxS32 s32Index, s32Result = -1;
1366 for(s32Index = _s32Position, pc = _zString + s32Index; *pc !=
orxCHAR_NULL; pc++, s32Index++)
1372 s32Result = s32Index;
1388 static orxINLINE orxS32 orxCDECL
orxString_NPrint(orxSTRING _zDstString, orxU32 _u32CharNumber,
const orxSTRING _zSrcString, ...)
1399 va_start(stArgs, _zSrcString);
1400 s32Result = vsnprintf(_zDstString, (
size_t)_u32CharNumber, _zSrcString, stArgs);
1407 s32Result = (orxS32)_u32CharNumber - 1;
1412 s32Result =
orxCLAMP(s32Result, 0, (orxS32)_u32CharNumber - 1);
1427 static orxINLINE orxS32 orxCDECL
orxString_Scan(
const orxSTRING _zString,
const orxSTRING _zFormat, ...)
1436 va_start(stArgs, _zFormat);
1437 s32Result = vsscanf(_zString, _zFormat, stArgs);
1441 s32Result =
orxMAX(s32Result, 0);
1453 orxS32 s32Index, s32NextIndex;
1454 const orxSTRING zResult;
1462 s32Index = s32NextIndex);
1465 zResult = (s32Index >= 0) ? _zFileName + s32Index + 1 :
orxSTRING_EMPTY;
1521 #pragma warning(default : 4996) static orxINLINE const orxSTRING orxString_GetExtension(const orxSTRING _zFileName)
static orxINLINE orxSTATUS orxString_ToS64(const orxSTRING _zString, orxS64 *_ps64OutValue, const orxSTRING *_pzRemaining)
orxDLLAPI orxSTRINGID orxFASTCALL orxString_GetID(const orxSTRING _zString)
orxDLLAPI void orxFASTCALL orxString_Setup()
static orxINLINE orxS32 orxString_SearchCharIndex(const orxSTRING _zString, orxCHAR _cChar, orxS32 _s32Position)
orxDLLAPI const orxSTRING orxFASTCALL orxString_Store(const orxSTRING _zString)
static orxINLINE orxBOOL orxString_IsCharacterAlphaNumeric(orxU32 _u32CharacterCodePoint)
static orxINLINE orxSTATUS orxString_ToU32Base(const orxSTRING _zString, orxU32 _u32Base, orxU32 *_pu32OutValue, const orxSTRING *_pzRemaining)
static orxINLINE orxS32 orxString_NICompare(const orxSTRING _zString1, const orxSTRING _zString2, orxU32 _u32CharNumber)
static orxINLINE const orxSTRING orxString_SkipWhiteSpaces(const orxSTRING _zString)
static orxINLINE orxSTRING orxString_Duplicate(const orxSTRING _zSrcString)
#define orxSTRING_KC_VECTOR_END
static orxINLINE orxSTRING orxString_LowerCase(orxSTRING _zString)
orxDLLAPI orxSTRINGID orxFASTCALL orxString_NHash(const orxSTRING _zString, orxU32 _u32CharNumber)
orxDLLAPI orxSTATUS orxFASTCALL orxString_Init()
static orxINLINE orxS32 orxString_NCompare(const orxSTRING _zString1, const orxSTRING _zString2, orxU32 _u32CharNumber)
static const orxU32 orxU32_UNDEFINED
#define orxSTRING_KC_VECTOR_END_ALT
static orxINLINE orxSTATUS orxString_ToU64(const orxSTRING _zString, orxU64 *_pu64OutValue, const orxSTRING *_pzRemaining)
static orxINLINE orxSTATUS orxString_ToU32(const orxSTRING _zString, orxU32 *_pu32OutValue, const orxSTRING *_pzRemaining)
static orxINLINE orxU32 orxString_ExtractBase(const orxSTRING _zString, const orxSTRING *_pzRemaining)
#define orxCLAMP(V, MIN, MAX)
static orxINLINE orxS32 orxCDECL orxString_Scan(const orxSTRING _zString, const orxSTRING _zFormat,...)
#define orxCHAR_DIRECTORY_SEPARATOR_WINDOWS
orxDLLAPI void *orxFASTCALL orxMemory_Allocate(orxU32 _u32Size, orxMEMORY_TYPE _eMemType)
static orxINLINE orxSTATUS orxString_ToS32Base(const orxSTRING _zString, orxU32 _u32Base, orxS32 *_ps32OutValue, const orxSTRING *_pzRemaining)
static orxINLINE const orxSTRING orxString_SkipPath(const orxSTRING _zString)
orxDLLAPI const orxSTRING orxSTRING_EMPTY
static orxINLINE orxSTATUS orxString_ToVector(const orxSTRING _zString, orxVECTOR *_pvOutValue, const orxSTRING *_pzRemaining)
orxDLLAPI const orxSTRING orxSTRING_TRUE
static orxU32 orxFASTCALL orxString_GetFirstCharacterCodePoint(const orxSTRING _zString, const orxSTRING *_pzRemaining)
static orxINLINE orxSTRING orxString_UpperCase(orxSTRING _zString)
static orxINLINE orxU32 orxString_GetLength(const orxSTRING _zString)
#define orxSTRING_KC_VECTOR_START
static orxINLINE orxSTATUS orxString_ToBool(const orxSTRING _zString, orxBOOL *_pbOutValue, const orxSTRING *_pzRemaining)
static orxINLINE orxSTATUS orxString_ToU64Base(const orxSTRING _zString, orxU32 _u32Base, orxU64 *_pu64OutValue, const orxSTRING *_pzRemaining)
static orxINLINE orxSTATUS orxString_Delete(orxSTRING _zString)
static orxINLINE orxU32 orxString_GetUTF8CharacterLength(orxU32 _u32CharacterCodePoint)
static orxINLINE orxS32 orxString_Compare(const orxSTRING _zString1, const orxSTRING _zString2)
static orxU32 orxFASTCALL orxString_PrintUTF8Character(orxSTRING _zDstString, orxU32 _u32Size, orxU32 _u32CharacterCodePoint)
static orxINLINE const orxSTRING orxString_SearchString(const orxSTRING _zString1, const orxSTRING _zString2)
static orxINLINE orxS32 orxString_ICompare(const orxSTRING _zString1, const orxSTRING _zString2)
static orxINLINE orxS32 orxCDECL orxString_NPrint(orxSTRING _zDstString, orxU32 _u32CharNumber, const orxSTRING _zSrcString,...)
static orxINLINE orxSTATUS orxString_ToS64Base(const orxSTRING _zString, orxU32 _u32Base, orxS64 *_ps64OutValue, const orxSTRING *_pzRemaining)
static orxINLINE orxBOOL orxString_IsCharacterASCII(orxU32 _u32CharacterCodePoint)
static orxINLINE const orxSTRING orxString_SearchChar(const orxSTRING _zString, orxCHAR _cChar)
orxDLLAPI void orxFASTCALL orxString_Exit()
static orxINLINE orxSTATUS orxString_ToFloat(const orxSTRING _zString, orxFLOAT *_pfOutValue, const orxSTRING *_pzRemaining)
static const orxFLOAT orxFLOAT_0
orxDLLAPI void orxFASTCALL orxMemory_Free(void *_pMem)
#define orxSTRING_KC_VECTOR_SEPARATOR
static orxINLINE orxSTATUS orxString_ToS32(const orxSTRING _zString, orxS32 *_ps32OutValue, const orxSTRING *_pzRemaining)
#define orxDEBUG_PRINT(LEVEL, STRING,...)
static orxINLINE orxU32 orxString_GetCharacterCount(const orxSTRING _zString)
static orxINLINE void * orxMemory_Copy(void *_pDest, const void *_pSrc, orxU32 _u32Size)
static orxINLINE orxSTRING orxString_NCopy(orxSTRING _zDstString, const orxSTRING _zSrcString, orxU32 _u32CharNumber)
orxDLLAPI const orxSTRING orxSTRING_FALSE
#define orxSTRING_KC_VECTOR_START_ALT
#define orxASSERT(TEST,...)
orxDLLAPI const orxSTRING orxFASTCALL orxString_GetFromID(orxSTRINGID _stID)
static orxINLINE orxVECTOR * orxVector_Copy(orxVECTOR *_pvDst, const orxVECTOR *_pvSrc)
#define orxCHAR_DIRECTORY_SEPARATOR_LINUX
orxDLLAPI orxSTRINGID orxFASTCALL orxString_Hash(const orxSTRING _zString)