#include "ccobject.h"
#include "errors.h"
Go to the source code of this file.
Classes | |
class | StringBase |
Defines | |
#define | FIX_LEN_BUFM(x) (((x)+1)*2) |
General-purpose string class. Overloads the C++ arithmetic operator += which for strings perform concatenation, together with the comparison operators <, >, !=, ==, etc, which will perform case-sensitive comparisons according to the local custom. | |
#define | DEFINE_BUFSIZE(x) const INT32 String_ ## x::FIX_LEN_BUFSIZE = FIX_LEN_BUFM(x); |
Functions | |
INT32 CCAPI | SmartLoadString (UINT32 modID, UINT32 resID, TCHAR *buf, INT32 size) |
TCHAR * | cc_camStrncpy (TCHAR *dest, const TCHAR *src, size_t n) |
const TCHAR * | cc_lstrstr (const TCHAR *String1, const TCHAR *String2) |
Read/write a string to/from a persistent stream, a.k.a. an archive, depending upon the value of ar.IsStoring(). Finds the first occurrence of string2 in string1 This version is case sensitive. Notes: Replaces the Windows API version which seems to be missing. Uses TCHAR's instead of char's, and also uses CompareString for multinational support. | |
TCHAR * | cc_lstrchr (TCHAR *Str, TCHAR c) |
Searches a string for a given character, which may be the 0 character ''. This version is case sensitive. Notes: Replaces the Windows API version which seems to be missing. Uses TCHAR's instead of char's. | |
TCHAR * | cc_lstrrchr (TCHAR *Str, TCHAR c) |
Finds the last occurrence of ch in string. The terminating 0 character is used as part of the search. This version is case sensitive. Notes: Replaces the Windows API version which seems to be missing. Uses TCHAR's instead of char's. | |
TCHAR * | cc_lstrtok (TCHAR *String1, TCHAR *String2) |
strtok considers the string to consist of a sequence of zero or more text tokens separated by spans of one or more control chars. the first call, with string specified, returns a pointer to the first char of the first token, and will write a 0 char into string immediately following the returned token. subsequent calls with zero for the first argument (string) will work thru the string until no tokens remain. the control string may be different from call to call. when no tokens remain in string a 0 pointer is returned. remember the control chars with a bit map, one bit per ascii char. the 0 char is always a control char. Notes: Replaces the Windows API version which seems to be missing. Uses TCHAR's instead of char's. I'm not totally convinced it's going to work with DBCS, but if everyone uses it, at least we've got a single fix... | |
INT32 | cc_lstrncmp (TCHAR *String1, TCHAR *String2, INT32 Count) |
Compares two strings for lexical order. The comparison stops after: (1) a difference between the strings is found, (2) the end of the strings is reached, or (3) count characters have been compared. Notes: Replaces the Windows API version which seems to be missing. Uses TCHAR's instead of char's, and also uses CompareString for multinational support. | |
size_t | cc_strlenCharacters (const TCHAR *string) |
Returns the number of characters in a string - not necessaraily the length of the string. | |
size_t | cc_strlenBytes (const TCHAR *string) |
Returns the number of bytes needed to store the given string. Dosen't include the terminator. Unicode and DBCS aware. | |
bool | operator== (const StringBase &x, const TCHAR *y) |
Comparison (logical) operators, eg. x = "alpha"; y = "beta"; cout << "First is " << (x < y ? x : y) << endl; These functions will work according to local custom. | |
bool | operator== (const StringBase &x, const StringBase &y) |
bool | operator!= (const StringBase &x, const StringBase &y) |
Comparison (logical) operators, eg. x = "alpha"; y = "beta"; cout << "First is " << (x < y ? x : y) << endl; These functions will work according to local custom. | |
bool | operator!= (const StringBase &x, const TCHAR *y) |
bool | operator< (const StringBase &x, const StringBase &y) |
Comparison (logical) operators, eg. x = "alpha"; y = "beta"; cout << "First is " << (x < y ? x : y) << endl; These functions will work according to local custom. | |
bool | operator< (const StringBase &x, const TCHAR *y) |
bool | operator> (const StringBase &x, const StringBase &y) |
Comparison (logical) operators, eg. x = "alpha"; y = "beta"; cout << "First is " << (x < y ? x : y) << endl; These functions will work according to local custom. | |
bool | operator> (const StringBase &x, const TCHAR *y) |
bool | operator<= (const StringBase &x, const StringBase &y) |
Comparison (logical) operators, eg. x = "alpha"; y = "beta"; cout << "First is " << (x < y ? x : y) << endl; These functions will work according to local custom. | |
bool | operator<= (const StringBase &x, const TCHAR *y) |
bool | operator>= (const StringBase &x, const TCHAR *y) |
Comparison (logical) operators, eg. x = "alpha"; y = "beta"; cout << "First is " << (x < y ? x : y) << endl; These functions will work according to local custom. | |
bool | operator>= (const StringBase &x, const StringBase &y) |
TCHAR * | cc_camStrncpy (TCHAR *dest, const TCHAR *src, INT32 n) |
Replaces the Windows API function camStrncpy(), whose existence has been rewritten out of history. Does basically what the standard C library function memmove() does, only for TCHARs. | |
Variables | |
const size_t | MAX_STRING_RES_LENGTH = 255 |
const INT32 | str_MAXEXCEPTIONS = 30 |
|
|
|
General-purpose string class. Overloads the C++ arithmetic operator += which for strings perform concatenation, together with the comparison operators <, >, !=, ==, etc, which will perform case-sensitive comparisons according to the local custom.
The primary use of this class is to serve as a base for the derivation of fixed length StringBases. Derived String_N's, unlike their StringBase base classes, do not allocate a buffer for text on the heap, but within their class instance. Note that these kind of base-class strings CAN be of an arbitrary length, but the user must call Alloc() to change the length - all member functions assume that the StringBase is long enough to cope with the operation of the function. Attempts to access past the end of the string will be trapped with ASSERTions.
|
|
Replaces the Windows API function camStrncpy(), whose existence has been rewritten out of history. Does basically what the standard C library function memmove() does, only for TCHARs.
Definition at line 1121 of file basestr.h. 01122 { 01123 ERROR3IF(src == 0 || dest == 0 || n <= 0, 01124 "0 (zero) parameters passed to cc_camStrncpy!"); 01125 return camStrncpy(dest, src, n + 1); // +1 as camStrncpy includes the terminator. 01126 }
|
|
|
|
Searches a string for a given character, which may be the 0 character ''. This version is case sensitive. Notes: Replaces the Windows API version which seems to be missing. Uses TCHAR's instead of char's.
Definition at line 1352 of file basestr.h. 01353 { 01354 ERROR3IF(Str == 0, "0 (zero) parameters passed to cc_lstrchr"); 01355 return (Str != 0) ? camStrchr(Str, c) : 0; 01356 01357 // while (*Str && *Str != c) 01358 // Str++; 01359 // 01360 // if (*Str == c) 01361 // return(Str); 01362 // return(0); 01363 }
|
|
Compares two strings for lexical order. The comparison stops after: (1) a difference between the strings is found, (2) the end of the strings is reached, or (3) count characters have been compared. Notes: Replaces the Windows API version which seems to be missing. Uses TCHAR's instead of char's, and also uses CompareString for multinational support.
Definition at line 1286 of file basestr.h. 01287 { 01288 ERROR3IF(String1 == 0 || String2 == 0, 01289 "INT32 cc_lstrncmp(TCHAR *String1, TCHAR *String2, INT32 Count) given 0 params"); 01290 return (Count != 0) ? camStrncmp(String1, String2, Count) : 0; 01291 }
|
|
Finds the last occurrence of ch in string. The terminating 0 character is used as part of the search. This version is case sensitive. Notes: Replaces the Windows API version which seems to be missing. Uses TCHAR's instead of char's.
Definition at line 1151 of file basestr.h. 01152 { 01153 ERROR3IF(Str == 0, "0 (zero) parameters passed to cc_lstrrchr"); 01154 return (Str != 0) ? camStrrchr(Str, c) : 0; 01155 01156 // TCHAR *start = Str; 01157 // 01158 // /* find end of string */ 01159 // while (*Str++); 01160 // 01161 // /* search towards front */ 01162 // while (--Str != start && *Str != c); 01163 // 01164 // /* char found ? */ 01165 // if (*Str == c) 01166 // return(Str); 01167 // 01168 // return(0); 01169 }
|
|
Read/write a string to/from a persistent stream, a.k.a. an archive, depending upon the value of ar.IsStoring(). Finds the first occurrence of string2 in string1 This version is case sensitive. Notes: Replaces the Windows API version which seems to be missing. Uses TCHAR's instead of char's, and also uses CompareString for multinational support.
Definition at line 1632 of file basestr.cpp. 01633 { 01634 ERROR3IF(String1 == 0 || String2 == 0, 01635 "0 (zero) parameters passed to cc_lstrstr"); 01636 01637 if (String1 == 0 || String2 == 0) return 0; 01638 if (!*String2) return String1; 01639 return camStrstr(String1, String2); 01640 01641 // TCHAR *cp = String1; 01642 // TCHAR *s1; 01643 // TCHAR *s2; 01644 01645 // while (*cp) 01646 // { 01647 // s1 = cp; 01648 // s2 = String2; 01649 01650 // // DCBS compatible case sensitive string compare 01651 // while(*s1 && *s2 && (CompareString(LOCALE_USER_DEFAULT, 01652 // (NORM_IGNOREKANATYPE | NORM_IGNOREWIDTH), 01653 // s1, 1, s2, 1) == 2)) 01654 // s1++, s2++; 01655 // if(!*s2) 01656 // return(cp); 01657 // cp++; 01658 // } 01659 // 01660 // return(0); 01661 }
|
|
strtok considers the string to consist of a sequence of zero or more text tokens separated by spans of one or more control chars. the first call, with string specified, returns a pointer to the first char of the first token, and will write a 0 char into string immediately following the returned token. subsequent calls with zero for the first argument (string) will work thru the string until no tokens remain. the control string may be different from call to call. when no tokens remain in string a 0 pointer is returned. remember the control chars with a bit map, one bit per ascii char. the 0 char is always a control char. Notes: Replaces the Windows API version which seems to be missing. Uses TCHAR's instead of char's. I'm not totally convinced it's going to work with DBCS, but if everyone uses it, at least we've got a single fix...
Definition at line 1201 of file basestr.h. 01202 { 01203 return NULL; 01204 01205 // return _tcstok(String1, String2); 01206 01207 // TCHAR *string = String1; 01208 // TCHAR *str; 01209 // TCHAR *ctrl = String2; 01210 // 01211 // TCHAR map[32]; 01212 // INT32 count; 01213 // 01214 // static TCHAR nextoken[256]; 01215 // 01216 // /* Clear control map */ 01217 // for (count = 0; count < 32; count++) 01218 // map[count] = 0; 01219 // 01220 // /* Set bits in delimiter table */ 01221 // do 01222 // { 01223 // map[*ctrl >> 3] |= (1 << (*ctrl & 7)); 01224 // } while (*ctrl++); 01225 // 01226 // /* Initialize str. If string is 0, set str to the saved 01227 // * pointer (i.e., continue breaking tokens out of the string 01228 // * from the last strtok call) */ 01229 // if (string) 01230 // str = string; 01231 // else 01232 // str = (TCHAR *)nextoken; 01233 // 01234 // /* Find beginning of token (skip over leading delimiters). Note that 01235 // * there is no token iff this loop sets str to point to the terminal 01236 // * 0 (*str == '\0') */ 01237 // while ( (map[*str >> 3] & (1 << (*str & 7))) && *str ) 01238 // str++; 01239 // 01240 // string = str; 01241 // 01242 // /* Find the end of the token. If it is not the end of the string, 01243 // * put a 0 there. */ 01244 // for ( ; *str ; str++ ) 01245 // if ( map[*str >> 3] & (1 << (*str & 7)) ) 01246 // { 01247 // *str++ = '\0'; 01248 // break; 01249 // } 01250 // 01251 // /* Update nextoken (or the corresponding field in the per-thread data 01252 // * structure */ 01253 // camStrcpy(nextoken, str); 01254 // 01255 // /* Determine if a token has been found. */ 01256 // if ( string == str ) 01257 // return 0; 01258 // else 01259 // return string; 01260 }
|
|
Returns the number of bytes needed to store the given string. Dosen't include the terminator. Unicode and DBCS aware.
Definition at line 1324 of file basestr.h.
|
|
Returns the number of characters in a string - not necessaraily the length of the string.
Definition at line 1306 of file basestr.h. 01307 { 01308 return camStrclen(string); 01309 }
|
|
Definition at line 967 of file basestr.h. 00968 { 00969 return !x.IsIdentical(y); 00970 }
|
|
Comparison (logical) operators, eg. x = "alpha"; y = "beta"; cout << "First is " << (x < y ? x : y) << endl; These functions will work according to local custom.
Definition at line 961 of file basestr.h. 00962 { 00963 return !x.IsIdentical(y); 00964 }
|
|
Definition at line 993 of file basestr.h. 00994 { 00995 return x.CompareTo(y) < 0; 00996 }
|
|
Comparison (logical) operators, eg. x = "alpha"; y = "beta"; cout << "First is " << (x < y ? x : y) << endl; These functions will work according to local custom.
Definition at line 987 of file basestr.h. 00988 { 00989 return x.CompareTo(y) < 0; 00990 }
|
|
Definition at line 1047 of file basestr.h. 01048 { 01049 return x.CompareTo(y) <= 0; 01050 }
|
|
Comparison (logical) operators, eg. x = "alpha"; y = "beta"; cout << "First is " << (x < y ? x : y) << endl; These functions will work according to local custom.
Definition at line 1041 of file basestr.h. 01042 { 01043 return x.CompareTo(y) <= 0; 01044 }
|
|
Definition at line 938 of file basestr.h. 00939 { 00940 return x.IsIdentical(y); 00941 }
|
|
Comparison (logical) operators, eg. x = "alpha"; y = "beta"; cout << "First is " << (x < y ? x : y) << endl; These functions will work according to local custom.
Definition at line 932 of file basestr.h. 00933 { 00934 return x.IsIdentical(y); 00935 }
|
|
Definition at line 1020 of file basestr.h. 01021 { 01022 return x.CompareTo(y) > 0; 01023 }
|
|
Comparison (logical) operators, eg. x = "alpha"; y = "beta"; cout << "First is " << (x < y ? x : y) << endl; These functions will work according to local custom.
Definition at line 1014 of file basestr.h. 01015 { 01016 return x.CompareTo(y) > 0; 01017 }
|
|
Definition at line 1076 of file basestr.h. 01077 { 01078 return x.CompareTo(y) >= 0; 01079 }
|
|
Comparison (logical) operators, eg. x = "alpha"; y = "beta"; cout << "First is " << (x < y ? x : y) << endl; These functions will work according to local custom.
Definition at line 1069 of file basestr.h. 01070 { 01071 return x.CompareTo(y) >= 0; 01072 }
|
|
|
|
|
|
|