338 lines
13 KiB
C++
338 lines
13 KiB
C++
|
|
|
|
#include <iostream>
|
|
#include "ZCppMain/ZtCSimList.H"
|
|
#include "ZCppMain/ZtCStringEx.H"
|
|
|
|
|
|
using namespace std ;
|
|
using namespace ZNsMain ;
|
|
|
|
|
|
namespace ZNsMain
|
|
{
|
|
|
|
namespace ZNsExam
|
|
{
|
|
|
|
template<typename TDummy=void*> class ZtCExamCSimList
|
|
{
|
|
public:
|
|
|
|
|
|
typedef ZtCStringBase<char> CStringBase ;
|
|
typedef const CStringBase CCStringBase;
|
|
|
|
/* 아래 자료형에 대해, CStringBase::Fetch() 호출 여부 실험.
|
|
|
|
ZtCSimList<CStringBase&, CCStringBase&>
|
|
ZtCSimList<CStringBase&, CCCStringBase&>
|
|
|
|
*/
|
|
typedef ZtCSimList
|
|
<CStringBase, CStringBase&> CStringList1 ;
|
|
typedef ZtCSimList
|
|
<CStringBase, CCStringBase&> CStringList2 ;
|
|
|
|
|
|
|
|
class CHelpObj
|
|
{
|
|
public:
|
|
int mi_CallNo;
|
|
public:
|
|
|
|
CHelpObj() : mi_CallNo(0)
|
|
{
|
|
cout<<"* CHelpObj()"<<endl;
|
|
}
|
|
|
|
CHelpObj(const CHelpObj& rhs) : mi_CallNo(0)
|
|
{
|
|
cout<<"* CHelpObj(const CHelpObj& rhs)"<<endl;
|
|
}
|
|
|
|
void operator()( CStringBase& AR_DataCStr)
|
|
{ cout<<"# CallNo="<<++mi_CallNo<<" : "<<AR_DataCStr<<endl; }
|
|
void operator()(CCStringBase& AR_DataCStr)
|
|
{ cout<<"# CallNo="<<++mi_CallNo<<" : "<<AR_DataCStr<<endl; }
|
|
|
|
public:
|
|
};/*
|
|
class CHelpObj*/
|
|
|
|
|
|
struct StFunctor
|
|
{
|
|
static void ShowElement(int ArgiValue){cout<<"#1 Value="<<ArgiValue<<endl;}
|
|
};
|
|
struct StFunctor2
|
|
{
|
|
static void ShowElement(int ArgiValue, CHelpObj)
|
|
{cout<<"#2 Value="<<ArgiValue<<", CHelpObj Addr=None"<<" With CHelpObj"<<endl;}
|
|
};
|
|
struct StFunctor3
|
|
{
|
|
static void ShowElement(int ArgiValue, CHelpObj& AR_CHelpObj)
|
|
{cout<<"#3 Value="<<ArgiValue<<", HelpObj Ptr="<<&AR_CHelpObj<<" With CHelpObj Ref"<<endl;}
|
|
};
|
|
struct StFunctor4
|
|
{
|
|
static void ShowElement(int ArgiValue, CHelpObj& AR_CHelpObj)
|
|
{cout<<"#4 Value="<<ArgiValue<<", HelpObj Ptr="<<&AR_CHelpObj<<" With CHelpObj in Ptr"<<endl;}
|
|
};
|
|
struct StFunctor5
|
|
{
|
|
static void ShowElement(int ArgiValue, CHelpObj& AR_CHelpObj, CHelpObj& AR_CHelpObj2)
|
|
{cout<<"#5 Value="<<ArgiValue<<", HelpObj Ptr="<<&AR_CHelpObj<<" With CHelpObj Ref 2"<<endl;}
|
|
};
|
|
struct StFunctor6
|
|
{
|
|
static void ShowElement(int ArgiValue, CHelpObj& AR_CHelpObj, CHelpObj AO_CHelpObj2)
|
|
{cout<<"#6 Value="<<ArgiValue<<", HelpObj Ptr="<<&AR_CHelpObj<<" With CHelpObj Half Ref"<<endl;}
|
|
};
|
|
|
|
|
|
public:
|
|
|
|
|
|
static void ShowDataInNode(const CStringBase& AR_Data)
|
|
{
|
|
cout<<"* Data : "<<AR_Data<<endl;
|
|
}/*
|
|
static void ShowDataInNode(const CStringBase& AR_Data)*/
|
|
|
|
static int Main(int AI_ArgCnt=0, char* APP_ArgVal[]=0)
|
|
{
|
|
CStringBase VO_CStringBase;
|
|
CStringList1 VO_ListOfStr10 ;
|
|
CStringList2 VO_ListOfStr20 ;
|
|
|
|
VO_ListOfStr10.AddTail(VO_CStringBase("data 10"));
|
|
VO_ListOfStr10.AddTail(VO_CStringBase("data 40"));
|
|
VO_ListOfStr10.AddTail(VO_CStringBase("data 20"));
|
|
VO_ListOfStr10.AddTail(VO_CStringBase("data 40"));
|
|
VO_ListOfStr10.AddTail(VO_CStringBase("data 04"));
|
|
|
|
cout<<"# VO_CStringBase data : " <<VO_CStringBase<<endl;
|
|
|
|
cout<<"# 1th IterElement ####" <<endl;
|
|
{
|
|
VO_ListOfStr10.IterElement(&ShowDataInNode);
|
|
}
|
|
/*///////////////////////////////////*/
|
|
|
|
|
|
cout<<endl;
|
|
|
|
|
|
VO_ListOfStr20.AddTail(VO_CStringBase("data 10"));
|
|
VO_ListOfStr20.AddTail(VO_CStringBase("data 40"));
|
|
VO_ListOfStr20.AddTail(VO_CStringBase("data 20"));
|
|
VO_ListOfStr20.AddTail(VO_CStringBase("data 40"));
|
|
VO_ListOfStr20.AddTail(VO_CStringBase("data 04"));
|
|
|
|
cout<<"# VO_CStringBase data : " <<VO_CStringBase<<endl;
|
|
|
|
cout<<"# 2th IterElement ####" <<endl;
|
|
{
|
|
VO_ListOfStr20.IterElement(&ShowDataInNode);
|
|
}
|
|
/*///////////////////////////////////*/
|
|
|
|
|
|
typedef ZtCSimList<int> CIntList;
|
|
|
|
CHelpObj VO_CHelpObj;
|
|
CIntList VO_CIntList;
|
|
|
|
VO_CIntList.AddTail(10);
|
|
VO_CIntList.AddTail(20);
|
|
VO_CIntList.AddTail(30);
|
|
VO_CIntList.AddTail(40);
|
|
|
|
cout<<endl<<"#### Show CIntList Element ####"<<endl<<endl;
|
|
|
|
VO_CIntList.IterElement(StFunctor ::ShowElement);
|
|
VO_CIntList.IterElement(StFunctor2::ShowElement, VO_CHelpObj );
|
|
VO_CIntList.IterElement(StFunctor3::ShowElement, ZftMCR(VO_CHelpObj) );
|
|
VO_CIntList.IterElement(StFunctor4::ShowElement, ZftMCP(VO_CHelpObj) );
|
|
VO_CIntList.IterElement(StFunctor5::ShowElement, ZftMCP(VO_CHelpObj), ZftMCP(VO_CHelpObj) );
|
|
VO_CIntList.IterElement(StFunctor6::ShowElement, ZftMCP(VO_CHelpObj), VO_CHelpObj );
|
|
|
|
|
|
|
|
CStringList1 VO_ListOfStr11 ;
|
|
|
|
cout<<"# add 2 elements and clear in VO_ListOfStr11"<<endl;
|
|
|
|
VO_ListOfStr11.AddTail(VO_CStringBase("lsit 11 data 01"));
|
|
VO_ListOfStr11.AddTail(VO_CStringBase("lsit 11 data 02"));
|
|
VO_ListOfStr11.clear();
|
|
|
|
cout<<"# After list10 Fetch from list11"<<endl;
|
|
|
|
VO_ListOfStr10.GetCFreeHeap().Fetch( VO_ListOfStr11.GetCFreeHeap() );
|
|
|
|
cout<<"# list10 size : " <<VO_ListOfStr10.size ()<<endl;
|
|
cout<<"# list11 size : " <<VO_ListOfStr11.size ()<<endl;
|
|
cout<<"# list10 free size: " <<VO_ListOfStr10.GetFreeSize ()<<endl;
|
|
cout<<"# list11 free size: " <<VO_ListOfStr11.GetFreeSize ()<<endl;
|
|
cout<<"# list10 capacity : " <<VO_ListOfStr10.capacity ()<<endl;
|
|
cout<<"# list11 capacity : " <<VO_ListOfStr11.capacity ()<<endl;
|
|
|
|
cout<<"# After list11 Fetch 3 from list10"<<endl;
|
|
|
|
VO_ListOfStr11.GetCFreeHeap().
|
|
Fetch( VO_ListOfStr10.GetCFreeHeap(), 3);
|
|
|
|
cout<<"# list10 size : " <<VO_ListOfStr10.size ()<<endl;
|
|
cout<<"# list11 size : " <<VO_ListOfStr11.size ()<<endl;
|
|
cout<<"# list10 free size: " <<VO_ListOfStr10.GetFreeSize ()<<endl;
|
|
cout<<"# list11 free size: " <<VO_ListOfStr11.GetFreeSize ()<<endl;
|
|
cout<<"# list10 capacity : " <<VO_ListOfStr10.capacity ()<<endl;
|
|
cout<<"# list11 capacity : " <<VO_ListOfStr11.capacity ()<<endl;
|
|
|
|
VO_ListOfStr11.AddTail(VO_CStringBase("list11 add1"));
|
|
VO_ListOfStr11.AddTail(VO_CStringBase("list11 add2"));
|
|
VO_ListOfStr11.AddTail(VO_CStringBase("list11 add3"));
|
|
VO_ListOfStr11.AddTail(VO_CStringBase("list11 add4"));
|
|
|
|
cout<<"# After add 4 in list11"<<endl;
|
|
|
|
cout<<"# list10 size : " <<VO_ListOfStr10.size ()<<endl;
|
|
cout<<"# list11 size : " <<VO_ListOfStr11.size ()<<endl;
|
|
cout<<"# list10 free size: " <<VO_ListOfStr10.GetFreeSize ()<<endl;
|
|
cout<<"# list11 free size: " <<VO_ListOfStr11.GetFreeSize ()<<endl;
|
|
cout<<"# list10 capacity : " <<VO_ListOfStr10.capacity ()<<endl;
|
|
cout<<"# list11 capacity : " <<VO_ListOfStr11.capacity ()<<endl;
|
|
|
|
VO_ListOfStr11.GetCFreeHeap().AddHeap(2);
|
|
VO_ListOfStr10.GetCFreeHeap().MakeEqual( VO_ListOfStr11.GetCFreeHeap() );
|
|
|
|
cout<<"# After adding free 2 in list11 and MakeEqual() : list10 and list11"<<endl;
|
|
|
|
cout<<"# list10 size : " <<VO_ListOfStr10.size ()<<endl;
|
|
cout<<"# list11 size : " <<VO_ListOfStr11.size ()<<endl;
|
|
cout<<"# list10 free size: " <<VO_ListOfStr10.GetFreeSize ()<<endl;
|
|
cout<<"# list11 free size: " <<VO_ListOfStr11.GetFreeSize ()<<endl;
|
|
cout<<"# list10 capacity : " <<VO_ListOfStr10.capacity ()<<endl;
|
|
cout<<"# list11 capacity : " <<VO_ListOfStr11.capacity ()<<endl;
|
|
|
|
cout<<"# list11 IterElement ####" <<endl;
|
|
{
|
|
VO_ListOfStr11.IterElement(&ShowDataInNode);
|
|
}/*
|
|
cout<<"# list11 IterElement ####" <<endl;*/
|
|
|
|
|
|
cout<<"# list11 IterElement : ZftMCR(CHelpObj)" <<endl;
|
|
VO_ListOfStr11.IterElement(ZftMCR(VO_CHelpObj));
|
|
cout<<"# list11 IterElement : ZftMCP(CHelpObj)" <<endl;
|
|
VO_ListOfStr11.IterElement(ZftMCP(VO_CHelpObj));
|
|
|
|
|
|
VO_ListOfStr11 = VO_ListOfStr10 ;
|
|
|
|
cout<<"# list11 IterElement : after list11=list10" <<endl;
|
|
VO_ListOfStr11.IterElement(ZftMCP(VO_CHelpObj));
|
|
|
|
|
|
return 0;
|
|
}/*
|
|
static int Main(int AI_ArgCnt=0, char* APP_ArgVal[]=0)*/
|
|
|
|
|
|
public:
|
|
};/*
|
|
template<typename TDummy=void*> class ZtCExamCSimList*/
|
|
|
|
}/*
|
|
namespace ZNsExam*/
|
|
|
|
}/*
|
|
namespace ZNsMain*/
|
|
|
|
|
|
int main(int AI_ArgCnt, char* APP_ArgVal[])
|
|
{
|
|
return ZNsMain::ZNsExam::
|
|
|
|
ZtCExamCSimList<>::Main(AI_ArgCnt, APP_ArgVal);
|
|
}/*
|
|
int main(int AI_ArgCnt, char* APP_ArgVal[])*/
|
|
|
|
|
|
/*////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
■ cygwin 컴파일
|
|
|
|
// g++ -mno-cygwin -o ZtCSimList_000.exe ZtCSimList_000.cpp -I../../my_CPP/CPP_Main/ -I../../my_CPP/CPP_Std/ -D__CYGWIN32__ -D__VISUAL_CPP_VER__=200300
|
|
// g++ -mno-cygwin -o ZtCSimList_000_D.exe ZtCSimList_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 ZtCSimList_000_mw.exe ZtCSimList_000.cpp -I../ -lWs2_32
|
|
g++.exe -o ZtCSimList_000_mw_D.exe ZtCSimList_000.cpp -I../ -lWs2_32 -D_DEBUG
|
|
|
|
./ZtCSimList_000_mw.exe
|
|
./ZtCSimList_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 ZtCSimList_000.exe ZtCSimList_000.cpp -I../ -Wall -Wno-unused-function -Wno-misleading-indentation
|
|
g++ -std=c++98 -o ZtCSimList_000_D.exe ZtCSimList_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.
|
|
|
|
■ 실행
|
|
|
|
./ZtCSimList_000.exe
|
|
./ZtCSimList_000_D.exe
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////*/
|