2025-09-01 21:22:06 +09:00
|
|
|
|
|
2025-09-01 14:07:33 +09:00
|
|
|
|
|
|
|
|
|
#ifndef __ZCPPMAIIN_ZCSTRINGSTD_H__
|
|
|
|
|
#define __ZCPPMAIIN_ZCSTRINGSTD_H__
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include<string>
|
|
|
|
|
#include "ZCppMain/ZtCMainChars.H"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace ZNsMain
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
class ZCStringStd : public std::string
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
typedef ZNsChars::ZNsType::ZtCTypeChars<char> ZCTypeChars;
|
|
|
|
|
typedef ZNsChars::ZtCMainChars<ZCTypeChars> ZCMainChars;
|
|
|
|
|
public:
|
|
|
|
|
typedef char TypeData ;
|
|
|
|
|
typedef std::string TypeBase ;
|
|
|
|
|
typedef std::string TypeStrStd;
|
|
|
|
|
typedef ZTypLength TypeLength;
|
|
|
|
|
typedef ZTypLength TypeSize ;
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
ZCStringStd(): TypeStrStd(){}
|
|
|
|
|
ZCStringStd(const ZCStringStd& rhs): TypeStrStd(rhs){}
|
|
|
|
|
ZCStringStd(const char* APC_Origin, TypeLength AL_Length): TypeStrStd(APC_Origin, AL_Length){}
|
|
|
|
|
ZCStringStd(const char* APC_Origin): TypeStrStd(APC_Origin){}
|
|
|
|
|
|
|
|
|
|
ZCStringStd& operator==(const ZCStringStd& rhs)
|
|
|
|
|
{
|
|
|
|
|
this->TypeStrStd::operator=(rhs); return *this;
|
|
|
|
|
}/*
|
|
|
|
|
ZCStringStd& operator==(const ZCStringStd& rhs)*/
|
|
|
|
|
|
|
|
|
|
template<typename TPosList> void FindPosToList
|
|
|
|
|
(const char* APC_SearchData, TypeLength AL_SearchLen, TPosList& ARR_CPosList)
|
|
|
|
|
{
|
|
|
|
|
// TPosList : ZNsMain::ZtCList<TypeLength> etc
|
|
|
|
|
|
|
|
|
|
if(this->size()<1) return;
|
|
|
|
|
|
|
|
|
|
const char* VPC_OriginStart = this->data();
|
|
|
|
|
TypeLength VL_OriginLen = this->size();
|
|
|
|
|
TypeLength VL_FindPos = -1 ;
|
|
|
|
|
TypeLength VL_Offset = 0 ;
|
|
|
|
|
|
|
|
|
|
while /*::::::::::::::::::::::::::::::::::::::::::::::*/
|
|
|
|
|
( ( VL_FindPos = ZCMainChars::FindPos
|
|
|
|
|
( VPC_OriginStart, APC_SearchData,
|
|
|
|
|
VL_OriginLen , AL_SearchLen, VL_Offset
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
>= 0
|
|
|
|
|
)
|
|
|
|
|
/*::::::::::::::::::::::::::::::::::::::::::::::::::::*/
|
|
|
|
|
{
|
|
|
|
|
ARR_CPosList.push_back(VL_FindPos);
|
|
|
|
|
|
|
|
|
|
VL_Offset = VL_FindPos + AL_SearchLen;
|
|
|
|
|
}
|
|
|
|
|
/*::::::::::::::::::::::::::::::::::::::::::::::::::::*/
|
|
|
|
|
}/*
|
|
|
|
|
template<typename TPosList> void FindPosToList
|
|
|
|
|
(const char* APC_SearchData, TypeLength AL_SearchLen, TFindList& ARR_CPosList)
|
|
|
|
|
*/
|
|
|
|
|
|
2025-09-01 21:22:06 +09:00
|
|
|
|
template<typename TPosList> ZCStringStd& ReplaceToOutByPosList
|
|
|
|
|
(
|
|
|
|
|
TPosList& AR_CPosList ,
|
|
|
|
|
const char* APC_Replace ,
|
|
|
|
|
TypeLength AL_Replace ,
|
|
|
|
|
TypeLength AL_Searched ,
|
|
|
|
|
ZCStringStd& ARR_SaveOut
|
|
|
|
|
)
|
|
|
|
|
/*##########################################################*/
|
|
|
|
|
{
|
|
|
|
|
// TPosList : ZNsMain::ZtCList<TypeLength> etc
|
|
|
|
|
// AL_Replace : APC_Replace 의 길이
|
|
|
|
|
// AL_Searched : 이전에 찾은 길이
|
|
|
|
|
// ARR_SaveOut : AL_Replace>AL_Searched 인 경우에 여기에 저장한다.
|
|
|
|
|
|
|
|
|
|
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 ;
|
|
|
|
|
|
|
|
|
|
char* VPC_ThisStart = this->data() ;
|
|
|
|
|
IterEasyID VH_IterEasyID = AR_CPosList.ItHID();
|
|
|
|
|
TypeLength VL_SearchedPos= 0 ;
|
|
|
|
|
TypeLength VL_SearchedPre= 0 ; // VL_SearchedPos 의 이전 값
|
|
|
|
|
|
|
|
|
|
if(AL_Replace<=AL_Searched) // 메모리 증가 불필요
|
|
|
|
|
{
|
|
|
|
|
char* VPC_MoveStart = 0 ;
|
|
|
|
|
char* VPC_DestStart = 0 ;
|
|
|
|
|
TypeLength VL_MoveStart = 0 ;
|
|
|
|
|
TypeLength VL_DestStart = 0 ;
|
|
|
|
|
|
|
|
|
|
TypeLength VL_MemMoveSize= 0 ;
|
|
|
|
|
char* 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
|
|
|
|
|
);
|
|
|
|
|
/*::::::::::::::::::::::::::::::::::::::::::::::::*/
|
|
|
|
|
}/*
|
|
|
|
|
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_DestStart<VL_MoveStart && VL_DestStart<VL_ThisSize)
|
|
|
|
|
{
|
|
|
|
|
::memmove /*::::::::::::::::::::::::::::::*/
|
|
|
|
|
(
|
|
|
|
|
VPC_ThisStart + VL_DestStart,
|
|
|
|
|
VPC_ThisStart + VL_MoveStart,
|
|
|
|
|
VL_MoveStart - VL_DestStart
|
|
|
|
|
);
|
|
|
|
|
/*::::::::::::::::::::::::::::::::::::::::*/
|
|
|
|
|
}/*
|
|
|
|
|
if(VL_DestStart<VL_MoveStart && VL_DestStart<VL_ThisSize)*/
|
|
|
|
|
|
|
|
|
|
this->resize(VL_NeedSize); return *this;
|
|
|
|
|
}/*
|
|
|
|
|
if(AL_Replace<=AL_Searched) // 메모리 증가 불필요*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ARR_SaveOut.resize(VL_NeedSize);
|
|
|
|
|
|
|
|
|
|
char* VPC_OutStart = ARR_SaveOut.data() ;
|
|
|
|
|
char* VPC_CopyStart = 0 ;
|
|
|
|
|
char* VPC_DestStart = 0 ;
|
|
|
|
|
TypeLength VL_CopyStart = 0 ;
|
|
|
|
|
TypeLength VL_DestStart = 0 ;
|
|
|
|
|
|
|
|
|
|
TypeLength VL_MemCopySize= 0 ;
|
|
|
|
|
char* VPC_RepalcePos= 0 ;
|
|
|
|
|
|
|
|
|
|
__for1(TypeLength, i, VL_PosListSize)
|
|
|
|
|
{
|
|
|
|
|
VL_SearchedPos = AR_CPosList.ItD(VH_IterEasyID) ;
|
|
|
|
|
VPC_CopyStart = VPC_ThisStart + VL_SearchedPre ;
|
|
|
|
|
VL_DestStart = VL_SearchedPre +
|
|
|
|
|
( AL_Replace-AL_Searched ) * (i-1) ;
|
|
|
|
|
VPC_DestStart = VPC_OutStart + VL_DestStart ;
|
|
|
|
|
|
|
|
|
|
if(VL_SearchedPos>VL_SearchedPre)
|
|
|
|
|
{
|
|
|
|
|
VL_MemCopySize =
|
|
|
|
|
VL_SearchedPos - VL_SearchedPre ;
|
|
|
|
|
|
|
|
|
|
::memcpy /*:::::::::::::::::::::::::::::::::::::::*/
|
|
|
|
|
(
|
|
|
|
|
VPC_DestStart, VPC_CopyStart, VL_MemCopySize
|
|
|
|
|
);
|
|
|
|
|
/*::::::::::::::::::::::::::::::::::::::::::::::::*/
|
|
|
|
|
}/*
|
|
|
|
|
if(VL_SearchedPos>VL_SearchedPre)*/
|
|
|
|
|
|
|
|
|
|
VL_SearchedPre = VL_SearchedPos + AL_Searched ;
|
|
|
|
|
VL_DestStart = VL_SearchedPos +
|
|
|
|
|
( AL_Replace-AL_Searched ) * (i-1) ;
|
|
|
|
|
VPC_RepalcePos = VPC_OutStart + VL_DestStart ;
|
|
|
|
|
|
|
|
|
|
::memcpy(VPC_RepalcePos, APC_Replace, AL_Replace);
|
|
|
|
|
|
|
|
|
|
AR_CPosList.ItNext(VH_IterEasyID);
|
|
|
|
|
}/*
|
|
|
|
|
__for1(TypeLength, i, VL_PosListSize)*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(VL_SearchedPre<VL_ThisSize)
|
|
|
|
|
{
|
|
|
|
|
VL_DestStart = VL_DestStart + AL_Replace ;
|
|
|
|
|
VPC_DestStart = VPC_OutStart + VL_DestStart ;
|
|
|
|
|
VPC_CopyStart = VPC_ThisStart+ VL_SearchedPre;
|
|
|
|
|
VL_MemCopySize = VL_ThisSize - VL_SearchedPre;
|
|
|
|
|
|
|
|
|
|
::memcpy /*:::::::::::::::::::::::::::::::::::::::*/
|
|
|
|
|
(
|
|
|
|
|
VPC_DestStart, VPC_CopyStart, VL_MemCopySize
|
|
|
|
|
);
|
|
|
|
|
/*::::::::::::::::::::::::::::::::::::::::::::::::*/
|
|
|
|
|
}/*
|
|
|
|
|
if(VL_SearchedPre<VL_ThisSize)*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return ARR_SaveOut;
|
|
|
|
|
}/*
|
|
|
|
|
template<typename TPosList> ZCStringStd& ReplaceToOutByPosList
|
|
|
|
|
(
|
|
|
|
|
TPosList& AR_CPosList ,
|
|
|
|
|
const char* APC_Replace ,
|
|
|
|
|
TypeLength AL_Replace ,
|
|
|
|
|
TypeLength AL_Searched ,
|
|
|
|
|
ZCStringStd& ARR_SaveOut
|
|
|
|
|
)
|
|
|
|
|
############################################################*/
|
|
|
|
|
|
2025-09-01 14:07:33 +09:00
|
|
|
|
public:
|
|
|
|
|
};/*
|
|
|
|
|
class ZCStringStd : public std::string*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}/*
|
|
|
|
|
namespace ZNsMain*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif //__ZCPPMAIIN_ZCSTRINGSTD_H__
|