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
{