Since I'm still a little underexperienced to some of the members here, I thought I'd ask for critics of the current definition of my string class. It's only the definition, of course, since it would get rather big otherwise and no one wants to browse through a lot of code.

I may post some snippets of the actual code somewhat later, but anyway, here goes!

(Note that I haven't replaced the + operators with boost yet, but will do so later since it requires more testing!)

Suggestions and critique most welcome :OCode:`#ifndef String_h__`

#define String_h__

namespace Strings

{

template<typename T> struct StrTraits

{

static const T* UINT64_T_IDENTIFIER;

static const T* INT64_T_IDENTIFIER;

static const T* LONG_IDENTIFIER;

};

template<typename T> class CTmplStringBase: public StrTraits<T>

{

public:

CTmplStringBase();

CTmplStringBase(const CTmplStringBase& rSrc);

CTmplStringBase(const CStringT< T, StrTraitMFC_DLL<T> >& strSrc);

CTmplStringBase(const T* strData);

CTmplStringBase(const T cData);

CTmplStringBase(uint64_t nData);

CTmplStringBase(int64_t nData);

CTmplStringBase(long nData);

~CTmplStringBase();

CTmplStringBase& operator = (const T* strData);

CTmplStringBase& operator = (const T cData);

CTmplStringBase& operator = (uint64_t nData);

CTmplStringBase& operator = (int64_t nData);

CTmplStringBase& operator = (long nData);

CTmplStringBase& operator = (const CTmplStringBase& rSrc);

CTmplStringBase& operator = (const CStringT< T, StrTraitMFC_DLL<T> >& rSrc);

CTmplStringBase& operator += (const T* strData);

CTmplStringBase& operator += (const T cData);

CTmplStringBase& operator += (uint64_t nData);

CTmplStringBase& operator += (int64_t nData);

CTmplStringBase& operator += (long nData);

CTmplStringBase operator + (const T* strData) const;

CTmplStringBase operator + (const T cData) const;

CTmplStringBase operator + (uint64_t nData) const;

CTmplStringBase operator + (int64_t nData) const;

CTmplStringBase operator + (long nData) const;

CTmplStringBase operator + (const CStringT< T, StrTraitMFC_DLL<T> >& strSrc) const;

bool operator == (const T* strData) const;

bool operator == (const T cData) const;

bool operator != (const T* strData) const;

bool operator != (const T cData) const;

operator const T* () const;

void Replace(const T* strReplaceWhat, const T* strReplaceWith);

void Replace(const T* strReplaceWhat, const T cReplaceWith);

void Replace(const T cReplaceWhat, const T* strReplaceWith);

void Replace(const T cReplaceWhat, const T cReplaceWith);

CTmplStringBase Right(uint32_t nCount) const;

void Delete(uint32_t nStartFrom, uint32_t nCount = 0);

uint32_t GetLength() const;

T* GetBuffer(uint32_t nMinSize);

void ReleaseBuffer();

void Truncate(uint32_t nNewSize);

int32_t Find(const T* strFind, uint32_t nBeginAt = 0) const;

int32_t Find(const T cFind, uint32_t nBeginAt = 0) const;

CTmplStringBase Mid(uint32_t nStart, uint32_t nCount = 0) const;

void Format(const T* strFormat, ...);

void AppendFormat(const T* strFormat, ...);

void Empty();

private:

typedef int (fnc_tprintf_s)(T* buffer, size_t sizeOfBuffer, const T* format, ...);

typedef int (fnc_tvprintf_s)(T* buffer, size_t sizeOfBuffer, const T* format, va_list argptr);

typedef int (fnc_tcscmp)(const T* string1, const T* string2);

typedef int (fnc_tvcprintf)(const T* format, va_list argptr);

void Init();

int32_t ReplaceInternal(const T* strReplaceWhat, const T* strReplaceWith, bool bReplace);

void FormatInternal(const T* strFormat, va_list arg);

uint32_t GetLength(const char* strData) const;

uint32_t GetLength(const wchar_t* strData) const;

fnc_tprintf_s* GetFormatFunction(const char*) const;

fnc_tprintf_s* GetFormatFunction(const wchar_t*) const;

fnc_tvprintf_s* GetVFormatFunction(const char*) const;

fnc_tvprintf_s* GetVFormatFunction(const wchar_t*) const;

fnc_tvcprintf* GetVFormatCountFunction(const char*) const;

fnc_tvcprintf* GetVFormatCountFunction(const wchar_t*) const;

fnc_tcscmp* GetCompareFunction(const char*) const;

fnc_tcscmp* GetCompareFunction(const wchar_t*) const;

void CopyStr(const T* strData);

void AppendStr(const T* strData);

void CopyStrLowLevel(T* strDst, uint32_t nDstSize, const T* strSrc, T** pUnusedPtr) const;

void PrepareBuffer(uint32_t nNeededSize);

template<typename Type> CTmplStringBase& Assign(Type& Data);

template<typename Type> CTmplStringBase& AppendNum(Type& Data, const T* strFormat);

template<typename Type> CTmplStringBase Append(Type& Data) const;

T* m_pData;

T* m_pUnusedStart;

uint32_t m_nSize; // Number of elements in m_pData

static const uint32_t nDefaultSize = 10;

};

#ifndef _AFXEXT

template class __declspec(dllimport) CTmplStringBase<wchar_t>;

template class __declspec(dllimport) CTmplStringBase<char>;

#endif

typedef CTmplStringBase<char> CStringExA;

typedef CTmplStringBase<wchar_t> CStringExW;

typedef CTmplStringBase<TCHAR> CStringEx;

}

#endif // String_h__