commit 2025-08-21 13:57 edit a bit ZMainHead.H

This commit is contained in:
2025-08-21 13:57:12 +09:00
parent 9d407559ca
commit 0610328f2f
2 changed files with 54 additions and 141 deletions

View File

@ -2338,14 +2338,14 @@ namespace ZNsMain
// 절대값을 가져온다.
template<typename TLong> TLong ABS(TLong AL_Value)
template<typename TLong> TLong ZfABS(TLong AL_Value)
{
if(AL_Value<0) return -AL_Value; return AL_Value;
}/*
template<typename TLong> TLong ABS(TLong AL_Value) */
template<typename TLong> TLong ZfABS(TLong AL_Value) */
template<typename TypeInt>
TypeInt AToInt(const char* ApcChar, ZTypIntI AI_Length)
TypeInt ZfAToInt(const char* ApcChar, ZTypIntI AI_Length)
{
if(AI_Length<1) return 0;
@ -2371,64 +2371,80 @@ namespace ZNsMain
return VL_Result;
}/*
template<typename TypeInt>
TypeInt AToInt(const char* ApcChar, ZTypIntI AI_Length) */
TypeInt ZfAToInt(const char* ApcChar, ZTypIntI AI_Length) */
#ifdef _WIN
inline ZTypLLong ATOLL(const char* ApcChar)
inline ZTypLLong ZfATOLL(const char* ApcChar)
{
if(ApcChar==0) return 0; return ::_atoi64(ApcChar);
}/*
inline ZTypLLong ATOLL(const char* ApcChar)*/
inline ZTypLLong ZfATOLL(const char* ApcChar)*/
#else // !defined(_WIN)
inline ZTypLLong ATOLL(const char* ApcChar)
inline ZTypLLong ZfATOLL(const char* ApcChar)
{
if(ApcChar==0) return 0; return ::atoll(ApcChar);
}/*
inline ZTypLLong ATOLL(const char* ApcChar)*/
inline ZTypLLong ZfATOLL(const char* ApcChar)*/
#endif // !defined(_WIN)
inline ZTypLLong ATOLL(const char* ApcChar, ZTypIntI AI_Length)
inline ZTypLLong ZfATOLL(const char* ApcChar, ZTypIntI AI_Length)
{
return AToInt<ZTypLLong>(ApcChar, AI_Length);
return ZfAToInt<ZTypLLong>(ApcChar, AI_Length);
}/*
inline ZTypLLong ATOL(const char* ApcChar, ZTypIntI AI_Length)*/
inline ZTypLLong ZfATOL(const char* ApcChar, ZTypIntI AI_Length)*/
inline ZTypLong ATOL(const char* ApcChar)
inline ZTypLong ZfATOL(const char* ApcChar)
{
if(ApcChar==0) return 0; return atol(ApcChar);
if(ApcChar==0) return 0; return ::atol(ApcChar);
}/*
inline ZTypLong ATOL(const char* ApcChar)*/
inline ZTypLong ZfATOL(const char* ApcChar)*/
inline ZTypLong ATOL(const char* ApcChar, ZTypIntI AI_Length)
inline ZTypLong ZfATOL(const char* ApcChar, ZTypIntI AI_Length)
{
return AToInt<ZTypLong>(ApcChar, AI_Length);
return ZfAToInt<ZTypLong>(ApcChar, AI_Length);
}/*
inline ZTypLong ATOL(const char* ApcChar, ZTypIntI AI_Length)*/
inline ZTypLong ZfATOL(const char* ApcChar, ZTypIntI AI_Length)*/
inline ZTypIntI ATOI(const char* ApcChar)
inline ZTypIntI ZfATOI(const char* ApcChar)
{
if(ApcChar==0) return 0; return atoi(ApcChar);
if(ApcChar==0) return 0; return ::atoi(ApcChar);
}/*
inline ZTypIntI ATOI(const char* ApcChar)*/
inline ZTypIntI ZfATOI(const char* ApcChar)*/
inline ZTypIntI ATOI(const char* ApcChar, ZTypIntI AI_Length)
inline ZTypIntI ZfATOI(const char* ApcChar, ZTypIntI AI_Length)
{
return AToInt<ZTypIntI>(ApcChar, AI_Length);
return ZfAToInt<ZTypIntI>(ApcChar, AI_Length);
}/*
inline ZTypIntI ATOI(const char* ApcChar, ZTypIntI AI_Length)*/
inline ZTypIntI ZfATOI(const char* ApcChar, ZTypIntI AI_Length)*/
inline double ATOD(const char* ApcChar)
inline double ZfATOD(const char* ApcChar)
{
return ApcChar==0 ? 0 : ::atof(ApcChar) ;
}/*
inline double ATOD(const char* ApcChar)*/
inline double ZfATOD(const char* ApcChar)*/
inline ZTypLLong ATOLL(const char* ApcChar){return ZfATOLL(ApcChar);}
inline ZTypLong ATOL (const char* ApcChar){return ZfATOL (ApcChar);}
inline ZTypIntI ATOI (const char* ApcChar){return ZfATOI (ApcChar);}
inline double ATOD (const char* ApcChar){return ZfATOD (ApcChar);}
inline ZTypLLong ATOLL(const char* ApcChar, ZTypIntI AI_Length)
{ return ZfAToInt<ZTypLLong>(ApcChar, AI_Length); }
inline ZTypLong ATOL (const char* ApcChar, ZTypIntI AI_Length)
{ return ZfAToInt<ZTypLong >(ApcChar, AI_Length); }
inline ZTypIntI ATOI (const char* ApcChar, ZTypIntI AI_Length)
{ return ZfAToInt<ZTypIntI >(ApcChar, AI_Length); }
template<typename TTypeCh>

