cstring.h File Reference

Safe constant, fixed-length and variable length string templates. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define ctl_sconst(tchar)   ppConcat(ctl_sconst_,tchar)
 Get class name from base name and character type.
#define ctl_sconst_(tchar, function)   ppConcat3(ctl_sconst( tchar ),_,function)
 Build the function name from character type and root class.
#define ctl_sconst_auto(tchar, begin, end, label)   ctl_sconst( tchar ) label = { (begin), (begin), (end) }
 Make fixed string operator on stack or as a global, with begin/end pointers Uses non-standard ANSI extension: non-const initializers.
#define ctl_sconst_auto_string(tchar, mstr, label)   ctl_sconst( tchar ) label = { (mstr)->begin, (mstr)->begin, (mstr)->end }
 Make fixed string operator on stack or as a global, with buffer Uses non-standard ANSI extension: non-const initializers.
#define ctl_sconst_auto_buff(tchar, buff, len, label)   ctl_sconst( tchar ) label = { (buff), (buff), (buff)+cstrnlen(tchar)((buff),(len)) }
 Make fixed string operator on stack or as a global, with buffer Uses non-standard ANSI extension: non-const initializers.
#define ctl_sconst_auto_sz(tchar, sz, label)   ctl_sconst( tchar ) label = { (sz), (sz), (sz)+cstrlen(tchar)((sz)) }
 Make fixed string operator on stack or as a global, with buffer Uses non-standard ANSI extension: non-const initializers.
#define ctl_sconst_auto_mmap(tchar, mmap, label)   ctl_sconst( tchar ) label = { (const tchar*)ctl_mmap_ptr(mmap), (const tchar*)ctl_mmap_ptr(mmap), (const tchar*)ctl_mmap_ptr(mmap)+ctl_mmap_size(mmap) }
 Make fixed string operator on stack or as a global, with buffer Uses non-standard ANSI extension: non-const initializers.
#define ctl_sconst_init(tchar, self, buff, len)
 Initialize from a pointer and length.
#define ctl_sconst_init_sz(tchar, self, sz)
 Initialize from a NUL terminated string pointer.
#define ctl_sconst_init_mmap(tchar, self, mmap)
 Initialize from a NUL terminated string pointer.
#define ctl_sconst_printf_fmt(tchar)   szconst(tchar,"%.*s")
 Printf format string for ctl_sconst_printf_arg.
#define ctl_sconst_printf_arg(self)   ((self)->end - (self)->begin), (self)->begin
 Printf arguments for ctl_sconst_printf_fmt.
#define ctl_sconst_copy(tchar, self, from)
 Copy from another ctlmfg_ctl_sconst.
#define ctl_sconst_init_pointers(tchar, self, pBegin, pEnd)
 Initialize from a pointer and length.
#define ctl_sconst_from_ctlfixed(tchar, self, fixed)
 Reference a fixed C string for parsing.
#define ctl_sconst_from_ctlstring(tchar, self, variable)
 Reference a fixed C string for parsing.
#define ctl_sconst_remain(tchar, self)   ( (self)->end - (self)->parse )
 Tell how many characters remain to be parsed.
#define ctl_sconst_consumed(tchar, self)   ( (self)->parse - (self)->begin )
 Tell how many characters have been parsed.
#define ctl_sconst_size(tchar, self)   ((size_t)( (self)->end - (self)->begin ))
 Tell how many characters are in the string.
#define ctl_sconst_parse(tchar, self)   ( (self)->parse )
 Get current parse position.
#define ctl_sconst_reset(tchar, self)   ( (self)->parse = (self)->begin )
 Reset parse point to beginning.
#define ctl_sconst_begin(tchar, self)   ( (self)->begin )
 Reset parse point to beginning.
#define ctl_sconst_end(tchar, self)   ( (self)->end )
 Reset parse point to beginning.
#define ctl_sconst_next(tchar, self)   ( (self)->parse < (self)->end ? (++(self)->parse) : (self)->end )
 Parse to next character in const string.
