00001
00006 #ifndef __BGDNetString_h__
00007 #define __BGDNetString_h__
00008
00009 #include "BGDNetConfig.h"
00010
00011 #include <string>
00012 #include "BGDNetShare.h"
00013
00014 namespace BGDNet
00015 {
00016
00017 using std::string;
00018
00025 class BGDNET_API StringImp : public Share
00026 {
00027 public:
00028
00029 StringImp( const char* p, size_t len = -1 );
00036 StringImp( const StringImp& imp );
00041 virtual ~StringImp( void );
00048 string* m_pStr;
00049 };
00050
00051
00052
00053
00054 #ifdef _MSC_VER
00055 # pragma warning(disable:4231)
00056 #endif
00057
00058 BGDNET_TEMPLATE(SharePtr<StringImp>);
00059
00060 #ifdef _MSC_VER
00061 # pragma warning(default:4231)
00062 #endif
00063
00064
00065
00066
00078 class BGDNET_API String
00079 {
00080 public:
00081
00082 String( void );
00087 String( const String& s );
00092 String( const char* p );
00098 String( const char* p, size_t len );
00105 String& operator =( const String& s );
00110 String& operator =( const char* p );
00115 String& operator +=( const String& s );
00120 String& operator +=( const char* s );
00125 String& operator +=( const char c );
00130 operator const char*( void ) const;
00135 const char* ptr( void ) const;
00141 size_t length( void ) const;
00147 friend bool operator ==( String s1, String s2 );
00148
00149 private:
00150
00151 void append( const char* buf, size_t len );
00158 void freeze( void );
00164 SharePtr<StringImp> m_pImp;
00168 };
00169
00173 inline bool operator ==( String s1, String s2 )
00174 {
00175 return (*s1.m_pImp->m_pStr) == (*s2.m_pImp->m_pStr);
00176 }
00177
00181 inline bool operator !=( String s1, String s2 )
00182 {
00183 return !(s1 == s2);
00184 }
00185
00186 }
00187
00188 #endif //__BGDNetString_h__