00001
00004
00005
00006 #if !defined(AFX_TSTRING_H__7F94F4C0_3291_11D6_8DF5_00C04F914030__INCLUDED_)
00007 #define AFX_TSTRING_H__7F94F4C0_3291_11D6_8DF5_00C04F914030__INCLUDED_
00008
00009 #if _MSC_VER > 1000
00010 #pragma once
00011 #endif // _MSC_VER > 1000
00012
00021 class TString
00022 {
00024
00025 friend TString operator +( const TString&, const TString& );
00026 friend TString operator +( const TString&, PCSTR );
00027 friend TString operator +( const TString&, PCWSTR );
00028 friend TString operator +( PCSTR, const TString& );
00029 friend TString operator +( PCWSTR, const TString& );
00030 friend TString operator +( const TString&, const WCHAR );
00031 friend TString operator +( const TString&, const CHAR );
00032 friend TString operator +( const WCHAR, const TString& );
00033 friend TString operator +( const CHAR, const TString& );
00035 public:
00036 bool set(PCSTR);
00037 bool set(PCWSTR);
00038 bool set(const WCHAR);
00039 bool set(const CHAR);
00040 bool set(const int);
00041
00042 int getBufferSize() const;
00043 int getLength() const;
00044
00045 PCTSTR get() const;
00047
00048 operator PCTSTR () const { return get(); }
00049
00050 TCHAR operator []( const int ) const;
00051
00052 const TString &operator =(const TString&);
00053 const TString &operator =(PCSTR);
00054 const TString &operator =(PCWSTR);
00055 const TString &operator =(const WCHAR);
00056 const TString &operator =(const CHAR);
00057
00058 const TString &operator +=( const TString& );
00059 const TString &operator +=( PCSTR );
00060 const TString &operator +=( PCWSTR );
00061 const TString &operator +=( const WCHAR );
00062 const TString &operator +=( const CHAR );
00063
00064 bool operator !() const;
00065
00066 clear();
00067
00068 TString(const WCHAR);
00069 TString(const CHAR);
00070 explicit TString(const int);
00071
00072 TString(PCSTR);
00073 TString(PCWSTR);
00074
00075 TString(const TString&);
00076
00077 TString();
00078 virtual ~TString();
00079
00080 private:
00081 static PTSTR EMPTYSTRING;
00082 PTSTR string;
00083
00084 int bufferLength;
00085
00086 inline int stringCopy(PCSTR, const int = -1);
00087 inline int stringCopy(PCWSTR, const int = -1);
00088
00089 inline int memoryAlloc(PCSTR, const bool = true);
00090 inline int memoryAlloc(PCWSTR, const bool = true);
00091 inline bool alloc(const int);
00092
00093 inline memoryDealloc();
00094 };
00095
00096 #endif // !defined(AFX_TSTRING_H__7F94F4C0_3291_11D6_8DF5_00C04F914030__INCLUDED_)