StringBase Class Reference

#include <basestr.h>

Inheritance diagram for StringBase:

CCObject SimpleCCObject String_128 String_16 String_256 String_32 String_64 String_8 StringVar List of all members.

Public Member Functions

 StringBase ()
 Default constructor for a StringBase. Sets the character buffer to 0 and the string length to zero. The user must call Alloc() before trying to use the StringBase. Scope: Public.
virtual ~StringBase ()
 Destroys & cleans up a string.
virtual BOOL Alloc (INT32 size)
 Allocates space on the heap for a 0-terminated string of the passed size. This function should only be called for the StringBase base class, NOT for any of its fixed-length derivatives.
BOOL Load (UINT32 resID, UINT32 inst=0)
 Extracts a string from the application's .EXE file, by default, or another module (eg. a dedicated DLL), overwriting the old contents of this StringBase object.
INT32 Length () const
 Calculates the length of the string.
INT32 MaxLength () const
 Calculates the longest allowed string that can be stored in this.
BOOL IsEmpty () const
 Tests for the 0 string.
INT32 NextIndex (INT32 index) const
 Find the next character index Notes: If string exceptions are enabled, an exception will be thrown if the index goes out of range.
INT32 PrevIndex (INT32 index) const
 Find the previous character index Notes: If string exceptions are enabled, an exception will be thrown if the index goes out of range.
BOOL IsLegal (INT32 index) const
 Check index for its legality.
BOOL IsIllegal (INT32 index) const
 Check index for its legality.
StringBaseEmpty ()
 Sets a string to the 0 string (zero-terminated but no characters, NOT A 0 POINTER!).
StringBasetoUpper ()
 Converts all lower-case letters in the string to upper-case.
StringBasetoLower ()
 Converts all upper-case letters to lower-case.
StringBasetoTitle ()
 Converts all the first letters of words to uppercase and the rest to lower case.
INT32 __cdecl MakeMsg (UINT32 resID...)
 Internationally portable version of sprintf(...), eg. StringBase s; INT32 x, y, z; s.MakeMsg(_R(IDS_COORDFORMAT), x, y, z); TextOut(hdc, 20, 20, s, s.Length());.
INT32 __cdecl _MakeMsg (const TCHAR *fmt...)
 Internationally portable version of sprintf(...), eg. UINT32 x; s._MakeMsg("#1%lu", x); TextOut(hdc, 20, 20, s, s.Length());.
 operator TCHAR * ()
 Cast a string into a C-style pointer to array of characters. If you intend to use the subscript operator [] with the results of the cast remember that no range checking is performed.
 operator const TCHAR * () const
 Cast a string into a C-style pointer to array of constant characters.
 operator wxString ()
 Cast a string into a wxString.
 operator const wxString () const
 Cast a string into a wxString.
StringBaseoperator+= (const StringBase &rhs)
 Append string y onto the end of string x, eg. x = TEXT("hello"); cout << (x += TEXT(" world!")) << endl;.
StringBaseoperator+= (const TCHAR *s)
 Append string y onto the end of string x, eg. x = TEXT("hello"); cout << (x += TEXT(" world!")) << endl;.
StringBaseoperator+= (const TCHAR ch)
 Appends this character to the end of this string.
StringBaseoperator= (const StringBase &other)
 Assignment (set equal to) operator, eg. StringBase x("rhubarb"); x = "custard";.
StringBaseoperator= (const TCHAR *s)
 Assignment (set equal to) operator, eg. StringBase x("rhubarb"); x = "custard";.
StringBaseoperator= (const TCHAR ch)
 Assigns the single character to this string.
const StringBaseLeft (StringBase *out, UINT32 count) const
 Similar to the BASIC Left$() string function.
const StringBaseMid (StringBase *out, UINT32 first, UINT32 count) const
 Similar to the BASIC Mid$() function.
const StringBaseRight (StringBase *out, UINT32 count) const
 Similar to the BASIC Right$() function.
void Split (StringBase *pstrStart, StringBase *pstrEnd, INT32 iSplit, BOOL fIncludeSplitChar)
 Splits a string into two separate strings at a given character.
INT32 Sub (const StringBase &mask, UINT32 from=0, TCHAR fuzz=0) const
 Similar to the (non-standard) BASIC Instr$() function. Scope: Public.
INT32 SubWithoutCase (const StringBase &strToFind) const
 Similar to the (non-standard) BASIC Instr$() function. Scope: Public.
void Remove (INT32 Position, INT32 Number)
 Inserting a string into another one. Scope: Public.
void Insert (const StringBase &InsertString, INT32 Position)
 Inserting a string into another one. Scope: Public.
void SwapChar (const TCHAR schar, const TCHAR rchar)
 Exchange all schar characters in the string with rchar characters Scope: Public.
INT32 CountChar (const TCHAR tchar)
 Count all tchar characters in the string Scope: Public.
TCHAR operator[] (const INT32 Index)
 Extract single characters from the string... 0 is the first char, String.Length() is the terminating zero...
const WCHAR CharAt (const INT32 Index) const
 Extract single characters from the string... 0 is the first char, String.Length() is the terminating zero...
INT32 SkipComma (INT32 pos=0) const
 Find the next comma (starting from pos) and skip on to the next none space character beyond it. Notes: ** Throws an exception if string exceptions are enabled **.
INT32 SkipSpace (INT32 pos=0) const
 Find the next non-space character starting from pos. If pos is a none space character, the function will simply return with the same index. Notes: ** Throws an exception if string exceptions are enabled **.
INT32 FindNextChar (INT32 position=0) const
 Find the next none space character starting from pos. If pos is a none space character, the function will simply return with the same index. Notes: ** Throws an exception if string exceptions are enabled **.
INT32 FindNextChar (TCHAR c, INT32 position=0) const
 Find the next character to match c starting from position. Notes: ** Throws an exception if string exceptions are enabled **.
INT32 ConvertToInteger (INT32 &position) const
 Convert the sequence of characters starting from position into a numeric value. 32 bits of precision are returned and hence approx 10 digit numbers can be represented. If the numeric string is longer, the value 0x7FFFFFFF is returned (ie represting an overflow). If string exceptions are enabled, an exception will be thrown in this instance. All valid numeric digits will be read, no matter whether an overflow is immanent or not, hence you can safely continue to parse what is expected to be the next token along the string. The types of numbers allowed are +123686 -12394 124802398 but not 12439127397123.
INT32 ReverseFind (TCHAR cToFind) const
 As above.
virtual void MakePercent (INT32 Value)
 Set the string equal to the given argument + a % character, or however the current locale wants it Example: String_32 Str; Str.MakePercent(23); For UK, Str now equals "23%".
virtual void MakePercent (double Value)
virtual void MakePercent (TCHAR *Value)
virtual void FixFormat ()
bool IsIdentical (const TCHAR *other) const
 Compare this StringBase object to another string.
bool IsIdentical (const StringBase &other) const
 Compare this StringBase object to another string.
INT32 CompareTo (const TCHAR *other, BOOL CaseSensitive=TRUE) const
 Compare this StringBase object to another string. This is mainly intended for use internally by the comparison operators, but may also come in handy in other places.
INT32 CompareTo (const StringBase &other, BOOL CaseSensitive=TRUE) const
 Compare this StringBase object to another string. This is mainly intended for use internally by the comparison operators, but may also come in handy in other places.

Static Public Member Functions

static BOOL IsAlpha (TCHAR c)
 Tests if the character is a-z, A-Z (or local equivalent).
static BOOL IsAlphaNumeric (TCHAR c)
 Tests if the character is a-z, A-Z, 0-9, or local equivalent.
static BOOL IsNumeric (TCHAR c)
 Tests if the character is 0-9, or local equivalent.
static BOOL IsLower (TCHAR c)
 Tests if the character is a-z (or local equivalent).
static BOOL IsUpper (TCHAR c)
 Tests if the character is A-Z, or local equivalent.
static BOOL IsSpace (TCHAR c)
static TCHARSafeCat (TCHAR *pstr1, const TCHAR *pcstr2, UINT32 nchMax)
 Appends string2 to the end of string1 and returns string1 as the result. The difference between this and camStrcat is the Max parameter which helps alleviate the buffer overwrite problems. Setting max to the length member of a stringbase will ERROR3IF that we don't go overwriting ends of buffers and suchlike... In such cases the result will be trucated.
static BOOL EnableExceptionHandler (BOOL PushNewHandler=TRUE)
 This function adds a new exception handler to the string exception handler stack (if PushNewHandler is TRUE). Otherwise it will simply change the state of the most recently pushed handler. If there are no handlers and Push is FALSE, an ERROR3IF will be generated.
static BOOL DisableExceptionHandler (BOOL PopHandler=TRUE)
 This function disables or completely removes the most previously enabled exception state. FALSE will be returned if the exception stack is empty. The default parameter allows you to temporarily disable the exception state without poping the handler.
static BOOL WillThrowException ()
 This function interogates the exceptions state stack and determins whether exceptions will be thrown or not.

Protected Attributes

TCHARtext
UINT32 length

Private Member Functions

INT32 IllegalIndex () const
 Generate an illegal index Notes: ** Can potentially throw a user exception **.
INT32 BuildList (const TCHAR *)
 This private helper function scans the layout string, breaking it up into literal text and parameters, which are placed on an private list in the order they are encountered, together with their type and which argument passed to Format that they refer to. The formatting must be done in two passes as the order of the parameters is not known until the whole format string has been scanned. Scope: Private.
INT32 CCvsprintf (const TCHAR *, va_list)
 This private helper function takes the list generated by StringBase::BuildList and scans through it, formatting stack-frame parameters according to their list entry. This produces another list, this time of formatted parameters, which is then concatenated to produce the final output. Scope: Private.
 StringBase (const StringBase &other)
 Copy constructor - this is made private (and unimplemented) as it will not work for base class strings, which must call Alloc() before they are used. Scope: Private.

Static Private Member Functions

static INT32 TCharToNum (TCHAR c)
 Convert a TCHAR into a numeric value. The routine does not check for valid numeric characters, it just performs the conversion. Hence it is possibly for you to pass in the character 's' for instance and receive a >9 value back.
