309 lines
15 KiB
C++
309 lines
15 KiB
C++
|
|
|
|
#include <string>
|
|
#include <iostream>
|
|
#include "ZCppMain/ZtCStringEx.H"
|
|
#include "ZCppMain/ZtCStringStd.H"
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
namespace ZNsMain
|
|
{
|
|
|
|
namespace ZNsExam
|
|
{
|
|
typedef ZtCStringStd<string> ZCStringStd ;
|
|
typedef ZtCStringStd<wstring> ZCStringStdW ;
|
|
|
|
typedef ZtCStringBase<char> ZCStringBase ;
|
|
typedef ZtCStringBase<wchar_t> ZCStringBaseW ;
|
|
|
|
typedef ZCStringBase ::ZCCharView ZCCharView ;
|
|
typedef ZCStringBaseW::ZCCharView ZCCharViewW ;
|
|
typedef ZCStringStd ::ZCCharView ZCCharViewS ;
|
|
typedef ZCStringStdW ::ZCCharView ZCCharViewSW ;
|
|
typedef ZtCCharType<ZCStringBase> ZCCharType ;
|
|
typedef ZtCCharType<ZCStringBaseW> ZCCharTypeW ;
|
|
typedef ZtCCharType<ZCStringStd > ZCCharTypeS ;
|
|
typedef ZtCCharType<ZCStringStdW> ZCCharTypeSW ;
|
|
|
|
typedef ZCCharType ::TypeChar TypeChar ;
|
|
typedef ZCCharTypeW ::TypeChar TypeCharW ;
|
|
typedef ZCCharType ::TypeInt TypeCharInt ;
|
|
typedef ZCCharTypeW ::TypeInt TypeCharIntW ;
|
|
|
|
typedef ZCCharTypeS ::TypeChar TypeCharS ;
|
|
typedef ZCCharTypeSW::TypeChar TypeCharSW ;
|
|
typedef ZCCharTypeS ::TypeInt TypeCharIntS ;
|
|
typedef ZCCharTypeSW::TypeInt TypeCharIntSW ;
|
|
|
|
const int CI_ByteSize = ZCCharType ::CI_ByteSize;
|
|
const int CI_ByteSizeW = ZCCharTypeW ::CI_ByteSize;
|
|
const int CI_ByteSizeS = ZCCharTypeS ::CI_ByteSize;
|
|
const int CI_ByteSizeSW = ZCCharTypeSW::CI_ByteSize;
|
|
|
|
|
|
template<typename TDummy=void*> class ZtCExamCStringBase_000
|
|
{
|
|
public:
|
|
|
|
static int Main(int AI_ArgCnt=0, char* APP_ArgVal[]=0)
|
|
{
|
|
cout<<"# TypeChar ="<<typeid(TypeChar ).name()<<endl;
|
|
cout<<"# TypeCharW ="<<typeid(TypeCharW ).name()<<endl;
|
|
cout<<"# TypeCharInt ="<<typeid(TypeCharInt ).name()<<endl;
|
|
cout<<"# TypeCharIntW ="<<typeid(TypeCharIntW ).name()<<endl;
|
|
cout<<"*****************************************************"<<endl;
|
|
cout<<"# TypeCharS ="<<typeid(TypeCharS ).name()<<endl;
|
|
cout<<"# TypeCharSW ="<<typeid(TypeCharSW ).name()<<endl;
|
|
cout<<"# TypeCharIntS ="<<typeid(TypeCharIntS ).name()<<endl;
|
|
cout<<"# TypeCharIntSW="<<typeid(TypeCharIntSW).name()<<endl;
|
|
cout<<"*****************************************************"<<endl;
|
|
cout<<"# CI_ByteSize ="<<CI_ByteSize <<endl;
|
|
cout<<"# CI_ByteSizeW ="<<CI_ByteSizeW <<endl;
|
|
cout<<"# CI_ByteSizeS ="<<CI_ByteSizeS <<endl;
|
|
cout<<"# CI_ByteSizeSW="<<CI_ByteSizeSW <<endl;
|
|
cout<<"*****************************************************"<<endl;
|
|
cout<<"# ZCStringBase ::TypeCharInt="<<typeid(ZCStringBase ::TypeCharInt).name()<<endl;
|
|
cout<<"# ZCStringBaseW::TypeCharInt="<<typeid(ZCStringBaseW::TypeCharInt).name()<<endl;
|
|
cout<<"# ZCStringBase ::size_type ="<<typeid(ZCStringBase ::size_type ).name()<<endl;
|
|
cout<<"# ZCStringBaseW::size_type ="<<typeid(ZCStringBaseW::size_type ).name()<<endl;
|
|
cout<<"*****************************************************"<<endl;
|
|
cout<<"# ZCStringStd ::TypeCharInt="<<typeid(ZCStringStd ::TypeCharInt).name()<<endl;
|
|
cout<<"# ZCStringStdW ::TypeCharInt="<<typeid(ZCStringStdW ::TypeCharInt).name()<<endl;
|
|
cout<<"# ZCStringStd ::size_type ="<<typeid(ZCStringStd ::size_type ).name()<<endl;
|
|
cout<<"# ZCStringStdW ::size_type ="<<typeid(ZCStringStdW ::size_type ).name()<<endl;
|
|
cout<<"*****************************************************"<<endl;
|
|
cout<<"# ZCStringBase ::traits_type::char_type="<<typeid(ZCStringBase ::traits_type::char_type).name()<<endl;
|
|
cout<<"# ZCStringBaseW::traits_type::char_type="<<typeid(ZCStringBaseW::traits_type::char_type).name()<<endl;
|
|
cout<<"# ZCStringBase ::traits_type::int_type ="<<typeid(ZCStringBase ::traits_type::int_type ).name()<<endl;
|
|
cout<<"# ZCStringBaseW::traits_type::int_type ="<<typeid(ZCStringBaseW::traits_type::int_type ).name()<<endl;
|
|
|
|
cout<<"# ZCStringBase ::traits_type="<<typeid(ZCStringBase ::traits_type).name()<<endl;
|
|
cout<<"# ZCStringBaseW::traits_type="<<typeid(ZCStringBaseW::traits_type).name()<<endl;
|
|
cout<<"*****************************************************"<<endl;
|
|
|
|
|
|
ZCStringBaseW VO_ZCStringBaseW;
|
|
ZCStringStdW VO_ZCStringStdW ;
|
|
|
|
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_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");
|
|
|
|
ZCStringBase VO_ZCStringStd(CO_ZCCharView);
|
|
cout<<"# "<<VO_ZCStringStd<<endl;
|
|
|
|
cout<<"* after VO_ZCStringStd.Replace('12', '***')"<<endl;
|
|
VO_ZCStringStd.Replace(ZCCharView("12"), ZCCharView("***"));
|
|
cout<<"# "<<VO_ZCStringStd<<endl;
|
|
cout<<"*****************************************************"<<endl;
|
|
|
|
cout<<"* after VO_ZCStringStd=CO_ZCCharView"<<endl;
|
|
VO_ZCStringStd=CO_ZCCharView;
|
|
cout<<"# "<<VO_ZCStringStd<<endl;
|
|
cout<<"*****************************************************"<<endl;
|
|
|
|
cout<<"* after Replace('AA', '___')"<<endl;
|
|
VO_ZCStringStd.Replace(ZCCharView("AA"), ZCCharView("___"));
|
|
cout<<"# "<<VO_ZCStringStd<<endl;
|
|
cout<<"*****************************************************"<<endl;
|
|
|
|
cout<<"* after Replace('12', '###')"<<endl;
|
|
VO_ZCStringStd.Replace(ZCCharView("12"), ZCCharView("###"));
|
|
cout<<"# "<<VO_ZCStringStd<<endl;
|
|
cout<<"*****************************************************"<<endl;
|
|
|
|
cout<<"* after Replace('##', 'T')"<<endl;
|
|
VO_ZCStringStd.Replace(ZCCharView("##"), ZCCharView("T"));
|
|
cout<<"# "<<VO_ZCStringStd<<endl;
|
|
cout<<"*****************************************************"<<endl;
|
|
|
|
cout<<"* after Replace('ss', '')"<<endl;
|
|
VO_ZCStringStd.Replace(ZCCharView("ss"), ZCCharView(""));
|
|
cout<<"# "<<VO_ZCStringStd<<endl;
|
|
cout<<"*****************************************************"<<endl;
|
|
|
|
|
|
ZftMakeStr(VO_ZCStringStd , ZTypIntULL(1234));
|
|
ZftMakeStr(VO_ZCStringStd , ZCCharView("--"));
|
|
ZftMakeStr(VO_ZCStringStd , double(10.01));
|
|
ZftMakeStr(VO_ZCStringStd , true);
|
|
ZftMakeStr(VO_ZCStringStd , 'Z');
|
|
ZftMakeStr(VO_ZCStringStd , ZCCharView("_Z_"));
|
|
|
|
ZftMakeStr(VO_ZCStringStdW, ZTypIntULL(1234));
|
|
ZftMakeStr(VO_ZCStringStdW, ZCCharViewSW(L"--"));
|
|
ZftMakeStr(VO_ZCStringStdW, double(10.01));
|
|
ZftMakeStr(VO_ZCStringStdW, true);
|
|
ZftMakeStr(VO_ZCStringStdW, L'Z');
|
|
ZftMakeStr(VO_ZCStringStdW, ZCCharViewSW(L"_Z_"));
|
|
|
|
VO_ZCStringStdW(false);
|
|
|
|
|
|
cout<<"* after ZftMakeStr(VO_ZCStringStd, ~)"<<endl;
|
|
cout<<"# "<<VO_ZCStringStd<<endl;
|
|
cout<<"*****************************************************"<<endl;
|
|
|
|
cout<<"* after ZftMakeStr(VO_ZCStringStdW, ~)"<<endl;
|
|
cout<<"# "<<VO_ZCStringStdW<<endl;
|
|
cout<<"*****************************************************"<<endl;
|
|
|
|
cout<<"* after VO_ZCStringStd.Replace('T#', '')"<<endl;
|
|
VO_ZCStringStd.Replace(ZCCharView("T#"), ZCCharView(""));
|
|
cout<<"# "<<VO_ZCStringStd<<endl;
|
|
cout<<"*****************************************************"<<endl;
|
|
|
|
cout<<"* after Replace('Z_', 'Z@%')"<<endl;
|
|
VO_ZCStringStd.Replace(ZCCharView("Z_"), ZCCharView("Z@%"));
|
|
cout<<"# "<<VO_ZCStringStd<<endl;
|
|
cout<<"*****************************************************"<<endl;
|
|
|
|
cout<<"* after Replace('true', '_TRUE_')"<<endl;
|
|
VO_ZCStringStd.Replace(ZCCharView("true"), ZCCharView("_TRUE_"));
|
|
cout<<"# "<<VO_ZCStringStd<<endl;
|
|
cout<<"*****************************************************"<<endl;
|
|
|
|
cout<<"* after Replace('_', '~&')"<<endl;
|
|
VO_ZCStringStd.Replace(ZCCharView("_"), ZCCharView("~&"));
|
|
cout<<"# "<<VO_ZCStringStd<<endl;
|
|
cout<<"*****************************************************"<<endl;
|
|
|
|
cout<<"* after ()(ZCCharViewW('_AZ'))"<<endl;
|
|
VO_ZCStringStd(ZCCharView("_AZ"));
|
|
cout<<"# "<<VO_ZCStringStd<<endl;
|
|
cout<<"*****************************************************"<<endl;
|
|
|
|
|
|
return 0;
|
|
}/*
|
|
static int Main(int AI_ArgCnt=0, char* APP_ArgVal[]=0)*/
|
|
|
|
public:
|
|
};/*
|
|
template<typename TDummy=void*> class ZtCExamCStringBase_000*/
|
|
|
|
}/*
|
|
namespace ZNsExam*/
|
|
|
|
}/*
|
|
namespace ZNsMain*/
|
|
|
|
|
|
int main(int AI_ArgCnt, char* APP_ArgVal[])
|
|
{
|
|
return ZNsMain::ZNsExam::
|
|
|
|
ZtCExamCStringBase_000<>::Main(AI_ArgCnt, APP_ArgVal);
|
|
}/*
|
|
int main(int AI_ArgCnt, char* APP_ArgVal[])*/
|
|
|
|
|
|
/*////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
■ cygwin 컴파일
|
|
|
|
// g++ -mno-cygwin -o ZtCStringBase_000.exe ZtCStringBase_000.cpp -I../../my_CPP/CPP_Main/ -I../../my_CPP/CPP_Std/ -D__CYGWIN32__ -D__VISUAL_CPP_VER__=200300
|
|
// g++ -mno-cygwin -o ZtCStringBase_000_D.exe ZtCStringBase_000.cpp -I../../my_CPP/CPP_Main/ -I../../my_CPP/CPP_Std/ -D__CYGWIN32__ -D__VISUAL_CPP_VER__=200300 -D_DEBUG
|
|
|
|
■ mingw 컴파일
|
|
|
|
g++.exe -o ZtCStringBase_000_mw.exe ZtCStringBase_000.cpp -I../ -lWs2_32 -Wall -Wno-unused-function -Wno-misleading-indentation
|
|
g++.exe -o ZtCStringBase_000_mw_D.exe ZtCStringBase_000.cpp -I../ -lWs2_32 -Wall -Wno-unused-function -Wno-misleading-indentation -D_DEBUG
|
|
|
|
./ZtCStringBase_000_mw.exe
|
|
./ZtCStringBase_000_mw_D.exe
|
|
|
|
|
|
Administrator@q381-2673 UCRT64 /e/my_CPP/ZCpp/ZCppMainTest
|
|
# date
|
|
Sun Aug 24 10:47:09 KST 2025
|
|
|
|
Administrator@q381-2673 UCRT64 /e/my_CPP/ZCpp/ZCppMainTest
|
|
# g++ --version
|
|
g++.exe (Rev2, Built by MSYS2 project) 13.2.0
|
|
Copyright (C) 2023 Free Software Foundation, Inc.
|
|
This is free software; see the source for copying conditions. There is NO
|
|
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
■ Linux 컴파일
|
|
|
|
g++ -std=c++98 -o ZtCStringBase_000.exe ZtCStringBase_000.cpp -I../
|
|
g++ -std=c++98 -o ZtCStringBase_000_D.exe ZtCStringBase_000.cpp -I../ -D_DEBUG
|
|
|
|
g++ -std=c++98 -o ZtCStringBase_000.exe ZtCStringBase_000.cpp -I../ -Wall -Wno-unused-function -Wno-misleading-indentation
|
|
g++ -std=c++98 -o ZtCStringBase_000_D.exe ZtCStringBase_000.cpp -I../ -Wall -Wno-unused-function -Wno-misleading-indentation -D_DEBUG
|
|
|
|
sauron@q381-2673:/mnt/e/my_CPP/ZCpp/ZCppMainTest$ gcc --version
|
|
gcc (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0
|
|
Copyright (C) 2019 Free Software Foundation, Inc.
|
|
This is free software; see the source for copying conditions. There is NO
|
|
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
sauron@q381-2673:/mnt/e/my_CPP/ZCpp/ZCppMainTest$ date
|
|
Sun Aug 24 00:05:51 DST 2025
|
|
|
|
sauron@q381-2673:/mnt/e/my_CPP/ZCpp/ZCppMainTest$ cat /etc/os-release
|
|
NAME="Ubuntu"
|
|
VERSION="20.04.6 LTS (Focal Fossa)"
|
|
ID=ubuntu
|
|
ID_LIKE=debian
|
|
PRETTY_NAME="Ubuntu 20.04.6 LTS"
|
|
VERSION_ID="20.04"
|
|
HOME_URL="https://www.ubuntu.com/"
|
|
SUPPORT_URL="https://help.ubuntu.com/"
|
|
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
|
|
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
|
|
VERSION_CODENAME=focal
|
|
UBUNTU_CODENAME=focal
|
|
|
|
|
|
[sauron@q381-2657 ZCppMainTest]$ cat /etc/centos-release
|
|
CentOS Linux release 7.9.2009 (Core)
|
|
|
|
[sauron@q381-2657 ZCppMainTest]$ g++ --version
|
|
g++ (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44)
|
|
Copyright (C) 2015 Free Software Foundation, Inc.
|
|
This is free software; see the source for copying conditions. There is NO
|
|
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
■ 실행
|
|
|
|
./ZtCStringBase_000.exe
|
|
./ZtCStringBase_000_D.exe
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////*/
|