View File

@ -1305,7 +1305,7 @@ namespace ZNsMain
{
const int CI_BuffSize=21; char VCA_BuffParam[CI_BuffSize];
int VI_ResultSize=::sprintf(VCA_BuffParam, "%d", AI_IntParam);
int VI_ResultSize = ::sprintf(VCA_BuffParam, "%d", AI_IntParam);
return (*this)(VCA_BuffParam, VI_ResultSize);
}/*
@ -1325,7 +1325,7 @@ namespace ZNsMain
{
const int CI_BuffSize=31; char VCA_BuffParam[CI_BuffSize];
int VI_ResultSize=::sprintf(VCA_BuffParam, "%ld", AL_LongParam);
int VI_ResultSize = ::sprintf(VCA_BuffParam, "%ld", AL_LongParam);
return (*this)(VCA_BuffParam, VI_ResultSize);
}/*
@ -1346,9 +1346,9 @@ namespace ZNsMain
const int CI_BuffSize=41; char VCA_BuffParam[CI_BuffSize];
#ifdef _WIN
int VI_ResultSize=::sprintf(VCA_BuffParam, "%I64d", ALL_LLongParam);
int VI_ResultSize = ::sprintf(VCA_BuffParam, "%I64d", ALL_LLongParam);
#else
int VI_ResultSize=::sprintf(VCA_BuffParam, "%lld" , ALL_LLongParam);
int VI_ResultSize = ::sprintf(VCA_BuffParam, "%lld" , ALL_LLongParam);
#endif
return (*this)(VCA_BuffParam, VI_ResultSize);
@ -1360,9 +1360,9 @@ namespace ZNsMain
const int CI_BuffSize=41; char VCA_BuffParam[CI_BuffSize];
#ifdef _WIN
int VI_ResultSize=::sprintf(VCA_BuffParam, "%I64u", AULL_LLongParam);
int VI_ResultSize = ::sprintf(VCA_BuffParam, "%I64u", AULL_LLongParam);
#else
int VI_ResultSize=::sprintf(VCA_BuffParam, "%llu" , AULL_LLongParam);
int VI_ResultSize = ::sprintf(VCA_BuffParam, "%llu" , AULL_LLongParam);
#endif
return (*this)(VCA_BuffParam, VI_ResultSize);
@ -1410,108 +1410,6 @@ namespace ZNsMain
TypeLength AL_AddSize, TypeCharC* APC_Format, ...)*/
ZCStringBase& AddInt4Byte(ZNsMain::ZTypLong AUL_LongType)
{
/*////////////////////////////////////////////////////////////////////////////////////////
■ ULongType 을 4 바이트의 비트 그대로 붙인다. 붙일때 big endian 으로 한다. big endian 이
인간의 표현과 일치한다. 즉 주소가 증가하는 순서로 메모리에 저장된다.
little endian 의 경우 4 바이트 정수형의 주소를 p 라 하면 p[3],p[2],p[1],p[0] 의 순서다.
■ AddInt~Byte 류의 멤버함수는 최적화의 여지가 있다.
////////////////////////////////////////////////////////////////////////////////////////*/
const int CI_AddSize =4;
const int CI_BitOfByte=8;
const int CI_LongByte =sizeof(ZNsMain::ZTypLong);
const bool CB_DoKeepString= true; ReAllocAdd
( CI_AddSize, CB_DoKeepString );
/*<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
TypeChar* VPC_Start=mpc_Data+ml_UseLen;
int i=CI_AddSize; /////////////////////
while(i>CI_LongByte)
{
*VPC_Start++ = 0 ; --i; // CI_AddSize>sizeof(TypeLength) 일 때는 대비.
}/*
while(i>CI_LongByte)*/
while(i>=1)
{
*VPC_Start++ = ////////////////////////////
(
( AUL_LongType << ((CI_LongByte-i)*CI_BitOfByte) ) >>
( (CI_LongByte-1)*CI_BitOfByte)
) ;
///////////////////////////////////////////
--i;
}/*
while(i>=1)*/
*VPC_Start=0; ml_UseLen += CI_AddSize ; return *this;
}/*
ZCStringBase& AddInt4Byte(ZNsMain::ZTypLong AUL_LongType)*/
ZCStringBase& AddInt8Byte(ZNsMain::ZTypLLong ALL_LLongType)
{
// ULongType 을 8 바이트의 비트 그대로 붙인다.
// 붙일 때 big endian 으로 한다.
const int CI_AddSize =8;
const int CI_BitOfByte =8;
const int CI_LLongByte =sizeof(ZNsMain::ZTypLLong);
ReAllocAdd(CI_AddSize, true); /*>>>>>>>>>>>>>>>>>>>>>>>>*/
TypeChar* VPC_Start=mpc_Data+ml_UseLen; int i=CI_AddSize;
while(i>CI_LLongByte)
{
*VPC_Start++ = 0 ; --i;
}/*
while(i>CI_LLongByte)*/
while(i>=1)
{
*VPC_Start++ = //////////////////////////////
(
( ALL_LLongType << ((CI_LLongByte-i)*CI_BitOfByte) ) >>
( (CI_LLongByte-1)*CI_BitOfByte )
) ;
/////////////////////////////////////////////
--i;
}/*
while(i>=1)*/
*VPC_Start=0; ml_UseLen += CI_AddSize; return *this;
}/*
ZCStringBase& AddInt8Byte(TypeLength ALL_LLongType)*/
ZCStringBase& AddInt2Byte(ZNsMain::ZTypInt AI_IntType)
{
const int CI_AddSize =2;
const int CI_BitOfByte=8;
const int CI_IntByte =sizeof(ZNsMain::ZTypInt);
ReAllocAdd(CI_AddSize,true);
TypeChar* VPC_Start=mpc_Data+ml_UseLen;
*VPC_Start++ = ( ( AI_IntType << ((CI_IntByte-2)*CI_BitOfByte) ) >> ((CI_IntByte-1)*CI_BitOfByte) ) ;
*VPC_Start++ = ( ( AI_IntType << ((CI_IntByte-1)*CI_BitOfByte) ) >> ((CI_IntByte-1)*CI_BitOfByte) ) ;
*VPC_Start=0; ml_UseLen += CI_AddSize; return *this;
}/*
ZCStringBase& AddInt2Byte(ZNsMain::ZTypInt AI_IntType)*/
template<typename TObject> ZCStringBase& AddObject(TObject& AR_CObject)
{
@ -1740,11 +1638,11 @@ namespace ZNsMain
}/*
bool IsEmpty() const*/
int GetInt () const{return ZNsMain::ATOI (mpc_Data);}
ZTypLong GetLong () const{return ZNsMain::ATOL (mpc_Data);}
ZTypLLong GetLongLong() const{return ZNsMain::ATOLL(mpc_Data);}
ZTypLLong GetLLong () const{return ZNsMain::ATOLL(mpc_Data);}
double GetDouble () const{return ZNsMain::ATOD (mpc_Data);}
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()
{
@ -7896,9 +7794,8 @@ namespace ZNsMain
{
// TyUInt 은 unsigned 형이어야 한다.
const int CI_Byte=sizeof(TyUInt)*8;
TyUInt VUI_Value=(0x01)<<(CI_Byte-1);
const int CI_Byte = sizeof(TyUInt)*8 ;
TyUInt VUI_Value = (0x01)<<(CI_Byte-1);
for(int i=1; i<CI_Byte; ++i)
{