static void ThrowStringException ()
 Throws a 'User' exception if the string exception stack says 'Yes'.

Static Private Attributes

static BOOL ThrowExceptionStack [str_MAXEXCEPTIONS]
static INT32 CurrEx = -1

Friends

class Error
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 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 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)
 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)
std::istream & operator>> (std::istream &is, StringBase &s)
 Read a string from a (non-persistent) stream. The input is terminated by a newline character (NOT whitespace, cf. reading C-style character arrays). If the string is longer than MAX_STRING_RES_LENGTH get() will read as many characters as possible and put a newline at the end.
std::ostream & operator<< (std::ostream &os, const StringBase &s)
 Write a string to a (non-persistent) stream. If the string is 0 then "[0]" is printed.

Detailed Description

Definition at line 161 of file basestr.h.


Constructor & Destructor Documentation

StringBase::StringBase  )  [inline]
 

Default constructor for a StringBase. Sets the character buffer to 0 and the string length to zero. The user must call Alloc() before trying to use the StringBase. Scope: Public.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
22nd April 1993
Parameters:
- [INPUTS]

Definition at line 340 of file basestr.h.

00341   : text(0), length(0)
00342 {
00343     // Empty.
00344 }

StringBase::~StringBase  )  [inline, virtual]
 

Destroys & cleans up a string.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
22nd April 1993

Definition at line 375 of file basestr.h.

00376 {
00377     if (text) delete[] text;
00378 }

StringBase::StringBase const StringBase other  )  [inline, private]
 

Copy constructor - this is made private (and unimplemented) as it will not work for base class strings, which must call Alloc() before they are used. Scope: Private.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
22nd April 1993
Parameters:
Another StringBase object. [INPUTS]

Definition at line 360 of file basestr.h.

00361 {
00362     // Empty.
00363 }


Member Function Documentation

INT32 __cdecl StringBase::_MakeMsg const TCHAR fmt...  ) 
 

Internationally portable version of sprintf(...), eg. UINT32 x; s._MakeMsg("#1%lu", x); TextOut(hdc, 20, 20, s, s.Length());.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
22nd April 1993
Parameters:
A constant character pointer, and a variable number of other parameters, [INPUTS] which must match the format specifiers embedded in the character pointer. Note that floating point parameters are NOT supported ****
Changes "this" to become the formatted string, with the passed parameters [OUTPUTS] substituted into the string resource in the correct order.
Returns:
The number of characters in the formatted string.

Definition at line 186 of file makemsg.cpp.

00187 {
00188 /*  if (IsUserName("JustinF"))
00189         TRACE( _T("_MakeMsg called with format string %s\n"), fmt);
00190 */
00191     ENSURE(text, "Call to StringBase::_MakeMsg for an unallocated String");
00192     ENSURE(fmt, "Call to StringBase::_MakeMsg with a null format parameter");
00193     
00194     va_list ap;
00195     va_start(ap, fmt);
00196     
00197     INT32 n = CCvsprintf(fmt, ap);
00198     
00199     va_end(ap);
00200     return n;   
00201 }

BOOL StringBase::Alloc INT32  size  )  [virtual]
 

Allocates space on the heap for a 0-terminated string of the passed size. This function should only be called for the StringBase base class, NOT for any of its fixed-length derivatives.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
22nd April 1993
Parameters:
The number of characters the string is to hold (EXCLUDING the [INPUTS] terminating 0).
Returns:
TRUE if the allocation was successful.

Errors: _R(IDE_NOMORE_MEMORY) Scope: Public

Reimplemented in String_128, String_256, String_16, String_32, String_64, and String_8.

Definition at line 142 of file basestr.cpp.

00143 {
00144     ERROR3IF(size < 0, "Attempt to ALLOCate a String of negative length");
00145     if (text) delete[] text;
00146 #ifdef _UNICODE
00147     text = new TCHAR[length = size + 1];
00148 #else
00149     text = new TCHAR[length = (size + 1) * 2];      // MBCS
00150 #endif
00151     ERRORIF(text == 0, _R(IDE_NOMORE_MEMORY), FALSE);
00152     *text = 0;
00153     return TRUE;
00154 }

INT32 StringBase::BuildList const TCHAR format  )  [private]
 

This private helper function scans the layout string, breaking it up into literal text and parameters, which are placed on an private list in the order they are encountered, together with their type and which argument passed to Format that they refer to. The formatting must be done in two passes as the order of the parameters is not known until the whole format string has been scanned. Scope: Private.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
22nd April 1993
Parameters:
A pointer to the format string to be analysed. [INPUTS]
Returns:
The number of format specifiers in the string, which should be the same as the number of arguments to be formatted.

Definition at line 284 of file makemsg.cpp.

00285 {
00286 /*  if (IsUserName("JustinF"))
00287         TRACE( _T("\tBuildList called with format string %s\n"), format);
00288 */
00289     ENSURE(format, "Null parameter passed to StringBase::BuildList");
00290     const TCHAR* start = format;
00291     INT32 nArgs = 0;    
00292     while (*start)
00293     {
00294         const TCHAR* next = start;      
00295         // Look for a format specifier in the layout string
00296         if (*next == TEXT('#'))
00297             if (IsNumeric(*(++next)))
00298             {
00299                 INT32 ArgPos = *next - TEXT('0');       // MS approved method - yuck!!!
00300                 ENSURE(ArgPos >= 1 && ArgPos <= 9,
00301                         "Illegal format string passed to MakeMsg!");
00302 
00303                 if (*(++next) == TEXT('%'))
00304                 {
00305                     // Seem to have found the beginning of a specifier,
00306                     // so try parsing it, to extract the type information
00307                     if (*(++next) == TEXT('-')) next++;
00308                     if (*next == TEXT('#')) next++;
00309                     if (*next == TEXT('0')) next++;
00310                     while (IsNumeric(*next)) next++;
00311                     if (*next == TEXT('.'))
00312                         while (IsNumeric(*++next));
00313                     
00314                     // Ok, we have skipped the width, precision etc. and
00315                     // "next" should now be pointing at the type character(s)
00316                     ArgType kind;
00317                     if (*next == TEXT('l'))     // an INT32 something or another?
00318                         switch (*++next)
00319                         {
00320                             case TEXT('d'):  case TEXT('i'):
00321                                 kind = SIGNED_INT32_ARG;
00322                                 break;
00323                             case TEXT('u'):  case TEXT('x'):  case TEXT('X'):
00324                                 kind = UNSIGNED_INT32_ARG;
00325                                 break;
00326                             default:            // false alarm, can't be a specifier
00327                                 next = start + 1;
00328                                 goto not_format;
00329                         }
00330                     else
00331                         switch (*next)          // single type character
00332                         {    
00333                             case TEXT('c'):
00334                                 kind = CHAR_ARG;
00335                                 break;
00336                             case TEXT('d'):  case TEXT('i'):
00337                                 kind = SIGNED_INT_ARG;
00338                                 break;
00339                             case TEXT('p'): // a pointer
00340                                 kind = UINT_PTR_ARG;
00341                                 break;
00342                             case TEXT('u'): case TEXT('x'): case TEXT('X'):
00343                                 kind = UNSIGNED_INT_ARG;
00344                                 break;
00345                             case TEXT('s'):
00346                                 kind = CHAR_POINTER_ARG;
00347                                 break;
00348                             case TEXT('S'):
00349                                 kind = STRING_POINTER_ARG;                              
00350                                 break;
00351                             default:
00352                                 next = start + 1;
00353                                 goto not_format;            // boo hiss hooray!
00354                         }
00355                     
00356                     // Successfully parsed the format specifier, so add
00357                     // it to the Item list.  Skip the leading #n of the specifier,
00358                     // so (next) now points to the character following the '%X'
00359                     // format specifier.
00360                     next++;
00361 
00362                     // Extract the specifier.
00363                     TCHAR temp[64];
00364                     INT32 len = next - start - 2;
00365                     camStrncpy(temp, start + 2, len);
00366                     temp[len] = 0;
00367                     new Item(temp, ArgPos, kind);
00368                     start = next;
00369                     nArgs++;
00370                     
00371 /*                  if (IsUserName("JustinF"))
00372                     {
00373                         TRACE( _T("\tItem: (%d) at #%d  %s\n"), kind, ArgPos, temp);
00374                         TRACE( _T("\t\tRemaining: %s\n"), start);
00375                     }
00376 */
00377                     continue;
00378                 }
00379                 else
00380                     // Put back the previous character
00381                     next--;
00382             }
00383         
00384 not_format:     
00385         // Scan a literal up to the next '#' or null, whichever is sooner
00386         while (*next && *next != TEXT('#')) next++;
00387 
00388         TCHAR temp[256];
00389         INT32 len = next - start;
00390 
00391         camStrncpy(temp, start, len);
00392         temp[len] = 0;
00393         new Item(temp, 0, LITERAL);
00394         start = next;
00395 
00396 /*      if (IsUserName("JustinF"))
00397         {
00398             TRACE( _T("\tLiteral: %s\n"), temp);
00399         }
00400 */
00401     }
00402 
00403     return nArgs;       
00404 }

INT32 StringBase::CCvsprintf const TCHAR layout,
va_list  va
[private]
 

This private helper function takes the list generated by StringBase::BuildList and scans through it, formatting stack-frame parameters according to their list entry. This produces another list, this time of formatted parameters, which is then concatenated to produce the final output. Scope: Private.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
22nd April 1993
Parameters:
A pointer to the format string, a variable-parameter pointer to the [INPUTS] arguments to be formatted.
Returns:
The length of the StringBase once the arguments have been substituted into it.

Definition at line 425 of file makemsg.cpp.

