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 #include <iostream.h>
00030 #endif
00031 #include <string.h>
00032
00033 #ifdef UNICODE_STRINGS
00034 typedef wchar_t Char;
00035 #define skSTR(x) L ## x
00036 #else
00037 typedef char Char;
00038 #define skSTR(x) x
00039 #endif
00040
00041 class P_String;
00042
00047 class CLASSEXPORT skString
00048 #ifdef __SYMBIAN32__
00049 : public CBase
00050 #endif
00051 {
00052 public:
00056 inline skString();
00060 inline skString(const skString&);
00061 #ifndef __SYMBIAN32__
00062
00066 inline skString(const Char *);
00073 inline skString(const Char * buffer, USize len);
00080 skString(const Char repeatChar, USize len);
00081 #endif
00082
00085 virtual inline ~skString();
00089 inline skString& operator=(const skString&);
00095 IMPORT_C skString& operator=(Char c);
00100 IMPORT_C skString& operator=(const Char *);
00105 inline bool operator<(const skString&) const;
00110 inline bool operator==(const skString&) const;
00115 inline bool operator==(const Char *) const;
00116 #ifdef __SYMBIAN32__
00117
00122 inline bool operator==(const TDesC&) const;
00123 #endif
00124
00128 IMPORT_C bool operator!=(const skString&) const;
00133 IMPORT_C bool operator!=(const Char *) const;
00134 #ifndef __SYMBIAN32__
00135
00140 inline operator const Char * () const;
00141 #endif
00142 #ifdef __SYMBIAN32__
00143
00148 inline skString& operator=(const TDesC&);
00154 inline TPtrC ptr() const;
00155 #else
00156
00161 inline const Char * ptr() const;
00162 #endif
00163
00167 inline const Char * c_str() const;
00173 IMPORT_C bool equalsIgnoreCase(const skString&) const;
00177 inline USize hash() const;
00183 inline Char at(USize index) const;
00191 IMPORT_C skString substr(USize start,USize length) const;
00198 IMPORT_C skString substr(USize start) const;
00204 IMPORT_C skString operator+(const skString&) const ;
00210 IMPORT_C skString& operator+=(const skString&);
00215 inline USize length() const;
00220 IMPORT_C int indexOf(const skString& s) const;
00225 IMPORT_C int indexOf(Char c) const;
00230 IMPORT_C int indexOfLast(Char c) const;
00234 IMPORT_C int to() const;
00235 #ifdef USE_FLOATING_POINT
00236
00239 IMPORT_C float toFloat() const;
00240 #endif
00241
00245 static IMPORT_C skString literal(const Char *);
00250 static IMPORT_C skString from(int);
00255 static IMPORT_C skString from(USize);
00256 #ifdef USE_FLOATING_POINT
00257
00261 static IMPORT_C skString from(float);
00262 #endif
00263
00267 static IMPORT_C skString from(Char ch);
00272 static IMPORT_C skString fromBuffer(Char * buffer);
00277 skString IMPORT_C ltrim() const;
00284 skString IMPORT_C removeInitialBlankLines() const;
00285 #ifndef __SYMBIAN32__
00286
00291 static skString IMPORT_C readFromFile(const skString& filename);
00297 void IMPORT_C writeToFile(const skString& filename);
00298 #endif
00299
00305 IMPORT_C skString replace(const skString& old_substr,const skString& new_substr) const;
00312 IMPORT_C skString replace(const Char * old_substr,const Char * new_substr) const;
00317 IMPORT_C static skString addStrings(const skString& s1,const skString & s2);
00322 IMPORT_C static skString addStrings(const skString & s1,const skString & s2,const skString & s3);
00327 IMPORT_C static skString addStrings(const skString & s1,const skString & s2,const skString & s3,const skString & s4);
00332 IMPORT_C static skString addStrings(const skString & s1,const skString & s2,const skString & s3,const skString & s4,const skString & s5);
00337 IMPORT_C static skString addStrings(const skString & s1,const skString & s2,const skString & s3,const skString & s4,const skString & s5,const skString & s6);
00342 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);
00347 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);
00348 #ifdef __SYMBIAN32__
00349
00356 IMPORT_C skString replace(const TDesC& old_substr,const TDesC& new_substr) const;
00362 IMPORT_C static skString addStrings(const TDesC& s1,const TDesC& s2);
00368 IMPORT_C static skString addStrings(const TDesC& s1,const TDesC& s2,const TDesC& s3);
00373 IMPORT_C static skString addStrings(const TDesC& s1,const TDesC& s2,const TDesC& s3,const TDesC& s4);
00379 IMPORT_C static skString addStrings(const TDesC& s1,const TDesC& s2,const TDesC& s3,const TDesC& s4,const TDesC& s5);
00385 IMPORT_C static skString addStrings(const TDesC& s1,const TDesC& s2,const TDesC& s3,const TDesC& s4,const TDesC& s5,const TDesC& s6);
00391 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);
00397 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);
00398 #endif
00399
00402 IMPORT_C void replaceInPlace(Char old_char,Char new_char);
00403 #ifdef __SYMBIAN32__
00404
00409 inline operator TCleanupItem();
00414 static inline void Cleanup(TAny * s);
00415 #endif
00416 protected:
00420 skString(P_String *);
00425 IMPORT_C void assign(const Char *,int len=0);
00429 void deRef();
00433 P_String * pimp;
00434 #ifdef __SYMBIAN32__
00435 friend CLASSEXPORT skString operator+(const TDesC& s1,const skString& s2);
00436 #endif
00437 friend CLASSEXPORT skString operator+(const Char * s1,const skString& s2);
00438
00439 };
00440
00441
00442
00443
00444 inline USize hashKey(const skString * s)
00445
00446 {
00447 return s->hash();
00448 }
00449
00450
00451
00452 #ifdef __SYMBIAN32__
00453 CLASSEXPORT skString operator+(const TDesC& s1,const skString& s2);
00454 #endif
00455 CLASSEXPORT skString operator+(const Char *& s1,const skString& s2);
00456
00457 #ifdef STREAMS_ENABLED
00458
00459
00460
00461 CLASSEXPORT ostream& operator<<(ostream&,const skString&s);
00462 #endif
00463
00464
00465
00466 #ifdef __SYMBIAN32__
00467
00468 #define skLITERAL(name) const TLitC16<sizeof(L## #name )/2> s_##name={sizeof(L## #name)/2-1,L## #name}
00469
00470 #define xskLITERAL(name) extern const TLitC16<sizeof(L## #name )/2> s_##name
00471
00472 #define skNAMED_LITERAL(name,value) const TLitC16<sizeof(value )/2> s_##name={sizeof(value)/2-1,value}
00473
00474 #define xskNAMED_LITERAL(name,value) extern const TLitC16<sizeof(value)/2> s_##name
00475
00476 #define skLITERAL_STRING(name,value) const TLitC16<sizeof(L## #value )/2> s_##name={sizeof(L## #value)/2-1,L## #value}
00477
00478 #define xskLITERAL_STRING(name,value) extern const TLitC16<sizeof(L##value)/2> s_##name
00479 #else
00480 #define skLITERAL(name) const Char * s_##name=skSTR(#name)
00481 #define xskLITERAL(name) extern const Char * s_##name
00482 #define skNAMED_LITERAL(name,value) const Char * s_##name=value
00483 #define xskNAMED_LITERAL(name,value) extern const Char * s_##name
00484 #define skLITERAL_STRING(name,value) const Char * s_##name=skSTR(value)
00485 #define xskLITERAL_STRING(name,value) extern const Char * s_##name;
00486 #endif
00487
00488
00489 #include "skString.inl"
00490
00491 #endif
00492
00493
00494