diff --git a/ZCppMain/ZMainHead.H b/ZCppMain/ZMainHead.H index d06df96..a7f3037 100644 --- a/ZCppMain/ZMainHead.H +++ b/ZCppMain/ZMainHead.H @@ -793,21 +793,44 @@ namespace ZNsMain //////////////////////////////////////////////////////////////////////*/ + namespace ZNsIn + { + const int CI_Char1Byte = 1; + const int CI_Char2Byte = 2; + const int CI_Char4Byte = 4; + }/* + namespace ZNsIn*/ + + + template class ZtCCharIntBySize + { + public: typedef ZTypLong TypeInt; + };/* + template class ZtCCharIntBySize*/ + + template<> class ZtCCharIntBySize + { public: typedef ZTypInt TypeInt; }; + template<> class ZtCCharIntBySize + { public: typedef ZTypInt TypeInt; }; + template<> class ZtCCharIntBySize + { public: typedef ZTypLong TypeInt; }; + + template class ZtCCharInt { - public: typedef int TypeInt; + public: typedef typename ZtCCharIntBySize::TypeInte TypeInt; };/* template class ZtCCharInt*/ template<> class ZtCCharInt { - public: typedef int TypeInt; + public: typedef typename ZtCCharIntBySize::TypeInt TypeInt; };/* template<> class ZtCCharInt*/ template<> class ZtCCharInt { - public: typedef int TypeInt; + public: typedef typename ZtCCharIntBySize::TypeInt TypeInt; };/* template<> class ZtCCharInt*/ @@ -7321,6 +7344,83 @@ namespace ZNsMain template<> string& ZftMakeStr(string& ARR_SaveCStr, const ZCCharView& AR_View)*/ + /*////////////////////////////////////////////////////////////////////////////////////// + + ■ template class ZtCCharType + + stl 의 string 나 wstring 같은 문자열 클래스를 인자로 받는 템플릿이 있다고 할 때, 해당 + 자열 클래스가 다루는 문자형이 char 인지 wchar_t 인지 알기가 약간 번거로운데, 이를 쉽 + 게 하기 위해서, 특히 ZtCStringBase 와 통일적으로 일관성있게 알 수 있도록 + + template<> class ZtCCharType + + cf) typedef ZtCCharType::TypeChar TypeChar; + + 을 설계한다. 물론 + + string::traits_type::char_type + string::traits_type::int_type + + 을 사용하면 관련 자료형을 알 수 있기는 한데, 혹시나 나중에 string 보다 간단한 문자열 + 클래스가 있을 경우를 대비하는 의미에서라도 이렇게 한 번 해보자. + + -- 2025-10-08 21:24 + + //////////////////////////////////////////////////////////////////////////////////////*/ + + + template class ZtCCharType + { + public: + typedef typename TTypString:: + traits_type::char_type /*++*/ TypeChar; + typedef TTypString /*+++++++++*/ TypeCStr; + public: + typedef typename + ZtCCharInt::TypeInt TypeInt ; + public: + static const int CI_ByteSize = sizeof(TypeChar); + public: + typedef TypeChar char_type ; // for stl + typedef TypeInt int_type ; // for stl + public: + };/* + template class ZtCCharType*/ + + template<> class ZtCCharType + { + public: + typedef std::string /*+++++++*/ TypeCStr; + typedef char /*+++++++++++++++*/ TypeChar; + public: + typedef typename + ZtCCharInt::TypeInt TypeInt ; + public: + static const int CI_ByteSize = sizeof(TypeChar); + public: + typedef TypeChar char_type ; // for stl + typedef TypeInt int_type ; // for stl + public: + };/* + template<> class ZtCCharType*/ + + template<> class ZtCCharType + { + public: + typedef std::wstring /*+++++++*/ TypeCStr; + typedef wchar_t /*+++++++++++*/ TypeChar; + public: + typedef typename + ZtCCharInt::TypeInt TypeInt ; + public: + static const int CI_ByteSize = sizeof(TypeChar); + public: + typedef TypeChar char_type ; // for stl + typedef TypeInt int_type ; // for stl + public: + };/* + template<> class ZtCCharType*/ + namespace ZNsView { diff --git a/ZCppMain/ZMainHeadEx.H b/ZCppMain/ZMainHeadEx.H index 358c29b..ae8737c 100644 --- a/ZCppMain/ZMainHeadEx.H +++ b/ZCppMain/ZMainHeadEx.H @@ -7399,7 +7399,7 @@ namespace ZNsMain ZTypLength VL_ReadSize = 0 ; ZTypCPChar VP_CopyStart = - const_cast(ARR_SaveCStr.c_str())+VL_PrevSize ; + const_cast(ARR_SaveCStr.data())+VL_PrevSize ; if((VL_ReadSize = read(AH_FileDesc, VP_CopyStart, VL_LastPos))<0) { @@ -7446,7 +7446,7 @@ namespace ZNsMain ::SetFilePointer(VH_File, AL_Offset, NULL, FILE_BEGIN); ZTypCPChar VP_CopyStart = - const_cast(ARR_SaveCStr.c_str())+VL_PrevSize ; + const_cast(ARR_SaveCStr.data())+VL_PrevSize ; if(::ReadFile(VH_File, (LPVOID)VP_CopyStart, dwRead, &dwRead2, NULL)==FALSE) { diff --git a/ZCppMain/ZtCStringEx.H b/ZCppMain/ZtCStringEx.H index 5d4978a..fabcda7 100644 --- a/ZCppMain/ZtCStringEx.H +++ b/ZCppMain/ZtCStringEx.H @@ -131,6 +131,40 @@ namespace ZNsMain class ZtCStringBase; /*::::::::::::::::::::::::::::::::::::::::::::*/ + + template ////////////////////////////////////////////////////////////////// + < + template + class ZtCStringBase, + typename TTypCh , typename TAlloc, + typename TAllocSize, typename TTypeString + > + class ZtCCharType + < ZtCStringBase > + /*#######################################################################*/ + { + public: + typedef ZtCStringBase /////////////////////////// + < + TTypCh, TAlloc, TAllocSize, TTypeString + > + /*/////////////////////////////////*/ TypeCStr ; + public: + typedef TTypCh /*//////////////////*/ TypeChar ; + public: + static const int CI_ByteSize = sizeof(TypeChar) ; + public: + typedef typename + ZtCCharInt::TypeInt TypeInt ; + public: + typedef TypeChar char_type ; // for stl + typedef TypeInt int_type ; // for stl + public: + };/* + class ZtCCharType /*#####################################################*/ + + + namespace ZNsType { @@ -258,12 +292,11 @@ namespace ZNsMain { public: - typedef typename TTypeString::template ZtCHelpBase< /////// - ZtCStringBase - < - TTypCh, TAlloc, TAllocSize, TTypeString - > - /*////////*/ > TypeHelpBase; ///////////////////////////// + typedef typename TTypeString::template ZtCHelpBase /////////// + < + ZtCStringBase + > + TypeHelpBase; //////////////////////////////////////////////// typedef typename TypeHelpBase::ZCStringList ZCStringList ; @@ -298,6 +331,10 @@ namespace ZNsMain typedef TAlloc TypeAlloc ; typedef ZCStringList TypeList ; public: + typedef ZNsMain::ZtCCharType ZCCharType ; + typedef ZNsMain::ZtCCharType traits_type; + typedef typename ZCCharType::TypeInt TypeCharInt; + public: enum EWriteFile // WriteFile() 에서 사용한다. { diff --git a/ZCppMainTest/ZtCStringBase_000.cpp b/ZCppMainTest/ZtCStringBase_000.cpp index f2d6f14..9e9ebbe 100644 --- a/ZCppMainTest/ZtCStringBase_000.cpp +++ b/ZCppMainTest/ZtCStringBase_000.cpp @@ -14,8 +14,19 @@ namespace ZNsMain namespace ZNsExam { - typedef ZtCStringBase CStringBase; - typedef CStringBase::ZCCharView ZCCharView ; + typedef ZtCStringBase ZCStringBase ; + typedef ZtCStringBase ZCStringBaseW ; + typedef ZCStringBase::ZCCharView ZCCharView ; + typedef ZtCCharType ZCCharType ; + typedef ZtCCharType ZCCharTypeW ; + + typedef ZCCharType ::TypeChar TypeChar ; + typedef ZCCharTypeW::TypeChar TypeCharW ; + typedef ZCCharType ::TypeInt TypeCharInt ; + typedef ZCCharTypeW::TypeInt TypeCharIntW ; + + const int CI_ByteSize = ZCCharType ::CI_ByteSize ; + const int CI_ByteSizeW= ZCCharTypeW::CI_ByteSize ; template class ZtCExamCStringBase_000 @@ -24,9 +35,29 @@ namespace ZNsMain static int Main(int AI_ArgCnt=0, char* APP_ArgVal[]=0) { + cout<<"# TypeChar ="<