00426 {
00427 /*  if (IsUserName("JustinF"))
00428         TRACE( _T("CCvsprintf called with format string %s\n"), layout);
00429 */
00430     INT32 n = BuildList(layout);
00431     for (INT32 i = 1; i <= n; i++)
00432     {
00433         for (Item* p = Item::head; p; p = p->next)
00434             if (p->pos != i)
00435                 continue;
00436             else
00437             {   // Found specifier i in the list, so grab from the stack
00438                 // and call wsprintf() to convert to text.  The converted
00439                 // text is put in the temp[] buffer - note the enormous
00440                 // size of this, in accordance with the C standard.
00441                 TCHAR temp[512];
00442                 switch (p->type)
00443                 {
00444                     // type 'c' - single character
00445                     case CHAR_ARG:
00446 #if defined(__WXMSW__)
00447                         camSnprintf( temp, 512, p->str, va_arg(va, TCHAR) );
00448 #else                   // TCHARs are promoted to INT32 when passed via ... under GCC
00449                         camSnprintf( temp, 512, p->str, va_arg(va, INT32) );
00450 #endif
00451                         break;
00452                     // type 'd' / 'i' - signed decimal integer
00453                     case SIGNED_INT_ARG:
00454                         camSnprintf(temp, 512, p->str, va_arg(va, INT32));
00455                         break;
00456                     // type 'ld' / 'li' - signed decimal INT32
00457                     case SIGNED_INT32_ARG:
00458                         camSnprintf(temp, 512, p->str, va_arg(va, INT32));
00459                         break;
00460                     // type 'u' - unsigned decimal integer
00461                     case UNSIGNED_INT_ARG:
00462                         camSnprintf(temp, 512, p->str, va_arg(va, UINT32));
00463                         break;
00464                     // type 'lu' / 'lx' / 'lX' - unsigned decimal INT32
00465                     case UNSIGNED_INT32_ARG:
00466                         camSnprintf(temp, 512, p->str, va_arg(va, UINT32));
00467                         break;
00468                     // type 's' - long pointer to array of (constant) char
00469                     case CHAR_POINTER_ARG:
00470                         camSnprintf(temp, 512, p->str, va_arg(va, LPCTSTR));
00471                         break;
00472                     // type 'p' a pointer
00473                     case UINT_PTR_ARG:
00474                         camSnprintf(temp, 512, p->str, va_arg(va, UINT_PTR));
00475                         break;
00476                     // type 'S' - a pointer to a StringBase.  First change the
00477                     // %S format specifier, which is our own, into a sprintf()
00478                     // compatible %s.  Note that the 'S' is always the last
00479                     // character of the format specifier.
00480                     case STRING_POINTER_ARG:
00481                         (p->str)[camStrlen(p->str) - 1] = TEXT('s');
00482                         camSnprintf(temp, 512, p->str, LPCTSTR(va_arg(va, const StringBase*)->text));
00483                         break;
00484                     default:
00485                         break;
00486                 }
00487                 // Replace the format specifier with the formatted text
00488                 delete[] p->str;
00489                 camStrcpy(p->str = new TCHAR[camStrlen(temp) + 1], temp);
00490                 break;
00491             }
00492     }
00493     
00494     // Concatenate every string in the list, tidy up, and return in "this" string
00495     *text = 0;
00496     UINT32 NextChar = 0;
00497     INT32 Index = 0;
00498     for (Item* p = Item::head; (p != NULL && NextChar < length) ; p = p->next)
00499     {
00500 /*      if (camStrlen(text) + camStrlen(p->str) < length)
00501             camStrcat(text, p->str);
00502         else
00503         {
00504             ENSURE(FALSE, "Call to String::MakeMsg will overflow - text has been truncated");
00505         }
00506 */
00507         for (Index = 0; p->str[Index] != 0 && NextChar < length; Index++)
00508             text[NextChar++] = p->str[Index];
00509     }
00510 
00511     if (NextChar > length)
00512         NextChar = length;
00513     text[NextChar] = TCHAR('\0');
00514 
00515     delete Item::head;
00516     return camStrlen(text);
00517 }

const WCHAR StringBase::CharAt const INT32  Index  )  const [inline]
 

Extract single characters from the string... 0 is the first char, String.Length() is the terminating zero...

Author:
Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
Date:
22nd November 1995 Returns The character at offset Index into the string... Or 0 if there were problems (or if the character was 0 of course).

Definition at line 898 of file basestr.h.

00899 {
00900 #ifdef UNICODE
00901     ERROR3IF(!text, "Call to String::operator[] for an unALLOCated String");
00902     TCHAR ch = (text && (Index <= (INT32)camStrlen(text))) ? text[Index] : 0;
00903 
00904     return (WCHAR)ch;
00905 
00906 #else
00907     PORTNOTETRACE("other", "WCHAR StringBase::CharAt does nothing in non-UNICODE builds!");
00908     ERROR3("This function is unimplemented in non-UNICODE builds!");
00909     return (WCHAR)0;
00910 #endif
00911 }

INT32 StringBase::CompareTo const StringBase other,
BOOL  CaseSensitive = TRUE
const
 

Compare this StringBase object to another string. This is mainly intended for use internally by the comparison operators, but may also come in handy in other places.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
24/5/94
Parameters:
other - A string against which this one will be compared [INPUTS]
Returns:
The same as the standard C strcmp, i.e:
A negative value if this is considered 'less than' other

Zero, if the strings are considered equal

A positive value if this is considered 'greater than' other

Notes: This function is VERY SLOW, but does proper comparisons for the locale to determine relative positioning of strings. Use StringBase::IsIdentical to see if 2 strings are exactly the same.

Returns:
Errors: If either of the strings is 0, an ENSURE failure is generated
See also:
StringBase::IsIdentical

Definition at line 285 of file basestr.cpp.

00286 {
00287     ERROR3IF(text == 0 || other.text == 0, "StringBase::CompareTo: not ALLOCed");
00288 PORTNOTE("other", "StringBase::CompareTo should be locale specific");
00289 #if FALSE
00290     DWORD dw = NORM_IGNOREKANATYPE | NORM_IGNOREWIDTH;
00291     if (!CaseSensitive) dw |= NORM_IGNORECASE;
00292     return CompareString(LOCALE_USER_DEFAULT, dw, text, -1, other.text, -1) - 2;
00293 #endif
00294 
00295     if( CaseSensitive )
00296     {
00297         return camStrcmp( text, other.text );
00298     }
00299     else
00300     {
00301         return camStricmp( text, other.text );
00302     }
00303 }

INT32 StringBase::CompareTo const TCHAR other,
BOOL  CaseSensitive = TRUE
const
 

Compare this StringBase object to another string. This is mainly intended for use internally by the comparison operators, but may also come in handy in other places.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
24/5/94
Parameters:
other - A string against which this one will be compared [INPUTS]
Returns:
The same as the standard C strcmp, i.e:
A negative value if this is considered 'less than' other

Zero, if the strings are considered equal

A positive value if this is considered 'greater than' other

Notes: This function is VERY SLOW, but does proper comparisons for the locale to determine relative positioning of strings. Use StringBase::IsIdentical to see if 2 strings are exactly the same.

Returns:
Errors: If either of the strings is 0, an ENSURE failure is generated
See also:
StringBase::IsIdentical

Definition at line 336 of file basestr.cpp.

00337 {
00338     ERROR3IF(text == 0 || other == 0, "StringBase::CompareTo: null buffers");
00339 PORTNOTE("other", "StringBase::CompareTo should be locale specific");
00340 #if FALSE
00341     DWORD dw = NORM_IGNOREKANATYPE | NORM_IGNOREWIDTH;
00342     if (!CaseSensitive) dw |= NORM_IGNORECASE;
00343     return CompareString(LOCALE_USER_DEFAULT, dw, text, -1, other, -1) - 2;
00344 #endif
00345 
00346     if( CaseSensitive )
00347     {
00348         return camStrcmp( text, other );
00349     }
00350     else
00351     {
00352         return camStricmp( text, other );
00353     }
00354 }

INT32 StringBase::ConvertToInteger INT32 &  position  )  const
 

Convert the sequence of characters starting from position into a numeric value. 32 bits of precision are returned and hence approx 10 digit numbers can be represented. If the numeric string is longer, the value 0x7FFFFFFF is returned (ie represting an overflow). If string exceptions are enabled, an exception will be thrown in this instance. All valid numeric digits will be read, no matter whether an overflow is immanent or not, hence you can safely continue to parse what is expected to be the next token along the string. The types of numbers allowed are +123686 -12394 124802398 but not 12439127397123.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
29/07/96
Parameters:
position = the character index [INPUTS]
position = the new character index [OUTPUTS]
Returns:
A signed numeric value for the sequence of characters starting at position in this string.
Notes: ** Throws an exception if string exceptions are enabled **

Definition at line 1529 of file basestr.cpp.

01530 {
01531     ERROR3IF(!text, "Call to StringBase::ConvertToInteger for unALLOCated String");
01532 
01533     const TCHAR pos = TEXT('+');
01534     const TCHAR neg = TEXT('-');
01535 
01536     INT32 value   = 0;
01537     BOOL isneg   = FALSE;
01538     INT32 maxdigs = 10;
01539     INT32 nchars  = Length();
01540 
01541     position = SkipSpace(position);
01542     if (position>-1 && position<nchars)
01543     {
01544         isneg = (text[position]==neg);
01545         if (isneg || text[position]==pos)
01546             position=NextIndex(position);
01547 
01548         while (position<nchars && IsNumeric(text[position]))
01549         {
01550             value = value*10 + (StringBase::TCharToNum(text[position]));
01551             position=NextIndex(position);
01552             maxdigs--;
01553         }
01554         
01555         if (maxdigs<0)
01556         {
01557             TRACEUSER("Mike", wxT("Overflow during ConvertToInteger") );
01558             StringBase::ThrowStringException();
01559             return ((isneg) ? 0x80000000 : 0x7FFFFFFF);
01560         }
01561 
01562         value = (isneg) ? (-value) : (value);
01563     }
01564 
01565     return value;
01566 }

INT32 StringBase::CountChar const TCHAR  tchar  ) 
 

Count all tchar characters in the string Scope: Public.

Author:
Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
Date:
20/11/95
Parameters:
tchar - the search character [INPUTS]
Returns:
Number of times 'tchar' appears in the string

Definition at line 975 of file basestr.cpp.

00976 {
00977     ERROR3IF(!text, "Call to String::CountChar for an unALLOCated String");
00978     INT32 Count = 0;
00979     if (text)
00980     {
00981         TCHAR* pThis = text;
00982         while (*pThis != 0)
00983         {
00984             if (*pThis == tchar)
00985                 Count ++;
00986             pThis = camStrinc(pThis);
00987         }
00988     }
00989     return Count;
00990 }       