#define ctl_sconst_prev(tchar, self)   ( (self)->parse > (self)->begin ? (--(self)->parse) : (self)->begin )
 Parse to previous character in const string.
#define ctl_sconst_isalnum(tchar, self)   ( cisalnum(tchar)(*(self)->parse) )
 C runtime clone of isalnum.
#define ctl_sconst_isalpha(tchar, self)   ( cisalpha(tchar)(*(self)->parse) )
 C runtime clone of isalpha.
#define ctl_sconst_iscntrl(tchar, self)   ( ciscntrl(tchar)(*(self)->parse) )
 C runtime clone of iscntrl.
#define ctl_sconst_isdigit(tchar, self)   ( cisdigit(tchar)(*(self)->parse) )
 C runtime clone of isdigit.
#define ctl_sconst_isgraph(tchar, self)   ( cisgraph(tchar)(*(self)->parse) )
 C runtime clone of isgraph.
#define ctl_sconst_islower(tchar, self)   ( cislower(tchar)(*(self)->parse) )
 C runtime clone of islower.
#define ctl_sconst_ispunct(tchar, self)   ( cispunct(tchar)(*(self)->parse) )
 C runtime clone of ispunct.
#define ctl_sconst_isspace(tchar, self)   ( cisspace(tchar)(*(self)->parse) )
 C runtime clone of isspace.
#define ctl_sconst_isupper(tchar, self)   ( cisupper(tchar)(*(self)->parse) )
 C runtime clone of isupper.
#define ctl_sconst_isprint(tchar, self)   ( cisprint(tchar)(*(self)->parse) )
 C runtime clone of isprint.
#define ctl_sconst_isxdigit(tchar, self)   ( cisxdigit(tchar)(*(self)->parse) )
 C runtime clone of isxdigit.
#define ctl_sconst_left(tchar, self, cstr_left, count)
 A bit like left$ in BASIC, except it produces a const substring.
#define ctl_sconst_right(tchar, self, cstr_right, count)
 A bit like right$ in BASIC, except it produces a const substring.
#define ctl_sconst_mid(tchar, self, cstr_mid, offset, count)
 A bit like mid$ in BASIC, except it produces a const substring.
#define ctl_sconst_strchr(tchar, self, ch)   ctl_sconst_(tchar,strchr)( self, ch )
 Look for a character in a string.
#define ctl_sconst_strichr(tchar, self, ch)   ctl_sconst_(tchar,strichr)( self, ch )
 Look for a character in a string; case insensitive.
#define ctl_sconst_strstr(tchar, self, sz)   ctl_sconst_(tchar,strstr)( self, sz )
 Look for a string in a string.
#define ctl_sconst_stristr(tchar, self, sz)   ctl_sconst_(tchar,stristr)( self, sz )
 Look for a string in a string; case insensitive.
#define ctl_sconst_dmatch(tchar, self, substring, chOpen, chClose)   ctl_sconst_(tchar,dmatch)( self, substring, chOpen, chClose )
 Search for a block of text enclosed by two symbols, such as (), {} or [] The depth of opening types is matched to the depth of closing types.
#define ctl_sconst_dmatchstr(tchar, self, substring, szOpen, szClose)   ctl_sconst_(tchar,dmatchstr)( self, substring, szOpen, szClose )
 Search for a block of text enclosed by two strings, such as "<",/>" "begin","end".
#define ctl_sconst_strpbrk(tchar, self, szSet)   ctl_sconst_(tchar,strpbrk)( self, szSet )
 Look for any one of the characters in szSet in this string starting at parse point.
#define ctl_sconst_skipspace(tchar, self)   ctl_sconst_(tchar,skipspace)( self )
 Skip over any white space.
#define ctl_sconst_nextspace(tchar, self)   ctl_sconst_(tchar,nextspace)( self )
 Skip over any NON-white space until we find a space.
#define ctl_sconst_findclass(tchar, self, classname)   ctl_sconst_(tchar,ppConcat(find_,classname))( self )
 Find the next instance of a character class ala ctype.h.
