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
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 {
00049 public:
00053 skString();
00057 skString(const Char *);
00061 skString(const skString&);
00067 skString(const Char * buffer, USize len);
00073 skString(const Char repeatChar, USize len);
00077 virtual ~skString();
00081 skString& operator=(const skString&);
00085 skString& operator=(const Char *);
00090 bool operator<(const skString&) const;
00095 bool operator==(const skString&) const;
00100 bool operator==(const Char *) const;
00105 bool operator!=(const skString&) const;
00110 bool operator!=(const Char *) const;
00115 operator const Char * () const;
00120 bool equalsIgnoreCase(const skString&) const;
00124 USize hash() const;
00130 Char at(USize index) const;
00137 skString substr(USize start,USize length) const;
00143 skString substr(USize start) const;
00148 skString operator+(const skString&) const ;
00153 skString& operator+=(const skString&);
00158 USize length() const;
00163 int indexOf(const skString& s) const;
00168 int indexOf(Char c) const;
00173 int indexOfLast(Char c) const;
00177 int to() const;
00181 float toFloat() const;
00185 static skString literal(const Char *);
00189 static skString from(int);
00193 static skString from(USize);
00197 static skString from(float);
00201 static skString from(Char ch);
00205 static skString fromBuffer(Char * buffer);
00209 skString ltrim() const;
00214 static skString readFromFile(const skString& filename);
00219 void writeToFile(const skString& filename);
00220 protected:
00224 skString(P_String *);
00228 skString(const Char * s,int);
00232 void assign(const Char *,int len=0);
00236 void deRef();
00240 P_String * pimp;
00241 };
00242
00243
00244
00245 inline USize hashKey(const skString * s)
00246 {
00247 return s->hash();
00248 }
00249
00250
00251
00252 CLASSEXPORT skString operator+(const Char * s1,const skString& s2);
00253
00254 #ifdef STREAMS_ENABLED
00255
00256
00257
00258 CLASSEXPORT ostream& operator<<(ostream&,const skString&s);
00259 #endif
00260
00261
00262
00263 #define skLITERAL(s) skString s_##s=skString::literal(skSTR(#s))
00264 #define xskLITERAL(s) extern skString s_##s
00265
00266
00267 inline float ATOF(const Char * c){
00268 #ifdef UNICODE_STRINGS
00269 return (float) wcstod(c,0);
00270 #else
00271 return (float) atof(c);
00272 #endif
00273 }
00274 inline int ATOI(const Char * c){
00275 #ifdef UNICODE_STRINGS
00276 return _wtoi(c);
00277 #else
00278 return atoi(c);
00279 #endif
00280 }
00281
00282 #include "skString.inl"
00283
00284 #endif
00285
00286
00287