commit 2025-10-08 20:43 add ZtCCharType in ZCppMain/ZMainHead.H
This commit is contained in:
@ -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<int TTyiByteSize> class ZtCCharIntBySize
|
||||
{
|
||||
public: typedef ZTypLong TypeInt;
|
||||
};/*
|
||||
template<int TTyiByteSize> class ZtCCharIntBySize*/
|
||||
|
||||
template<> class ZtCCharIntBySize<ZNsIn::CI_Char1Byte>
|
||||
{ public: typedef ZTypInt TypeInt; };
|
||||
template<> class ZtCCharIntBySize<ZNsIn::CI_Char2Byte>
|
||||
{ public: typedef ZTypInt TypeInt; };
|
||||
template<> class ZtCCharIntBySize<ZNsIn::CI_Char4Byte>
|
||||
{ public: typedef ZTypLong TypeInt; };
|
||||
|
||||
|
||||
template<typename TTypChar> class ZtCCharInt
|
||||
{
|
||||
public: typedef int TypeInt;
|
||||
public: typedef typename ZtCCharIntBySize<sizeof(TTypChar)>::TypeInte TypeInt;
|
||||
};/*
|
||||
template<typename TTypChar> class ZtCCharInt*/
|
||||
|
||||
template<> class ZtCCharInt<char>
|
||||
{
|
||||
public: typedef int TypeInt;
|
||||
public: typedef typename ZtCCharIntBySize<sizeof(char) >::TypeInt TypeInt;
|
||||
};/*
|
||||
template<> class ZtCCharInt<char>*/
|
||||
|
||||
template<> class ZtCCharInt<wchar_t>
|
||||
{
|
||||
public: typedef int TypeInt;
|
||||
public: typedef typename ZtCCharIntBySize<sizeof(wchar_t) >::TypeInt TypeInt;
|
||||
};/*
|
||||
template<> class ZtCCharInt<wchar_t>*/
|
||||
|
||||
@ -7321,6 +7344,83 @@ namespace ZNsMain
|
||||
template<> string& ZftMakeStr(string& ARR_SaveCStr, const ZCCharView& AR_View)*/
|
||||
|
||||
|
||||
/*//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
■ template<typename TTypString> 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<typename TTypString> class ZtCCharType
|
||||
{
|
||||
public:
|
||||
typedef typename TTypString::
|
||||
traits_type::char_type /*++*/ TypeChar;
|
||||
typedef TTypString /*+++++++++*/ TypeCStr;
|
||||
public:
|
||||
typedef typename
|
||||
ZtCCharInt<TypeChar>::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<typename TTypString> class ZtCCharType*/
|
||||
|
||||
template<> class ZtCCharType<std::string>
|
||||
{
|
||||
public:
|
||||
typedef std::string /*+++++++*/ TypeCStr;
|
||||
typedef char /*+++++++++++++++*/ TypeChar;
|
||||
public:
|
||||
typedef typename
|
||||
ZtCCharInt<char>::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<std::string>*/
|
||||
|
||||
template<> class ZtCCharType<std::wstring>
|
||||
{
|
||||
public:
|
||||
typedef std::wstring /*+++++++*/ TypeCStr;
|
||||
typedef wchar_t /*+++++++++++*/ TypeChar;
|
||||
public:
|
||||
typedef typename
|
||||
ZtCCharInt<wchar_t>::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<std::wstring>*/
|
||||
|
||||
|
||||
namespace ZNsView
|
||||
{
|
||||
|
Reference in New Issue
Block a user