#define ctl_sconst_findnotclass(tchar, self, classname)   ctl_sconst_(tchar,ppConcat(find_not_,classname))( self )
 Find the next instance that is not of a character class ala ctype.h.
#define ctl_sconst_scanclass(tchar, self, found, classname)   ctl_sconst_(tchar,ppConcat(scan_,classname))( self, found )
 Scan for a block of characters that are of a class type.
#define ctl_sconst_scannotclass(tchar, self, found, classname)   ctl_sconst_(tchar,ppConcat(scan_not_,classname))( self, found )
 Scan for a block of characters that are NOT of a class type.
#define ctl_sconst_strcmp(tchar, self, sz)   ctl_sconst_(tchar,strcmp)( self, sz )
 Do a string comparison at parse point.
#define ctl_sconst_stricmp(tchar, self, sz)   ctl_sconst_(tchar,stricmp)( self, sz )
 Do a case insensitive string comparison at parse point.
#define ctl_sconst_strncmp(tchar, self, sz, count)   ctl_sconst_(tchar,strncmp)( self, sz, count )
 Do a string comparison at parse point.
#define ctl_sconst_strnicmp(tchar, self, sz, count)   ctl_sconst_(tchar,strnicmp)( self, sz, count )
 Do a case insensitive string comparison at parse point.
#define ctl_sconst_compare(tchar, p1, p2)   ctl_sconst_(tchar,compare)( (p1),(p2) )
 Do a string comparison at parse point.
#define ctl_sconst_rcompare(tchar, p1, p2)   ctl_sconst_(tchar,compare)( (p2),(p1) )
 Do a string reverse comparison at parse point.
#define ctl_sconst_icompare(tchar, self, other)   ctl_sconst_(tchar,icompare)( (self), (other) )
 Do a case insensitive string comparison at parse point.
#define ctl_sconst_getbool(tchar, self, pValue)   ctl_sconst_(tchar,getbool)( self, pValue )
 Decode a boolean; any decimal number, true/on, false/off will do.
#define ctl_sconst_getint8(tchar, self, pValue)   ctl_sconst_(tchar,getint8)( self, pValue )
 Decode a value.
#define ctl_sconst_getuint8(tchar, self, pValue)   ctl_sconst_(tchar,getuint8)( self, pValue )
 Decode a value.
#define ctl_sconst_getint16(tchar, self, pValue)   ctl_sconst_(tchar,getint16)( self, pValue )
 Decode a value.
#define ctl_sconst_getuint16(tchar, self, pValue)   ctl_sconst_(tchar,getuint16)( self, pValue )
 Decode a value.
#define ctl_sconst_getint32(tchar, self, pValue)   ctl_sconst_(tchar,getint32)( self, pValue )
 Decode a value.
#define ctl_sconst_getuint32(tchar, self, pValue)   ctl_sconst_(tchar,getuint32)( self, pValue )
 Decode a value.
#define ctl_sconst_getint64(tchar, self, pValue)   ctl_sconst_(tchar,getint64)( self, pValue )
 Decode a value.
#define ctl_sconst_getuint64(tchar, self, pValue)   ctl_sconst_(tchar,getuint64)( self, pValue )
 Decode a value.
#define ctl_sconst_getfloat32(tchar, self, pValue)   ctl_sconst_(tchar,getfloat32)( self, pValue )
 Decode a value.
#define ctl_sconst_getfloat64(tchar, self, pValue)   ctl_sconst_(tchar,getfloat64)( self, pValue )
 Decode a value.
#define ctl_sconst_getxbool(tchar, self, pValue)   ctl_sconst_(tchar,getbool)( self, pValue )
 Decode an 8 bit hexadecimal value, stopping at 2 digits.
#define ctl_sconst_getxint8(tchar, self, pValue)   ctl_sconst_(tchar, getxint8 )( self, pValue )
 Decode an 8 bit hexadecimal value, stopping at 2 digits.
#define ctl_sconst_getxuint8(tchar, self, pValue)   ctl_sconst_(tchar, getxuint8 )( self, pValue )
 Decode an 8 bit hexadecimal value, stopping at 2 digits.
