Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

skString.h

00001 /*
00002   Copyright 1996-2001
00003   Simon Whiteside
00004 
00005 * $Id: skString.h,v 1.15 2001/11/16 21:19:22 sdw Exp $
00006 */
00007 
00008 
00009 #ifndef skSTRING_H
00010 #define skSTRING_H
00011 
00012 #include "skGeneral.h"
00013 
00014 #ifdef STREAMS_ENABLED
00015 #include <iostream.h>
00016 #endif
00017 
00018 
00019 #ifdef UNICODE_STRINGS
00020 typedef wchar_t Char;
00021 #define skSTR(x)                        L ## x
00022 #else
00023 typedef char Char;
00024 #define skSTR(x)                        x
00025 #endif
00026 
00027 class P_String;
00028 
00033 class CLASSEXPORT skString 
00034 {
00035  public:
00039   skString();
00043   skString(const Char *);
00047   skString(const skString&);
00053   skString(const Char * buffer, USize len);
00059   skString(const Char repeatChar, USize len);
00063   virtual ~skString();
00067   skString& operator=(const skString&);
00071   skString& operator=(const Char *);
00076   bool operator<(const skString&) const;
00081   bool operator==(const skString&) const;
00086   bool operator==(const Char *) const;
00091   bool operator!=(const skString&) const;
00096   bool operator!=(const Char *) const;
00101   operator const Char * () const;
00105   USize hash() const;
00111   Char at(USize index) const;
00118   skString substr(USize start,USize length) const;
00124   skString substr(USize start) const;
00129   skString operator+(const skString&) const ;
00134   skString& operator+=(const skString&);
00139   USize length() const;
00144   int indexOf(Char c) const;
00148   int to() const;
00152   float toFloat() const;
00156   static skString literal(const Char *);
00160   static skString from(int);
00164   static skString from(USize);
00168   static skString from(float);
00172   static skString from(Char ch);
00176   static skString fromBuffer(Char * buffer);
00177  protected:
00181   skString(P_String *);
00185   skString(const Char * s,int);
00189   void assign(const Char *,int len=0);                          
00193   void deRef();
00197   P_String * pimp;
00198 };
00199 /*
00200  * A hashKey function for HashTables
00201  */
00202 inline USize hashKey(const skString * s)
00203 {
00204     return s->hash();
00205 }
00206 #ifdef STREAMS_ENABLED
00207 /*
00208  * A streaming operator to write a string to an output stream
00209  */
00210 CLASSEXPORT ostream& operator<<(ostream&,const skString&s);
00211 #endif
00212 /*
00213  * Some helper macros for declaring literal strings, and references to literal strings
00214  */
00215 #define skLITERAL(s) skString s_##s=skString::literal(skSTR(#s))
00216 #define xskLITERAL(s) extern skString s_##s
00217 //#define skSTR(s) skString(s)
00218 
00219 inline float ATOF(const Char * c){
00220 #ifdef UNICODE_STRINGS
00221   return (float) wcstod(c,0);
00222 #else
00223   return (float) atof(c);
00224 #endif
00225 }
00226 inline int ATOI(const Char * c){
00227 #ifdef UNICODE_STRINGS
00228   return _wtoi(c);
00229 #else
00230   return atoi(c);
00231 #endif
00232 }
00233 
00234 #include "skString.inl"
00235 
00236 #endif
00237 
00238 
00239 

Generated on Tue Nov 20 17:56:21 2001 for Simkin by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001