BOOL StringBase::DisableExceptionHandler BOOL  PopHandler = TRUE  )  [static]
 

This function disables or completely removes the most previously enabled exception state. FALSE will be returned if the exception stack is empty. The default parameter allows you to temporarily disable the exception state without poping the handler.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
29/07/96
Parameters:
PopHandler = a default parameter, determining whether the current [INPUTS] handler state is poped or not
Returns:
TRUE if all goes well FALSE if there are no exception states to pop!

Errors:

Definition at line 1333 of file basestr.cpp.

01334 {
01335     ERROR2IF(CurrEx < 0, FALSE, "StringBase::DisableExceptions; Nothing on the exception stack!");
01336     ThrowExceptionStack[CurrEx]=FALSE;
01337     if (PopHandler) CurrEx--;
01338     return TRUE;
01339 }

StringBase & StringBase::Empty  )  [inline]
 

Sets a string to the 0 string (zero-terminated but no characters, NOT A 0 POINTER!).

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
10th August 1993

Definition at line 719 of file basestr.h.

00720 {
00721     ERROR3IF(!text, "Attempt to EMPTY an unALLOCated String");
00722     if (text) *text = 0;
00723     return *this;
00724 }

BOOL StringBase::EnableExceptionHandler BOOL  PushNewHandler = TRUE  )  [static]
 

This function adds a new exception handler to the string exception handler stack (if PushNewHandler is TRUE). Otherwise it will simply change the state of the most recently pushed handler. If there are no handlers and Push is FALSE, an ERROR3IF will be generated.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
29/07/96
Parameters:
PushNewHandler = a default parameter, determining whether a new [INPUTS] exception handler state is pushed on the handler stack or not.
Returns:
TRUE if throwing exceptions is enabled FALSE if a new exception state could not be pushed.

Errors: if an attempt is made to push a new handler when the stack is full if an attempt is made to set the current exception handler to 'on' when there's no exception handlers on the stack

Definition at line 1303 of file basestr.cpp.

01304 {
01305     if (PushNewHandler) CurrEx++;
01306 
01307     ERROR2IF(CurrEx >= str_MAXEXCEPTIONS, FALSE, "StringBase::EnableExceptions overflow!");
01308     ERROR2IF(CurrEx < 0, FALSE, "StringBase::EnableExceptions - handler does not exist");
01309 
01310     ThrowExceptionStack[CurrEx]=TRUE;
01311     return TRUE;
01312 }

INT32 StringBase::FindNextChar TCHAR  c,
INT32  position = 0
const
 

Find the next character to match c starting from position. Notes: ** Throws an exception if string exceptions are enabled **.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
29/07/96
Parameters:
c = the character whose index we need [INPUTS] position = the character index from which to start
Returns:
the index of the next none space character, -1 if none, OR an exception is thrown

Definition at line 1455 of file basestr.cpp.

01456 {
01457     ERROR3IF(!text, "Call to StringBase::FindNextChar for unALLOCated String");
01458     INT32 nchars = Length();
01459     if (!text || position<0 || position>=nchars)
01460         return IllegalIndex();
01461 
01462     while ((text[position]!=c) && position<nchars)
01463         position=NextIndex(position);
01464 
01465     return ((position==nchars) ? (IllegalIndex()) : (position));
01466 }

INT32 StringBase::FindNextChar INT32  position = 0  )  const
 

Find the next none space character starting from pos. If pos is a none space character, the function will simply return with the same index. Notes: ** Throws an exception if string exceptions are enabled **.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
29/07/96
Parameters:
position = the character index from which to start [INPUTS]
Returns:
the index of the next none space character -1 if none, OR an exception is thrown

Definition at line 1423 of file basestr.cpp.

01424 {
01425     ERROR3IF(!text, "Call to StringBase::FindNextChar for unALLOCated String");
01426 
01427     // get the length of this string in characters  
01428     INT32 nchars = Length();
01429     if (!text || position<0 || position>=nchars)
01430         return IllegalIndex();
01431 
01432     TCHAR c = TEXT(' ');
01433     while ((text[position]==c) && position<nchars)
01434         position=NextIndex(position);
01435 
01436     return ((position==nchars) ? (IllegalIndex()) : (position));
01437 }

void StringBase::FixFormat  )  [virtual]
 

Definition at line 1042 of file basestr.cpp.

01043 {
01044 #if FALSE
01045 #if 0 != wxUSE_UNICODE
01046     INT32 i=0;
01047     while ((i+1)<Length()) // Don't look at the last character
01048     {
01049         if ( (text[i]==_T('%')) && ( (text[i+1]==_T('s')) || (text[i+1]==_T('c')) ) )
01050         {
01051             String_8 l(_T("l"));
01052             Insert(l, i+1);
01053             i++; // Skip over the inserted char too
01054         }
01055         i++;
01056     }
01057 #endif
01058 #endif
01059 }

INT32 StringBase::IllegalIndex  )  const [inline, private]
 

Generate an illegal index Notes: ** Can potentially throw a user exception **.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
29/07/96
Parameters:
- [INPUTS]
Returns:
An illegal index ie -1 if exceptions are disabled, otherwise an exception is thrown

Definition at line 567 of file basestr.h.

00568 {
00569     StringBase::ThrowStringException();
00570     return -1;
00571 }

void StringBase::Insert const StringBase InsertString,
INT32  Position
 

Inserting a string into another one. Scope: Public.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
26th August 1994
Parameters:
InsertString - the string to inserted. [INPUTS] Position - the number of the character before which InsertString is to be inserted. Counting starts at 0.
Returns:
-

Definition at line 838 of file basestr.cpp.

00839 {
00840     ERROR3IF(Position < 0,"Negative position passed to StringBase::Insert");
00841     ERROR3IF(!text || !InsertString.text, "Not ALLOCed in StringBase::Insert");
00842 
00843     if (text && InsertString && InsertString.text)
00844     {
00845         INT32   LeftL = Position;
00846         INT32   RightL = Length()-Position;
00847         StringBase  LeftS;
00848         StringBase  RightS;
00849 
00850         if (LeftL<=0)
00851         {
00852             RightS.Alloc(this->Length());
00853             RightS=*this;
00854             *this=*InsertString;
00855             *this+=RightS;
00856         }
00857         else
00858         {
00859             if (RightL<=0)
00860             {
00861                 *this+=*InsertString;
00862             }
00863             else
00864             {
00865                 LeftS.Alloc(LeftL);
00866                 Left(&LeftS, LeftL);
00867                 RightS.Alloc(RightL);
00868                 Right(&RightS, RightL);
00869 
00870                 *this=LeftS;
00871                 *this+=*InsertString;
00872                 *this+=RightS;
00873             }
00874         }
00875     }
00876 }

BOOL StringBase::IsAlpha TCHAR  c  )  [inline, static]
 

Tests if the character is a-z, A-Z (or local equivalent).

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
10th August 1993
Parameters:
A Unicode character. [INPUTS]
Returns:
TRUE if the passed character is an alphabet letter.

Definition at line 625 of file basestr.h.

00626 {
00627     return camIsalpha(c); // IsCharAlpha(c);
00628 }

BOOL StringBase::IsAlphaNumeric TCHAR  c  )  [inline, static]
 

Tests if the character is a-z, A-Z, 0-9, or local equivalent.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
10th August 1993
Parameters:
A Unicode character [INPUTS]
Returns:
TRUE if the passed character is an alphabet letter or a digit.

Definition at line 641 of file basestr.h.

00642 {
00643     return camIsalnum(c);   //IsCharAlphaNumeric(c);
00644 }

BOOL StringBase::IsEmpty  )  const [inline]
 

Tests for the 0 string.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
25th August 1993
Returns:
TRUE if the string has no length.

Definition at line 425 of file basestr.h.

00426 {
00427     return text == 0 || *text == 0;
00428 }

bool StringBase::IsIdentical const StringBase other  )  const [inline]
 

Compare this StringBase object to another string.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
23/4/96
Parameters:
other - A string against which this one will be compared [INPUTS]
Returns:
TRUE if the strings are identical FALSE if the strings are different in any way

Errors: If either of the strings is 0, an ESNURE failure is generated

Notes: We define different versions of the function for UNICODE builds, as camStrcmp is very slow compared to vanilla strcmp.

Note also that this is a very fast comparison compared to CompareTo. It should be used in preference where relative ordering of strings does not need to be determined.

See also:
StringBase::CompareTo

Definition at line 459 of file basestr.h.

00460 {
00461     ERROR3IF(text == 0 || other.text == 0, "StringBase::IsIdentical: not ALLOCed");
00462     return wxStrcmp(text, other.text) == 0;
00463 }

bool StringBase::IsIdentical const TCHAR other  )  const [inline]
 

Compare this StringBase object to another string.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
23/4/96
Parameters:
other - A string against which this one will be compared [INPUTS]
Returns:
TRUE if the strings are identical FALSE if the strings are different in any way

Errors: If either of the strings is 0, an ESNURE failure is generated

Notes: We define different versions of the function for UNICODE builds, as camStrcmp is very slow compared to vanilla strcmp.

Note also that this is a very fast comparison compared to CompareTo. It should be used in preference where relative ordering of strings does not need to be determined.

See also:
StringBase::CompareTo

Definition at line 494 of file basestr.h.

00495 {
00496     ERROR3IF(text == 0 || other == 0, "StringBase::IsIdentical: null params");
00497     return wxStrcmp( text, other ) == 0;
00498 }

BOOL StringBase::IsIllegal INT32  index  )  const [inline]
 

Check index for its legality.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
29/07/96
Parameters:
index,a character index in this string [INPUTS]
Returns:
TRUE if index is illegal FALSE if not

Definition at line 588 of file basestr.h.

00589 {
00590     return ((index<0) || index>(Length()));
00591 }

BOOL StringBase::IsLegal INT32  index  )  const [inline]
 

Check index for its legality.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
29/07/96
Parameters:
index,a character index in this string [INPUTS]
Returns:
TRUE if index is llegal FALSE if its illegal

Definition at line 608 of file basestr.h.

00609 {
00610     return !IsIllegal(index);
00611 }