#define ctl_sconst_getxint16(tchar, self, pValue)   ctl_sconst_(tchar, getxint16 )( self, pValue )
 Decode a 16 bit hexadecimal value, stopping at 4 digits.
#define ctl_sconst_getxuint16(tchar, self, pValue)   ctl_sconst_(tchar, getxuint16 )( self, pValue )
 Decode a 16 bit hexadecimal value, stopping at 4 digits.
#define ctl_sconst_getxint32(tchar, self, pValue)   ctl_sconst_(tchar, getxuint32 )( self, (uint32*)(pValue), 8 )
 Decode a 32 bit hexadecimal value, stopping at 8 digits.
#define ctl_sconst_getxuint32(tchar, self, pValue)   ctl_sconst_(tchar, getxuint32 )( self, pValue, 8 )
 Decode a 32 bit hexadecimal value, stopping at 8 digits.
#define ctl_sconst_getxint64(tchar, self, pValue)   ctl_sconst_(tchar, getxuint64 )( self, (uint64*)(pValue), 16 )
 Decode a 64 bit hexadecimal value, stopping at 16 digits.
#define ctl_sconst_getxuint64(tchar, self, pValue)   ctl_sconst_(tchar, getxuint64 )( self, pValue, 16 )
 Decode a 64 bit hexadecimal value, stopping at 16 digits.
#define ctl_sconst_getxn(tchar, self, pValue, numDigits)   ctl_sconst_(tchar, getx64 )( self, pValue, numDigits )
 Decode a hexadecimal value up to 32 bits (8 digits), limiting to some arbitrary number of places of precision Useful for places where we simply append hexadecimal data together at fixed widths.
#define ctl_sconst_getxnn(tchar, self, pValue, numDigits)   ctl_sconst_(tchar, getx64 )( self, pValue, numDigits )
 Decode a hexadecimal value up to 64 bits (16 digits), limiting to some arbitrary number of places of precision Useful for places where we simply append hexadecimal data together at fixed widths.
#define ctl_sconst_getenum(tchar, self, pValue, szz)   ctl_sconst_(tchar,getenum)( self, pValue, szz )
 Decode one of a set of possible strings to an index into that set.
#define ctl_sconst_getienum(tchar, self, pValue, szz)   ctl_sconst_(tchar,getienum)( self, pValue, szz )
 Decode one of a set of possible strings to an index into that set, case insensitive.
#define ctldecl_ctl_sconst(tchar)
 Declare a constant string parser class of functionality.
#define DEF_Supported_Class_Scans(tchar, def)
 This is the generator template list for scanning for character types ala ctype.h; add your custom handlers here to extend it, if you like.
#define decl_sconst_findclass(tchar, classname)   bool ctl_sconst_(tchar, ppConcat(find_,classname) )( ctl_sconst( tchar )* self );
#define ctl_sconst_foreach(tchar, self, iterator)
 Iterate the characters in the string from beginning to end.
#define ctl_sconst_foreach_reverse(tchar, self, iterator)
 Iterate the characters in the string from end to beginning.

Functions

struct ppConcat (ctl_sconst_, char)
 Constant substring parser class\.
struct ppConcat (ctl_sconst_, wchar_t)
 Constant substring parser class\.


Detailed Description

Safe constant, fixed-length and variable length string templates.

Author:
David Mace
Currently these only support wchar_t or char. The wchar_t is for assumed to be wide (unicode) characters, and if it isn't defined for your target, just stick to char, or define all of the relevant translations and extensions, then plug them in as your own lib.

Definition in file cstring.h.


Define Documentation

#define decl_sconst_findclass ( tchar,
classname   )     bool ctl_sconst_(tchar, ppConcat(find_,classname) )( ctl_sconst( tchar )* self );

Manufacture character class search declarations based on ctype.h functions

Definition at line 983 of file cstring.h.


Generated on Fri Jan 2 15:28:35 2009 for Squat by  doxygen 1.5.6