SIBCString.h

Go to the documentation of this file.
00001 //***************************************************************************************
00002 // File supervisor: Crosswalk team
00012 //***************************************************************************************
00013 
00014 //***************************************************************************************
00015 // Defines
00016 //***************************************************************************************
00017 #ifndef __CSIBCString_H__
00018 #define __CSIBCString_H__
00019 
00020 //***************************************************************************************
00021 // Includes
00022 //***************************************************************************************
00023 #include <SIBCUtil.h>
00024 
00025 
00026 //***************************************************************************************
00027 // CSIBCString | General purpose string class
00028 //***************************************************************************************
00029 
00036 class XSICOREEXPORT CSIBCString
00037 {
00038 public:
00039 
00043     CSIBCString();
00044 
00049     CSIBCString( const CSIBCString &in_pString );
00050 
00051 
00057     CSIBCString(const SI_Char *in_pString );            // Constructor
00058 
00059     ~CSIBCString();                                     // Default Destructor
00060 
00064     SI_Int GetLength();
00065 
00082     SI_Char *GetText();
00083 
00086     void Clear();
00087 
00092     SI_Error Concat(CSIBCString *in_pString);
00093 
00098     SI_Error Concat(const SI_Char *in_pString);         // Concatenate to the string
00099 
00114     SI_Error Concat(const SI_Int in_lInt);
00115 
00128     SI_Error Concat(const SI_Float in_fFloat);          // Concatenate to the string
00129 
00134     SI_Error SetText(CSIBCString *in_pString);          // Assign to the string
00135 
00142     SI_Error SetText(const SI_Char *in_pString);        // Assign to the string
00143 
00148     SI_Error SetText(const SI_Int in_lInt);             // Assign to the string
00149 
00155     SI_Error SetText(const SI_Float in_fFloat);         // Assign to the string
00156 
00171     SI_Int Compare(CSIBCString *in_pString);
00172 
00188     SI_Int Compare(const SI_Char *in_pString);          // Compare with the string
00189 
00199     SI_Int Compare(const SI_Int in_lInt);               // Compare with the string
00200 
00209     SI_Int Compare(const SI_Float in_fFloat);           // Compare with the string
00210 
00214     SI_Error LowerCase();
00215 
00219     SI_Error UpperCase();                               // Turns all characters in string to upper case
00220 
00224     SI_Error RemoveIllegalXSICharacters();
00225 
00230     SI_Bool IsXSILegalName();
00231 
00232 
00237     CSIBCString &operator = ( const CSIBCString & i_pString);
00238 
00244     CSIBCString &operator = ( const SI_Char * i_pString);
00245 
00251     bool operator == (CSIBCString & i_pString);
00252 
00259     bool operator == (const SI_Char * i_pString);
00260 
00266     bool operator != (CSIBCString & i_pString);                 // Tests to see if strings are not equal
00267 
00271     void Dump();
00272 
00278     SI_UInt UsedMemory();                               // returns the amount of used memory
00279 
00285     SI_UInt AllocatedMemory();                          // returns the amount of allocated memory.
00286 
00287 protected:
00288 
00289 
00290 private:
00291 
00292     SI_Int      m_lLength;                              // Length of the string
00293     SI_Char     *m_pBuffer;                             // Internal SI_Char buffer
00294 };
00295 
00296 //***************************************************************************************
00297 // CSIAccumString | Optimized string class.
00298 //***************************************************************************************
00299 
00306 class XSICOREEXPORT CSIAccumString
00307 {
00308     enum {eAllocSize = 0x100};
00309 public:
00310 
00315     CSIAccumString()
00316     {
00317         m_AllocSize = eAllocSize;
00318         m_Buffer = (SI_Char*) malloc(m_AllocSize);
00319         m_BufferEnd = m_Buffer;
00320         *m_BufferEnd = 0;
00321     }
00322 
00323     ~CSIAccumString()
00324     {
00325         free( m_Buffer );
00326     }
00327 
00331     void Clear()
00332     {
00333         free( m_Buffer );
00334         m_AllocSize = eAllocSize;
00335         m_Buffer = (SI_Char*) malloc(m_AllocSize);
00336         m_BufferEnd = m_Buffer;
00337         *m_BufferEnd = 0;
00338     }
00339 
00343     void ConcatByte( SI_Byte in_Byte )
00344     {
00345         SI_Int l_iCurrDelta = (SI_Int)(m_BufferEnd - m_Buffer);
00346         if ( l_iCurrDelta > ( m_AllocSize - 2 ) )
00347         {
00348             // Array doubling... Good enough.
00349             m_AllocSize <<= 1;
00350             m_Buffer = (SI_Char*) realloc(m_Buffer,m_AllocSize);
00351             m_BufferEnd = m_Buffer + l_iCurrDelta;
00352         }
00353         *m_BufferEnd = in_Byte;
00354         ++m_BufferEnd;
00355         *m_BufferEnd = 0;
00356     }
00357 
00361     SI_Int GetLength() const { return (SI_Int)(m_BufferEnd - m_Buffer); }
00362 
00368     SI_Char *GetText() const { return m_Buffer; }
00369 
00370 private:
00371 
00372     // No copy semantics needed. Play safe.
00373     CSIAccumString(const CSIAccumString&);
00374     const CSIAccumString& operator=( const CSIAccumString &);
00375 
00376     SI_Char*        m_Buffer;
00377     SI_Char*        m_BufferEnd;
00378     SI_Int          m_AllocSize;
00379 };
00380 
00381 #endif
00382 // CSIBCString