Game Accessibility Library logo SourceForge.net Logo
Game Accessibility Suite: CAT/CATString.h Source File

CATString.h

Go to the documentation of this file.
00001 /// \file    CATString.h
00002 /// \brief   String class
00003 /// \ingroup CAT
00004 ///
00005 /// Copyright (c) 2002-2008 by Michael Ellison.
00006 /// See COPYING.txt for the \ref gaslicense License (MIT License).
00007 ///
00008 // $Author: mikeellison $
00009 // $Date: 2008-01-27 01:25:54 -0600 (Sun, 27 Jan 2008) $
00010 // $Revision:   $
00011 // $NoKeywords: $
00012 
00013 #ifndef _CATString_H_
00014 #define _CATString_H_
00015 
00016 #include "CATInternal.h"
00017 
00018 const CATWChar kCRLF[3] = { 0x0d, 0x0a, 0 };
00019 
00020 /// \class CATString CATString.h
00021 /// \brief String class that supports both char* and unicode/CATWChar types
00022 /// \ingroup CAT
00023 ///
00024 /// This needs a few features for optimization when time is available.
00025 /// First of all, there needs to be a copy-on-write / reference counting
00026 /// feature added so that when strings are copied as return values and such,
00027 /// they don't need to allocate additional RAM unless they are modified.
00028 ///
00029 /// Also, it could be smarter about the unicode/ASCII buffer swapping.
00030 /// Right now the class is rather innefficient, but it's pretty
00031 /// convenient.
00032 ///
00033 /// Watch for performance hits when using this class, and fix them
00034 /// if necessary.  Don't use in an inner loop :)
00035 ///
00036 /// Lastly, this ain't directly portable off windows.  Many of the 
00037 /// string functions (e.g. _vsnwprintf) will need to be modified. Sorry,
00038 /// planning on doing that first thing when porting it :)
00039 class CATString
00040 {
00041 public:
00042     /// CATString() - Default constructor
00043     CATString();
00044 
00045     /// Copy constructor from existing string.
00046     /// \param str - String to copy into new CATString object
00047     CATString(const CATString& str);        
00048 
00049     /// Constructor using a normal ASCIIZ string
00050     /// \param str - ASCIIZ string to copy into new CATString object
00051     CATString(const char* str);
00052 
00053     /// Constructor using wide character null-terminated string
00054     /// \param str - Zero-terminated wide-char string to copy in
00055     CATString(const CATWChar* str);
00056 
00057     /// Constructor conversion from unsigned long value
00058     /// \param val - unsigned long value to convert to a string
00059     /// \sa AppendHex()
00060     CATString(CATUInt32 val);
00061 
00062     /// Constructor conversion from long value
00063     /// \param val - signed long value to convert to a string
00064     /// \sa AppendHex()
00065     CATString(CATInt32 val);      
00066 
00067     /// Constructor conversion from 32-bit float value
00068     /// \param val - floating point value to convert to a string
00069     CATString(CATFloat32 val);
00070 
00071     /// Constructor conversion from 64-bit float value
00072     /// \param val = floating point value to convert to a string
00073     CATString(CATFloat64 val);
00074 
00075     CATString(const GUID& guid);
00076     CATString(const GUID* guid);
00077     /// Constructor conversion from char
00078     /// \param val - char value to convert directly into a string
00079     CATString(char    val);
00080 
00081     /// Constructor conversion from a wide char
00082     /// \param val - wide char value to convert directly into a string
00083     CATString(CATWChar val);
00084 
00085     /// Constructor conversion from a bool
00086     /// \param val - boolean to convert to a "True" or "False" string
00087     CATString(bool val);
00088 
00089     /// Destructor
00090     ~CATString();       
00091 
00092     /// Sets the local codepage used for MBCS <-> Unicode conversions
00093     /// \param codePage - target code page
00094     void SetCodePage(CATUInt32 codePage);
00095 
00096     //--------------------------------------------------------------------
00097     // Operator overrides       
00098     //--------------------------------------------------------------------
00099 
00100     /// = override to copy in a CATString
00101     /// \param str - source CATString
00102     CATString& operator=(const CATString& str);
00103 
00104     /// = override to copy in an ASCIIZ string
00105     /// \param asciistr - ASCIIZ string source
00106     CATString& operator=(const char* asciistr);
00107 
00108     /// = override to copy in a zero-terminated wide char string
00109     /// \param unistr - Unicode string source
00110     CATString& operator=(const CATWChar* unistr);
00111 
00112     /// = override to copy in a character as a string
00113     /// \param val - char value
00114     CATString& operator=(char    val);
00115 
00116     /// = override to copy in a wide char as a string
00117     /// \param val - char value
00118     CATString& operator=(CATWChar val);
00119 
00120     /// = override to copy in a float value as a string
00121     /// \param val - floating point value
00122     CATString& operator=(CATFloat32 val);
00123 
00124     /// = override to copy in a large float value as a string
00125     /// \param val - floating point value
00126     CATString& operator=(CATFloat64 val);
00127 
00128     CATString& operator=(const GUID& guid);
00129     CATString& operator=(const GUID* guid);
00130     /// = override to copy in an unsigned integer value
00131     /// \param val - unsigned integer to convert to string
00132     CATString& operator=(CATUInt32 val);
00133 
00134     /// = override to copy in an integer value
00135     /// \param val - integer to convert to string
00136     CATString& operator=(CATInt32 val);
00137 
00138     /// = override to set string to True or False from a bool
00139     /// \param val - boolean value. String becomes "True" if true, "False"
00140     CATString& operator=(bool val);
00141 
00142     /// += appending override - appends a string to current
00143     /// \param str - string to append
00144     CATString& operator+=(const CATString& str);
00145 
00146     //--------------------------------------------------------------------
00147     // Add 'em as you need 'em, but don't make it 
00148     // dependant on other classes. Instead, provide 
00149     // an override to a char* from your class.
00150 
00151     /// << override - append a string to the current one
00152     /// \param str - string to append (CATString)
00153     CATString& operator<<(const CATString& str);
00154 
00155     /// << override - append a string to the current one
00156     /// \param str - string to append (ASCIIZ)
00157     CATString& operator<<(const char* str); 
00158 
00159     /// << override - append a string to the current one
00160     /// \param str - string to append (Unicode)
00161     CATString& operator<<(const CATWChar* str);
00162 
00163     /// << override - append a char to the current string
00164     /// \param strChar - char to append
00165     CATString& operator<<(char strChar);
00166 
00167     /// << override - append a wide char to the current string
00168     /// \param strChar - char to append
00169     ///
00170     /// WARNING: short's will be interpreted as wchar's in some
00171     ///          compilers!
00172     CATString& operator<<(const CATWChar strChar);  
00173 
00174     /// << override - append an unsigned long to the string
00175     /// \param val - value to convert to string and append
00176     CATString& operator<<(CATUInt32 val);
00177 
00178     /// << override - append a long to the string
00179     /// \param val - value to convert to string and append
00180     CATString& operator<<(CATInt32 val);
00181 
00182     /// << override - append a float to the string
00183     /// \param val - value to convert to string and append
00184     CATString& operator<<(CATFloat32 val);              
00185 
00186     /// << override - append a double to the string
00187     /// \param val - value to convert to string and append
00188     CATString& operator<<(CATFloat64 val);
00189 
00190     /// << override - append a hex guid (no {}'s)
00191     /// \param guid - guid to covert to string
00192     CATString& operator<<(const GUID& guid);
00193     CATString& operator<<(const GUID* guid);
00194 
00195     /// Const char* override - you may not modify the
00196     /// string this way, but you can use it for const 
00197     /// functions.  
00198     ///
00199     /// Be careful to specifically specify
00200     /// this overload for multi-argument functions like printf,
00201     /// otherwise you'll end up with garbage.
00202     ///
00203     /// \return const char* - pointer to string buffer in ASCIIZ format.
00204     /// \sa GetAsciiBuffer(), ReleaseBuffer()
00205     operator const char *() const;
00206 
00207     /// Const CATWChar* override - you may not modify the
00208     /// string this way, but you can use it for const 
00209     /// functions.  
00210     ///
00211     /// Be careful to specifically specify
00212     /// this overload for multi-argument functions like wprintf,
00213     /// otherwise you'll end up with garbage.
00214     ///
00215     /// \return const CATWChar* - pointer to string buffer in wide-char
00216     /// (Unicode) format.
00217     /// \sa GetUnicodeBuffer(), ReleaseBuffer()
00218     operator const CATWChar *() const;
00219 
00220     /// Convert the string to a long, if possible.
00221     operator CATInt32  () const;
00222 
00223     operator CATInt64 () const;
00224 
00225     /// Convert the string to a float, if possible.
00226     operator CATFloat32 () const;
00227 
00228     /// Convert the string to a float, if possible.
00229     operator CATFloat64 () const;
00230 
00231     /// Convert the string to an unsigned long, if possible.
00232     operator CATUInt32 () const;
00233 
00234     /// Convert the string to a bool, if possible.
00235     operator bool    () const;
00236 
00237     //--------------------------------------------------------------------
00238     // Standard string functions
00239     //--------------------------------------------------------------------
00240 
00241 
00242     /// GetWChar() retrieves the wide character at the specified offset 
00243     /// in the string.
00244     ///
00245     /// GetWChar is preferred to GetChar().
00246     ///
00247     /// \param offset - 0-based offset of character.
00248     /// \return CATWChar - character at offset or 0 if the offset is
00249     /// out of bounds (will also assert in debug in this case)
00250     /// \sa SetWChar()
00251     CATWChar    GetWChar(CATUInt32 offset) const;
00252 
00253 
00254     /// SetWChar() sets the character at the specified offset in the
00255     /// string.
00256     ///
00257     /// SetWChar() is preferred over SetChar().
00258     /// You may *not* set a character past the current length of the
00259     /// string or buffer size.
00260     ///
00261     /// \param offset - 0-based offset of character.
00262     /// \param theChar - the wide character to place at the offset
00263     /// \return bool - true on success.      
00264     /// \sa GetWChar()
00265     bool        SetWChar(CATUInt32 offset, CATWChar theChar);
00266 
00267     /// Length() retrieves the length of active string.
00268     ///
00269     /// \return CATUInt32 - length of string.
00270     /// \sa LengthCalc()
00271     CATUInt32 Length();
00272 
00273     /// LengthCalc() calculates the length w/o using or updating dirty flag
00274     ///
00275     /// \return CATUInt32 - length of string
00276     /// \sa Length()
00277     CATUInt32 LengthCalc() const;
00278 
00279     /// Compare() checks the equality of two strings - 
00280     /// Case sensitive.
00281     ///
00282     /// Result is the same as strcmp (0 == same).
00283     ///
00284     /// \param str    - CATString to compare against
00285     /// \param cmpLen - length to compare (0 = all)
00286     /// \param offset - offset to begin comparison
00287     /// 
00288     /// \return CATInt32 - 0 if equal, < 0 if less than, > 0 if greater.
00289     ///
00290     /// \sa CompareNoCase()
00291     CATInt32 Compare (const CATString&     str, 
00292         CATUInt32             cmpLen = 0, 
00293         CATUInt32             offset = 0) const;
00294 
00295     /// CompareNoCase() checks the equality of two strings -
00296     /// case insensitive.
00297     /// Result is the same as strcmp (0 == same).
00298     ///
00299     /// \param str    - CATString to compare against
00300     /// \param cmpLen - length to compare (0 = all)
00301     /// \param offset - offset to begin comparison
00302     /// 
00303     /// \return CATInt32 - 0 if equal, < 0 if less than, > 0 if greater.
00304     ///
00305     /// \sa Compare()
00306     CATInt32 CompareNoCase (  const CATString&   str, 
00307         CATUInt32           cmpLen = 0, 
00308         CATUInt32           offset = 0) const;
00309 
00310     /// Left() returns the left portion of the string, up to
00311     /// maxlength characters in length.
00312     ///
00313     /// \param maxlength - the maximum length from the left
00314     ///
00315     /// \return CATString - the resulting string.
00316     /// \sa Right(), FromRight(), Sub()
00317     CATString Left(CATUInt32 maxlength) const;
00318 
00319     /// Right() returns the right-hand of the string, starting
00320     /// at the position specified by start.
00321     ///
00322     /// \param start - index of first character of new string.
00323     ///
00324     /// \return CATString - the resulting string.
00325     /// \sa Left(), FromRight(), Sub()      
00326     CATString Right(CATUInt32 start) const;
00327 
00328     /// FromRight() returns the right-hand of the string, starting
00329     /// length characters from the end (e.g. the string will be
00330     /// [length] characters long).
00331     ///
00332     /// \param length - length from end of string to return
00333     ///
00334     /// \return CATString - the resulting string.
00335     /// \sa Right(), Left(), Sub()              
00336     CATString FromRight(CATUInt32 length) const;
00337 
00338     /// Sub() returns a substring of the current string.
00339     ///
00340     /// \param start - starting 0-based offset in string
00341     /// \param length - number of characters, starting at [start],
00342     ///        to return.
00343     ///
00344     /// \return CATString - the resulting string.
00345     /// \sa Left(), Right(), FromRight()
00346     CATString Sub(CATUInt32 start, CATUInt32 length) const;
00347 
00348     /// PullNextToken() retrieves the next token from a string.
00349     ///
00350     /// Finds the first instance of any of the characters in 'splitTokens'.
00351     /// Then, sets "token" to be everything to the left of that char.
00352     /// The string object becomes everything to the right of the char.
00353     /// If no more tokenizers remain in the string, then the command returns
00354     /// false and any remaining string is placed into 'token', and the string
00355     /// is left empty.
00356     ///
00357     /// example:
00358     /// CATString test = "Beer:Whiskey!Sex";
00359     /// CATString token;
00360     ///
00361     /// while (!test.IsEmpty())
00362     /// {
00363     ///      if (!test.PullNextToken(token,":!"))
00364     ///         printf("(Last token....)\n");
00365     ///     printf("%s\n",(const char*)token);
00366     /// }
00367     ///
00368     ///
00369     /// Output:
00370     ///    Beer
00371     ///    Whiskey
00372     ///    (Last token....)
00373     ///    Sex
00374     bool PullNextToken(CATString& token, const CATString& splitTokens);
00375 
00376     /// Find() finds a substring within the string, starting at offset.  
00377     ///
00378     /// \param str - substring to find
00379     /// \param offset - reference used to return position if found.  
00380     ///
00381     /// \return true if found, false otherwise      
00382     /// \sa ReverseFind()
00383     bool Find(const CATString& str, CATUInt32& offset) const;
00384 
00385     /// Find() finds a char within the string, starting at offset.  
00386     ///
00387     /// \param theChar - character to find
00388     /// \param offset - reference used to return position if found.  
00389     ///
00390     /// \return true if found, false otherwise      
00391     /// \sa ReverseFind()
00392     bool Find(CATWChar theChar, CATUInt32& offset) const;
00393 
00394     /// ReverseFind() finds a substring in a string starting at the end.
00395     ///
00396     /// \param str - substring to find
00397     /// \param offset - offset to start search from
00398     ///       -1 is a special value indicating "from the end of the string".
00399     ///        Otherwise, the offset value returned will be the position 
00400     ///        within the string as in the Find functions above. 
00401     ///        e.g. offset == -1 has the same effect as offset==mystring.Length();
00402     ///
00403     /// \sa Find()
00404     bool ReverseFind(const CATString& str, CATUInt32& offset) const;
00405 
00406     /// ReverseFind() finds a character in a string starting at the end.
00407     ///
00408     /// \param theChar - character to find
00409     /// \param offset - offset to start search from
00410     ///       -1 is a special value indicating "from the end of the string".
00411     ///        Otherwise, the offset value returned will be the position 
00412     ///        within the string as in the Find functions above. 
00413     ///        e.g. offset == -1 has the same effect as offset==mystring.Length();
00414     ///
00415     /// \sa Find()
00416     bool ReverseFind(CATWChar theChar, CATUInt32& offset) const;
00417 
00418 
00419     /// Returns true if string is empty
00420     bool IsEmpty() const;
00421 
00422     /// Ensures string is contiguous and makes the buffer the greater
00423     /// of the current string length (+1 for null), or the minLength specified.
00424     ///
00425     /// Call 
00426     char*    GetAsciiBuffer(CATUInt32 minLength = 0);
00427     CATWChar* GetUnicodeBuffer(CATUInt32 minlength = 0);
00428 
00429     /// Releases the previous get buffer
00430     void ReleaseBuffer();
00431 
00432     /// Trims whitespace chars off both ends of the string
00433     void Trim();
00434 
00435     /// Pad() pads the string with the specified char to be a certain length.
00436     ///
00437     /// If the string is already longer, then it leaves it alone.
00438     ///
00439     /// \param length - desired minimum length to pad to.
00440     /// \param theChar - pad char, space by default.
00441     void Pad (CATUInt32 length, CATWChar theChar = (CATWChar)0x20);
00442 
00443     /// Converts an unsigned long value to hex and appends it
00444     /// to the string.
00445     /// 
00446     /// \param hexValue - value to convert and append
00447     /// \return - reference to the string
00448     /// \sa AppendHexByte()
00449     CATString& AppendHex(CATUInt32 hexValue, bool addX = true);
00450 
00451     /// Converts a byte to hex and appends it to the string
00452     ///
00453     /// \param hexValue - unsigned char to convert and append
00454     /// \param addX - if true, '0x' is appended to the string.
00455     /// \return - reference to the string
00456     /// \sa AppendHex()
00457     CATString& AppendHexByte(CATUInt8 hexValue, bool addX = false);
00458 
00459     /// FromHex() converts a string from hex to a CATUInt32.
00460     CATUInt32 FromHex() const;
00461 
00462     /// Retrieve a GUID from the string. returns true if 
00463     /// it's a GUID (and sets guid), false otherwise.
00464     bool GetGUID(GUID& guid) const;
00465 
00466     /// ToUpper() converts the string to all upper-case.
00467     /// It will ignore anything that's not in standard a-z range.
00468     /// \sa ToLower()
00469     void ToUpper();
00470 
00471     /// ToLower() converts the string to all lower-case.
00472     ///
00473     /// It will ignore anything that's not in standard A-Z range.
00474     /// \sa ToUpper()
00475     void ToLower();
00476 
00477     /// Similar to (and uses) swprintf, variable arg formatting
00478     const CATString& Format(const CATWChar* formatSpecs, ...);
00479     
00480     /// Similar to (and uses) sprintf, variable arg formatting
00481     const CATString& Format(const char* formatSpecs, ...);
00482     
00483     /// Formats a string with arguments given a va_list (wide char version)
00484     const CATString& FormatArgs(const CATWChar* formatSpecs, va_list args);
00485     
00486     /// Formats a string with arguments given a va_list
00487     const CATString& FormatArgs(const char*    formatSpecs, va_list args);
00488 
00489     /// Splits a path into its components.  All parameters are optional and may be null if you don't
00490     /// need the portion. behaves similarly to wsplitpath.
00491     ///
00492     /// \param drive    ptr to string to receive drive, or null
00493     /// \param path     ptr to string to receive path (directory), or null
00494     /// \param filename ptr to string to receive filename, or null
00495     /// \param ext      ptr to receive file extension, or null.
00496     /// \return bool    true on success
00497     bool SplitPath(CATString* drive, CATString* path, CATString* filename, CATString* ext) const;
00498 
00499     /// Retrieve just the drive and directory from a full path
00500     CATString GetDriveDirectory() const;
00501 
00502     /// Retrieve just the filename and extension from a full path
00503     CATString GetFilenameExt()    const;
00504 
00505     /// Retrieve the filename, but not the extension from a full path
00506     CATString GetFilenameNoExt()  const;
00507 
00508     /// Escape() a string for XML
00509     /// \return CATString   Escaped string ready for output
00510     CATString Escape() const;
00511 
00512     /// Unescape() a string from XML
00513     /// \return CATString   Escape string ready for output
00514     CATString Unescape() const;
00515 
00516     /// Escape a string for use in a URL.
00517     ///
00518     /// Escapes characters in string to be valid within a URL. 
00519     /// Do NOT use on a full URL - it will escape the control characters.
00520     ///
00521     /// \return CATString   Escaped string
00522     CATString EncodeURL() const;
00523 
00524     /// Unescape a string from URL encoding.
00525     /// \return CATString   Unescaped string
00526     CATString DecodeURL() const;
00527 
00528 protected:
00529     /// Creates a buffer for a string of the specified length
00530     bool Create(CATUInt32 length);
00531 
00532     /// Should only be called by constructors (or very carefully from Destroy) to init members
00533     _inline void Init()
00534     {
00535         fCodePage           = CP_ACP;   // default to ANSI codepage
00536         fUnicodeBuffer      = 0;
00537         fBufferSizeLocked   = false;
00538         fBuffer             = 0;    
00539         fBufferLength       = 0;
00540         fStrLen             = 0;
00541         fLenDirty           = true;         
00542         fAsciiLocked        = false;
00543         fUnicodeLocked      = false;
00544     }
00545 
00546     _inline void CATString::Destroy()
00547     {
00548         delete [] fBuffer;
00549         fBuffer = 0;
00550         delete [] fUnicodeBuffer;
00551         fUnicodeBuffer = 0;
00552         Init();
00553     }
00554 
00555     // These retrieve the length of ascii or unicode strings (0 terminated ones)        
00556     CATUInt32 GetLength(const char* asciistr) const;
00557     CATUInt32 GetLength(const CATWChar* unistr) const;
00558 
00559     /// Copies the unicode string into the fUnicodeStr
00560     void CopyIn(const CATWChar* unistr);
00561 
00562     /// Copies a buffer of chars
00563     static void CopyBuffer(char* str1, const char* str2, CATUInt32 length);
00564 
00565     /// Copies a buffer of wide chars
00566     static void CopyBuffer(CATWChar* str1, const CATWChar* str2, CATUInt32 length);
00567 
00568     // Allocation / expansion of string buffer
00569     bool AllocBuffer(CATUInt32 minLength = 0);
00570     bool ExpandBuffer(CATUInt32 minLength = 0);
00571 
00572     /// These replace the old Update() function.
00573     bool ImportAscii(const char* ascii);
00574     bool UnicodeFromAscii();
00575     bool AsciiFromUnicode() const;
00576 
00577 private:
00578     bool             fBufferSizeLocked;     ///< True when locked by get buffer
00579     CATUInt32        fStrLen;               ///< String length if known and not dirty
00580     bool             fLenDirty;             ///< String modified since last size check
00581     CATUInt32        fBufferLength;         ///< Length of current buffer - include 0.
00582 
00583     mutable char*    fBuffer;               ///< ASCII buffer
00584     CATWChar*        fUnicodeBuffer;        ///< Unicode buffer
00585 
00586     bool             fAsciiLocked;          ///< Ascii is locked - can't use unicode functions
00587     bool             fUnicodeLocked;        ///< Unicode is locked - can't use ascii functions
00588 
00589     CATUInt32        fCodePage;             ///< Current codepage
00590 };
00591 
00592 //-----------------------------------------------------------------------------
00593 // operator overloads
00594 //-----------------------------------------------------------------------------
00595 
00596 inline CATString operator+(const CATString& str1, const CATString& str2)
00597 {
00598     CATString newStr = str1;
00599     newStr += str2;
00600     return newStr;
00601 }
00602 
00603 //---------------------------------------------------------------
00604 // Comparators... 
00605 //---------------------------------------------------------------
00606 inline bool operator==(const CATString& str1, const CATString& str2)
00607 {
00608     return (str1.Compare(str2) == 0);
00609 }
00610 
00611 inline bool operator==(const CATString& str1, const char *unistr2)
00612 {   
00613     CATString str2 = unistr2;
00614     return (str1.Compare(str2) == 0);
00615 }
00616 
00617 inline bool operator==(const CATString& str1, const CATWChar* unistr2)
00618 {   
00619     CATString str2 = unistr2;
00620     return (str1.Compare(str2) == 0);
00621 }
00622 
00623 inline bool operator==(const char *unistr2,const CATString& str1)
00624 {
00625     CATString str2 = unistr2;
00626     return (str1.Compare(str2) == 0);
00627 }
00628 
00629 inline bool operator==(const CATWChar *unistr2,const CATString& str1)
00630 {
00631     CATString str2 = unistr2;
00632     return (str1.Compare(str2) == 0);
00633 }
00634 
00635 //---------------------------------------------------------------
00636 // Not equals... 
00637 //---------------------------------------------------------------
00638 inline bool operator!=(const CATString& str1, const CATString& str2)
00639 {
00640     return (str1.Compare(str2) != 0);
00641 }
00642 
00643 inline bool operator!=(const CATString& str1, const char *unistr2)
00644 {
00645     CATString str2 = unistr2;
00646     return (str1.Compare(str2) != 0);
00647 }
00648 
00649 inline bool operator!=(const CATString& str1, const CATWChar* unistr2)
00650 {
00651     CATString str2 = unistr2;
00652     return (str1.Compare(str2) != 0);
00653 }
00654 
00655 inline bool operator!=(const char *unistr2,const CATString& str1)
00656 {
00657     CATString str2 = unistr2;
00658     return (str1.Compare(str2) != 0);
00659 }
00660 
00661 inline bool operator!=(const CATWChar *unistr2,const CATString& str1)
00662 {
00663     CATString str2 = unistr2;
00664     return (str1.Compare(str2) != 0);
00665 }
00666 
00667 //---------------------------------------------------------------
00668 // Less Than
00669 //---------------------------------------------------------------
00670 
00671 inline bool operator<(const CATString& str1, const CATString& str2)
00672 {
00673     return (str1.Compare(str2) < 0);
00674 }
00675 
00676 inline bool operator<(const CATString& str1, const char *unistr2)
00677 {
00678     CATString str2 = unistr2;
00679     return (str1.Compare(str2) < 0);
00680 }
00681 
00682 inline bool operator<(const CATString& str1, const CATWChar *unistr2)
00683 {
00684     CATString str2 = unistr2;
00685     return (str1.Compare(str2) < 0);
00686 }
00687 
00688 inline bool operator<(const char *unistr2,const CATString& str1)
00689 {
00690     CATString str2 = unistr2;
00691     return (str1.Compare(str2) > 0);
00692 }
00693 
00694 inline bool operator<(const CATWChar *unistr2,const CATString& str1)
00695 {
00696     CATString str2 = unistr2;
00697     return (str1.Compare(str2) > 0);
00698 }
00699 
00700 //---------------------------------------------------------------
00701 // Greater than
00702 //---------------------------------------------------------------
00703 
00704 inline bool operator>(const CATString& str1, const CATString& str2)
00705 {
00706     return (str1.Compare(str2) > 0);
00707 }
00708 
00709 inline bool operator>(const CATString& str1, const char *asciistr2)
00710 {
00711     CATString str2 = asciistr2;
00712     return (str1.Compare(str2) > 0);
00713 }
00714 
00715 inline bool operator>(const CATString& str1, const CATWChar *unistr2)
00716 {
00717     CATString str2 = unistr2;
00718     return (str1.Compare(str2) > 0);
00719 }
00720 
00721 inline bool operator>(const char *asciistr2,const CATString& str1)
00722 {
00723     CATString str2 = asciistr2;
00724     return (str1.Compare(str2) < 0);
00725 }
00726 
00727 inline bool operator>(const CATWChar *unistr2,const CATString& str1)
00728 {
00729     CATString str2 = unistr2;
00730     return (str1.Compare(str2) < 0);
00731 }
00732 
00733 //---------------------------------------------------------------
00734 // Greater than or equals
00735 //---------------------------------------------------------------
00736 
00737 inline bool operator>=(const CATString& str1, const CATString& str2)
00738 {
00739     return (str1.Compare(str2) >= 0);
00740 }
00741 
00742 inline bool operator>=(const CATString& str1, const char *unistr2)
00743 {
00744     CATString str2 = unistr2;
00745     return (str1.Compare(str2) >= 0);
00746 }
00747 
00748 inline bool operator>=(const CATString& str1, const CATWChar *unistr2)
00749 {
00750     CATString str2 = unistr2;
00751     return (str1.Compare(str2) >= 0);
00752 }
00753 
00754 inline bool operator>=(const char *unistr2,const CATString& str1)
00755 {
00756     CATString str2 = unistr2;
00757     return (str1.Compare(str2) <= 0);
00758 }
00759 
00760 inline bool operator>=(const CATWChar *unistr2,const CATString& str1)
00761 {
00762     CATString str2 = unistr2;
00763     return (str1.Compare(str2) <= 0);
00764 }
00765 
00766 //---------------------------------------------------------------
00767 // Less Than or Equals
00768 //---------------------------------------------------------------
00769 
00770 inline bool operator<=(const CATString& str1, const CATString& str2)
00771 {
00772     return (str1.Compare(str2) <= 0);
00773 }
00774 
00775 inline bool operator<=(const CATString& str1, const char *unistr2)
00776 {
00777     CATString str2 = unistr2;
00778     return (str1.Compare(str2) <= 0);
00779 }
00780 
00781 inline bool operator<=(const CATString& str1, const CATWChar *unistr2)
00782 {
00783     CATString str2 = unistr2;
00784     return (str1.Compare(str2) <= 0);
00785 }
00786 
00787 inline bool operator<=(const char *unistr2,const CATString& str1)
00788 {
00789     CATString str2 = unistr2;
00790     return (str1.Compare(str2) >= 0);
00791 }
00792 
00793 inline bool operator<=(const CATWChar *unistr2,const CATString& str1)
00794 {
00795     CATString str2 = unistr2;
00796     return (str1.Compare(str2) >= 0);
00797 }
00798 
00799 
00800 
00801 
00802 #endif // _CATString_H_

Generated on Mon Feb 11 04:09:49 2008 for Game Accessibility Suite by doxygen 1.5.4