commit 2025-09-03 23:57 ZCppMain/ZtCMainChars.H of ZtCMainChars.H => ZtCChars of ZCppMain/ZMainHead.H

This commit is contained in:
2025-09-03 23:57:28 +09:00
parent 6a3b673a19
commit 37df093b7a
2 changed files with 277 additions and 297 deletions

View File

@ -4227,6 +4227,272 @@ namespace ZNsMain
class ZtCList /*######################################*/
namespace ZNsChars
{
template<typename TTypeChars> class ZtCMainChars;
}/*
namespace ZNsChars*/
template< typename TTypeChar, typename TTypeLength=ZTypLength
>
class ZtCChars /**#########################################*/
{
public :
template<typename TTypeChars>
friend class ZNsChars::ZtCMainChars ;
public :
typedef TTypeChar TypeChar ;
typedef TTypeLength TypeLength ;
public:
typedef const TTypeChar TypeCharC ;
typedef const TTypeChar* TypeCharCP ;
private:
TypeChar* mp_TypeChar ;
TypeLength ml_TypeLength;
public :
ZtCChars()
{
mp_TypeChar =0;
ml_TypeLength=0;
}/*
ZtCChars()*/
ZtCChars(TypeCharC* APC_TypeChar)
{
mp_TypeChar =
const_cast<TypeChar*> (APC_TypeChar);
ml_TypeLength = ZftGetLength(mp_TypeChar );
}/*
ZtCChars(TypeCharC* APC_TypeChar)*/
ZtCChars(TypeCharC* APC_TypeChar, TypeLength AL_Length)
{
mp_TypeChar = const_cast
<TypeChar*>(APC_TypeChar) ;
ml_TypeLength= AL_Length ;
}/*
ZtCChars(TypeCharC* APC_TypeChar, TypeLength AL_Length)*/
void Init()
{
mp_TypeChar = 0;
ml_TypeLength= 0;
}/*
void Init()*/
void Init(TypeCharC* APC_TypeChar)
{
mp_TypeChar =
const_cast<TypeChar*> (APC_TypeChar);
ml_TypeLength= ZftGetLength(mp_TypeChar );
}/*
void Init(TypeCharC* APC_TypeChar)*/
void Init(TypeCharC* APC_TypeChar, TypeLength AL_Length)
{
mp_TypeChar =const_cast
<TypeChar*>(APC_TypeChar) ;
ml_TypeLength=AL_Length ;
}/*
void Init(TypeCharC* APC_TypeChar, TypeLength AL_Length)*/
void InitData(TypeCharC* APC_TypeChar)
{
mp_TypeChar=const_cast<TypeChar*>(APC_TypeChar);
}/*
void InitData(TypeCharC* APC_TypeChar)*/
void InitLength(TypeLength AL_Length)
{
ml_TypeLength=AL_Length;
}/*
void InitLength(TypeLength AL_Length)*/
TypeChar* data() {return mp_TypeChar ;}
TypeCharC* data() const{return mp_TypeChar ;}
TypeLength size() const{return ml_TypeLength;}
ZtCChars& operator+=(TypeLength AI_MovePos)
{
return MoveChar(AI_MovePos);
}/*
ZtCChars& operator+=(TypeLength AI_MovePos)*/
int operator-(const ZtCChars& rhs) const
{
// 두 문자열이 같으면 0
// 왼쪽 문자열이 크면 0 보다 큰 어떤 수
// 오른쪽 문자열이 크면 0 보다 작은 어떤 수를 반환
TypeCharC* VP_Left = mp_TypeChar;
TypeCharC* VP_Right=rhs.mp_TypeChar;
#if(_CODE_OLD_)
TypeChar VC_Minus=0;
#else
int VI_Minus=0; // 페이지 하단의 'char 의 int 확장에 따른 문제의 코드' 참고.
#endif
TypeLength VL_Index=0;
TypeLength VL_Loop =(ml_TypeLength<=rhs.ml_TypeLength ? ml_TypeLength : rhs.ml_TypeLength) ;
while(VL_Index<VL_Loop)
{
#if(_CODE_OLD_)
if((VC_Minus=*VP_Left++ - *VP_Right++)!=0)
{
return VC_Minus;
}/*
if((VC_Minus=*VP_Left++ - *VP_Right++)!=0)*/
#else
if((VI_Minus=int(*VP_Left++) - int(*VP_Right++))!=0)
{
return VI_Minus; // 페이지 하단의 'char 의 int 확장에 따른 문제의 코드' 참고.
}/*
if((VI_Minus=int(*VP_Left++) - int(*VP_Right++))!=0)*/
#endif
++VL_Index;
}/*
while(VL_Index<VL_Loop)*/
return ml_TypeLength-rhs.ml_TypeLength;
}/*
int operator-(const ZtCChars& rhs) const*/
bool operator==(const ZtCChars& rhs) const{return (*this)-rhs == 0 ;}
bool operator> (const ZtCChars& rhs) const{return (*this)-rhs > 0 ;}
bool operator< (const ZtCChars& rhs) const{return (*this)-rhs < 0 ;}
bool operator>=(const ZtCChars& rhs) const{return (*this)-rhs >= 0 ;}
bool operator<=(const ZtCChars& rhs) const{return (*this)-rhs <= 0 ;}
ZtCChars& MoveChar(TypeLength AI_MovePos)
{
mp_TypeChar += AI_MovePos ;
ml_TypeLength -= AI_MovePos ;
return *this;
}/*
ZtCChars& MoveChar(TypeLength AI_MovePos)*/
ZTypIntI GetInt(bool AB_IsBigEndian=true) const
{
const ZTypIntI CI_IntByte = sizeof(ZTypIntI);
const ZTypIntI CI_SearchSize =
(ml_TypeLength<CI_IntByte ? ml_TypeLength : CI_IntByte) ;
ZTypIntI VI_Result =0;
ZTypIntI VI_TempInt=1;
if(AB_IsBigEndian)
{
for(ZTypIntI i=CI_SearchSize-1; i>=0; --i)
{
VI_Result += (ZTypIntI)(ZTypUChar)(mp_TypeChar[i]) * VI_TempInt ;
VI_TempInt*= 256 ;
}/*
for(ZTypIntI i=CI_SearchSize-1; i>=0; --i)*/
return VI_Result;
}/*
if(AB_IsBigEndian)*/
for(ZTypIntI i=0; i<CI_SearchSize; ++i)
{
VI_Result += (ZTypIntI)(ZTypUChar)(mp_TypeChar[i]) * VI_TempInt ;
VI_TempInt*= 256 ;
}/*
for(ZTypIntI i=0; i<CI_SearchSize; ++i)*/
return VI_Result;
}/*
ZTypIntI GetInt(bool AB_IsBigEndian=true) const*/
ZTypIntL GetLong(bool AB_IsBigEndian=true) const
{
const ZTypIntI CI_IntByte = sizeof(ZTypIntL);
const ZTypIntI CI_SearchSize =
(ml_TypeLength<CI_IntByte ? ml_TypeLength : CI_IntByte) ;
ZTypIntL VI_Result =0;
ZTypIntL VI_TempInt=1;
if(AB_IsBigEndian)
{
for(ZTypIntI i=CI_SearchSize-1; i>=0; --i)
{
VI_Result += (ZTypIntI)(ZTypUChar)(mp_TypeChar[i]) * VI_TempInt ;
VI_TempInt *= 256 ;
}/*
for(ZTypIntI i=CI_SearchSize-1; i>=0; --i)*/
return VI_Result;
}/*
if(AB_IsBigEndian)*/
for(ZTypIntI i=0; i<CI_SearchSize; ++i)
{
VI_Result += (ZTypIntI)(ZTypUChar)(mp_TypeChar[i]) * VI_TempInt ;
VI_TempInt *= 256 ;
}/*
for(ZTypIntI i=0; i<CI_SearchSize; ++i)*/
return VI_Result;
}/*
ZTypIntL GetLong(bool AB_IsBigEndian=true) const*/
ZTypIntLL GetLLong(bool AB_IsBigEndian=true) const
{
const ZTypIntI CI_IntByte = sizeof(ZTypIntLL);
const ZTypIntI CI_SearchSize =
(ml_TypeLength<CI_IntByte ? ml_TypeLength : CI_IntByte) ;
ZTypIntLL VI_Result =0 ;
ZTypIntLL VI_TempInt =1 ;
if(AB_IsBigEndian)
{
for(ZTypIntI i=CI_SearchSize-1; i>=0; --i)
{
VI_Result += (ZTypIntI)(ZTypUChar)(mp_TypeChar[i]) * VI_TempInt ;
VI_TempInt *= 256 ;
}/*
for(ZTypIntI i=CI_SearchSize-1; i>=0; --i)*/
return VI_Result;
}/*
if(AB_IsBigEndian)*/
for(ZTypIntI i=0; i<CI_SearchSize; ++i)
{
VI_Result += (ZTypIntI)(ZTypUChar)(mp_TypeChar[i]) * VI_TempInt ;
VI_TempInt *= 256 ;
}/*
for(ZTypIntI i=0; i<CI_SearchSize; ++i)*/
return VI_Result;
}/*
ZTypIntLL GetLLong(bool AB_IsBigEndian=true) const*/
public:
};/*
template< typename TTypeChar, typename TTypeLength=ZTypLength
>
class ZtCChars /**#########################################*/
namespace ZNsView
{

View File

@ -193,11 +193,13 @@ namespace ZNsMain
class ZtCTypeChars /*////////////////////*/
{
public:
typedef TTypeChar TypeChar ;
typedef TTypeLength TypeLength; // signed 형이어야 한다.
typedef TTypeChar TypeChar ;
typedef TTypeLength TypeLength; // signed 형이어야 한다.
public:
typedef const TypeChar TypeCharC ;
typedef const TypeChar* TypeCharCP;
typedef const TypeChar TypeCharC ;
typedef const TypeChar* TypeCharCP;
public:
typedef ZNsMain::ZtCChars<TTypeChar, TTypeLength> ZCChars;
public:
static TypeChar GetCharOfAnsi(char AC_AnsiChar)
@ -223,15 +225,7 @@ namespace ZNsMain
static TypeLength GetLength(TypeCharC* APC_TypeChar)
{
if(APC_TypeChar==0) return 0; TypeLength VL_Length=0;
while(*(APC_TypeChar+VL_Length)!=ZtCTypeChars::GetCharOfAnsi('\0'))
{
++VL_Length;
}/*
while(*(APC_TypeChar+VL_Length)!=ZtCTypeChars::GetCharOfAnsi('\0'))*/
return VL_Length;
return ZNsMain::ZftGetLengthType<TypeLength, TypeCharC>(APC_TypeChar);
}/*
static TypeLength GetLength(TypeCharC* APC_TypeChar)
@ -240,287 +234,6 @@ namespace ZNsMain
public:
class ZCChars
{
public :
template<typename TTypeName> friend class ZtCMainChars;
public :
typedef ZtCTypeChars ZCTypeChars;
typedef TTypeChar TypeChar ;
typedef TTypeLength TypeLength ;
public:
typedef const TTypeChar TypeCharC ;
typedef const TTypeChar* TypeCharCP ;
private:
TypeChar* mp_TypeChar ;
TypeLength ml_TypeLength;
public :
ZCChars()
{
mp_TypeChar =0;
ml_TypeLength=0;
}/*
ZCChars()*/
ZCChars(TypeCharC* APC_TypeChar)
{
mp_TypeChar =const_cast<TypeChar*> (APC_TypeChar);
ml_TypeLength=ZtCTypeChars::GetLength(mp_TypeChar );
}/*
ZCChars(TypeCharC* APC_TypeChar)*/
ZCChars(TypeCharC* APC_TypeChar, TypeLength AL_Length)
{
mp_TypeChar = const_cast
<TypeChar*>(APC_TypeChar) ;
ml_TypeLength=AL_Length ;
}/*
ZCChars(TypeCharC* APC_TypeChar, TypeLength AL_Length)*/
void Init()
{
mp_TypeChar = 0;
ml_TypeLength= 0;
}/*
void Init()*/
void Init(TypeCharC* APC_TypeChar)
{
mp_TypeChar = const_cast<TypeChar*> (APC_TypeChar);
ml_TypeLength= ZtCTypeChars::GetLength(mp_TypeChar );
}/*
void Init(TypeCharC* APC_TypeChar)*/
void Init(TypeCharC* APC_TypeChar, TypeLength AL_Length)
{
mp_TypeChar =const_cast
<TypeChar*>(APC_TypeChar) ;
ml_TypeLength=AL_Length ;
}/*
void Init(TypeCharC* APC_TypeChar, TypeLength AL_Length)*/
void InitData(TypeCharC* APC_TypeChar)
{
mp_TypeChar=const_cast<TypeChar*>(APC_TypeChar);
}/*
void InitData(TypeCharC* APC_TypeChar)*/
void InitLength(TypeLength AL_Length)
{
ml_TypeLength=AL_Length;
}/*
void InitLength(TypeLength AL_Length)*/
TypeChar* data() {return mp_TypeChar ;}
TypeCharC* data() const{return mp_TypeChar ;}
TypeLength size() const{return ml_TypeLength;}
ZCChars& operator+=(TypeLength AI_MovePos)
{
return MoveChar(AI_MovePos);
}/*
ZCChars& operator+=(TypeLength AI_MovePos)*/
int operator-(const ZCChars& rhs) const
{
// 두 문자열이 같으면 0
// 왼쪽 문자열이 크면 0 보다 큰 어떤 수
// 오른쪽 문자열이 크면 0 보다 작은 어떤 수를 반환
TypeCharC* VP_Left = mp_TypeChar;
TypeCharC* VP_Right=rhs.mp_TypeChar;
#if(_CODE_OLD_)
TypeChar VC_Minus=0;
#else
int VI_Minus=0; // 페이지 하단의 'char 의 int 확장에 따른 문제의 코드' 참고.
#endif
TypeLength VL_Index=0;
TypeLength VL_Loop =(ml_TypeLength<=rhs.ml_TypeLength ? ml_TypeLength : rhs.ml_TypeLength) ;
while(VL_Index<VL_Loop)
{
#if(_CODE_OLD_)
if((VC_Minus=*VP_Left++ - *VP_Right++)!=0)
{
return VC_Minus;
}/*
if((VC_Minus=*VP_Left++ - *VP_Right++)!=0)*/
#else
if((VI_Minus=int(*VP_Left++) - int(*VP_Right++))!=0)
{
return VI_Minus; // 페이지 하단의 'char 의 int 확장에 따른 문제의 코드' 참고.
}/*
if((VI_Minus=int(*VP_Left++) - int(*VP_Right++))!=0)*/
#endif
++VL_Index;
}/*
while(VL_Index<VL_Loop)*/
return ml_TypeLength-rhs.ml_TypeLength;
}/*
int operator-(const ZCChars& rhs) const*/
bool operator==(const ZCChars& rhs) const{return (*this)-rhs == 0 ;}
bool operator> (const ZCChars& rhs) const{return (*this)-rhs > 0 ;}
bool operator< (const ZCChars& rhs) const{return (*this)-rhs < 0 ;}
bool operator>=(const ZCChars& rhs) const{return (*this)-rhs >= 0 ;}
bool operator<=(const ZCChars& rhs) const{return (*this)-rhs <= 0 ;}
ZCChars& MoveChar(TypeLength AI_MovePos)
{
mp_TypeChar +=AI_MovePos;
ml_TypeLength-=AI_MovePos;
return *this;
}/*
ZCChars& MoveChar(TypeLength AI_MovePos)*/
ZTypIntI GetInt(bool AB_IsBigEndian=true) const
{
const ZTypIntI CI_IntByte = sizeof(ZTypIntI);
const ZTypIntI CI_SearchSize =
(ml_TypeLength<CI_IntByte ? ml_TypeLength : CI_IntByte) ;
ZTypIntI VI_Result =0;
ZTypIntI VI_TempInt=1;
if(AB_IsBigEndian)
{
for(ZTypIntI i=CI_SearchSize-1; i>=0; --i)
{
VI_Result += (ZTypIntI)(ZTypUChar)(mp_TypeChar[i]) * VI_TempInt ;
VI_TempInt*= 256 ;
}/*
for(ZTypIntI i=CI_SearchSize-1; i>=0; --i)*/
return VI_Result;
}/*
if(AB_IsBigEndian)*/
for(ZTypIntI i=0; i<CI_SearchSize; ++i)
{
VI_Result += (ZTypIntI)(ZTypUChar)(mp_TypeChar[i]) * VI_TempInt ;
VI_TempInt*= 256 ;
}/*
for(ZTypIntI i=0; i<CI_SearchSize; ++i)*/
return VI_Result;
}/*
ZTypIntI GetInt(bool AB_IsBigEndian=true) const*/
ZTypIntL GetLong(bool AB_IsBigEndian=true) const
{
const ZTypIntI CI_IntByte = sizeof(ZTypIntL);
const ZTypIntI CI_SearchSize =
(ml_TypeLength<CI_IntByte ? ml_TypeLength : CI_IntByte) ;
ZTypIntL VI_Result =0;
ZTypIntL VI_TempInt=1;
if(AB_IsBigEndian)
{
for(ZTypIntI i=CI_SearchSize-1; i>=0; --i)
{
VI_Result += (ZTypIntI)(ZTypUChar)(mp_TypeChar[i]) * VI_TempInt ;
VI_TempInt *= 256 ;
}/*
for(ZTypIntI i=CI_SearchSize-1; i>=0; --i)*/
return VI_Result;
}/*
if(AB_IsBigEndian)*/
for(ZTypIntI i=0; i<CI_SearchSize; ++i)
{
VI_Result += (ZTypIntI)(ZTypUChar)(mp_TypeChar[i]) * VI_TempInt ;
VI_TempInt *= 256 ;
}/*
for(ZTypIntI i=0; i<CI_SearchSize; ++i)*/
return VI_Result;
}/*
ZTypIntL GetLong(bool AB_IsBigEndian=true) const*/
ZTypIntLL GetLLong(bool AB_IsBigEndian=true) const
{
const ZTypIntI CI_IntByte = sizeof(ZTypIntLL);
const ZTypIntI CI_SearchSize =
(ml_TypeLength<CI_IntByte ? ml_TypeLength : CI_IntByte) ;
ZTypIntLL VI_Result =0 ;
ZTypIntLL VI_TempInt =1 ;
if(AB_IsBigEndian)
{
for(ZTypIntI i=CI_SearchSize-1; i>=0; --i)
{
VI_Result += (ZTypIntI)(ZTypUChar)(mp_TypeChar[i]) * VI_TempInt ;
VI_TempInt *= 256 ;
}/*
for(ZTypIntI i=CI_SearchSize-1; i>=0; --i)*/
return VI_Result;
}/*
if(AB_IsBigEndian)*/
for(ZTypIntI i=0; i<CI_SearchSize; ++i)
{
VI_Result += (ZTypIntI)(ZTypUChar)(mp_TypeChar[i]) * VI_TempInt ;
VI_TempInt *= 256 ;
}/*
for(ZTypIntI i=0; i<CI_SearchSize; ++i)*/
return VI_Result;
}/*
ZTypIntLL GetLLong(bool AB_IsBigEndian=true) const*/
template<typename TypeInt> TypeInt GetIntType(bool AB_IsBigEndian=true) const
{
const ZTypIntI CI_IntByte = sizeof(TypeInt);
const ZTypIntI CI_SearchSize =
(ml_TypeLength<CI_IntByte ? ml_TypeLength : CI_IntByte) ;
TypeInt VI_Result =0;
TypeInt VI_TempInt=1;
if(AB_IsBigEndian)
{
for(ZTypIntI i=CI_SearchSize-1; i>=0; --i)
{
VI_Result += (ZTypIntI)(ZTypUChar)(mp_TypeChar[i]) * VI_TempInt ;
VI_TempInt *= 256 ;
}/*
for(ZTypIntI i=CI_SearchSize-1; i>=0; --i)*/
return VI_Result;
}/*
if(AB_IsBigEndian)*/
for(ZTypIntI i=0; i<CI_SearchSize; ++i)
{
VI_Result += (ZTypIntI)(ZTypUChar)(mp_TypeChar[i]) * VI_TempInt ;
VI_TempInt *= 256 ;
}/*
for(ZTypIntI i=0; i<CI_SearchSize; ++i)*/
return VI_Result;
}/*
template<typename TypeInt> TypeInt GetIntType(bool AB_IsBigEndian=true) const*/
public:
};/*
class ZCChars*/
static TypeChar GetUpperChar(TypeChar AC_TypeChar)
{
const int CI_Distance='a'-'A'; return
@ -707,9 +420,10 @@ namespace ZNsMain
}/*
static TypeChar* Trim(TypeChar* APC_Char,TypeLength& ARRL_Length)*/
static ZCChars& Trim(ZCChars& ARR_CChars)
{
ZtCMainChars::Trim(ARR_CChars.mp_TypeChar, RR(ARR_CChars.ml_TypeLength)); return ARR_CChars;
ZtCMainChars::Trim(ARR_CChars.data(), RR(ARR_CChars.ml_TypeLength)); return ARR_CChars;
}/*
static ZCChars& Trim(ZCChars& ARR_CChars)*/
@ -4320,7 +4034,7 @@ namespace ZNsMain
TypeLength VL_PermitLength=AL_PermitLength/2;
TypeLength j =0;
for(TypeLength i=0;i<AL_Length;++i)
for(TypeLength i=0; i<AL_Length; ++i)
{
for(; j<VL_PermitLength; ++j)
{
@ -4388,7 +4102,7 @@ namespace ZNsMain
VL_SearchSum += VL_SearchNow;
ARA_SearchArray.MoveNextIter(RR(CI_IterEasyID));
ARA_SearchArray.ItNext(RR(CI_IterEasyID));
}/*
for(TypeLength i=0; i<VL_ArrSize; ++i)*/