00001
00002
00003
00004
00005
00007
00008 #ifndef _ROKU_INCLUDE_CASCADE_UTIL_CASCADESTRING_H
00009 #define _ROKU_INCLUDE_CASCADE_UTIL_CASCADESTRING_H
00010
00011 #include <cascade/CascadeObject.h>
00012
00025 class CascadeString : public CascadeObject
00026 {
00027 public:
00028 CascadeString();
00032 CascadeString(const CascadeString & string);
00037 CascadeString(const char * pString);
00043 virtual ~CascadeString();
00047 public:
00048 static bool SetSystemLanguage (const char * pLanguage);
00050 static bool GetSystemLanguage (char * pLanguageToSet, u32 nBuffLen);
00052 typedef bool (* LanguageEnumProc)(const CascadeString & lang, const CascadeString & friendlyLang, void * pClientData);
00053 static bool EnumerateStringResourceLanguages(class CascadeStream & stream, LanguageEnumProc callback, void * pClientData);
00060 static bool LoadStringResources(class CascadeStream & stream, const char * pLang = NULL, bool bClearFirst = true);
00086 static void ClearStringResources();
00091 static bool AddStringResource(const CascadeString & resourceID, const CascadeString & string);
00099 static bool RemoveStringResource(const CascadeString & resourceID);
00106 bool LoadString(const char * pResourceID);
00118 public:
00119 inline u32 GetLength() const { return m_nLength; }
00125 inline u32 GetTerminatedLength() const { return m_nLength + 1; }
00130 u32 CountChars() const;
00136 CascadeUnicodeChar ReadOneUnicodeChar( u32 &ioToken ) const;
00152 CascadeUnicodeChar ReadNthUnicodeChar( u32 inIdx ) const;
00164 void AppendUnicodeChar( CascadeUnicodeChar inCh );
00170 static CascadeUnicodeChar UnicodeCharToUpper( CascadeUnicodeChar inChar );
00181 static CascadeUnicodeChar UnicodeCharToLower( CascadeUnicodeChar inChar );
00192 static CascadeUnicodeChar UnicodeCharStripDiacritical( CascadeUnicodeChar inChar );
00207 static bool UnicodeCharIsAlpha( CascadeUnicodeChar inChar );
00215 static bool UnicodeCharIsDigit( CascadeUnicodeChar inChar );
00224 inline bool IsEmpty() const { return (0 == m_nLength); }
00229 void Empty();
00233 bool TrimAllocation();
00240 void Truncate(u32 nNewLength);
00250 u32 TruncateToByteLen(u32 nNewByteLength, bool bBreakOnChar = true);
00275
00276 inline bool IsEqual(const char * pString, bool bCaseSensitive = true) const { return (0 == Compare(pString, bCaseSensitive)); }
00284 s32 Compare( const char * pString,
00285 bool bCaseSensitive = true,
00286 bool bIgnoreDiacritical = false,
00287 u32 nLen = 0xFFFFFFFF ) const;
00306 s32 CompareNBytes(const char * pString,
00307 u32 nBytes) const;
00321
00322 bool Contains(const char * pString,
00323 bool bCaseSensitive = true,
00324 bool bIgnoreDiacriticals = false) const;
00338 bool ContainsBytes( const char * pString ) const;
00347 void ToLower( bool bStripDiacriticals = false );
00356 void ToUpper( bool bStripDiacriticals = false );
00365 void StripDiacriticals();
00371 inline operator const char * () const { return ((NULL == m_pString) ? "" : m_pString); }
00406 const CascadeString & operator = (const char * pString);
00410 inline const CascadeString & operator = (const CascadeString & string) { return operator = (((const char *)string)); }
00414 const CascadeString & operator += (const char * pString);
00418 const CascadeString & operator += (char ch);
00422 inline char operator [] (u32 nIndex) { return ((nIndex < m_nLength) ? (*(m_pString + nIndex)) : 0); }
00432 private:
00433 operator const void * () const;
00434
00435
00436
00437
00438 private:
00439
00440 u32 m_nLength;
00441
00442
00443 u32 m_nBuffSize;
00444
00445 char * m_pString;
00446 };
00447
00448
00450
00451
00452
00453
00454
00455 CascadeString operator + (const CascadeString & string1, const CascadeString & string2);
00464
00465 CascadeString operator + (const CascadeString & string, const char * pString);
00466 CascadeString operator + (const char * pString, const CascadeString & string);
00467
00468 inline bool
00469 operator == (const CascadeString & string1, const CascadeString & string2)
00470 {
00471 return (0 == string1.Compare(string2));
00472 }
00479
00480 inline bool
00481 operator == (const CascadeString & string, const char * pString)
00482 {
00483 return (0 == string.Compare(pString));
00484 }
00485
00486 inline bool
00487 operator == (const char * pString, const CascadeString & string)
00488 {
00489 return (0 == string.Compare(pString));
00490 }
00491
00492 inline bool
00493 operator != (const CascadeString & string1, const CascadeString & string2)
00494 {
00495 return (0 != string1.Compare(string2));
00496 }
00497
00498 inline bool
00499 operator != (const CascadeString & string, const char * pString)
00500 {
00501 return (0 != string.Compare(pString));
00502 }
00503
00504 inline bool
00505 operator != (const char * pString, const CascadeString & string)
00506 {
00507 return (0 != string.Compare(pString));
00508 }
00509
00510 inline bool
00511 operator < (const CascadeString & string1, const CascadeString & string2)
00512 {
00513 return (string1.Compare(string2) < 0);
00514 }
00515
00516 inline bool
00517 operator < (const CascadeString & string, const char * pString)
00518 {
00519 return (string.Compare(pString) < 0);
00520 }
00521
00522 inline bool
00523 operator < (const char * pString, const CascadeString & string)
00524 {
00525 return (string.Compare(pString) > 0);
00526 }
00527
00528 inline bool
00529 operator > (const CascadeString & string1, const CascadeString & string2)
00530 {
00531 return (string1.Compare(string2) > 0);
00532 }
00533
00534 inline bool
00535 operator > (const CascadeString & string, const char * pString)
00536 {
00537 return (string.Compare(pString) > 0);
00538 }
00539
00540 inline bool
00541 operator > (const char * pString, const CascadeString & string)
00542 {
00543 return (string.Compare(pString) < 0);
00544 }
00545
00546 inline bool
00547 operator <= (const CascadeString & string1, const CascadeString & string2)
00548 {
00549 return (string1.Compare(string2) <= 0);
00550 }
00551
00552 inline bool
00553 operator <= (const CascadeString & string, const char * pString)
00554 {
00555 return (string.Compare(pString) <= 0);
00556 }
00557
00558 inline bool
00559 operator <= (const char * pString, const CascadeString & string)
00560 {
00561 return (string.Compare(pString) >= 0);
00562 }
00563
00564 inline bool
00565 operator >= (const CascadeString & string1, const CascadeString & string2)
00566 {
00567 return (string1.Compare(string2) >= 0);
00568 }
00569
00570 inline bool
00571 operator >= (const CascadeString & string, const char * pString)
00572 {
00573 return (string.Compare(pString) >= 0);
00574 }
00575
00576 inline bool
00577 operator >= (const char * pString, const CascadeString & string)
00578 {
00579 return (string.Compare(pString) <= 0);
00580 }
00581
00582 #endif // #ifndef _ROKU_INCLUDE_CASCADE_UTIL_CASCADESTRING_H
00583
00585
00587
00588
00589
00590
00591
00592
00593
00594
00595
00596
00597
00598
00599
00600
00601
00602
00603
00604
00605
00606
00607
00608
00609
00610
00611
00612
00613
00614