BOOL StringBase::IsLower TCHAR  c  )  [inline, static]
 

Tests if the character is a-z (or local equivalent).

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
10th August 1993
Parameters:
A Unicode character [INPUTS]
Returns:
TRUE if the passed character is a lower-case letter.

Definition at line 673 of file basestr.h.

00674 {
00675     return camIslower(c); // IsCharLower(c)
00676 }

BOOL StringBase::IsNumeric TCHAR  c  )  [inline, static]
 

Tests if the character is 0-9, or local equivalent.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
10th August 1993
Parameters:
A Unicode character [INPUTS]
Returns:
TRUE if the passed character is a digit.

Definition at line 657 of file basestr.h.

00658 {
00659     return camIsalnum(c) && !camIsalpha(c);
00660 }

BOOL StringBase::IsSpace TCHAR  c  )  [inline, static]
 

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
10th August 1993
Parameters:
A Unicode character [INPUTS]
Returns:
TRUE if the passed character is whitespace.

Definition at line 704 of file basestr.h.

00705 {
00706     return camIsspace(c);
00707 }

BOOL StringBase::IsUpper TCHAR  c  )  [inline, static]
 

Tests if the character is A-Z, or local equivalent.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
10th August 1993
Parameters:
A Unicode character [INPUTS]
Returns:
TRUE if the passed character is an upper-case letter.

Definition at line 689 of file basestr.h.

00690 {
00691     return camIsupper(c); // IsCharUpper(c)
00692 }

const StringBase & StringBase::Left StringBase out,
UINT32  count
const
 

Similar to the BASIC Left$() string function.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
22nd April 1993
Parameters:
The number of characters in the prefix. [INPUTS]
The leftmost [count] characters of the StringBase. If count is greater than [OUTPUTS] the StringBase's length, the the whole StringBase is returned. If count is equal to zero, the 0 StringBase is output.
Returns:
Errors: ERROR3IF failure if (count) is negative, or if the out StringBase is not large enough to hold the result.
See also:
StringBase::Right StringBase::Mid

Definition at line 535 of file basestr.cpp.

00536 {
00537     ERROR3IF(out == 0, "0 output parameter in StringBase::Left");
00538     ERROR3IF(!text || !out->text, "Call to String::Left for unALLOCated String");
00539     ERROR3IF(count < 0, "Call to String::Left with a meaningless character count");
00540     ERROR3IF(out->length <= count, "Call to String::Left will overflow");
00541 
00542     if (text && out && out->text)
00543     {
00544         if (count == 0)
00545             *(out->text) = 0;
00546         else if (count >= camStrlen(text))
00547             camStrcpy(out->text, text);
00548         else
00549         {
00550             camStrncpy(out->text, text, (INT32)count);
00551             out->text[count] = 0;
00552         }
00553     }
00554 
00555     return *this;
00556 }

INT32 StringBase::Length  )  const [inline]
 

Calculates the length of the string.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
22nd April 1993
Returns:
The number of characters in the string, excluding any terminating 0.

Definition at line 390 of file basestr.h.

00391 {
00392     ERROR3IF(!text, "Attempt to find the LENGTH of an unALLOCated String");
00393     return (text) ? camStrlen( text ) : 0;
00394 }

BOOL StringBase::Load UINT32  resID,
UINT32  moduleID = 0
 

Extracts a string from the application's .EXE file, by default, or another module (eg. a dedicated DLL), overwriting the old contents of this StringBase object.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
22nd April 1993
Parameters:
A string resource identifier and an optional module handle. Specify [INPUTS] a module handle only if the resource is not located in the default place (CAMELOT.EXE). Most resources will be. If a moduleID is given, the string will try to be loaded from that module. If it fails, it will fall-back to the .exe file. The string will be truncated if required to fit the available buffer size.
Returns:
TRUE of the string is successfully loaded, FALSE otherwise.
See also:
SmartLoadString

Definition at line 176 of file basestr.cpp.

00177 {
00178     ERROR3IF(text == 0, "Attempt to LOAD a String which hasn't been ALLOCated");
00179 
00180     // Load the string resource. Get OIL layer to truncate to suit the destination.
00181     if (!text) return FALSE;
00182     return SmartLoadString(moduleID, resID, text, length*sizeof(TCHAR));
00183 }

INT32 __cdecl StringBase::MakeMsg UINT32  resID...  ) 
 

Internationally portable version of sprintf(...), eg. StringBase s; INT32 x, y, z; s.MakeMsg(_R(IDS_COORDFORMAT), x, y, z); TextOut(hdc, 20, 20, s, s.Length());.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
22nd April 1993
Parameters:
A string resource identifier, and a variable number of other parameters, [INPUTS] which must match the format specifiers embedded in the string resource. Note that floating point parameters are NOT supported.
Changes "this" to become the formatted string, with the passed parameters [OUTPUTS] substituted into the string resource in the correct order.
Returns:
The number of characters in the formatted string. This will be zero if a problem occurs, such as not being able to load the format string resource.

Errors: ENSURE failure if called for a String that hasn't been allocated.

Definition at line 132 of file makemsg.cpp.

00133 {
00134 /*  if (IsUserName("JustinF"))
00135         TRACE( _T("MakeMsg called with resource ID %u\n"), resID);
00136 */
00137     ENSURE(text, "Call to StringBase::MakeMsg for unallocated String");
00138 
00139     va_list ap;
00140     va_start(ap, resID);
00141     
00142     INT32 n = 0;
00143     StringBase s;
00144     if (s.Alloc(MAX_STRING_RES_LENGTH) && s.Load(resID))
00145     {
00146         n = CCvsprintf(s.text, ap);
00147     }
00148 #ifdef _DEBUG
00149 /*  else
00150     {
00151         if (IsUserName("JustinF"))
00152             TRACE( _T("Failed to allocate or load the format string in MakeMsg()\n"));
00153     } */
00154 #endif
00155     
00156     va_end(ap);
00157     
00158 #if !defined(EXCLUDE_FROM_RALPH) && !defined(EXCLUDE_FROM_XARALX)
00159     // Remember the resource ID, in case the help system can't work out the message ID.
00160     SetNextMsgHelpContext(resID);
00161 #endif
00162     
00163     // Return the number of characters in the formatted string.
00164     return n;
00165 }

void StringBase::MakePercent TCHAR Value  )  [virtual]
 

Reimplemented in StringVar.

Definition at line 1029 of file basestr.cpp.

01030 {
01031     if (text)
01032     {
01033         // Some callers seem to call this with Value=Text ... Grrr
01034         String_32 tmp(Value);
01035         String_32 Format(_R(IDS_PERCENT_STRING));
01036         Format.FixFormat();
01037         camSnprintf( text, 32, (TCHAR *)Format, tmp.text );
01038     }
01039 }

void StringBase::MakePercent double  Value  )  [virtual]
 

Reimplemented in StringVar.

Definition at line 1019 of file basestr.cpp.

01020 {
01021     if (text)
01022     {
01023         String_32 TmpStr;
01024         if(Convert::DoubleToString(Value, &TmpStr))
01025             MakePercent((TCHAR *)TmpStr);
01026     }
01027 }

void StringBase::MakePercent INT32  Value  )  [virtual]
 

Set the string equal to the given argument + a % character, or however the current locale wants it Example: String_32 Str; Str.MakePercent(23); For UK, Str now equals "23%".

Author:
Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
Date:
22nd November 1995
Parameters:
Takes a number / string [INPUTS]

Reimplemented in StringVar.

Definition at line 1009 of file basestr.cpp.

01010 {   
01011     if (text)
01012     {
01013         String_32 Format(_R(IDS_PERCENT_LONG));
01014         Format.FixFormat();
01015         camSnprintf( text, 32, (TCHAR *)Format, Value );
01016     }
01017 }

INT32 StringBase::MaxLength  )  const [inline]
 

Calculates the longest allowed string that can be stored in this.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
25th August 1993
Returns:
The maximum number of characters the string can contain.

Definition at line 406 of file basestr.h.

00407 {
00408 #ifdef _UNICODE
00409     return length - 1;
00410 #else
00411     return (length / 2) - 1;        // MBCS - two chars per character
00412 #endif
00413 }

const StringBase & StringBase::Mid StringBase out,
UINT32  first,
UINT32  count
const
 

Similar to the BASIC Mid$() function.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
22nd April 1993
Parameters:
The position of the first character to extract and the total number of [INPUTS] characters to include in the sub-string. Note that the first character of a string is at position 0, like C, not 1, like BASIC.
Places the n characters starting at position m in [out], which must be [OUTPUTS] large enough.
See also:
StringBase::Left StringBase::Right

Definition at line 575 of file basestr.cpp.

00576 {
00577     ERROR3IF(out == 0, "0 output parameter in StringBase::Mid");
00578     ERROR3IF(!text || !out->text, "Call to String::Mid for unALLOCated String");
00579     ERROR3IF(count < 0, "Call to String::Mid with a meaningless character count");
00580     ERROR3IF(out->length <= count, "Call to String::Mid will overflow");
00581 
00582     if (text && out && out->text)
00583     {   
00584         UINT32 L = camStrlen(text);
00585         if ((first + count) > L) count = L - first;
00586         if (count <= 0)
00587             *(out->text) = 0;
00588         else
00589         {
00590             camStrncpy(out->text, text + first, (INT32)count);
00591             out->text[count] = 0;
00592         }
00593     }
00594 
00595     return *this;
00596 }

INT32 StringBase::NextIndex INT32  index  )  const [inline]
 

Find the next character index Notes: If string exceptions are enabled, an exception will be thrown if the index goes out of range.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
29/07/96
Parameters:
index = the current character index [INPUTS]
Returns:
the next characater index after 'index' -1 if there is no next index, OR an exception is thrown

Definition at line 517 of file basestr.h.

00518 {
00519     INT32 i = index + 1;
00520     if (IsLegal(i)) return i;
00521     TRACEUSER( "Mike", wxT("String index overflow in StringBase::NextIndex()") );
00522     return IllegalIndex();
00523 }

StringBase::operator const TCHAR *  )  const [inline]
 

Cast a string into a C-style pointer to array of constant characters.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
22nd April 1993
Returns:
N/A
See also:
StringBase::operator TCHAR*()

