658 lines
25 KiB
C++
658 lines
25 KiB
C++
|
|
|
|
#ifndef __ZCPPMAIIN_ZTCSTRINGSTD_H__
|
|
#define __ZCPPMAIIN_ZTCSTRINGSTD_H__
|
|
|
|
|
|
#include<string>
|
|
#include "ZCppMain/ZtCMainChars.H"
|
|
|
|
|
|
namespace ZNsMain
|
|
{
|
|
|
|
|
|
template<typename TTypString> class ZtCStringStd;
|
|
|
|
|
|
template //////////////////////////////////////////////////////////////////
|
|
<
|
|
template<typename> class ZtCStringStd, typename TTypeBaseStr
|
|
>
|
|
/*#######################################################################*/
|
|
class ZtCCharType< ZtCStringStd<TTypeBaseStr> >
|
|
{
|
|
public:
|
|
typedef ZtCStringStd<TTypeBaseStr> TypeCStr ;
|
|
typedef typename TypeCStr::traits_type::char_type TypeChar ;
|
|
typedef typename TypeCStr::traits_type::int_type TypeInt ;
|
|
typedef typename TypeCStr::size_type TypeSize ;
|
|
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
|
|
static const int CI_ByteSize = sizeof(TypeChar) ;
|
|
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
|
|
public:
|
|
typedef TypeChar char_type ; // for stl string/wstring
|
|
typedef TypeInt int_type ; // for stl string/wstring
|
|
typedef TypeSize size_type ; // for stl string/wstring
|
|
public:
|
|
};/*
|
|
class ZtCCharType #######################################################*/
|
|
|
|
|
|
|
|
template
|
|
< typename TTypString = std::string >
|
|
class ZtCStringStd : public TTypString
|
|
{
|
|
public:
|
|
typedef ZtCStringStd TypeThis;
|
|
/*+++++++++++++++++++++++++++++++++++++++++++++++++*/
|
|
typedef typename TTypString::traits_type::char_type TypeChar ;
|
|
typedef typename TTypString::traits_type::int_type TypeCharInt ;
|
|
typedef typename TTypString::size_type TypeLength ;
|
|
/*+++++++++++++++++++++++++++++++++++++++++++++++++*/
|
|
typedef ZNsChars::ZNsType::
|
|
ZtCTypeChars <TypeChar > ZCTypeChars ;
|
|
typedef ZNsChars::
|
|
ZtCMainChars<ZCTypeChars> ZCMainChars ;
|
|
/*+++++++++++++++++++++++++++++++++++++++++++++++++*/
|
|
typedef TypeChar* TypePChar ;
|
|
typedef const TypeChar* TypeCPChar ;
|
|
typedef TTypString TypeBase ;
|
|
typedef TTypString TypeStrStd ;
|
|
typedef TypeLength TypeSize ;
|
|
/*+++++++++++++++++++++++++++++++++++++++++++++++++*/
|
|
typedef ZtCChars
|
|
<TypeChar, TypeLength> ZCChars ;
|
|
typedef ZtCChars
|
|
<TypeChar, TypeLength> ZCCharView ;
|
|
/*+++++++++++++++++++++++++++++++++++++++++++++++++*/
|
|
|
|
ZtCStringStd(): TypeStrStd(){}
|
|
ZtCStringStd(const ZtCStringStd& rhs): TypeStrStd(rhs){}
|
|
ZtCStringStd(TypeCPChar APC_Origin, TypeLength AL_Length):
|
|
TypeStrStd(APC_Origin, AL_Length){}
|
|
|
|
ZtCStringStd(const ZCCharView& AR_View):
|
|
TypeStrStd(AR_View.data(), AR_View.size()){}
|
|
|
|
explicit ZtCStringStd(TypeCPChar APC_Origin):
|
|
TypeStrStd(APC_Origin){}
|
|
|
|
ZtCStringStd& operator=(const ZtCStringStd& rhs)
|
|
{
|
|
if(this==&rhs){ return *this; }
|
|
|
|
this->TypeStrStd::operator=(rhs); return *this;
|
|
}/*
|
|
ZtCStringStd& operator=(const ZtCStringStd& rhs)*/
|
|
|
|
ZtCStringStd& operator=(const TypeBase& rhs)
|
|
{
|
|
if(this->data()==rhs.data()){ return *this; }
|
|
|
|
this->TypeStrStd::operator=(rhs); return *this;
|
|
}/*
|
|
ZtCStringStd& operator=(const TypeBase& rhs)*/
|
|
|
|
ZtCStringStd& operator=(const ZCCharView& AR_View)
|
|
{
|
|
if(this->data()==AR_View.data()){ return *this; }
|
|
if( 1 > AR_View.size())
|
|
{ this->resize(0); return *this; }
|
|
|
|
this->resize(AR_View.size());
|
|
|
|
const int CI_CopySize =
|
|
AR_View.size() * sizeof(TypeChar) ;
|
|
|
|
::memcpy(this->data(), AR_View.data(), CI_CopySize);
|
|
|
|
return *this; /*::::::::::::::::::::::::::::::::::*/
|
|
}/*
|
|
ZtCStringStd& operator=(const ZCCharView& AR_View)*/
|
|
|
|
|
|
ZtCStringStd& operator=(ZTypInt AI_Int )
|
|
{ this->resize(0); return (*this)(AI_Int ); }
|
|
ZtCStringStd& operator=(ZTypLong AL_Long )
|
|
{ this->resize(0); return (*this)(AL_Long ); }
|
|
ZtCStringStd& operator=(ZTypLLong AL_LLong )
|
|
{ this->resize(0); return (*this)(AL_LLong ); }
|
|
ZtCStringStd& operator=(double AD_Double)
|
|
{ this->resize(0); return (*this)(AD_Double); }
|
|
|
|
|
|
|
|
template<typename TPosList> void FindPosToList /////////////
|
|
(
|
|
TPosList& ARR_CPosList, TypeCPChar APC_SearchData,
|
|
TypeLength AL_SearchLen, TypeLength AL_Offset=0
|
|
)
|
|
/*########################################################*/
|
|
{
|
|
// TPosList : ZNsMain::ZtCBaseList<TypeLength> etc
|
|
|
|
if(0 > AL_Offset) AL_Offset=0 ;
|
|
if(this->size() <= AL_Offset) return ;
|
|
if(this->size() < 1 ) return ;
|
|
|
|
TypeCPChar VPC_OriginStart = this->data();
|
|
TypeLength VL_OriginLen = this->size();
|
|
TypeLength VL_FindPos = -1 ;
|
|
TypeLength VL_OffsetNow = AL_Offset ;
|
|
|
|
while /*::::::::::::::::::::::::::::::::::::::::::::::*/
|
|
(
|
|
( VL_FindPos = ZCMainChars::FindPos
|
|
(
|
|
VPC_OriginStart, APC_SearchData,
|
|
VL_OriginLen , AL_SearchLen , VL_OffsetNow
|
|
)
|
|
) >= 0
|
|
)
|
|
/*::::::::::::::::::::::::::::::::::::::::::::::::::::*/
|
|
{
|
|
ARR_CPosList.push_back(VL_FindPos);
|
|
|
|
VL_OffsetNow = VL_FindPos + AL_SearchLen;
|
|
}
|
|
/*::::::::::::::::::::::::::::::::::::::::::::::::::::*/
|
|
}/*
|
|
template<typename TPosList> void FindPosToList /////////////
|
|
(
|
|
TPosList& ARR_CPosList, TypeCPChar APC_SearchData,
|
|
TypeLength AL_SearchLen, TypeLength AL_Offset=0
|
|
)
|
|
##########################################################*/
|
|
|
|
|
|
public :
|
|
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
|
|
private:
|
|
|
|
template<typename TPosList> ZtCStringStd& ReplaceByPosList ///////////////////
|
|
(
|
|
TPosList& AR_CPosList ,
|
|
TypeCPChar APC_Replace ,
|
|
TypeLength AL_Replace ,
|
|
TypeLength AL_Searched
|
|
)
|
|
/*#########################################################################*/
|
|
{
|
|
/*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
|
|
|
■ TPosList : ZNsMain::ZtCBaseList<TypeLength> etc
|
|
AL_Replace : APC_Replace 의 길이
|
|
AL_Searched : 이전에 찾은 길이
|
|
|
|
Replace() 에서 FindPosToList() 다음에 호출한다.
|
|
|
|
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::*/
|
|
|
|
if(AR_CPosList.size()<1) return *this;
|
|
|
|
TypeLength VL_PosListSize= AR_CPosList.size() ;
|
|
TypeLength VL_ThisSize = this->size() ;
|
|
TypeLength VL_NeedSize = VL_ThisSize +
|
|
(AL_Replace-AL_Searched) * VL_PosListSize ;
|
|
|
|
TypePChar VPC_ThisStart = const_cast<TypeChar*>(this->data()) ;
|
|
IterEasyID VH_IterEasyID = AR_CPosList.ItHID();
|
|
TypeLength VL_SearchedPos= 0 ;
|
|
TypeLength VL_SearchedPre= 0 ; // VL_SearchedPos 의 이전 값
|
|
|
|
TypePChar VPC_MoveStart = 0 ;
|
|
TypePChar VPC_DestStart = 0 ;
|
|
TypeLength VL_MoveStart = 0 ;
|
|
TypeLength VL_DestStart = 0 ;
|
|
TypeLength VL_MemMoveSize= 0 ;
|
|
|
|
if(AL_Replace<=AL_Searched) // 메모리 증가 불필요
|
|
{
|
|
TypePChar VPC_MoveStart = 0 ;
|
|
TypePChar VPC_DestStart = 0 ;
|
|
TypeLength VL_MoveStart = 0 ;
|
|
TypeLength VL_DestStart = 0 ;
|
|
|
|
TypeLength VL_MemMoveSize= 0 ;
|
|
TypePChar VPC_RepalcePos= 0 ;
|
|
|
|
__for1(TypeLength, i, VL_PosListSize)
|
|
{
|
|
VL_SearchedPos = AR_CPosList.ItD(VH_IterEasyID) ;
|
|
VPC_RepalcePos = VPC_ThisStart + VL_SearchedPos -
|
|
( AL_Searched-AL_Replace ) * (i-1) ;
|
|
|
|
if(VL_MoveStart>VL_DestStart)
|
|
{
|
|
VL_MemMoveSize =
|
|
VL_SearchedPos - VL_SearchedPre - AL_Searched ;
|
|
VPC_MoveStart = VPC_ThisStart + VL_MoveStart ;
|
|
VPC_DestStart = VPC_ThisStart + VL_DestStart ;
|
|
|
|
::memmove /*:::::::::::::::::::::::::::::::::::::::::::::::::::::::*/
|
|
(
|
|
VPC_DestStart, VPC_MoveStart, VL_MemMoveSize*sizeof(TypeChar)
|
|
);
|
|
/*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::*/
|
|
}/*
|
|
if(VL_MoveStart>VL_DestStart)*/
|
|
|
|
VL_SearchedPre = VL_SearchedPos ;
|
|
VL_MoveStart = VL_SearchedPos+ AL_Searched ;
|
|
VL_DestStart = VL_SearchedPos+ AL_Searched -
|
|
( AL_Searched-AL_Replace ) * i ;
|
|
|
|
::memcpy(VPC_RepalcePos, APC_Replace, AL_Replace);
|
|
|
|
AR_CPosList.ItNext(VH_IterEasyID);
|
|
}/*
|
|
__for1(TypeLength, i, VL_PosListSize)*/
|
|
|
|
if(VL_ThisSize > VL_MoveStart)
|
|
{
|
|
::memmove /*::::::::::::::::::::::::::::::*/
|
|
(
|
|
VPC_ThisStart + VL_DestStart,
|
|
VPC_ThisStart + VL_MoveStart,
|
|
(VL_ThisSize - VL_MoveStart)*sizeof(TypeChar)
|
|
);
|
|
/*::::::::::::::::::::::::::::::::::::::::*/
|
|
}/*
|
|
if(VL_ThisSize > VL_MoveStart)*/
|
|
|
|
this->resize(VL_NeedSize); return *this;
|
|
}/*
|
|
if(AL_Replace<=AL_Searched) // 메모리 증가 불필요*/
|
|
|
|
|
|
/*======*/ VL_SearchedPre = this->size() ;
|
|
/*======*/ VH_IterEasyID = AR_CPosList.ItTID() ;
|
|
TypeLength VL_NowEleNo = VL_PosListSize ;
|
|
TypeLength VL_DiffLength = AL_Replace-AL_Searched;
|
|
|
|
this->resize(VL_NeedSize); VPC_ThisStart = this->data();
|
|
|
|
__for1(TypeLength, i, VL_PosListSize)
|
|
{
|
|
VL_SearchedPos = AR_CPosList.ItD(VH_IterEasyID) ;
|
|
VL_MemMoveSize = VL_SearchedPre - (VL_SearchedPos+AL_Searched);
|
|
|
|
if(VL_MemMoveSize>0)
|
|
{
|
|
VPC_MoveStart = VPC_ThisStart + VL_SearchedPos + AL_Searched ;
|
|
VPC_DestStart = VPC_ThisStart + VL_SearchedPos + AL_Searched + VL_DiffLength*VL_NowEleNo ;
|
|
|
|
::memmove /*:::::::::::::::::::::::::::::::::::::::::::::::::::::::*/
|
|
(
|
|
VPC_DestStart, VPC_MoveStart, VL_MemMoveSize*sizeof(TypeChar)
|
|
);
|
|
/*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::*/
|
|
}/*
|
|
if(VL_MemMoveSize>0)*/
|
|
|
|
VPC_DestStart = VPC_ThisStart + VL_SearchedPos + VL_DiffLength*(VL_PosListSize - i) ;
|
|
|
|
::memcpy /*:::::::::::::::::::::::::::::::::::::::::::::::::*/
|
|
(
|
|
VPC_DestStart, APC_Replace, AL_Replace*sizeof(TypeChar)
|
|
);
|
|
/*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::*/
|
|
|
|
VL_SearchedPre = VL_SearchedPos; --VL_NowEleNo;
|
|
|
|
AR_CPosList.ItPrev(VH_IterEasyID);
|
|
}/*
|
|
__for1(TypeLength, i, VL_PosListSize)*/
|
|
|
|
|
|
return *this;
|
|
}/*
|
|
template<typename TPosList> ZtCStringStd& ReplaceByPosList //////////////////
|
|
(
|
|
TPosList& AR_CPosList ,
|
|
TypeCPChar APC_Replace ,
|
|
TypeLength AL_Replace ,
|
|
TypeLength AL_Searched
|
|
)
|
|
###########################################################################*/
|
|
|
|
|
|
private:
|
|
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
|
|
public :
|
|
|
|
|
|
ZtCStringStd& Replace /*///////////////////////////////////////////////////*/
|
|
(
|
|
TypeCPChar APC_Search, TypeCPChar APC_Replace,
|
|
TypeLength AL_Search , TypeLength AL_Replace , TypeLength AL_Offset=0
|
|
)
|
|
/*#########################################################################*/
|
|
{
|
|
if(0 > AL_Offset) AL_Offset=0 ;
|
|
if(this->size() <= AL_Offset) return *this;
|
|
if(this->size() < 1 ) return *this;
|
|
|
|
ZtCBaseList<TypeLength> VO_CPosCList; FindPosToList
|
|
(
|
|
RR(VO_CPosCList), APC_Search, AL_Search, AL_Offset
|
|
);
|
|
/*////////////////////////////////////////////////*/
|
|
|
|
return ReplaceByPosList /*::::::::::::::::::::::::::::*/
|
|
(
|
|
VO_CPosCList, APC_Replace, AL_Replace, AL_Search
|
|
);
|
|
/*::::::::::::::::::::::::::::::::::::::::::::::::::::*/
|
|
}
|
|
/*#########################################################################*/
|
|
|
|
ZtCStringStd& Replace /*///////////////////////////////////////////////////*/
|
|
(
|
|
TypeCPChar APC_Search, TypeCPChar APC_Replace, TypeLength AL_Offset=0
|
|
)
|
|
/*#########################################################################*/
|
|
{
|
|
return Replace(APC_Search, APC_Replace, ZftLength(APC_Search), ZftLength(APC_Replace), AL_Offset);
|
|
}
|
|
/*#########################################################################*/
|
|
|
|
|
|
ZtCStringStd& operator()(ZtCStringStd& rhs)
|
|
{
|
|
if(this==&rhs) {return *this;} this->append(rhs); return *this;
|
|
}/*
|
|
ZtCStringStd& operator()(ZtCStringStd& rhs)*/
|
|
|
|
ZtCStringStd& operator()(TypeCPChar APC_Data, TypeLength AI_Length)
|
|
{
|
|
if(this->data()==APC_Data) return *this;
|
|
|
|
this->append(APC_Data, AI_Length); return *this;
|
|
}/*
|
|
ZtCStringStd& operator()(TypeCPChar APC_Data, TypeLength AI_Length)*/
|
|
|
|
ZtCStringStd& operator()(TypeCPChar APC_Data)
|
|
{
|
|
if(this->data()==APC_Data) return *this;
|
|
|
|
this->append(APC_Data); return *this;
|
|
}/*
|
|
ZtCStringStd& operator()(TypeCPChar APC_Data)*/
|
|
|
|
ZtCStringStd& operator()(TypeLength AI_Repeat, TypeChar AC_Data)
|
|
{
|
|
this->append(AI_Repeat, AC_Data); return *this;
|
|
}/*
|
|
ZtCStringStd& operator()(TypeChar AC_Data, TypeLength AI_Repeat)*/
|
|
|
|
ZtCStringStd& operator()(TypeChar AC_Data, TypeLength AI_Repeat=1)
|
|
{
|
|
this->append(AI_Repeat, AC_Data); return *this;
|
|
}/*
|
|
ZtCStringStd& operator()(TypeChar AC_Data, TypeLength AI_Repeat=1)*/
|
|
|
|
ZtCStringStd& operator()(const ZCCharView& AR_View)
|
|
{
|
|
this->append(AR_View.data(), AR_View.size()); return *this;
|
|
}/*
|
|
ZtCStringStd& operator()(const ZCCharView& AR_View)*/
|
|
|
|
ZtCStringStd& operator()(bool AB_Bool)
|
|
{
|
|
typedef typename TypeThis::TypeChar TypeChar ;
|
|
typedef typename TypeThis::TypeSize TypeSize ;
|
|
|
|
typedef ZtCBoolStr
|
|
<TypeChar, TypeSize> ZCBoolStr;
|
|
|
|
return (*this)( ZCBoolStr::GetMark(AB_Bool) );
|
|
}/*
|
|
ZtCStringStd& operator()(bool AB_Bool)*/
|
|
|
|
|
|
ZtCStringStd& operator()(int AI_IntParam)
|
|
{
|
|
const int CI_BuffSize= 21; TypeChar VCA_BuffParam[CI_BuffSize] ;
|
|
|
|
int VI_ResultSize = /*::::::::::::::::::::::::::::::::::::::::*/
|
|
(
|
|
sizeof(TypeChar)<=1
|
|
? ::sprintf ((char* )VCA_BuffParam, /*+++++++*/ "%d", AI_IntParam)
|
|
: ::swprintf((wchar_t*)VCA_BuffParam, CI_BuffSize, L"%d", AI_IntParam)
|
|
);
|
|
return (*this)(VCA_BuffParam, VI_ResultSize); /*::::::::::::::*/
|
|
}/*
|
|
ZtCStringStd& operator()(int AI_IntParam)*/
|
|
|
|
ZtCStringStd& operator()(ZTypUInt AUI_UIntParam)
|
|
{
|
|
const int CI_BuffSize= 21; TypeChar VCA_BuffParam[CI_BuffSize] ;
|
|
|
|
int VI_ResultSize = /*::::::::::::::::::::::::::::::::::::::::*/
|
|
(
|
|
sizeof(TypeChar)<=1
|
|
? ::sprintf ((char* )VCA_BuffParam, /*++++++++*/ "%u", AUI_UIntParam)
|
|
: ::swprintf((wchar_t*)VCA_BuffParam, CI_BuffSize, L"%u", AUI_UIntParam)
|
|
);
|
|
return (*this)(VCA_BuffParam, VI_ResultSize); /*::::::::::::::*/
|
|
}/*
|
|
ZtCStringStd& operator()(ZTypUInt AUI_UIntParam)*/
|
|
|
|
ZtCStringStd& operator()(long AL_LongParam)
|
|
{
|
|
const int CI_BuffSize= 31; TypeChar VCA_BuffParam[CI_BuffSize] ;
|
|
|
|
int VI_ResultSize = /*::::::::::::::::::::::::::::::::::::::::*/
|
|
(
|
|
sizeof(TypeChar)<=1
|
|
? ::sprintf ((char* )VCA_BuffParam, /*++++++++*/ "%ld", AL_LongParam)
|
|
: ::swprintf((wchar_t*)VCA_BuffParam, CI_BuffSize, L"%ld", AL_LongParam)
|
|
);
|
|
return (*this)(VCA_BuffParam, VI_ResultSize); /*::::::::::::::*/
|
|
}/*
|
|
ZtCStringStd& operator()(long AL_LongParam)*/
|
|
|
|
ZtCStringStd& operator()(ZTypULong AUL_ULongParam)
|
|
{
|
|
const int CI_BuffSize= 31; TypeChar VCA_BuffParam[CI_BuffSize] ;
|
|
|
|
int VI_ResultSize = /*::::::::::::::::::::::::::::::::::::::::*/
|
|
(
|
|
sizeof(TypeChar)<=1
|
|
? ::sprintf ((char* )VCA_BuffParam, /*++++++++*/ "%lu", AUL_ULongParam)
|
|
: ::swprintf((wchar_t*)VCA_BuffParam, CI_BuffSize, L"%lu", AUL_ULongParam)
|
|
);
|
|
return (*this)(VCA_BuffParam, VI_ResultSize); /*::::::::::::::*/
|
|
}/*
|
|
ZtCStringStd& operator()(ZTypULong AUL_ULongParam)*/
|
|
|
|
ZtCStringStd& operator()(ZTypLLong ALL_LLongParam)
|
|
{
|
|
const int CI_BuffSize= 41; TypeChar VCA_BuffParam[CI_BuffSize] ;
|
|
|
|
int VI_ResultSize = /*::::::::::::::::::::::::::::::::::::::::*/
|
|
(
|
|
sizeof(TypeChar)<=1
|
|
? ::sprintf ((char* )VCA_BuffParam, /*++++++++*/ "%lld" , ALL_LLongParam)
|
|
: ::swprintf((wchar_t*)VCA_BuffParam, CI_BuffSize, L"%lld" , ALL_LLongParam)
|
|
);
|
|
return (*this)(VCA_BuffParam, VI_ResultSize); /*::::::::::::::*/
|
|
}/*
|
|
ZtCStringStd& operator()(ZTypLLong ALL_LLongParam)*/
|
|
|
|
ZtCStringStd& operator()(ZTypULLong AULL_LLongParam)
|
|
{
|
|
const int CI_BuffSize= 41; TypeChar VCA_BuffParam[CI_BuffSize] ;
|
|
|
|
int VI_ResultSize = /*::::::::::::::::::::::::::::::::::::::::*/
|
|
(
|
|
sizeof(TypeChar)<=1
|
|
? ::sprintf ((char* )VCA_BuffParam, /*++++++++*/ "%llu" , AULL_LLongParam)
|
|
: ::swprintf((wchar_t*)VCA_BuffParam, CI_BuffSize, L"%llu" , AULL_LLongParam)
|
|
);
|
|
return (*this)(VCA_BuffParam, VI_ResultSize); /*::::::::::::::*/
|
|
}/*
|
|
ZtCStringStd& operator()(ZTypULLong AULL_LLongParam)*/
|
|
|
|
ZtCStringStd& operator()(double AD_DoubleParam)
|
|
{
|
|
const int CI_BuffSize= 51; TypeChar VCA_BuffParam[CI_BuffSize] ;
|
|
|
|
int VI_ResultSize = /*::::::::::::::::::::::::::::::::::::::::*/
|
|
(
|
|
sizeof(TypeChar)<=1
|
|
? ::sprintf ((char* )VCA_BuffParam, /*++++++++*/ "%f", AD_DoubleParam)
|
|
: ::swprintf((wchar_t*)VCA_BuffParam, CI_BuffSize, L"%f", AD_DoubleParam)
|
|
);
|
|
ZNsMain::ZftTrimDecimalZero(VCA_BuffParam, RR(VI_ResultSize));
|
|
|
|
return (*this)(VCA_BuffParam, VI_ResultSize); /*::::::::::::::*/
|
|
}/*
|
|
ZtCStringStd& operator()(double AD_DoubleParam)*/
|
|
|
|
|
|
int GetInt () const{return ZNsMain::ZftAtoI (this->data());}
|
|
ZTypLong GetLong () const{return ZNsMain::ZftAtoL (this->data());}
|
|
ZTypLLong GetLongLong() const{return ZNsMain::ZftAtoLL(this->data());}
|
|
ZTypLLong GetLLong () const{return ZNsMain::ZftAtoLL(this->data());}
|
|
double GetDouble () const{return ZNsMain::ZftAtoD (this->data());}
|
|
|
|
public:
|
|
};/*
|
|
template //////////////////////////////////////////////////////////
|
|
< typename TTypString = std::string >
|
|
class ZtCStringStd
|
|
#################################################################*/
|
|
|
|
|
|
typedef ZtCStringStd<std::string > ZCStringStd ;
|
|
typedef ZtCStringStd<std::wstring> ZCStringStdW;
|
|
|
|
|
|
#define _ZCSTRINGSTD_ ZtCStringStd< TTypString >
|
|
#define _ZCSTRINGSTD_ARG_ template< typename TTypString >
|
|
|
|
_ZCSTRINGSTD_ARG_ _ZCSTRINGSTD_& ZftMakeStr
|
|
( _ZCSTRINGSTD_& ARR_SaveCStr, const _ZCSTRINGSTD_& AR_DataCStr)
|
|
{ return ARR_SaveCStr(AR_DataCStr ); }
|
|
|
|
_ZCSTRINGSTD_ARG_ _ZCSTRINGSTD_& ZftMakeStr
|
|
( _ZCSTRINGSTD_& ARR_SaveCStr, const typename
|
|
_ZCSTRINGSTD_::ZCChars& AR_DataCStr )
|
|
{ return ARR_SaveCStr(AR_DataCStr ); }
|
|
|
|
_ZCSTRINGSTD_ARG_ _ZCSTRINGSTD_& ZftMakeStr
|
|
( _ZCSTRINGSTD_& ARR_SaveCStr, typename
|
|
_ZCSTRINGSTD_::TypeChar AC_Char )
|
|
{ return ARR_SaveCStr(AC_Char ); }
|
|
|
|
_ZCSTRINGSTD_ARG_ _ZCSTRINGSTD_& ZftMakeStr
|
|
( _ZCSTRINGSTD_& ARR_SaveCStr, ZTypInt AI_IntI )
|
|
{ return ARR_SaveCStr(AI_IntI ); }
|
|
|
|
_ZCSTRINGSTD_ARG_ _ZCSTRINGSTD_& ZftMakeStr
|
|
( _ZCSTRINGSTD_& ARR_SaveCStr, ZTypIntL AL_Long )
|
|
{ return ARR_SaveCStr(AL_Long ); }
|
|
|
|
_ZCSTRINGSTD_ARG_ _ZCSTRINGSTD_& ZftMakeStr
|
|
( _ZCSTRINGSTD_& ARR_SaveCStr, ZTypIntUI AUI_Int )
|
|
{ return ARR_SaveCStr(AUI_Int ); }
|
|
|
|
_ZCSTRINGSTD_ARG_ _ZCSTRINGSTD_& ZftMakeStr
|
|
( _ZCSTRINGSTD_& ARR_SaveCStr, ZTypIntUL AUL_Long )
|
|
{ return ARR_SaveCStr(AUL_Long ); }
|
|
|
|
_ZCSTRINGSTD_ARG_ _ZCSTRINGSTD_& ZftMakeStr
|
|
( _ZCSTRINGSTD_& ARR_SaveCStr, ZTypIntULL AULL_Long )
|
|
{ return ARR_SaveCStr(AULL_Long ); }
|
|
|
|
_ZCSTRINGSTD_ARG_ _ZCSTRINGSTD_& ZftMakeStr
|
|
( _ZCSTRINGSTD_& ARR_SaveCStr, double AD_Double )
|
|
{ return ARR_SaveCStr(AD_Double ); }
|
|
|
|
_ZCSTRINGSTD_ARG_ _ZCSTRINGSTD_& ZftMakeStr
|
|
( _ZCSTRINGSTD_& ARR_SaveCStr, bool AB_Bool )
|
|
{
|
|
typedef typename _ZCSTRINGSTD_::TypeChar TypeChar;
|
|
typedef typename _ZCSTRINGSTD_::TypeSize TypeSize;
|
|
|
|
typedef ZtCBoolStr<TypeChar, TypeSize> ZCBoolStr ;
|
|
|
|
return ARR_SaveCStr(ZCBoolStr::GetMark(AB_Bool)) ;
|
|
}/*
|
|
_ZCSTRINGSTD_ARG_ _ZCSTRINGSTD_& ZftMakeStr
|
|
( _ZCSTRINGSTD_& ARR_SaveCStr, bool AB_Bool ) */
|
|
|
|
|
|
#undef _ZCSTRINGSTD_
|
|
#undef _ZCSTRINGSTD_ARG_
|
|
|
|
|
|
|
|
template<typename TTypString> std::ostream& operator<<
|
|
(std::ostream& AR_COStream, const ZtCStringStd<TTypString>& AR_DataCStr)
|
|
{
|
|
typedef typename ZtCStringStd
|
|
<TTypString>::TypeBase TypeBaseCStr ;
|
|
|
|
AR_COStream<< static_cast
|
|
<const TypeBaseCStr&>(AR_DataCStr);
|
|
|
|
return AR_COStream; ///////////////////////////
|
|
}/*
|
|
template<typename TTypString> std::ostream& operator<<
|
|
(std::ostream& AR_COStream, const ZtCStringStd& AR_DataCStr)*/
|
|
|
|
|
|
std::ostream& operator<<
|
|
(std::ostream& AR_COStream, const ZCStringStd& AR_DataCStr)
|
|
{
|
|
typedef ZCStringStd::TypeBase TypeBaseCStr;
|
|
|
|
AR_COStream<< static_cast
|
|
<const TypeBaseCStr&>( AR_DataCStr );
|
|
|
|
return AR_COStream; /*********************/
|
|
}/*
|
|
template<typename TTypString> std::ostream& operator<<
|
|
(std::ostream& AR_COStream, const ZtCStringStd& AR_DataCStr)*/
|
|
|
|
|
|
std::ostream& operator<<
|
|
(std::ostream& AR_COStream, const ZCStringStdW& AR_DataCStr)
|
|
{
|
|
// ascii 코드 범위에서만 출력한다.
|
|
|
|
typedef ZCStringStdW::TypeSize TypeLength ;
|
|
typedef ZCStringStdW::TypeCharInt TypeCharInt;
|
|
|
|
ZTypCCharW* VP_Data = AR_DataCStr.data();
|
|
TypeLength VI_Size = AR_DataCStr.size();
|
|
|
|
const int CI_AsciiMax = 127 ;
|
|
|
|
__for0(TypeLength, i, VI_Size)
|
|
{
|
|
TypeCharInt VI_Code = TypeCharInt(*VP_Data++);
|
|
|
|
if(VI_Code>0 && VI_Code<=CI_AsciiMax)
|
|
{ AR_COStream.put( char(VI_Code) ); }
|
|
}/*
|
|
__for0(TypeLength, i, VI_Size)*/
|
|
|
|
return AR_COStream; /*********************/
|
|
}/*
|
|
template<typename TTypString> std::ostream& operator<<
|
|
(std::ostream& AR_COStream, const ZtCStringStd& AR_DataCStr)*/
|
|
|
|
|
|
}/*
|
|
namespace ZNsMain*/
|
|
|
|
|
|
|
|
#endif //__ZCPPMAIIN_ZTCSTRINGSTD_H__
|