00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef skSTRING_H
00024 #define skSTRING_H
00025
00026 #include "skGeneral.h"
00027
00028 #ifdef STREAMS_ENABLED
00029
00030 #ifdef STL_STREAMS
00031 #include <ostream>
00032 using namespace std;
00033 #else
00034 #include <iostream.h>
00035 #endif
00036
00037 #endif
00038 #include <string.h>
00039
00040 #ifdef UNICODE_STRINGS
00041 typedef wchar_t Char;
00042 #define skSTR(x) L ## x
00043 #else
00044 typedef char Char;
00045 #define skSTR(x) x
00046 #endif
00047
00048 class P_String;
00049
00054 class CLASSEXPORT skString
00055 #ifdef __SYMBIAN32__
00056 : public CBase
00057 #endif
00058 {
00059 public:
00063 inline skString();
00067 inline skString(const skString&);
00068 #ifndef __SYMBIAN32__
00069
00073 inline skString(const Char *);
00080 inline skString(const Char * buffer, USize len);
00087 skString(const Char repeatChar, USize len);
00088 #endif
00089
00092 virtual inline ~skString();
00096 inline skString& operator=(const skString&);
00102 IMPORT_C skString& operator=(Char c);
00107 IMPORT_C skString& operator=(const Char *);
00112 inline bool operator<(const skString&) const;
00117 inline bool operator==(const skString&) const;
00122 inline bool operator==(const Char *) const;
00123 #ifdef __SYMBIAN32__
00124
00129 inline bool operator==(const TDesC&) const;
00130 #endif
00131
00135 IMPORT_C bool operator!=(const skString&) const;
00140 IMPORT_C bool operator!=(const Char *) const;
00141 #ifndef __SYMBIAN32__
00142
00147 inline operator const Char * () const;
00148 #endif
00149 #ifdef __SYMBIAN32__
00150
00155 inline skString& operator=(const TDesC&);
00161 inline TPtrC ptr() const;
00162 #else
00163
00168 inline const Char * ptr() const;
00169 #endif
00170
00174 inline const Char * c_str() const;
00180 IMPORT_C bool equalsIgnoreCase(const skString&) const;
00184 inline USize hash() const;
00190 inline Char at(USize index) const;
00198 IMPORT_C skString substr(USize start,USize length) const;
00205 IMPORT_C skString substr(USize start) const;
00211 IMPORT_C skString operator+(const skString&) const ;
00217 IMPORT_C skString& operator+=(const skString&);
00222 inline USize length() const;
00227 IMPORT_C int indexOf(const skString& s) const;
00232 IMPORT_C int indexOf(Char c) const;
00237 IMPORT_C int indexOfLast(Char c) const;
00241 IMPORT_C int to() const;
00242 #ifdef USE_FLOATING_POINT
00243
00246 IMPORT_C float toFloat() const;
00247 #endif
00248
00252 static IMPORT_C skString literal(const Char *);
00257 static IMPORT_C skString from(int);
00262 static IMPORT_C skString from(USize);
00263 #ifdef USE_FLOATING_POINT
00264
00268 static IMPORT_C skString from(float);
00269 #endif
00270
00274 static IMPORT_C skString from(Char ch);
00279 static IMPORT_C skString fromBuffer(Char * buffer);
00284 static IMPORT_C skString copyFromBuffer(const Char * buffer,USize length);
00289 skString IMPORT_C ltrim() const;
00296 skString IMPORT_C removeInitialBlankLines() const;
00297 #ifndef __SYMBIAN32__
00298
00303 static skString IMPORT_C readFromFile(const skString& filename);
00309 void IMPORT_C writeToFile(const skString& filename);
00310 #endif
00311
00317 IMPORT_C skString replace(const skString& old_substr,const skString& new_substr) const;
00324 IMPORT_C skString replace(const Char * old_substr,const Char * new_substr) const;
00329 IMPORT_C static skString addStrings(const skString& s1,const skString & s2);
00334 IMPORT_C static skString addStrings(const skString & s1,const skString & s2,const skString & s3);
00339 IMPORT_C static skString addStrings(const skString & s1,const skString & s2,const skString & s3,const skString & s4);
00344 IMPORT_C static skString addStrings(const skString & s1,const skString & s2,const skString & s3,const skString & s4,const skString & s5);
00349 IMPORT_C static skString addStrings(const skString & s1,const skString & s2,const skString & s3,const skString & s4,const skString & s5,const skString & s6);
00354 IMPORT_C static skString addStrings(const skString & s1,const skString & s2,const skString & s3,const skString & s4,const skString & s5,const skString & s6,const skString & s7);
00359 IMPORT_C static skString addStrings(const skString & s1,const skString & s2,const skString & s3,const skString & s4,const skString & s5,const skString & s6,const skString & s7,const skString & s8);
00360 #ifdef __SYMBIAN32__
00361
00368 IMPORT_C skString replace(const TDesC& old_substr,const TDesC& new_substr) const;
00374 IMPORT_C static skString addStrings(const TDesC& s1,const TDesC& s2);
00380 IMPORT_C static skString addStrings(const TDesC& s1,const TDesC& s2,const TDesC& s3);
00385 IMPORT_C static skString addStrings(const TDesC& s1,const TDesC& s2,const TDesC& s3,const TDesC& s4);
00391 IMPORT_C static skString addStrings(const TDesC& s1,const TDesC& s2,const TDesC& s3,const TDesC& s4,const TDesC& s5);
00397 IMPORT_C static skString addStrings(const TDesC& s1,const TDesC& s2,const TDesC& s3,const TDesC& s4,const TDesC& s5,const TDesC& s6);
00403 IMPORT_C static skString addStrings(const TDesC& s1,const TDesC& s2,const TDesC& s3,const TDesC& s4,const TDesC& s5,const TDesC& s6,const TDesC& s7);
00409 IMPORT_C static skString addStrings(const TDesC& s1,const TDesC& s2,const TDesC& s3,const TDesC& s4,const TDesC& s5,const TDesC& s6,const TDesC& s7,const TDesC& s8);
00410 #endif
00411
00414 IMPORT_C void replaceInPlace(Char old_char,Char new_char);
00415 #ifdef __SYMBIAN32__
00416
00421 inline operator TCleanupItem();
00426 static inline void Cleanup(TAny * s);
00427 #endif
00428 protected:
00432 skString(P_String *);
00437 IMPORT_C void assign(const Char *,int len=0);
00441 void deRef();
00445 P_String * pimp;
00446 #ifdef __SYMBIAN32__
00447 friend IMPORT_C skString operator+(const TDesC& s1,const skString& s2);
00448 #endif
00449 friend CLASSEXPORT IMPORT_C skString operator+(const Char * s1,const skString& s2);
00450
00451 };
00452
00453
00454
00455
00456 inline USize hashKey(const skString * s)
00457
00458 {
00459 return s->hash();
00460 }
00461
00462
00463
00464 #ifdef __SYMBIAN32__
00465 EXPORT_C skString operator+(const TDesC& s1,const skString& s2);
00466 #endif
00467 CLASSEXPORT IMPORT_C skString operator+(const Char *& s1,const skString& s2);
00468
00469 #ifdef STREAMS_ENABLED
00470
00471
00472
00473 CLASSEXPORT ostream& operator<<(ostream& out,const skString& s);
00474 #endif
00475
00476
00477
00478 #ifdef __SYMBIAN32__
00479
00480 #define skLITERAL(name) const TLitC16<sizeof(L## #name )/2> s_##name={sizeof(L## #name)/2-1,L## #name}
00481
00482 #define xskLITERAL(name) extern const TLitC16<sizeof(L## #name )/2> s_##name
00483
00484 #define skNAMED_LITERAL(name,value) const TLitC16<sizeof(value )/2> s_##name={sizeof(value)/2-1,value}
00485
00486 #define xskNAMED_LITERAL(name,value) extern const TLitC16<sizeof(value)/2> s_##name
00487
00488 #define skLITERAL_STRING(name,value) const TLitC16<sizeof(L## #value )/2> s_##name={sizeof(L## #value)/2-1,L## #value}
00489
00490 #define xskLITERAL_STRING(name,value) extern const TLitC16<sizeof(L##value)/2> s_##name
00491 #else
00492 #define skLITERAL(name) const Char * s_##name=skSTR(#name)
00493 #define xskLITERAL(name) extern const Char * s_##name
00494 #define skNAMED_LITERAL(name,value) const Char * s_##name=value
00495 #define xskNAMED_LITERAL(name,value) extern const Char * s_##name
00496 #define skLITERAL_STRING(name,value) const Char * s_##name=skSTR(value)
00497 #define xskLITERAL_STRING(name,value) extern const Char * s_##name;
00498 #endif
00499
00500
00501 #include "skString.inl"
00502
00503 #endif
00504
00505
00506