Definition at line 786 of file basestr.h.

00787 {
00788     return text;
00789 }

StringBase::operator const wxString  )  const [inline]
 

Cast a string into a wxString.

Author:
Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
Date:
28th January 2006
Returns:
N/A
See also:
StringBase::operator TCHAR*()

Definition at line 819 of file basestr.h.

00820 {
00821     return wxString(text);
00822 }

StringBase::operator TCHAR *  )  [inline]
 

Cast a string into a C-style pointer to array of characters. If you intend to use the subscript operator [] with the results of the cast remember that no range checking is performed.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
22nd April 1993
Returns:
Not applicable!

Definition at line 769 of file basestr.h.

00770 {
00771     return text;
00772 }

StringBase::operator wxString  )  [inline]
 

Cast a string into a wxString.

Author:
Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
Date:
28th January 2006
Returns:
Not applicable!

Definition at line 802 of file basestr.h.

00803 {
00804     return wxString(text);
00805 }

StringBase & StringBase::operator+= const TCHAR  ch  ) 
 

Appends this character to the end of this string.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
11/12/95
Parameters:
A character to add to the end of this String. [INPUTS]
Returns:
A reference to the lhs, ie. this StringBase as an lvalue.

Reimplemented in StringVar.

Definition at line 445 of file basestr.cpp.

00446 {
00447     ERROR3IF(text == 0, "Call to String::operator+= for an unALLOCated String");
00448     INT32 CurrentLength = camStrlen(text);
00449     ERROR3IF(CurrentLength == MaxLength() - 1, "StringBase::operator+= will overflow");
00450 
00451     text[CurrentLength] = ch;
00452     text[CurrentLength + 1] = 0;
00453     return *this;
00454 }

StringBase & StringBase::operator+= const TCHAR s  ) 
 

Append string y onto the end of string x, eg. x = TEXT("hello"); cout << (x += TEXT(" world!")) << endl;.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
22nd April 1993
Parameters:
The C-style character "string" to add to the end of this String. [INPUTS]
Returns:
A reference to the lhs, ie. this StringBase as an lvalue.

Reimplemented in StringVar.

Definition at line 426 of file basestr.cpp.

00427 {
00428     ERROR3IF(!text || !s, "Call to String::operator+= for an unALLOCated String");
00429     ERROR3IF(camStrlen(text) + camStrlen(s) >= length,
00430             "Call to String::operator+= will result in overflow");
00431     if (text && s) SafeCat(text, s, length-1);
00432     return *this;
00433 }

StringBase & StringBase::operator+= const StringBase rhs  )  [inline]
 

Append string y onto the end of string x, eg. x = TEXT("hello"); cout << (x += TEXT(" world!")) << endl;.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
22nd April 1993
Parameters:
The string to add to the end of this string. [INPUTS]
Returns:
A reference to the lhs, ie. this StringBase as an lvalue.

Reimplemented in StringVar.

Definition at line 838 of file basestr.h.

00839 {
00840     ERROR3IF(!text || !rhs.text, "Call to String::operator+= for an unALLOCated String");
00841 /*  ERROR3IF(camStrlen(text) + camStrlen(rhs.text) >= length,
00842             "Call to String::operator+= will result in overflow");*/
00843 
00844     if (text && rhs.text) SafeCat(text, rhs.text, length-1);
00845     return *this;
00846 }

StringBase & StringBase::operator= const TCHAR  ch  )  [inline]
 

Assigns the single character to this string.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
11/12/1995
Parameters:
ch - a single character [INPUTS]
Returns:
A reference to this.

Reimplemented in StringVar.

Definition at line 859 of file basestr.h.

00860 {
00861     ERROR3IF(text == 0, "Call to String::operator= for an unALLOCated String");
00862     text[0] = ch;
00863     text[1] = 0;
00864     return *this;
00865 }

StringBase & StringBase::operator= const TCHAR s  ) 
 

Assignment (set equal to) operator, eg. StringBase x("rhubarb"); x = "custard";.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
22nd April 1993
Parameters:
A pointer to a constant C-style (possibly wide-character) string. [INPUTS]
Returns:
A reference to this.

Reimplemented in StringVar.

Definition at line 398 of file basestr.cpp.

00399 {
00400     ERROR3IF(!text || !s, "Call to String::operator= for an unALLOCated String or 0 char*");
00401 //  ERROR3IF(camStrlen(s) >= length, "Call to String::operator= will result in overflow");
00402 
00403     if (text && s)
00404     {
00405         if(camStrlen(s) >= length)
00406             camStrncpy(text, s, (INT32)length-1);
00407         else
00408             camStrcpy(text, s);
00409     }
00410     return *this;
00411 }

StringBase & StringBase::operator= const StringBase other  ) 
 

Assignment (set equal to) operator, eg. StringBase x("rhubarb"); x = "custard";.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
22nd April 1993
Parameters:
A reference to a constant String. [INPUTS]
Returns:
A reference to this.

Reimplemented in StringVar.

Definition at line 370 of file basestr.cpp.

00371 {
00372     ERROR3IF(!text || !other.text, "Call to String::operator= for an unALLOCated String");
00373 //  ERROR3IF(camStrlen(other.text) >= length, "Call to String::operator= will result in overflow");
00374 
00375     if (text && other.text)
00376     {
00377         if(camStrlen(other.text) >= length)
00378             camStrncpy(text, other.text, (INT32)length - 1);
00379         else
00380             camStrcpy(text, other.text);
00381     }
00382     return *this;
00383 }

TCHAR StringBase::operator[] const INT32  Index  )  [inline]
 

Extract single characters from the string... 0 is the first char, String.Length() is the terminating zero...

Author:
Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
Date:
22nd November 1995 Returns The character at offset Index into the string... Or 0 if there were problems (or if the character was 0 of course).

Definition at line 880 of file basestr.h.

00881 {
00882     ERROR3IF(!text, "Call to String::operator[] for an unALLOCated String");
00883     return (text && (Index <= (INT32)camStrlen(text))) ? text[Index] : 0;
00884 }

INT32 StringBase::PrevIndex INT32  index  )  const [inline]
 

Find the previous character index Notes: If string exceptions are enabled, an exception will be thrown if the index goes out of range.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
29/07/96
Parameters:
index = the current character index [INPUTS]
Returns:
the previous characater index before 'index' -1 if there is no previous index, OR an exception is thrown

Definition at line 542 of file basestr.h.

00543 {
00544     INT32 i = index-1;
00545     if (IsLegal(i)) return i;
00546 
00547     TRACEUSER( "Mike", wxT("String index underflow in StringBase::PrevIndex()") );
00548     return IllegalIndex();
00549 }

void StringBase::Remove INT32  nchStartPos,
INT32  nchRemove
 

Inserting a string into another one. Scope: Public.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
26th August 1994 Position - the position of the first character to be removed. Counting starts at 0. Number - the number of characters to be removed.
Returns:
-

Definition at line 892 of file basestr.cpp.

00893 {
00894     ERROR3IF(nchStartPos < 0,"Bad start position passed to StringBase::Remove");
00895     if (!text)
00896     {
00897         ERROR3("Not ALLOCed in StringBase::Remove");
00898         return;
00899     }
00900 
00901     StringBase strLeftSeg;
00902     StringBase strRightSeg;
00903     INT32   nchRightSeg = Length() - nchStartPos - nchRemove;
00904 
00905     if (nchStartPos <= 0)
00906     {
00907         if (nchRightSeg <= 0)
00908             Empty();
00909         else
00910             Right(this, nchRightSeg);
00911     }
00912     else
00913     {
00914         if (nchRightSeg <= 0)
00915         {
00916             Left(this, nchStartPos);
00917         }
00918         else
00919         {
00920             if (!strLeftSeg.Alloc(nchStartPos) || !strRightSeg.Alloc(nchRightSeg)) return;
00921             Left(&strLeftSeg, nchStartPos);
00922             Right(&strRightSeg, nchRightSeg);
00923             *this = strLeftSeg;
00924             *this += strRightSeg;
00925         }
00926     }
00927 }

INT32 StringBase::ReverseFind TCHAR  cToFind  )  const
 

As above.

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>, from Mike
Date:
2/5/97
Parameters:
c = the character whose index we need [INPUTS]
Returns:
The index of the last occurrence of character cToFind in the string.

Definition at line 1481 of file basestr.cpp.

01482 {
01483     ERROR2IF(text==0, IllegalIndex(), "Call to StringBase::ReverseFind for unALLOCated String");
01484     
01485     INT32 iPosition=Length()-1;
01486 
01487     while ((text[iPosition]!=cToFind) && iPosition>=0)
01488         iPosition--;
01489 
01490     if (iPosition<0)
01491         return IllegalIndex();
01492     else
01493         return iPosition;
01494 }

const StringBase & StringBase::Right StringBase out,
UINT32  count
const
 

Similar to the BASIC Right$() function.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
22nd April 1993
Parameters:
The number of characters in the postfix. [INPUTS]
Returns:
The rightmost n characters of the StringBase. If n is greater than the StringBase's length, the value of the whole StringBase is returned. If n is less than or equal to zero, the 0 StringBase is returned.
See also:
StringBase::Left StringBase::Mid

Definition at line 614 of file basestr.cpp.

00615 {
00616     ERROR3IF(out == 0, "0 output parameter in StringBase::Right");
00617     ERROR3IF(!text || !out->text, "Call to StringBase::Right for unALLOCated String");
00618     ERROR3IF(count < 0, "Call to StringBase::Right with a meaningless character count");
00619     ERROR3IF(out->length <= count, "Call to StringBase::Right will overflow");
00620 
00621     if (text && out && out->text)
00622     {    
00623         UINT32 L = camStrlen(text);
00624         if (count == 0)
00625             *(out->text) = 0;
00626         else if (count >= L)
00627             camStrcpy(out->text, text);
00628         else
00629         {
00630             camStrncpy(out->text, text + L - count, (INT32)count);
00631             out->text[count] = 0;
00632         }
00633     }
00634 
00635     return *this;
00636 }

TCHAR * StringBase::SafeCat TCHAR string1,
const TCHAR string2,
UINT32  Max
[static]
 

