commit 2025-10-09 10:41 bug fix about wchar_t in ZCppMain/ZtCStringEx.H and add ZftAtoI(), ZftAotL() etc in ZCppMain/ZMainHead.H
This commit is contained in:
@ -193,6 +193,7 @@
|
||||
#include <string>
|
||||
#include <climits>
|
||||
#include <typeinfo>
|
||||
#include <wchar.h>
|
||||
|
||||
|
||||
#define _CODE_OLD_ 0
|
||||
@ -817,22 +818,11 @@ namespace ZNsMain
|
||||
|
||||
|
||||
template<typename TTypChar> class ZtCCharInt
|
||||
{
|
||||
public: typedef typename ZtCCharIntBySize<sizeof(TTypChar)>::TypeInte TypeInt;
|
||||
};/*
|
||||
template<typename TTypChar> class ZtCCharInt*/
|
||||
|
||||
template<> class ZtCCharInt<char>
|
||||
{
|
||||
public: typedef typename ZtCCharIntBySize<sizeof(char) >::TypeInt TypeInt;
|
||||
};/*
|
||||
template<> class ZtCCharInt<char>*/
|
||||
|
||||
template<> class ZtCCharInt<wchar_t>
|
||||
{
|
||||
public: typedef typename ZtCCharIntBySize<sizeof(wchar_t) >::TypeInt TypeInt;
|
||||
};/*
|
||||
template<> class ZtCCharInt<wchar_t>*/
|
||||
{ public: typedef typename ZtCCharIntBySize<sizeof(TTypChar)>::TypeInt TypeInt; };
|
||||
template<> class ZtCCharInt<char >
|
||||
{ public: typedef typename ZtCCharIntBySize<sizeof(char) >::TypeInt TypeInt; };
|
||||
template<> class ZtCCharInt<wchar_t>
|
||||
{ public: typedef typename ZtCCharIntBySize<sizeof(wchar_t) >::TypeInt TypeInt; };
|
||||
|
||||
|
||||
template<typename TTyChar, typename TTyiLength> ZTypIntE ZftGetCompareCode
|
||||
@ -3814,6 +3804,78 @@ namespace ZNsMain
|
||||
inline double ZfAtoD(const char* ApcChar)*/
|
||||
|
||||
|
||||
/*#############################################################################
|
||||
|
||||
■ #include <wchar.h>
|
||||
long int wcstol(const wchar_t *nptr, wchar_t **endptr, int base);
|
||||
|
||||
#include <wchar.h>
|
||||
long long int wcstoll(const wchar_t *nptr, wchar_t **endptr, int base);
|
||||
|
||||
|
||||
float wcstof ( const wchar_t* str, wchar_t** str_end ); (since C++11)
|
||||
double wcstod ( const wchar_t* str, wchar_t** str_end );
|
||||
long double wcstold( const wchar_t* str, wchar_t** str_end ); (since C++11)
|
||||
|
||||
-- 2025-10-08 09:23
|
||||
#############################################################################*/
|
||||
template<typename TTypChar> inline
|
||||
ZTypInt ZftAtoI (const TTypChar* ApcChar){ return 0; }
|
||||
template<> inline
|
||||
ZTypInt ZftAtoI (const char* ApcChar){ return ZfAtoI(ApcChar); }
|
||||
template<> inline
|
||||
ZTypInt ZftAtoI (const wchar_t* ApcChar){ return (ZTypInt)::wcstol(ApcChar, 0, 0) ; }
|
||||
|
||||
template<typename TTypChar> inline
|
||||
ZTypLong ZftAtoL (const TTypChar* ApcChar){ return 0; }
|
||||
template<> inline
|
||||
ZTypLong ZftAtoL (const char* ApcChar){ return ZfAtoI(ApcChar); }
|
||||
template<> inline
|
||||
ZTypLong ZftAtoL (const wchar_t* ApcChar){ return ::wcstol(ApcChar, 0, 0) ; }
|
||||
|
||||
template<typename TTypChar> inline
|
||||
ZTypLLong ZftAtoLL(const TTypChar* ApcChar){ return 0; }
|
||||
template<> inline
|
||||
ZTypLLong ZftAtoLL(const char* ApcChar){ return ZfAtoLL(ApcChar); }
|
||||
template<> inline
|
||||
ZTypLLong ZftAtoLL(const wchar_t* ApcChar){ return ::wcstoll(ApcChar, 0, 0) ; }
|
||||
|
||||
template<typename TTypChar> inline
|
||||
double ZftAtoD (const TTypChar* ApcChar){ return 0; }
|
||||
template<> inline
|
||||
double ZftAtoD (const char* ApcChar){ return ZfAtoD(ApcChar); }
|
||||
template<> inline
|
||||
double ZftAtoD (const wchar_t* ApcChar){ return ::wcstod(ApcChar, 0) ; }
|
||||
|
||||
|
||||
template<typename TTypChar> inline
|
||||
ZTypInt ZftAtoI (const TTypChar* ApcChar, ZTypInt AI_Length){ return 0; }
|
||||
template<> inline
|
||||
ZTypInt ZftAtoI (const char* ApcChar, ZTypInt AI_Length){ return ZfAtoI(ApcChar); }
|
||||
template<> inline
|
||||
ZTypInt ZftAtoI (const wchar_t* ApcChar, ZTypInt AI_Length){ return (ZTypInt)::wcstol(ApcChar, 0, 0) ; }
|
||||
|
||||
template<typename TTypChar> inline
|
||||
ZTypLong ZftAtoL (const TTypChar* ApcChar, ZTypInt AI_Length){ return 0; }
|
||||
template<> inline
|
||||
ZTypLong ZftAtoL (const char* ApcChar, ZTypInt AI_Length){ return ZfAtoI(ApcChar); }
|
||||
template<> inline
|
||||
ZTypLong ZftAtoL (const wchar_t* ApcChar, ZTypInt AI_Length){ return ::wcstol(ApcChar, 0, 0) ; }
|
||||
|
||||
template<typename TTypChar> inline
|
||||
ZTypLLong ZftAtoLL(const TTypChar* ApcChar, ZTypInt AI_Length){ return 0; }
|
||||
template<> inline
|
||||
ZTypLLong ZftAtoLL(const char* ApcChar, ZTypInt AI_Length){ return ZfAtoLL(ApcChar); }
|
||||
template<> inline
|
||||
ZTypLLong ZftAtoLL(const wchar_t* ApcChar, ZTypInt AI_Length){ return ::wcstoll(ApcChar, 0, 0) ; }
|
||||
|
||||
template<typename TTypChar> inline
|
||||
double ZftAtoD (const TTypChar* ApcChar, ZTypInt AI_Length){ return 0; }
|
||||
template<> inline
|
||||
double ZftAtoD (const char* ApcChar, ZTypInt AI_Length){ return ZfAtoD(ApcChar); }
|
||||
template<> inline
|
||||
double ZftAtoD (const wchar_t* ApcChar, ZTypInt AI_Length){ return ::wcstod(ApcChar, 0) ; }
|
||||
|
||||
|
||||
|
||||
inline ZTypLLong AtoLL(const char* ApcChar){return ZfAtoLL(ApcChar);}
|
||||
@ -3837,9 +3899,9 @@ namespace ZNsMain
|
||||
|
||||
ZTypLength VL_Length=0;
|
||||
|
||||
while(*(ApcChar+VL_Length)!=_T('\0'))
|
||||
while(*(ApcChar+VL_Length)!=TTypeCh('\0'))
|
||||
++VL_Length;
|
||||
/*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
|
||||
/*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
|
||||
|
||||
return VL_Length;
|
||||
}/*
|
||||
|
@ -1300,12 +1300,12 @@ namespace ZNsMain
|
||||
bool operator<=(TypeCharC* APC_Data) const{return Minus(APC_Data)<=0 ;}
|
||||
bool operator< (TypeCharC* APC_Data) const{return Minus(APC_Data)< 0 ;}
|
||||
|
||||
bool operator==(const ZCStringBase& rhs) const{return Minus(rhs.data(), rhs.GetUseLength())==0 ;}
|
||||
bool operator!=(const ZCStringBase& rhs) const{return Minus(rhs.data(), rhs.GetUseLength())!=0 ;}
|
||||
bool operator> (const ZCStringBase& rhs) const{return Minus(rhs)> 0;}
|
||||
bool operator>=(const ZCStringBase& rhs) const{return Minus(rhs)>=0;}
|
||||
bool operator< (const ZCStringBase& rhs) const{return Minus(rhs)< 0;}
|
||||
bool operator<=(const ZCStringBase& rhs) const{return Minus(rhs)<=0;}
|
||||
bool operator==(const ZCStringBase& rhs ) const{return Minus(rhs.data(), rhs.GetUseLength())==0 ;}
|
||||
bool operator!=(const ZCStringBase& rhs ) const{return Minus(rhs.data(), rhs.GetUseLength())!=0 ;}
|
||||
bool operator> (const ZCStringBase& rhs ) const{return Minus(rhs)> 0;}
|
||||
bool operator>=(const ZCStringBase& rhs ) const{return Minus(rhs)>=0;}
|
||||
bool operator< (const ZCStringBase& rhs ) const{return Minus(rhs)< 0;}
|
||||
bool operator<=(const ZCStringBase& rhs ) const{return Minus(rhs)<=0;}
|
||||
|
||||
bool operator==(const ZCChars& AR_CChars) const{return Minus(AR_CChars.data(), AR_CChars.size())==0 ;}
|
||||
bool operator!=(const ZCChars& AR_CChars) const{return Minus(AR_CChars.data(), AR_CChars.size())!=0 ;}
|
||||
@ -1928,36 +1928,23 @@ namespace ZNsMain
|
||||
}/*
|
||||
bool IsEmpty() const*/
|
||||
|
||||
int GetInt () const{return ZNsMain::ZfAtoI (mpc_Data);}
|
||||
ZTypLong GetLong () const{return ZNsMain::ZfAtoL (mpc_Data);}
|
||||
ZTypLLong GetLongLong() const{return ZNsMain::ZfAtoLL(mpc_Data);}
|
||||
ZTypLLong GetLLong () const{return ZNsMain::ZfAtoLL(mpc_Data);}
|
||||
double GetDouble () const{return ZNsMain::ZfAtoD (mpc_Data);}
|
||||
|
||||
ZCStringBase& ConvertLLong()
|
||||
{
|
||||
ZNsMain::ZTypLLong LLongValue = ZNsMain::ZfAtoLL(mpc_Data);
|
||||
|
||||
this->Invalid(); return (*this)(LLongValue);
|
||||
}/*
|
||||
ZCStringBase& ConvertLLong()*/
|
||||
|
||||
ZCStringBase& ConvertLong()
|
||||
{
|
||||
ZNsMain::ZTypLLong LongValue = ZNsMain::ZfAtoL(mpc_Data);
|
||||
|
||||
this->Invalid(); return (*this)(LongValue);
|
||||
}/*
|
||||
ZCStringBase& ConvertLong()*/
|
||||
int GetInt () const{return ZNsMain::ZftAtoI (mpc_Data);}
|
||||
ZTypLong GetLong () const{return ZNsMain::ZftAtoL (mpc_Data);}
|
||||
ZTypLLong GetLongLong() const{return ZNsMain::ZftAtoLL(mpc_Data);}
|
||||
ZTypLLong GetLLong () const{return ZNsMain::ZftAtoLL(mpc_Data);}
|
||||
double GetDouble () const{return ZNsMain::ZftAtoD (mpc_Data);}
|
||||
|
||||
|
||||
ZCStringBase& Format(TypeCharC* APC_Format, ...)
|
||||
{
|
||||
// 이 함수 수행전에 적당한 문자열 메모리가 할당되어 있어야 한다.
|
||||
|
||||
va_list VP_VarParam;
|
||||
va_list VP_VarParam;
|
||||
va_start(VP_VarParam, APC_Format);
|
||||
vsprintf(mpc_Data, APC_Format, VP_VarParam);
|
||||
|
||||
if(sizeof(TypeChar)<=1)
|
||||
::vsprintf ((char* )mpc_Data, /*+++*/ (char* )APC_Format, VP_VarParam);
|
||||
else ::vswprintf((wchar_t*)mpc_Data, size(), (wchar_t*)APC_Format, VP_VarParam);
|
||||
|
||||
InvalidNull(); return *this;
|
||||
}/*
|
||||
@ -1969,9 +1956,12 @@ namespace ZNsMain
|
||||
|
||||
ReAllocKeep(ml_UseLen+AL_FormatSize);
|
||||
|
||||
va_list VP_VarParam;
|
||||
va_start( VP_VarParam, APC_Format);
|
||||
vsprintf(mpc_Data+ml_UseLen, APC_Format, VP_VarParam);
|
||||
va_list VP_VarParam;
|
||||
va_start(VP_VarParam, APC_Format);
|
||||
|
||||
if(sizeof(TypeChar)<=1)
|
||||
::vsprintf ((char* )mpc_Data, /*+++*/ (char* )APC_Format, VP_VarParam);
|
||||
else ::vswprintf((wchar_t*)mpc_Data, size(), (wchar_t*)APC_Format, VP_VarParam);
|
||||
|
||||
InvalidNull(ml_UseLen); return *this;
|
||||
}/*
|
||||
|
@ -62,6 +62,34 @@ namespace ZNsMain
|
||||
}/*
|
||||
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 /////////////
|
||||
(
|
||||
@ -457,6 +485,13 @@ namespace ZNsMain
|
||||
}/*
|
||||
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
|
||||
|
@ -20,7 +20,8 @@ namespace ZNsMain
|
||||
|
||||
typedef ZtCStringBase<char> ZCStringBase ;
|
||||
typedef ZtCStringBase<wchar_t> ZCStringBaseW ;
|
||||
typedef ZCStringBase::ZCCharView ZCCharView ;
|
||||
typedef ZCStringBase ::ZCCharView ZCCharView ;
|
||||
typedef ZCStringBaseW::ZCCharView ZCCharViewW ;
|
||||
typedef ZtCCharType<ZCStringBase> ZCCharType ;
|
||||
typedef ZtCCharType<ZCStringBaseW> ZCCharTypeW ;
|
||||
|
||||
@ -61,19 +62,35 @@ namespace ZNsMain
|
||||
ZCStringBaseW VO_ZCStringBaseW;
|
||||
ZCStringStdW VO_ZCStringStdW ;
|
||||
|
||||
VO_ZCStringBaseW(123);
|
||||
cout<<"* after VO_ZCStringBaseW(123)"<<endl;
|
||||
cout<<"# '.' ascii code ="<<int('.')<<endl;
|
||||
cout<<"*****************************************************"<<endl;
|
||||
|
||||
VO_ZCStringBaseW=123;
|
||||
cout<<"* after VO_ZCStringBaseW=123"<<endl;
|
||||
cout<<"# VO_ZCStringBaseW[0]="<<int(VO_ZCStringBaseW[0])<<endl;
|
||||
cout<<"# VO_ZCStringBaseW[1]="<<int(VO_ZCStringBaseW[1])<<endl;
|
||||
cout<<"# VO_ZCStringBaseW[2]="<<int(VO_ZCStringBaseW[2])<<endl;
|
||||
cout<<"*****************************************************"<<endl;
|
||||
cout<<"# VO_ZCStringBaseW.GetLong()="<<VO_ZCStringBaseW.GetLong()<<endl;
|
||||
cout<<"*****************************************************"<<endl;
|
||||
|
||||
VO_ZCStringStdW(1.2);
|
||||
cout<<"* after VO_ZCStringStdW(1.2)"<<endl;
|
||||
VO_ZCStringBaseW=2.3;
|
||||
cout<<"* after VO_ZCStringBaseW=2.3"<<endl;
|
||||
cout<<"# VO_ZCStringBaseW[0]="<<int(VO_ZCStringBaseW[0])<<endl;
|
||||
cout<<"# VO_ZCStringBaseW[1]="<<int(VO_ZCStringBaseW[1])<<endl;
|
||||
cout<<"# VO_ZCStringBaseW[2]="<<int(VO_ZCStringBaseW[2])<<endl;
|
||||
cout<<"*****************************************************"<<endl;
|
||||
cout<<"# VO_ZCStringBaseW.GetDouble()="<<VO_ZCStringBaseW.GetDouble()<<endl;
|
||||
cout<<"*****************************************************"<<endl;
|
||||
|
||||
VO_ZCStringStdW=1.2;
|
||||
cout<<"* after VO_ZCStringStdW=1.2"<<endl;
|
||||
cout<<"# VO_ZCStringStdW [0]="<<int(VO_ZCStringStdW[0])<<endl;
|
||||
cout<<"# VO_ZCStringStdW [1]="<<int(VO_ZCStringStdW[1])<<endl;
|
||||
cout<<"# VO_ZCStringStdW [2]="<<int(VO_ZCStringStdW[2])<<endl;
|
||||
cout<<"*****************************************************"<<endl;
|
||||
cout<<"# VO_ZCStringStdW.GetDouble()="<<VO_ZCStringStdW.GetDouble()<<endl;
|
||||
cout<<"*****************************************************"<<endl;
|
||||
|
||||
|
||||
const ZCCharView CO_ZCCharView("1234AA5678AA90abcAAss");
|
||||
@ -113,6 +130,7 @@ namespace ZNsMain
|
||||
|
||||
|
||||
ZftMakeStr(VO_ZCStringStd, 1234);
|
||||
ZftMakeStr(VO_ZCStringStd, ZCCharView("--"));
|
||||
ZftMakeStr(VO_ZCStringStd, double(10.01));
|
||||
ZftMakeStr(VO_ZCStringStd, true);
|
||||
ZftMakeStr(VO_ZCStringStd,'Z');
|
||||
@ -143,6 +161,11 @@ namespace ZNsMain
|
||||
cout<<"# "<<VO_ZCStringStd<<endl;
|
||||
cout<<"*****************************************************"<<endl;
|
||||
|
||||
cout<<"* after ()(ZCCharViewW('_AZ'))"<<endl;
|
||||
VO_ZCStringStd(ZCCharView("_AZ"));
|
||||
cout<<"# "<<VO_ZCStringStd<<endl;
|
||||
cout<<"*****************************************************"<<endl;
|
||||
|
||||
|
||||
return 0;
|
||||
}/*
|
||||
|
Reference in New Issue
Block a user