16,548
社区成员




#include "stdafx.h"
#include "ptString.h"
#include <assert.h>
#include <stdio.h>
//#define PT_DEBUG
//#ifdef PT_DEBUG
// #include <ptDebugView.h>
//#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
#ifndef max
#define max(a,b) (((a) > (b)) ? (a) : (b))
#endif
#ifndef min
#define min(a,b) (((a) < (b)) ? (a) : (b))
#endif
#ifndef _wcsinc
#define _wcsinc(_pc) ((_pc)+1)
#endif
#ifndef _strinc
#define _strinc(_pc) ((_pc)+1)
#endif
#pragma warning(push)
#pragma warning( disable : 4290 )
CptStringBase::CStrMemBuf* CptStringBase::m_pStrMemBuf = NULL ;
///----------------------------------------------------------------------------------------------------
// 字符串类内存池
CptStringBase::CStrMemBuf::CStrMemBuf()//:m_chEmpty(0)
{
// m_chEmpty = 0 ;
#ifndef USE_STL_MEMORY_FOR_PTSTRING
::memset(m_aMemList,0,sizeof(m_aMemList)) ;
::memset(m_byUnitCount,0,sizeof(m_byUnitCount)) ;
::InitializeCriticalSection(&m_csLock) ;
#endif
::memset(m_EmptyBuf,0,sizeof(m_EmptyBuf)) ;
SStringDesc* pEmptyDesc = (SStringDesc*)m_EmptyBuf ;
pEmptyDesc->nRefs = 1 ;
pEmptyDesc->nUsedSize = 0 ;
pEmptyDesc->nMallocBufSize = 1 ;
#ifdef PT_DEBUG
m_nAllocCounter = 0 ;
m_uAllocBufSize = 0 ;
#endif
}
CptStringBase::CStrMemBuf::~CStrMemBuf()
{
#ifdef PT_DEBUG
Debug_PrintfW(_T("~CStrMemBuf() ")) ;
#endif
#ifndef USE_STL_MEMORY_FOR_PTSTRING
::EnterCriticalSection(&m_csLock) ;
SStringDesc* pResult = NULL ;
for(int i=0; i<sizeof(m_aMemList)/sizeof(void*);++i)
{
while (m_aMemList[i]!=NULL)
{
pResult = reinterpret_cast<SStringDesc*>(m_aMemList[i]) ;
m_aMemList[i] = reinterpret_cast<void*>(*reinterpret_cast<unsigned*>(m_aMemList[i])) ;
--m_byUnitCount[i] ;
if(pResult!=NULL)
{
#ifdef PT_DEBUG
//if(pResult->nMallocBufSize==STRING_SIZE_128)
{
Debug_PrintfW(_T("free() 2 空间 0x%x size=%d ref=%d"),pResult,pResult->nMallocBufSize,pResult->nRefs ) ;
}
//Debug_Printf("free() 1 空间 0x%x",pResult) ;
#endif
::free(pResult) ;
pResult = NULL ;
}
}
}
::LeaveCriticalSection(&m_csLock) ;
::DeleteCriticalSection(&m_csLock) ;
#endif
}
CptStringBase::SStringDesc* CptStringBase::CStrMemBuf::GetEmptyBuffer() const
{
return (SStringDesc*)m_EmptyBuf ;
}
CptStringBase::SStringDesc* CptStringBase::CStrMemBuf::GetBuffer(const UINT uSize)
{
SStringDesc* pResult = NULL ;
#ifdef USE_STL_MEMORY_FOR_PTSTRING
pResult = (SStringDesc*)m_Alloc.allocate(uSize) ;
pResult->nMallocBufSize = uSize ;
#else
int nIndex = -1 ;
UINT uMaxSize = 0 ;
if(uSize<STRING_SIZE_8)
{
nIndex = 0 ;
uMaxSize = STRING_SIZE_8 ;
}
else if(uSize<STRING_SIZE_16)
{
nIndex = 1 ;
uMaxSize = STRING_SIZE_16 ;
}
else if(uSize<STRING_SIZE_32)
{
nIndex = 2 ;
uMaxSize = STRING_SIZE_32 ;
}
else if(uSize<STRING_SIZE_64)
{
nIndex = 3 ;
uMaxSize = STRING_SIZE_64 ;
}
else if(uSize<STRING_SIZE_128)
{
nIndex = 4 ;
uMaxSize = STRING_SIZE_128 ;
}
else if(uSize<STRING_SIZE_256)
{
nIndex = 5 ;
uMaxSize = STRING_SIZE_256 ;
}
else if(uSize<STRING_SIZE_512)
{
nIndex = 6 ;
uMaxSize = STRING_SIZE_512 ;
}
::EnterCriticalSection(&m_csLock) ;
if(nIndex>-1 && nIndex<7)
{
if(m_aMemList[nIndex]!=NULL)
{
pResult = (SStringDesc*)m_aMemList[nIndex] ;
m_aMemList[nIndex] = reinterpret_cast<void*>(*reinterpret_cast<unsigned*>(m_aMemList[nIndex])) ;
--m_byUnitCount[nIndex] ;
#ifdef PT_DEBUG
if(nIndex==4)
{
Debug_PrintfW(_T("摘取了空间 0x%x %d "),pResult,nIndex,pResult->nRefs) ;
}
#endif
}
if(pResult==NULL)
{
switch(nIndex)
{
case 0: pResult = (SStringDesc*)::malloc(STRING_SIZE_8) ; break;
case 1: pResult = (SStringDesc*)::malloc(STRING_SIZE_16) ; break;
case 2: pResult = (SStringDesc*)::malloc(STRING_SIZE_32) ; break;
case 3: pResult = (SStringDesc*)::malloc(STRING_SIZE_64) ; break;
case 4: pResult = (SStringDesc*)::malloc(STRING_SIZE_128) ;break;
case 5: pResult = (SStringDesc*)::malloc(STRING_SIZE_256) ; break;
case 6: pResult = (SStringDesc*)::malloc(STRING_SIZE_512) ; break;
default: break ;
}
}
pResult->nMallocBufSize = uMaxSize ;
#ifdef PT_DEBUG
if(nIndex==4 )
{
Debug_PrintfW(_T("malloc()了空间 0x%x"),pResult) ;
}
#endif
}
if(pResult==NULL)
{
pResult = (SStringDesc*)::malloc(uSize) ;
pResult->nMallocBufSize = uSize ;
}
#ifdef PT_DEBUG
++m_nAllocCounter ;
m_uAllocBufSize += pResult->nMallocBufSize ;
#endif
::LeaveCriticalSection(&m_csLock) ;
#endif
return pResult ;
}
void CptStringBase::CStrMemBuf::ReleaseBuffer(CptStringBase::SStringDesc* pDesc)
{
assert(pDesc!=NULL) ;
#ifdef PT_DEBUG
--m_nAllocCounter ;
m_uAllocBufSize -= pDesc->nMallocBufSize ;
#endif
#ifdef USE_STL_MEMORY_FOR_PTSTRING
m_Alloc.deallocate((char*)pDesc,pDesc->nMallocBufSize) ;
#else
int nIndex = -1 ;
if(pDesc->nMallocBufSize ==STRING_SIZE_16 && m_byUnitCount[0]<MAX_POOL_8)
{
nIndex = 0 ;
}
else if(pDesc->nMallocBufSize ==STRING_SIZE_16 && m_byUnitCount[1]<MAX_POOL_16)
{
#ifdef PT_DEBUG
//Debug_PrintfW(_T("回收空间 0x%x %d"),pDesc,STRING_SIZE_16) ;
#endif
nIndex = 1 ;
}
else if(pDesc->nMallocBufSize ==STRING_SIZE_32 && m_byUnitCount[2]<MAX_POOL_32)
{
#ifdef PT_DEBUG
//Debug_PrintfW(_T("回收空间 0x%x %d"),pDesc,STRING_SIZE_32) ;
#endif
nIndex = 2 ;
}
else if(pDesc->nMallocBufSize ==STRING_SIZE_64 && m_byUnitCount[3]<MAX_POOL_64)
{
#ifdef PT_DEBUG
//Debug_PrintfW(_T("回收空间 0x%x %d"),pDesc,STRING_SIZE_64) ;
#endif
nIndex = 3 ;
}
else if(pDesc->nMallocBufSize ==STRING_SIZE_128 && m_byUnitCount[4]<MAX_POOL_128)
{
#ifdef PT_DEBUG
//Debug_PrintfW(_T("回收空间 0x%x %d ref=%d"),pDesc,STRING_SIZE_128,pDesc->nRefs) ;
#endif
nIndex = 4 ;
}
else if(pDesc->nMallocBufSize ==STRING_SIZE_256 && m_byUnitCount[5]<MAX_POOL_256)
{
#ifdef PT_DEBUG
//Debug_PrintfW(_T("回收空间 0x%x %d"),pDesc,STRING_SIZE_256) ;
#endif
nIndex = 5 ;
}
else if(pDesc->nMallocBufSize ==STRING_SIZE_512 && m_byUnitCount[6]<MAX_POOL_512)
{
#ifdef PT_DEBUG
//Debug_PrintfW(_T("回收空间 0x%x %d"),pDesc,STRING_SIZE_512) ;
#endif
nIndex = 6 ;
}
::EnterCriticalSection(&m_csLock) ;
if(nIndex>=0)
{
*(reinterpret_cast<unsigned*>(pDesc)) = reinterpret_cast<unsigned>(m_aMemList[nIndex]) ;
m_aMemList[nIndex] = pDesc ;
++m_byUnitCount[nIndex] ;
}
else
{
#ifdef PT_DEBUG
//if(pDesc->nMallocBufSize==STRING_SIZE_128)
{
Debug_PrintfW(_T("free() 1 空间 0x%x size=%d ref=%d"),pDesc,pDesc->nMallocBufSize,pDesc->nRefs) ;
}
#endif
::free(pDesc) ;
}
::LeaveCriticalSection(&m_csLock) ;
#endif
}
//----------------------------------------------------------------------------------------
// CptStringBase
CptStringBase::CptStringBase():m_pchStrData(NULL)
{
}
void CptStringBase::NewMemBufInstance()
{
if(NULL==m_pStrMemBuf)
{
m_pStrMemBuf = new CStrMemBuf() ;
}
}
void CptStringBase::SetEmptyStr()
{
if(m_pchStrData!=NULL && this->GetRefCount()>0)
{
this->DecreaseRef() ;
}
CptStringBase::NewMemBufInstance() ;
m_pchStrData = (StringPointer_t*)(m_pStrMemBuf->GetEmptyBuffer())->GetStringPtr() ;
}
void CptStringBase::AllocBuf(const int nStringSize)
{
CptStringBase::NewMemBufInstance() ;
if(nStringSize>0)
{
SStringDesc* pDesc = (SStringDesc*)(m_pStrMemBuf->GetBuffer(nStringSize+sizeof(SStringDesc)+2)) ;
m_pchStrData = (StringPointer_t*)pDesc->GetStringPtr() ;
::memset(m_pchStrData,0,pDesc->GetStrBufSize()) ;
pDesc->nRefs = 1 ; // 引用 1 次
pDesc->nUsedSize = 0 ; // 长度为0
}
else
{
m_pchStrData = (StringPointer_t*)(m_pStrMemBuf->GetEmptyBuffer())->GetStringPtr() ;
}
//#ifdef PT_DEBUG
// Debug_Printf("申请了空间:0x%x,%d",this->GetStringDesc(),pDesc->nMallocBufSize) ;
//#endif
}
// 释放一个字符串内存空间
void CptStringBase::FreeBuf()
{
if(m_pStrMemBuf!=NULL)
{
m_pStrMemBuf->ReleaseBuffer(this->GetStringDesc()) ;
m_pchStrData = NULL ;
}
}
// 减少引用
inline int CptStringBase::DecreaseRef()
{
_ASSERT(NULL!=m_pchStrData) ;
if(NULL!=m_pStrMemBuf && this->GetStringDesc()!=m_pStrMemBuf->GetEmptyBuffer())
{// 若为非空字符串
int nResult = ::InterlockedDecrement(&(this->GetStringDesc()->nRefs)) ;
#ifdef PT_DEBUG
//if(this->GetStringDesc()->nMallocBufSize==STRING_SIZE_128)
//{
// Debug_PrintfW(_T("减少引用计数:0x%x %d"),this->GetStringDesc(),nResult) ;
//}
#endif
if(nResult==0)
{
this->FreeBuf() ;
}
return nResult;
}
return 1 ;
}
// 增加引用
inline int CptStringBase::IncreaseRef() const
{
_ASSERT(NULL!=m_pchStrData) ;
if(NULL!=m_pStrMemBuf && this->GetStringDesc()!=m_pStrMemBuf->GetEmptyBuffer())
{// 若为非空字符串
int nResult = ::InterlockedIncrement(&(this->GetStringDesc()->nRefs)) ;
return nResult ;
}
return 1 ;
}
/////////////////////////////////////////////
//字符串类, UNICODE
class CptStringW : public CptStringBase
{
public:
CptStringW(void);
~CptStringW(void);
CptStringW( const CptStringW& StrSrc );
CptStringW( WCHAR ch, int nRepeat = 1 );
CptStringW(LPCSTR lpsz);
CptStringW(LPCWSTR lpsz);
// CString(const unsigned WCHAR* psz);
int GetLength() const ;
//LPCWSTR
// int GetCharCount() const ;
operator LPCWSTR() const;
// 赋值
const CptStringW& operator=(const CptStringW& StrSrc);
const CptStringW& operator=(WCHAR ch);
const CptStringW& operator=(LPCSTR lpsz);
const CptStringW& operator=(LPCWSTR lpsz);
// 串接
friend CptStringW operator+(const CptStringW& str1,const CptStringW& str2) ;
friend CptStringW operator+(const CptStringW& str,const WCHAR ch) ;
friend CptStringW operator+(const WCHAR ch,const CptStringW& str) ;
friend CptStringW operator+(const CptStringW& str, LPCWSTR lpsz);
friend CptStringW operator+(LPCWSTR lpsz, const CptStringW& str);
// 串接并赋值
const CptStringW& operator+=(const CptStringW& string);
const CptStringW& operator+=(WCHAR ch);
const CptStringW& operator+=(LPCSTR lpsz);
const CptStringW& operator+=(LPCWSTR lpsz);
// 比较
bool operator==(const CptStringW str) const ;
bool operator==(LPCWSTR lpsz) const ;
bool operator==(WCHAR ch) const ;
bool operator!=(const CptStringW str) const ;
bool operator!=(LPCWSTR lpsz) const ;
bool operator!=(WCHAR ch) const ;
int Compare(LPCWSTR lpsz) const;
int CompareNoCase(LPCWSTR lpsz) const;
//
void MakeUpper();
void MakeLower();
// 提取
CptStringW Mid(int nFirst, int nCount) const;
CptStringW Left(int nCount) const;
CptStringW Right(int nCount) const;
// 查找
int Replace(WCHAR chOld, WCHAR chNew);
int Replace(LPCWSTR lpszOld, LPCWSTR lpszNew);
int Remove(int nBegin,int nLength) ;
int RemoveAt(int nIndex) ;
int Remove(WCHAR chRemove);
int Insert(int nIndex, WCHAR ch);
int Insert(int nIndex, LPCWSTR pstr);
int Delete(int nIndex, int nCount = 1);
int Find(LPCWSTR lpszSub) const;
int Find(LPCWSTR lpszSub, int nStart) const;
int Find(WCHAR ch) const;
int Find(WCHAR ch, int nStart) const ;
int ReverseFind(WCHAR ch) const ;
int FindOneOf(LPCWSTR lpszWCHARSet) const ;
void Format(LPCWSTR lpszFormat, ...);
void FormatV(LPCWSTR lpszFormat, va_list argList);
void SetAt(int nIndex, WCHAR ch) ;
WCHAR GetAt(int nIndex) const ;
WCHAR operator []( int nIndex ) const;
const WCHAR* c_str() const ;
int AsInt() const throw(int) ;
__int64 As64Int() const throw(int) ;
double AsFloat() const throw(int) ;
int TrimLeft(WCHAR c) ;
int TrimLeft(const WCHAR* szStr) ;
int TrimRight(WCHAR c) ;
int TrimRight(const WCHAR* szStr) ;
private:
inline int InlineGetLength() const ;
};
class CptStringListW
{
public:
CptStringListW() ;
CptStringListW(const CptStringListW& StrList) ;
CptStringListW& operator=(const CptStringListW& StrList) ;
int Add(const CptStringW& str) ;
int GetCount() const ;
int Delete(int nIndex) ;
int Delete(const CptStringW& str) ;
int Find(const CptStringW& str) const;
CptStringW& operator[](int nIndex) ;
CptStringW operator[](int nIndex) const ;
const CptStringListW operator-(const CptStringListW& sl) ;
const CptStringListW operator+(const CptStringListW& sl) ;
int Split(CptStringW strData,CptStringW strSep) ;
void Clear() ;
private:
std::vector<CptStringW> m_StrVecr ;
};
#pragma warning(pop)
#endif // !defined(AFX_PTSTRING_H__347C9F70_FF17_45CF_8649_38695F9B8FCF__INCLUDED_)
// ptString.h: interface for the CptStringA class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_PTSTRING_H__347C9F70_FF17_45CF_8649_38695F9B8FCF__INCLUDED_)
#define AFX_PTSTRING_H__347C9F70_FF17_45CF_8649_38695F9B8FCF__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
//#define _UNICODE
#ifdef _DEBUG
//#define PT_DEBUG
#endif
#include <windows.h>
#include <tchar.h>
#include <vector>
//#ifndef char_ARG
//
//#define char_ARG char
///**
//#ifdef _UNICODE
//#define char_ARG 2
//#else
//#define char_ARG 1
//#endif
///**/
//#endif
//#define USE_SGI_STL_MEMORY_FOR_PTSTRING
#ifdef USE_SGI_STL_MEMORY_FOR_PTSTRING
#define USE_STL_MEMORY_FOR_PTSTRING
#endif
#ifdef USE_SGI_STL_MEMORY_FOR_PTSTRING
#include "sgi_stl_alloc.h"
#define __STD_SPACE sgi_std
#else
#define __STD_SPACE std
#endif
#ifdef _UNICODE
#define CptString CptStringW
#define CptStringList CptStringListW
#else
#define CptString CptStringA
#define CptStringList CptStringListA
#endif //#ifdef _UNICODE
class CptStringA ;
CptStringA operator+(const CptStringA& str1,const CptStringA& str2) ;
CptStringA operator+(const CptStringA& str,const char ch) ;
CptStringA operator+(const char ch,const CptStringA& str) ;
CptStringA operator+(const CptStringA& str, LPCSTR lpsz);
CptStringA operator+(LPCSTR lpsz, const CptStringA& str);
#pragma warning(push)
#pragma warning( disable : 4290 )
#pragma pack(push,1)
class CptStringBase
{
public:
int GetRefCount() const {return this->GetStringDesc()->nRefs;}
protected:
CptStringBase() ;// 不被外部访问
~CptStringBase() {this->DecreaseRef();}
struct SStringDesc
{
long nRefs; // 内存块引用计数
long nUsedSize; // 字符串长度
long nMallocBufSize; // 内存分配长度
SStringDesc():nRefs(0),nUsedSize(0),nMallocBufSize(0) {} ;
void* GetStringPtr() const { return (void*)(this+1); }
int GetStrBufSize() const { return nMallocBufSize-sizeof(SStringDesc) ;}
};
// 字符串内存池
class CStrMemBuf
{
#ifdef PT_DEBUG
#define MAX_POOL_8 0
#define MAX_POOL_16 0
#define MAX_POOL_32 0
#define MAX_POOL_64 0
#define MAX_POOL_128 0
#define MAX_POOL_256 0
#define MAX_POOL_512 0
#else
#define MAX_POOL_8 50
#define MAX_POOL_16 20
#define MAX_POOL_32 30
#define MAX_POOL_64 50
#define MAX_POOL_128 10
#define MAX_POOL_256 10
#define MAX_POOL_512 10
#endif
public:
CStrMemBuf() ;
~CStrMemBuf() ;
// 连同SStringDesc空间一起分配,返回SStringDesc的入口地址
SStringDesc* GetBuffer(const UINT uSize) ;
void ReleaseBuffer(SStringDesc* pDesc) ;
SStringDesc* GetEmptyBuffer() const;
private:
// inline SStringDesc* GetSpace(const int& nIndex) ;
// inline void ReleaseSpace(const int& nIndex) ;
private:
BYTE m_EmptyBuf[sizeof(SStringDesc)+sizeof(WCHAR)] ;
#ifdef USE_STL_MEMORY_FOR_PTSTRING
__STD_SPACE::allocator<char> m_Alloc ;
#else
//WCHAR m_chEmpty ;
void* m_aMemList[7] ;
BYTE m_byUnitCount[7] ;
CRITICAL_SECTION m_csLock ;
#endif
#ifdef PT_DEBUG
public:
int m_nAllocCounter ;
unsigned m_uAllocBufSize ;
#endif
};
#define STRING_SIZE_8 8
#define STRING_SIZE_16 16
#define STRING_SIZE_32 32
#define STRING_SIZE_64 64
#define STRING_SIZE_128 128
#define STRING_SIZE_256 256
#define STRING_SIZE_512 512
inline SStringDesc* GetStringDesc() const {return (((SStringDesc*)m_pchStrData)-1) ; } ;
void AllocBuf(const int nStringSize) ;
void FreeBuf() ;
inline int DecreaseRef() ;
inline int IncreaseRef() const;
inline void BeforeWrite(const int nStringSize) ;
inline void SetEmptyStr() ;
inline void CloneBeforeWrite() ;
static inline void NewMemBufInstance() ;
public:
bool IsEmpty() const ;
int GetUsedSize() const ;
//int GetLength() const ;
void Empty() ;
protected:
//inline int InlineGetLength() const ;
#ifdef _UNICODE
#define StringPointer_t WCHAR
#else
#define StringPointer_t char
#endif
StringPointer_t* m_pchStrData ; // 字符串开始入口地址. 存储格式:[SStringDesc][String]
#ifdef PT_DEBUG
public:
#else
protected:
#endif
static CStrMemBuf* m_pStrMemBuf ;
};
#pragma pack(pop)
// 字符串类 ANSI
class CptStringA : public CptStringBase
{
public:
CptStringA();
CptStringA( const CptStringA& StrSrc );
CptStringA( char ch, int nRepeat = 1 );
CptStringA(LPCSTR lpsz);
CptStringA(LPCWSTR lpsz);
~CptStringA() ;
// CString(const unsigned char* psz);
int GetLength() const ;
//int GetCharCount() const ;
operator LPCSTR() const;
// 赋值
const CptStringA& operator=(const CptStringA& stringSrc);
const CptStringA& operator=(char ch);
const CptStringA& operator=(LPCSTR lpsz);
const CptStringA& operator=(LPCWSTR lpsz);
// 串接
friend CptStringA operator+(const CptStringA& str1,const CptStringA& str2) ;
friend CptStringA operator+(const CptStringA& str,const char ch) ;
friend CptStringA operator+(const char ch,const CptStringA& str) ;
friend CptStringA operator+(const CptStringA& str, LPCSTR lpsz);
friend CptStringA operator+(LPCSTR lpsz, const CptStringA& str);
// 串接并赋值
const CptStringA& operator+=(const CptStringA& string);
const CptStringA& operator+=(char ch);
const CptStringA& operator+=(LPCWSTR lpsz);
const CptStringA& operator+=(LPCSTR lpsz);
// 比较
bool operator==(const CptStringA str) const ;
bool operator==(LPCSTR lpsz) const ;
bool operator==(char ch) const ;
bool operator!=(const CptStringA str) const ;
bool operator!=(LPCSTR lpsz) const ;
bool operator!=(char ch) const ;
int Compare(LPCSTR lpsz) const;
int CompareNoCase(LPCSTR lpsz) const;
//
void MakeUpper();
void MakeLower();
// 提取
CptStringA Mid(int nFirst, int nCount) const;
CptStringA Left(int nCount) const;
CptStringA Right(int nCount) const;
// 查找
int Replace(char chOld, char chNew);
int Replace(LPCSTR lpszOld, LPCSTR lpszNew);
int Remove(char chRemove);
int Remove(int nBegin,int nLength) ;
int RemoveAt(int nIndex) ;
int Insert(int nIndex, char ch);
int Insert(int nIndex, LPCSTR pstr);
int Delete(int nIndex, int nCount = 1);
int Find(LPCSTR lpszSub) const;
int Find(LPCSTR lpszSub, int nStart) const;
int Find(char ch) const;
int Find(char ch, int nStart) const ;
int ReverseFind(char ch) const ;
int FindOneOf(LPCSTR lpszCharSet) const ;
void Format(LPCSTR lpszFormat, ...);
void FormatV(LPCSTR lpszFormat, va_list argList);
void SetAt(int nIndex, char ch) ;
char GetAt(int nIndex) const ;
char operator []( int nIndex ) const;
const char* c_str() const ;
int AsInt() const throw(int) ;
__int64 As64Int() const throw(int) ;
double AsFloat() const throw(int) ;
int TrimLeft(char c) ;
int TrimLeft(const char* szStr) ;
int TrimRight(char c) ;
int TrimRight(const char* szStr) ;
private:
inline int InlineGetLength() const ;
};
class CptStringListA
{
public:
CptStringListA() ;
CptStringListA(const CptStringListA& StrList) ;
CptStringListA& operator=(const CptStringListA& StrList) ;
int Add(const CptStringA& str) ;
int GetCount() const ;
int Delete(int nIndex) ;
int Delete(const CptStringA& str) ;
int Find(const CptStringA& str) const;
CptStringA& operator[](int nIndex) ;
CptStringA operator[](int nIndex) const ;
const CptStringListA operator-(const CptStringListA& sl) ;
const CptStringListA operator+(const CptStringListA& sl) ;
int Split(CptStringA strData,CptStringA strSep) ;
void Clear() ;
private:
std::vector<CptStringA> m_StrVecr ;
};