Appends string2 to the end of string1 and returns string1 as the result. The difference between this and camStrcat is the Max parameter which helps alleviate the buffer overwrite problems. Setting max to the length member of a stringbase will ERROR3IF that we don't go overwriting ends of buffers and suchlike... In such cases the result will be trucated.

Author:
Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
Date:
26th February 1996
Parameters:
string1 0-terminated destination string [INPUTS] string2 0-terminated source string Max Maximum number of characters string1 is allowed to contain
string1 Resulting string [OUTPUTS]
Returns:
string1
eg, TCHAR String1[256] = "Fish"; SafeCat(String1, "cake", 7); will result in "Fishcak" being placed in String1...

Definition at line 484 of file basestr.cpp.

00485 {
00486     ERROR3IF(string1 == 0 || string2 == 0, "StringBase::SafeCat given 0 params");
00487 
00488     UINT32 len1 = camStrlen(string1);
00489 
00490     ERROR3IF(len1 > Max, "First parameter to StringBase::SafeCat already larger than safe");
00491 
00492     // No point trying if all space used up
00493     if (len1 <= Max)
00494     {
00495         // Are we going to overflow ?
00496         if ((len1 + camStrlen(string2)) > Max)
00497         {
00498             ERROR3("Call to StringBase::SafeCat will give truncated result");
00499 
00500             // Yeah, so we need to chop some of the second string off before concatenation
00501             INT32 Required = Max - len1;
00502             if (Required > 0)
00503             {
00504                 camStrncpy( &(string1[len1]), string2, Required);
00505                 string1[Max] = 0;
00506             }
00507         }
00508         else
00509         {
00510             // No, just do a normal strcat
00511             camStrcat(string1, string2);
00512         }
00513     }
00514     
00515     return string1;
00516 }

INT32 StringBase::SkipComma INT32  pos = 0  )  const
 

Find the next comma (starting from pos) and skip on to the next none space character beyond it. Notes: ** Throws an exception if string exceptions are enabled **.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
29/07/96
Parameters:
pos = the character index from which to start [INPUTS]
Returns:
the index of the next none space character after the comma, -1 if none, OR an exception is thrown Throws an exception if string exceptions are enabled

Definition at line 1400 of file basestr.cpp.

01401 {
01402     if ((pos = FindNextChar(TEXT(','), pos)) >= 0) pos = FindNextChar(pos + 1);
01403     return pos;
01404 }

INT32 StringBase::SkipSpace INT32  pos = 0  )  const [inline]
 

Find the next non-space character starting from pos. If pos is a none space character, the function will simply return with the same index. Notes: ** Throws an exception if string exceptions are enabled **.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
29/07/96
Parameters:
pos = the character index from which to start [INPUTS]
Returns:
the index of the next none space character -1 if none, OR an exception is thrown

Definition at line 1382 of file basestr.h.

01383 {
01384     return FindNextChar(pos);
01385 }

void StringBase::Split StringBase pstrStart,
StringBase pstrEnd,
INT32  iSplit,
BOOL  fIncludeSplitChar
 

Splits a string into two separate strings at a given character.

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
2/5/97
Parameters:
iSplit Index of the splitting character [INPUTS] fIncludeSplitChar TRUE Put the splitting character at the end of strStart FALSE Put the splitting character at the start of strEnd
pstrStart The string into which to put everything before [OUTPUTS] the splitting character pstrEnd The string into which to put everything before the splitting character
Note that pstrStart or pstrEnd may either be 0 or may point at this string.

Useful in parsing URLs.

Returns:
Errors: If any parameters are invalid
See also:
WebAddress::Parse

Definition at line 665 of file basestr.cpp.

00666 {
00667     //First check our parameters
00668     if (iSplit<0)
00669     {
00670         ERROR2RAW("StringBase::Split - 0 parameter");
00671         return;
00672     }
00673 
00674     //If iSplit is greater than the length of the string, then
00675     //put the entire string into pstrStart
00676     if (iSplit>=Length())
00677     {
00678         if (pstrStart)
00679             *pstrStart=*this;
00680 
00681         if (pstrEnd)
00682             pstrEnd->Empty();
00683 
00684         return;
00685     }
00686         
00687     //This variable is 1 if we're including the splitting character
00688     //and 0 otherwise
00689     INT32 iIncludeSplitChar=(fIncludeSplitChar? 1 : 0);
00690 
00691     //And get the length
00692     INT32 iLength=Length();
00693 
00694     //Now, let's get the start string
00695     String_256 strStart;
00696 
00697     //This is the number of characters to include in the start string
00698     INT32 iStartChars=iSplit+iIncludeSplitChar;
00699 
00700     //And now actually create the start string
00701     Left(&strStart, iStartChars);
00702 
00703     //And the end string
00704     String_256 strEnd;
00705 
00706     Right(&strEnd, iLength-iStartChars);
00707 
00708     //Now, if we have been passed an output start string
00709     if (pstrStart)
00710         //Copy our start string into it
00711         *pstrStart=strStart;
00712 
00713     //And if we have been passed an output end string
00714     if (pstrEnd)
00715         //Copy our end string into it
00716         *pstrEnd=strEnd;
00717 
00718 }

INT32 StringBase::Sub const StringBase mask,
UINT32  from = 0,
TCHAR  fuzz = 0
const
 

Similar to the (non-standard) BASIC Instr$() function. Scope: Public.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
22nd April 1993
Parameters:
A reference to the substring (mask) to search for; optionally the first [INPUTS] character position to search from (default is first character in the string); optionally the character in the mask which is acting as a wildcard (if not specified, there is no wildcard in the mask).
Returns:
Returns the starting position of the substring, or -1 if the substring does not appear within "this".

Definition at line 735 of file basestr.cpp.

00736 {
00737     ERROR3IF(!text || !mask.text, "Call to String::Sub for an unALLOCated String");
00738     ERROR3IF(from < 0, "Call to String::Sub with a negative \"from\" character position");
00739     
00740     if (text && mask.text)
00741     {
00742         if (from >= camStrlen(text) || camStrlen(mask.text) == 0)
00743             return -1;
00744 
00745         BOOL matched = FALSE;                       // 2 state DFA
00746         const TCHAR* pSub = mask.text;
00747         for (const TCHAR* pThis = text + from; *pThis; pThis++)
00748             if (*pSub != fuzz && *pThis != *pSub)   // current pair match?
00749             {
00750                 if (matched)                        // no, so if we had a match previously
00751                 {
00752                     pThis--;                        // then we must go back one character
00753                     matched = FALSE;
00754                 }
00755                 pSub = mask.text;                   // and also match from beginning of mask
00756             }
00757             else
00758             {
00759                 matched = TRUE;                     // yes, we have a match
00760                 if (*++pSub == 0)                   // matched all of mask?
00761                     return (pThis - text) - (pSub - mask.text) + 1;
00762             }
00763     }
00764 
00765     // return NOT FOUND
00766     return -1;                                  
00767 }

INT32 StringBase::SubWithoutCase const StringBase strToFind  )  const
 

Similar to the (non-standard) BASIC Instr$() function. Scope: Public.

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
26/6/97
Parameters:
mask The string to search for [INPUTS] from (optional) the character to search from
Returns:
Returns the starting position of the substring, or -1 if the substring does not appear within "this".
The comparison is done without regard to case. For example, trying to find the string "fILe" in the following string:

"The Rockford Files"

would give a result of 13.

Definition at line 788 of file basestr.cpp.

00789 {
00790     ERROR3IF(!text || !strToFind.text, "Call to String::Sub for an unALLOCated String");
00791 
00792     if (IsEmpty() || strToFind.IsEmpty())
00793         return -1;
00794     
00795 #if !defined(__WXMAC__)
00796     //First set up a pointer to search this string with
00797     TCHAR* pcThisChar=text;
00798     INT32 iThisChar=0;
00799     
00800     //Now, while pcThisChar is valid
00801     while (pcThisChar!=0 && *pcThisChar!='\0')
00802     {
00803         //Is strToSearch from pcThisChar onwards the same
00804         //as strToFind, doing a case insensitive comparision?
00805         if (camStrnicmp(pcThisChar, strToFind, camStrlen(strToFind))==0)
00806         {
00807             //Yes. So return the index of the character we found
00808             return iThisChar;
00809         }
00810 
00811         pcThisChar=camStrinc(pcThisChar);
00812         iThisChar++;
00813     }
00814 #else
00815 PORTNOTE("macport", "StringBase::SubWithoutCase not yet implemented");
00816 ERROR3("StringBase::SubWithoutCase not yet implemented");
00817 #endif
00818     //Otherwise return -1
00819     return -1;
00820 
00821 }

void StringBase::SwapChar const TCHAR  schar,
const TCHAR  rchar
 

Exchange all schar characters in the string with rchar characters Scope: Public.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
19/04/95
Parameters:
schar - the search character [INPUTS] rchar - the replacement character
Returns:
-

Definition at line 946 of file basestr.cpp.

00947 {
00948     ERROR3IF(!text ,"Call to String::SwapChar for an unALLOCated String");
00949     if (text)
00950     {
00951         TCHAR* pThis = text;
00952         while( *pThis != wxT('\0') )
00953         {
00954             if (*pThis == schar)
00955                 *pThis = rchar;
00956             pThis = camStrinc(pThis);
00957         }
00958     }
00959 }

INT32 StringBase::TCharToNum TCHAR  c  )  [inline, static, private]
 

Convert a TCHAR into a numeric value. The routine does not check for valid numeric characters, it just performs the conversion. Hence it is possibly for you to pass in the character 's' for instance and receive a >9 value back.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
29/07/96
Parameters:
c,a character [INPUTS]
Returns:
If c turns out to be a numeric character, its numeric value 0..9

Definition at line 1097 of file basestr.h.

01098 {
01099     return c - TEXT('0');
01100 }

void StringBase::ThrowStringException  )  [static, private]
 

Throws a 'User' exception if the string exception stack says 'Yes'.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
29/07/96

Definition at line 1374 of file basestr.cpp.

01375 {
01376     PORTNOTETRACE("other","StringBase::ThrowStringException - do nothing");
01377 #ifndef EXCLUDE_FROM_XARALX
01378     if (StringBase::WillThrowException()) AfxThrowUserException();
01379 #endif
01380 }

