00001 #ifndef FSTRING_H
00002 #define FSTRING_H
00003
00010 #ifndef CTLSTRING_H
00011 #error This should be included from "ctl/ctlstring.h"
00012 #endif
00013
00020 #define ctl_fstring(tchar) ctl_mstring(tchar,fixed)
00021
00023 #define ctl_fstring_(tchar) ctl_mstring_(tchar,fixed)
00024
00031 #define ctl_fstring_destroy(tchar, self )
00032
00041 #define ctl_fstring_auto(tchar, size, label )\
00042 tchar ppConcat(buff_,label)[size] = szconst(tchar,"");\
00043 ctl_fstring_auto_buff(tchar, ppConcat(buff_,label), size, label )
00044
00054 #define ctl_fstring_auto_buff(tchar, buff, size, label )\
00055 ctl_mstring(tchar,fixed) label = {(buff),(buff),(buff)+(size)-1}
00056
00065 #define ctl_fstring_init(tchar, self, buff, len )\
00066 {\
00067 (self)->begin = (self)->end = (buff);\
00068 (self)->endBuff = (self)->begin + (len)-1;\
00069 *(self)->begin = *(self)->endBuff = 0;\
00070 }
00071
00079 #define ctl_fstring_init_sz(tchar, self, sz )\
00080 {\
00081 (self)->begin = (self)->end = (buff);\
00082 (self)->endBuff = (self)->begin + (len);\
00083 ctl_fstring_strcpy(tchar, (self), (sz) );\
00084 }
00085
00093 #define ctl_fstring_swap(tchar, p1, p2 )\
00094 {\
00095 ctl_fstring(tchar) tmp = *(p1);\
00096 *(p1) = *(p2);\
00097 *(p2) = tmp;\
00098 }
00099
00107 #define ctl_fstring_move(tchar, p1, p2 )\
00108 {\
00109 (p1)->begin = (p2)->begin;\
00110 (p1)->end = (p2)->end;\
00111 (p1)->endBuff = (p2)->endBuff;\
00112 (p2)->begin = (p2)->end = (p2)->endBuff = NULL;\
00113 }
00114
00122 #define ctl_fstring_remain(tchar, self ) ( (self)->endBuff - (self)->end )
00123
00131 #define ctl_fstring_size(tchar, self ) ((size_t)( (self)->end - (self)->begin ))
00132
00140 #define ctl_fstring_maxsize(tchar, self ) ((size_t)( (self)->endBuff - (self)->begin ))
00141
00149 #define ctl_fstring_reset(tchar, self ) ( *((self)->end = (self)->begin) = 0 )
00150
00158 #define ctl_fstring_begin(tchar, self ) ( (self)->begin )
00159
00167 #define ctl_fstring_end(tchar, self ) ( (self)->end )
00168
00177 #define ctl_fstring_fill(tchar, self, fillVal, count ) ctl_mstring_(tchar,fixed, fill )((self), (fillVal), (count) )
00178
00186 #define ctl_fstring_add(tchar, self, ch ) ctl_mstring_(tchar,fixed, fill )((self), (ch), 1 )
00187
00196 #define ctl_fstring_filltab(tchar, self, fillVal, tabPos ) ctl_mstring_(tchar,fixed, filltab )((self), (fillVal), (tabPos) )
00197
00205 #define ctl_fstring_putbool(tchar, self, value ) ctl_mstring_(tchar,fixed, strncat )((self),(value) ? szconst(tchar,"true") : szconst(tchar,"false"), ~0u )
00206
00214 #define ctl_fstring_putboolyesno(tchar, self, value ) ctl_mstring_(tchar,fixed, strncat )((self),(value) ? szconst(tchar,"yes") : szconst(tchar,"no"), ~0u )
00215
00223 #define ctl_fstring_putboolonoff(tchar, self, value ) ctl_mstring_(tchar,fixed, strncat )((self),(value) ? szconst(tchar,"on") : szconst(tchar,"off"), ~0u )
00224
00232 #define ctl_fstring_putbool10(tchar, self, value ) ctl_mstring_(tchar,fixed, strncat )((self),(value) ? szconst(tchar,"1") : szconst(tchar,"0"), ~0u )
00233
00241 #define ctl_fstring_putint8(tchar, self, value ) ctl_mstring_(tchar,fixed, putint32 )((self),(int32)(int8)(value) )
00242
00250 #define ctl_fstring_putuint8(tchar, self, value ) ctl_mstring_(tchar,fixed, putuint32 )((self),(uint32)(uint8)(value) )
00251
00259 #define ctl_fstring_putint16(tchar, self, value ) ctl_mstring_(tchar,fixed, putint32 )((self),(int32)(int16)(value) )
00260
00268 #define ctl_fstring_putuint16(tchar, self, value ) ctl_mstring_(tchar,fixed, putuint32 )((self),(uint32)(uint16)(value) )
00269
00277 #define ctl_fstring_putint32(tchar, self, value ) ctl_mstring_(tchar,fixed, putint32 )((self),(value) )
00278
00286 #define ctl_fstring_putuint32(tchar, self, value ) ctl_mstring_(tchar,fixed, putuint32 )((self),(value) )
00287
00295 #define ctl_fstring_putint64(tchar, self, value ) ctl_mstring_(tchar,fixed, putint64 )((self),(value) )
00296
00304 #define ctl_fstring_putuint64(tchar, self, value ) ctl_mstring_(tchar,fixed, putuint64 )((self),(value) )
00305
00313 #define ctl_fstring_putfloat32(tchar, self, value ) ctl_mstring_(tchar,fixed, putfloat64 )((self),(value) )
00314
00322 #define ctl_fstring_putfloat64(tchar, self, value ) ctl_mstring_(tchar,fixed, putfloat64 )((self),(value) )
00323
00331 #define ctl_fstring_putxint8(tchar, self, value ) ctl_mstring_(tchar,fixed, putxuint32 )((self),(uint32)(value), 2 )
00332
00340 #define ctl_fstring_putxint16(tchar, self, value ) ctl_mstring_(tchar,fixed, putxuint32 )((self),(uint32)(value), 4 )
00341
00349 #define ctl_fstring_putxint32(tchar, self, value ) ctl_mstring_(tchar,fixed, putxuint32 )((self),(uint32)(value), 8 )
00350
00358 #define ctl_fstring_putxint64(tchar, self, value ) ctl_mstring_(tchar,fixed, putxuint64 )((self),(uint32)(value), 16 )
00359
00367 #define ctl_fstring_putxuint8(tchar, self, value ) ctl_mstring_(tchar,fixed, putxuint32 )((self),(uint32)(value), 2 )
00368
00376 #define ctl_fstring_putxuint16(tchar, self, value ) ctl_mstring_(tchar,fixed, putxuint32 )((self),(value), 4 )
00377
00385 #define ctl_fstring_putxuint32(tchar, self, value ) ctl_mstring_(tchar,fixed, putxuint32 )((self),(value), 8 )
00386
00394 #define ctl_fstring_putxuint64(tchar, self, value ) ctl_mstring_(tchar,fixed, putxuint64 )((self),(value), 16 )
00395
00405 #define ctl_fstring_putenum(tchar, self, value, szzList, szUndefined ) ctl_mstring_(tchar,fixed, putenum )((self),(value),(szzList), countof(szzList),(szUndefined) )
00406
00417 #define ctl_fstring_putenum_max(tchar, self, value, szzList, max, szUndefined ) ctl_mstring_(tchar,grow, putenum )((self),(value),(szzList), (max), (szUndefined) )
00418
00426 #define ctl_fstring_strcat(tchar, self, sz ) ctl_mstring_(tchar,fixed, strncat )((self),(sz), ~0u )
00427
00435 #define ctl_fstring_strcpy(tchar, self, sz ) ctl_mstring_(tchar,fixed, strncpy )((self),(sz), ~0u )
00436
00445 #define ctl_fstring_strncat(tchar, self, sz, maxLen ) ctl_mstring_(tchar,fixed, strncat )((self),(sz),(maxLen) )
00446
00455 #define ctl_fstring_strncpy(tchar, self, sz, maxLen ) ctl_mstring_(tchar,fixed, strncpy )((self),(sz),(maxLen) )
00456
00465 #define ctl_fstring_strinsert(tchar, self, position, sz ) ctl_mstring_(tchar,fixed, strninsert )((self),(position),(sz), 0u )
00466
00476 #define ctl_fstring_strninsert(tchar, self, position, sz, maxLen ) ctl_mstring_(tchar,fixed, strninsert )((self),(position),(sz),(maxLen) )
00477
00486 #define ctl_fstring_vsprintf(tchar, self, fmt, args ) ctl_mstring_(tchar,fixed, vsprintf )((self),(fmt),(args) )
00487
00496 #define ctl_fstring_sprintf(tchar, selffmtargs ) ctl_mstring_(tchar,fixed, sprintf ) selffmtargs
00497
00504 #define ctl_fstring_makeClabel(tchar,self) ctl_mstring_(tchar,fixed, makeClabel )( (self) )
00505
00513 #define ctl_fstring_truncate(tchar, self, newsize ) ctl_mstring_(tchar,fixed, truncate )( (self), (newsize) )
00514
00515 #define ctl_fstring_strncmp(tchar, p1, p2, lenp2 ) ctl_mstring_(tchar,fixed, strncmp )( p1, p2, (lenp2) )
00516 #define ctl_fstring_strnicmp(tchar, p1, p2, lenp2 ) ctl_mstring_(tchar,fixed, strnicmp )( p1, p2, (lenp2) )
00517 #define ctl_fstring_strcmp(tchar, p1, p2 ) ctl_mstring_(tchar,fixed, strncmp )( p1, p2, ~0u )
00518 #define ctl_fstring_stricmp(tchar, p1, p2 ) ctl_mstring_(tchar,fixed, strnicmp )( p1, p2, ~0u )
00519
00527 #define ctl_fstring_foreach(tchar,self,iterator) \
00528 tchar* iterator = (self)->begin;\
00529 tchar* ppConcat(end_,iterator) = (self)->end;\
00530 for( ; iterator < ppConcat(end_,iterator); ++iterator )
00531
00539 #define ctl_fstring_foreach_reverse(tchar,self,iterator) \
00540 tchar* iterator = (self)->end;\
00541 tchar* ppConcat(end_,iterator) = (self)->begin;\
00542 while( iterator-- < ppConcat(end_,iterator) )
00543
00544 #endif