41 #define strcmp idStr::Cmp // use_idStr_Cmp
42 #define strncmp use_idStr_Cmpn
44 #if defined( StrCmpN )
47 #define StrCmpN use_idStr_Cmpn
49 #if defined( strcmpi )
52 #define strcmpi use_idStr_Icmp
54 #if defined( StrCmpI )
57 #define StrCmpI use_idStr_Icmp
59 #if defined( StrCmpNI )
62 #define StrCmpNI use_idStr_Icmpn
64 #define stricmp idStr::Icmp // use_idStr_Icmp
65 #define _stricmp use_idStr_Icmp
66 #define strcasecmp use_idStr_Icmp
67 #define strnicmp use_idStr_Icmpn
68 #define _strnicmp use_idStr_Icmpn
69 #define _memicmp use_idStr_Icmpn
70 #define snprintf use_idStr_snPrintf
71 #define _snprintf use_idStr_snPrintf
72 #define vsnprintf use_idStr_vsnPrintf
73 #define _vsnprintf use_idStr_vsnPrintf
77 #ifndef FILE_HASH_SIZE
78 #define FILE_HASH_SIZE 1024
95 #define S_COLOR_DEFAULT "^0"
96 #define S_COLOR_RED "^1"
97 #define S_COLOR_GREEN "^2"
98 #define S_COLOR_YELLOW "^3"
99 #define S_COLOR_BLUE "^4"
100 #define S_COLOR_CYAN "^5"
101 #define S_COLOR_MAGENTA "^6"
102 #define S_COLOR_WHITE "^7"
103 #define S_COLOR_GRAY "^8"
104 #define S_COLOR_BLACK "^9"
122 idStr(
const char *text );
123 idStr(
const char *text,
int start,
int end );
124 explicit idStr(
const bool b );
125 explicit idStr(
const char c );
126 explicit idStr(
const int i );
127 explicit idStr(
const unsigned u );
128 explicit idStr(
const float f );
131 size_t Size(
void )
const;
132 const char *
c_str(
void )
const;
133 operator const char *(
void )
const;
134 operator const char *(
void );
171 int Cmp(
const char *text )
const;
172 int Cmpn(
const char *text,
int n )
const;
176 int Icmp(
const char *text )
const;
177 int Icmpn(
const char *text,
int n )
const;
184 int IcmpPath(
const char *text )
const;
185 int IcmpnPath(
const char *text,
int n )
const;
193 void Append(
const char a );
195 void Append(
const char *text );
196 void Append(
const char *text,
int len );
197 void Insert(
const char a,
int index );
198 void Insert(
const char *text,
int index );
208 void Fill(
const char ch,
int newlen );
210 int Find(
const char c,
int start = 0,
int end = -1 )
const;
211 int Find(
const char *text,
bool casesensitive =
true,
int start = 0,
int end = -1 )
const;
212 bool Filter(
const char *
filter,
bool casesensitive )
const;
213 int Last(
const char c )
const;
215 const char *
Right(
int len,
idStr &result )
const;
216 const char *
Mid(
int start,
int len,
idStr &result )
const;
219 idStr Mid(
int start,
int len )
const;
226 void Strip(
const char c );
227 void Strip(
const char *
string );
230 void Replace(
const char *old,
const char *nw );
250 static int Length(
const char *
s );
251 static char *
ToLower(
char *s );
252 static char *
ToUpper(
char *s );
254 static bool IsColor(
const char *s );
255 static bool HasLower(
const char *s );
256 static bool HasUpper(
const char *s );
259 static int Cmp(
const char *s1,
const char *s2 );
260 static int Cmpn(
const char *s1,
const char *s2,
int n );
261 static int Icmp(
const char *s1,
const char *s2 );
262 static int Icmpn(
const char *s1,
const char *s2,
int n );
263 static int IcmpNoColor(
const char *s1,
const char *s2 );
264 static int IcmpPath(
const char *s1,
const char *s2 );
265 static int IcmpnPath(
const char *s1,
const char *s2,
int n );
267 static void Copynz(
char *dest,
const char *src,
int destsize );
269 static int vsnPrintf(
char *dest,
int size,
const char *fmt, va_list argptr );
270 static int FindChar(
const char *str,
const char c,
int start = 0,
int end = -1 );
271 static int FindText(
const char *str,
const char *text,
bool casesensitive =
true,
int start = 0,
int end = -1 );
272 static bool Filter(
const char *filter,
const char *
name,
bool casesensitive );
278 static int Hash(
const char *
string );
279 static int Hash(
const char *
string,
int length );
280 static int IHash(
const char *
string );
281 static int IHash(
const char *
string,
int length );
296 friend int sprintf(
idStr &dest,
const char *fmt, ... );
297 friend int vsprintf(
idStr &dest,
const char *fmt, va_list ap );
305 void SetUnit(
const char *format,
float value,
int unit,
Measure_t measure );
328 ID_INLINE
void idStr::EnsureAlloced(
int amount,
bool keepold ) {
329 if ( amount > alloced ) {
330 ReAllocate( amount, keepold );
339 #ifdef ID_DEBUG_UNINITIALIZED_MEMORY
363 if ( end > text.
Length() ) {
366 if ( start > text.
Length() ) {
368 }
else if ( start < 0 ) {
379 for ( i = 0; i <
l; i++ ) {
380 data[
i ] = text[ start +
i ];
394 strcpy(
data, text );
401 int l = strlen( text );
409 }
else if ( start < 0 ) {
420 for ( i = 0; i <
l; i++ ) {
421 data[
i ] = text[ start +
i ];
431 data[ 0 ] = b ?
'1' :
'0';
451 strcpy(
data, text );
462 strcpy(
data, text );
472 while( l > 0 && text[l-1] ==
'0' ) text[--
l] =
'\0';
473 while( l > 0 && text[l-1] ==
'.' ) text[--
l] =
'\0';
475 strcpy(
data, text );
491 ID_INLINE idStr::operator
const char *(
void ) {
495 ID_INLINE idStr::operator
const char *(
void )
const {
500 assert( ( index >= 0 ) && ( index <=
len ) );
505 assert( ( index >= 0 ) && ( index <=
len ) );
539 result.
Append( b ?
"true" :
"false" );
622 Append( a ?
"true" :
"false" );
742 for ( i = 0; i < text.
len; i++ ) {
754 newLen =
len + strlen( text );
756 for ( i = 0; text[
i ]; i++ ) {
771 for ( i = 0; text[
i ] && i <
l; i++ ) {
784 }
else if ( index >
len ) {
802 }
else if ( index >
len ) {
811 for ( i = 0; i <
l; i++ ) {
818 for (
int i = 0;
data[
i];
i++ ) {
820 data[
i] += (
'a' -
'A' );
826 for (
int i = 0;
data[
i];
i++ ) {
828 data[
i] -= (
'a' -
'A' );
860 if (
len <= newlen ) {
893 return Mid( 0, len, result );
901 return Mid(
Length() - len, len, result );
905 return Mid( 0, len );
931 for ( i = 0; s[
i]; i++ ) {}
936 for (
int i = 0; s[
i];
i++ ) {
938 s[
i] += (
'a' -
'A' );
945 for (
int i = 0; s[
i];
i++ ) {
947 s[
i] -= (
'a' -
'A' );
955 for ( i = 0; *
string !=
'\0'; i++ ) {
956 hash += ( *
string++ ) * ( i + 119 );
963 for ( i = 0; i <
length; i++ ) {
964 hash += ( *
string++ ) * ( i + 119 );
971 for( i = 0; *
string !=
'\0'; i++ ) {
972 hash +=
ToLower( *
string++ ) * ( i + 119 );
979 for ( i = 0; i <
length; i++ ) {
980 hash +=
ToLower( *
string++ ) * ( i + 119 );
991 return ( c + (
'a' -
'A' ) );
997 if ( c >=
'a' && c <=
'z' ) {
998 return ( c - (
'a' -
'A' ) );
1005 return ( c >= 0x20 && c <= 0x7E ) || ( c >= 0xA1 && c <= 0xFF );
1010 return ( c >=
'a' && c <=
'z' ) || ( c >= 0xE0 && c <= 0xFF );
1020 return ( ( c >=
'a' && c <=
'z' ) || ( c >=
'A' && c <=
'Z' ) ||
1021 ( c >= 0xC0 && c <= 0xFF ) );
1029 return ( c ==
'\n' || c ==
'\r' || c ==
'\v' );
1033 return ( c ==
'\t' );
static int snPrintf(char *dest, int size, const char *fmt,...) id_attribute((format(printf
GLsizei const GLfloat * value
idStr & SetFileExtension(const char *extension)
static bool CharIsUpper(int c)
assert(prefInfo.fullscreenBtn)
const int C_COLOR_DEFAULT
int Cmp(const char *text) const
int CmpPrefix(const char *text) const
void StripLeading(const char c)
idStr & DefaultPath(const char *basepath)
GLenum GLsizei GLenum format
idStr & StripQuotes(void)
char * va(const char *fmt,...) id_attribute((format(printf
bool Filter(const char *filter, bool casesensitive) const
ID_INLINE idStr operator+(const idStr &a, const idStr &b)
bool StripTrailingOnce(const char *string)
void StripTrailingWhitespace(void)
void StripTrailing(const char c)
static int ColorIndex(int c)
friend bool operator!=(const idStr &a, const idStr &b)
void ExtractFileBase(idStr &dest) const
static const char * FloatArrayToString(const float *array, const int length, const int precision)
static void StripMediaName(const char *name, idStr &mediaName)
const char * Left(int len, idStr &result) const
static void ShowMemoryUsage_f(const idCmdArgs &args)
idStr & DefaultFileExtension(const char *extension)
int Cmpn(const char *text, int n) const
int IcmpNoColor(const char *text) const
ID_INLINE bool operator==(const idStr &a, const idStr &b)
static idVec4 & ColorForIndex(int i)
friend int sprintf(idStr &dest, const char *fmt,...)
int Icmp(const char *text) const
int BestUnit(const char *format, float value, Measure_t measure)
idStr & BackSlashesToSlashes(void)
bool HasLower(void) const
char operator[](int index) const
void ExtractFilePath(idStr &dest) const
static bool CharIsNumeric(int c)
static bool CharIsLower(int c)
void ReAllocate(int amount, bool keepold)
int Icmpn(const char *text, int n) const
bool CheckExtension(const char *ext)
void ExtractFileName(idStr &dest) const
idStr & StripFileExtension(void)
static idStr FormatNumber(int number)
static void InitMemory(void)
idStr & operator+=(const idStr &a)
void EnsureAlloced(int amount, bool keepold=true)
GLsizei GLsizei GLenum GLenum const GLvoid * data
static bool CharIsNewLine(char c)
idStr & StripAbsoluteFileExtension(void)
static int FindText(const char *str, const char *text, bool casesensitive=true, int start=0, int end=-1)
static void Copynz(char *dest, const char *src, int destsize)
const int C_COLOR_MAGENTA
void Insert(const char a, int index)
const char * Right(int len, idStr &result) const
int Find(const char c, int start=0, int end=-1) const
idStr & RemoveColors(void)
static int Hash(const char *string)
GLubyte GLubyte GLubyte a
void AppendPath(const char *text)
friend int vsprintf(idStr &dest, const char *fmt, va_list ap)
int FileNameHash(void) const
static int IHash(const char *string)
int IcmpnPath(const char *text, int n) const
bool IsNumeric(void) const
static int FindChar(const char *str, const char c, int start=0, int end=-1)
void operator=(const idStr &text)
static void ShutdownMemory(void)
const char * Mid(int start, int len, idStr &result) const
static int static int vsnPrintf(char *dest, int size, const char *fmt, va_list argptr)
friend idStr operator+(const idStr &a, const idStr &b)
static bool CharIsAlpha(int c)
void Append(const char a)
int Last(const char c) const
ID_INLINE bool operator!=(const idStr &a, const idStr &b)
void Fill(const char ch, int newlen)
GLsizei const GLcharARB const GLint * length
int IcmpPrefix(const char *text) const
int DynamicMemoryUsed() const
typedef void(APIENTRYP PFNGLBLENDCOLORPROC)(GLclampf red
const char * c_str(void) const
void SetUnit(const char *format, float value, int unit, Measure_t measure)
int IcmpPrefixPath(const char *text) const
friend bool operator==(const idStr &a, const idStr &b)
void ExtractFileExtension(idStr &dest) const
static bool CharIsTab(char c)
char baseBuffer[STR_ALLOC_BASE]
bool HasUpper(void) const
void Replace(const char *old, const char *nw)
int sprintf(idStr &string, const char *fmt,...)
int LengthWithoutColors(void) const
idStr & StripFilename(void)
static void PurgeMemory(void)
int IcmpPath(const char *text) const
bool StripLeadingOnce(const char *string)
int Allocated(void) const
static bool CharIsPrintable(int c)