StringBase & StringBase::toLower  )  [inline]
 

Converts all upper-case letters to lower-case.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
22nd April 1993

Definition at line 749 of file basestr.h.

00750 {
00751     ERROR3IF(!text, "Call to TOLOWER for an unALLOCated String");
00752     if (text) CharLower(text);
00753     return *this;
00754 }

StringBase & StringBase::toTitle  ) 
 

Converts all the first letters of words to uppercase and the rest to lower case.

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/10/97

Definition at line 196 of file basestr.cpp.

00197 {
00198     ERROR3IF(text == 0, "Call to TOLOWER for an unALLOCated String");
00199 
00200     //First set up a pointer with which to go through the string
00201     TCHAR* pText=text;
00202 
00203     //And set up a buffer, which we will use to convert the case of single
00204     //characters
00205 
00206     //GTODO: Put this in a separate function?
00207     TCHAR bufToConvert[2];
00208     bufToConvert[0]='\0';
00209     bufToConvert[1]='\0';
00210 
00211     //Now, until we reach the end of the string
00212     while (pText && *pText!='\0')
00213     {
00214         //Move pText through the string until it points
00215         //to a letter
00216         while (pText && !IsAlpha(*pText) && *pText!='\0')
00217         {
00218             pText++;
00219         }
00220 
00221         //And, if we are not at the end of the string
00222         if (pText && *pText!='\0')
00223         {
00224             //Convert that letter to upper case
00225             bufToConvert[0]=*pText;
00226 
00227             CharUpper(bufToConvert);
00228 
00229             *pText=bufToConvert[0];
00230 
00231             //Now advance to the next character
00232             pText++;
00233         }
00234 
00235         //And convert any following letters to lower case, until
00236         //we reach the end of the string of letters. We also
00237         //count apostrophes as letters, since they may be part of
00238         //a word
00239         while (pText && (IsAlpha(*pText) || *pText=='\''))
00240         {
00241             // Convert that letter to lower case
00242             bufToConvert[0]=*pText;
00243             CharLower(bufToConvert);
00244             *pText=bufToConvert[0];
00245             
00246             // And advance to the next letter
00247             pText++;
00248         }
00249     }
00250 
00251     return *this;
00252 }

StringBase & StringBase::toUpper  )  [inline]
 

Converts all lower-case letters in the string to upper-case.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
22nd April 1993

Definition at line 735 of file basestr.h.

00736 {
00737     ERROR3IF(!text, "Call to TOUPPER for an unALLOCated String");
00738     if (text) CharUpper(text);                          // get Windows API to convert
00739     return *this;
00740 }

BOOL StringBase::WillThrowException  )  [static]
 

This function interogates the exceptions state stack and determins whether exceptions will be thrown or not.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
29/07/96
Parameters:
- [INPUTS]
Returns:
TRUE if exceptions will currently be thrown FALSE if functions will return errors (ie out of range indexes)

Definition at line 1357 of file basestr.cpp.

01358 {
01359     return (CurrEx < 0) ? FALSE : ThrowExceptionStack[CurrEx];
01360 }


Friends And Related Function Documentation

friend class Error [friend]
 

Definition at line 164 of file basestr.h.

bool operator!= const StringBase x,
const StringBase y
[friend]
 

Comparison (logical) operators, eg. x = "alpha"; y = "beta"; cout << "First is " << (x < y ? x : y) << endl; These functions will work according to local custom.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> (Jason)
Date:
22nd April 1993 (24/5/94) (23/4/96) Returns Return 0 (FALSE) or 1 (TRUE) according to the relative lexical order of two strings.
Notes: Now uses IsIdentical to compare the strings, which is 12 times faster than the new internationalised CompareTo.

Definition at line 961 of file basestr.h.

00962 {
00963     return !x.IsIdentical(y);
00964 }

bool operator!= const StringBase x,
const TCHAR y
[friend]
 

Definition at line 967 of file basestr.h.

00968 {
00969     return !x.IsIdentical(y);
00970 }

bool operator< const StringBase x,
const StringBase y
[friend]
 

Comparison (logical) operators, eg. x = "alpha"; y = "beta"; cout << "First is " << (x < y ? x : y) << endl; These functions will work according to local custom.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> (Jason)
Date:
22nd April 1993 (24/5/94) Returns Return 0 (FALSE) or 1 (TRUE) according to the relative lexical order of two strings.

Definition at line 987 of file basestr.h.

00988 {
00989     return x.CompareTo(y) < 0;
00990 }

bool operator< const StringBase x,
const TCHAR y
[friend]
 

Definition at line 993 of file basestr.h.

00994 {
00995     return x.CompareTo(y) < 0;
00996 }

std::ostream& operator<< std::ostream &  os,
const StringBase s
[friend]
 

Write a string to a (non-persistent) stream. If the string is 0 then "[0]" is printed.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
22nd April 1993
Parameters:
A reference to an output stream) and a reference to the constant string [INPUTS] to write to it.
Returns:
Reference to the output stream.
See also:
istream& operator>>(istream& is, StringBase& s)

Definition at line 1274 of file basestr.cpp.

01275 {
01276     ERROR3IF(!s.text, "Call to ostream << for an unALLOCated String");  
01277     os << (s.Length() ? s.text : TEXT("[0]"));
01278     return os;
01279 }

bool operator<= const StringBase x,
const StringBase y
[friend]
 

Comparison (logical) operators, eg. x = "alpha"; y = "beta"; cout << "First is " << (x < y ? x : y) << endl; These functions will work according to local custom.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> (Jason)
Date:
22nd April 1993 (24/5/94) Returns Return 0 (FALSE) or 1 (TRUE) according to the relative lexical order of two strings.

Definition at line 1041 of file basestr.h.

01042 {
01043     return x.CompareTo(y) <= 0;
01044 }

bool operator<= const StringBase x,
const TCHAR y
[friend]
 

Definition at line 1047 of file basestr.h.

01048 {
01049     return x.CompareTo(y) <= 0;
01050 }

bool operator== const StringBase x,
const StringBase y
[friend]
 

Definition at line 938 of file basestr.h.

00939 {
00940     return x.IsIdentical(y);
00941 }

bool operator== const StringBase x,
const TCHAR y
[friend]
 

Comparison (logical) operators, eg. x = "alpha"; y = "beta"; cout << "First is " << (x < y ? x : y) << endl; These functions will work according to local custom.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> (Jason)
Date:
22nd April 1993 (24/5/94) (23/4/96) Returns Return 0 (FALSE) or 1 (TRUE) according to the relative lexical order of two strings.
Notes: Now uses IsIdentical to compare the strings, which is 12 times faster than the new internationalised CompareTo.

Definition at line 932 of file basestr.h.

00933 {
00934     return x.IsIdentical(y);
00935 }

bool operator> const StringBase x,
const StringBase y
[friend]
 

Comparison (logical) operators, eg. x = "alpha"; y = "beta"; cout << "First is " << (x < y ? x : y) << endl; These functions will work according to local custom.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> (Jason)
Date:
22nd April 1993 (24/5/94) Returns Return 0 (FALSE) or 1 (TRUE) according to the relative lexical order of two strings.

Definition at line 1014 of file basestr.h.

01015 {
01016     return x.CompareTo(y) > 0;
01017 }

bool operator> const StringBase x,
const TCHAR y
[friend]
 

Definition at line 1020 of file basestr.h.

01021 {
01022     return x.CompareTo(y) > 0;
01023 }

bool operator>= const StringBase x,
const StringBase y
[friend]
 

Definition at line 1076 of file basestr.h.

01077 {
01078     return x.CompareTo(y) >= 0;
01079 }

bool operator>= const StringBase x,
const TCHAR y
[friend]
 

Comparison (logical) operators, eg. x = "alpha"; y = "beta"; cout << "First is " << (x < y ? x : y) << endl; These functions will work according to local custom.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> (Jason)
Date:
22nd April 1993 (24/5/94) Returns Return 0 (FALSE) or 1 (TRUE) according to the relative lexical order of two strings.

Definition at line 1069 of file basestr.h.

01070 {
01071     return x.CompareTo(y) >= 0;
01072 }

std::istream& operator>> std::istream &  is,
StringBase s
[friend]
 

Read a string from a (non-persistent) stream. The input is terminated by a newline character (NOT whitespace, cf. reading C-style character arrays). If the string is longer than MAX_STRING_RES_LENGTH get() will read as many characters as possible and put a newline at the end.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
22nd April 1993
Parameters:
A reference to an input stream and a reference to the string whose [INPUTS] value is to be read.
Returns:
A reference to the input stream, which enables the chaining of stream operations.
See also:
ostream& operator<<(ostream& os, const StringBase& s)

Definition at line 1240 of file basestr.cpp.

01241 {
01242     ERROR3IF(!s.text, "Call to istream >> for an unALLOCated String");
01243 
01244     char                temp[MAX_STRING_RES_LENGTH];
01245     is >> std::ws;                              // skip any leading whitespace
01246     is.get(temp, MAX_STRING_RES_LENGTH);    // grab a chunk of input, up to a newline
01247     
01248     ERROR3IF( size_t(s.length) <= strlen(temp), "Call to istream >> will overflow String" );
01249 #if wxUSE_UNICODE
01250 PORTNOTE("other","This is not very efficient needs revisiting")
01251     TCHAR               ptsz[MAX_STRING_RES_LENGTH];
01252     mbstowcs( ptsz, temp, MAX_STRING_RES_LENGTH );
01253 #else
01254     s = temp;                               // NB. s.operator=(const TCHAR*)
01255 #endif
01256     return is;
01257 }


Member Data Documentation

INT32 StringBase::CurrEx = -1 [static, private]
 

Definition at line 298 of file basestr.h.

UINT32 StringBase::length [protected]
 

Definition at line 307 of file basestr.h.

TCHAR* StringBase::text [protected]
 

Definition at line 306 of file basestr.h.

BOOL StringBase::ThrowExceptionStack [static, private]
 

Definition at line 297 of file basestr.h.


The documentation for this class was generated from the following files:
Generated on Sat Nov 10 04:01:30 2007 for Camelot by  doxygen 1.4.4