diff --git a/ZCppMain/ZMainHead.H b/ZCppMain/ZMainHead.H index a4ddb3b..925644c 100644 --- a/ZCppMain/ZMainHead.H +++ b/ZCppMain/ZMainHead.H @@ -5408,13 +5408,41 @@ namespace ZNsMain //////////////////////////////////////////// - template<> string& ZftMakeStr(string& ARR_SaveCStr, const string& AR_DataCStr) - { - ARR_SaveCStr.append(AR_DataCStr); return ARR_SaveCStr; - }/* - template<> string& ZftMakeStr(string& ARR_SaveCStr, const string& AR_DataCStr)*/ + template<> string& ZftMakeStr(string& ARR_SaveCStr, const string& AR_DataCStr) + { ARR_SaveCStr.append(AR_DataCStr); return ARR_SaveCStr; } + template<> wstring& ZftMakeStr(wstring& ARR_SaveCStr, const wstring& AR_DataCStr) + { ARR_SaveCStr.append(AR_DataCStr); return ARR_SaveCStr; } + /*#############################################################################*/ - template<> string& ZftMakeStr(string& ARR_SaveCStr, long AL_Long) + + //::swprintf((wchar_t*)VCA_BuffParam, CI_BuffSize, L"%d", AI_IntParam) + + template<> string& ZftMakeStr(string& ARR_SaveCStr, int AI_Int) + { + ZTycInt CI_BuffSize = 31 ; + ZTypChar VCA_BuffParam[CI_BuffSize] ; + + ZTypInt VI_ResultSize = + ::sprintf(VCA_BuffParam, "%d", AI_Int); + + return ARR_SaveCStr.append + (VCA_BuffParam, VI_ResultSize); + }/* + template<> string& ZftMakeStr(string& ARR_SaveCStr, int AI_Int)*/ + template<> wstring& ZftMakeStr(wstring& ARR_SaveCStr, int AI_Int) + { + ZTycInt CI_BuffSize = 31 ; + ZTypCharW VCA_BuffParam[CI_BuffSize] ; + + ZTypInt VI_ResultSize = ::swprintf + (VCA_BuffParam, CI_BuffSize, L"%d", AI_Int); + + return ARR_SaveCStr.append + (VCA_BuffParam, VI_ResultSize) ; + }/* + template<> string& ZftMakeStr(string& ARR_SaveCStr, int AI_Int)*/ + + template<> string& ZftMakeStr(string& ARR_SaveCStr, long AL_Long) { ZTycInt CI_BuffSize = 31 ; ZTypChar VCA_BuffParam[CI_BuffSize] ; @@ -5422,48 +5450,99 @@ namespace ZNsMain ZTypInt VI_ResultSize = ::sprintf(VCA_BuffParam, "%ld", AL_Long); - ARR_SaveCStr.append + return ARR_SaveCStr.append (VCA_BuffParam, VI_ResultSize); + }/* + template<> string& ZftMakeStr(string& ARR_SaveCStr, long AL_Long)*/ + template<> wstring& ZftMakeStr(wstring& ARR_SaveCStr, long AL_Long) + { + ZTycInt CI_BuffSize = 31 ; + ZTypCharW VCA_BuffParam[CI_BuffSize] ; + + ZTypInt VI_ResultSize = ::swprintf + (VCA_BuffParam, CI_BuffSize, L"%ld", AL_Long); + + ARR_SaveCStr.append + (VCA_BuffParam, VI_ResultSize) ; return ARR_SaveCStr; }/* - template<> string& ZftMakeStr(string& ARR_SaveCStr, long AL_Long)*/ + template<> wstring& ZftMakeStr(wstring& ARR_SaveCStr, long AL_Long)*/ - template<> string& ZftMakeStr(string& ARR_SaveCStr, double AD_Double) + template<> string& ZftMakeStr(string& ARR_SaveCStr, ZTypLLong ALL_Long) + { + ZTycInt CI_BuffSize = 41 ; + ZTypChar VCA_BuffParam[CI_BuffSize] ; + + #ifdef _WIN + ZTypInt VI_ResultSize = + ( ::sprintf(VCA_BuffParam, "%I64u", ALL_Long) ); + #else + ZTypInt VI_ResultSize = + ( ::sprintf(VCA_BuffParam, "%llu" , ALL_Long) ); + #endif + return ARR_SaveCStr.append + (VCA_BuffParam, VI_ResultSize); + }/* + template<> string& ZftMakeStr(string& ARR_SaveCStr, ZTypLLong ALL_Long)*/ + template<> wstring& ZftMakeStr(wstring& ARR_SaveCStr, ZTypLLong ALL_Long) + { + ZTycInt CI_BuffSize = 41 ; + ZTypCharW VCA_BuffParam[CI_BuffSize] ; + + #ifdef _WIN + ZTypInt VI_ResultSize = ::swprintf + (VCA_BuffParam, CI_BuffSize, L"%I64u", ALL_Long) ; + #else + ZTypInt VI_ResultSize = ::swprintf + (VCA_BuffParam, CI_BuffSize, L"%llu" , ALL_Long) ; + #endif + return ARR_SaveCStr.append + (VCA_BuffParam, VI_ResultSize); + }/* + template<> wstring& ZftMakeStr(wstring& ARR_SaveCStr, ZTypLLong ALL_Long)*/ + + template<> string& ZftMakeStr(string& ARR_SaveCStr, double AD_Double) { ZTycInt CI_BuffSize=51 ; ZTypChar VCA_BuffParam[CI_BuffSize]; ZTypInt VI_ResultSize = ::sprintf - ( - VCA_BuffParam, "%f", AD_Double - ); - ///////////////////////////// + ( VCA_BuffParam, "%f", AD_Double ); + /********************************/ - ARR_SaveCStr.append + return ARR_SaveCStr.append (VCA_BuffParam, VI_ResultSize); - - return ARR_SaveCStr; }/* - template<> string& ZftMakeStr(string& ARR_SaveCStr, double AD_Double)*/ - - template<> string& ZftMakeStr(string& ARR_SaveCStr, bool AB_Bool) + template<> string& ZftMakeStr(string& ARR_SaveCStr, double AD_Double)*/ + template<> wstring& ZftMakeStr(wstring& ARR_SaveCStr, double AD_Double) { - if (AB_Bool) - ARR_SaveCStr.append("true" ); - else ARR_SaveCStr.append("false"); + ZTycInt CI_BuffSize=51 ; + ZTypCharW VCA_BuffParam[CI_BuffSize]; - return ARR_SaveCStr; + ZTypInt VI_ResultSize = ::swprintf + (VCA_BuffParam, CI_BuffSize, L"%f", AD_Double); + /*********************************/ + + return ARR_SaveCStr.append + (VCA_BuffParam, VI_ResultSize); }/* - template<> string& ZftMakeStr(string& ARR_SaveCStr, bool AB_Bool)*/ + template<> wstring& ZftMakeStr(wstring& ARR_SaveCStr, double AD_Double)*/ + + template<> string& ZftMakeStr(string& ARR_SaveCStr, bool AB_Bool) + { return ARR_SaveCStr.append( AB_Bool ? "true" : "false" ); } + template<> wstring& ZftMakeStr(wstring& ARR_SaveCStr, bool AB_Bool) + { return ARR_SaveCStr.append( AB_Bool ? L"true" : L"false" ); } template class ZtCChars ; /*++++++++++++++++++++++++++++++++++++++++++++++*/ - template<> string& ZftMakeStr - (string& ARR_SaveCStr, const ZtCChars& AR_View); + template<> string & ZftMakeStr + (string& ARR_SaveCStr, const ZtCChars& AR_View); + template<> wstring& ZftMakeStr + (wstring& ARR_SaveCStr, const ZtCChars& AR_View); @@ -7186,8 +7265,9 @@ namespace ZNsMain explicit ZtCChars(TypeCharC* APC_TypeChar) { mp_TypeChar = - const_cast(APC_TypeChar); - ml_TypeSize = ZftGetLength(mp_TypeChar); + const_cast (APC_TypeChar); + ml_TypeSize = ZftLengthType + (mp_TypeChar ); }/* explicit ZtCChars(TypeCharC* APC_TypeChar)*/ @@ -7195,14 +7275,15 @@ namespace ZNsMain { mp_TypeChar = const_cast (APC_TypeChar); - ml_TypeSize = AL_Length ; + ml_TypeSize = AL_Length ; }/* ZtCChars(TypeCharC* APC_TypeChar, TypeSize AL_Length)*/ ZtCChars(const ZtCChars& rhs) { - mp_TypeChar = const_cast(rhs).mp_TypeChar ; - ml_TypeSize = const_cast(rhs).ml_TypeSize ; + mp_TypeChar = const_cast + ( rhs.mp_TypeChar ) ; + ml_TypeSize = rhs.ml_TypeSize ; }/* ZtCChars(const ZtCChars& rhs)*/ @@ -7462,11 +7543,16 @@ namespace ZNsMain - template<> string& ZftMakeStr(string& ARR_SaveCStr, const ZCCharView& AR_View) + template<> string& ZftMakeStr(string& ARR_SaveCStr, const ZCCharView& AR_View) { ARR_SaveCStr.append(AR_View.data(), AR_View.size()); return ARR_SaveCStr; }/* - template<> string& ZftMakeStr(string& ARR_SaveCStr, const ZCCharView& AR_View)*/ + template<> string& ZftMakeStr(string& ARR_SaveCStr, const ZCCharView& AR_View)*/ + template<> wstring& ZftMakeStr(wstring& ARR_SaveCStr, const ZCCharViewW& AR_View) + { + ARR_SaveCStr.append(AR_View.data(), AR_View.size()); return ARR_SaveCStr; + }/* + template<> wstring& ZftMakeStr(wstring& ARR_SaveCStr, const ZCCharViewW& AR_View)*/ /*////////////////////////////////////////////////////////////////////////////////////// @@ -7556,6 +7642,69 @@ namespace ZNsMain template<> class ZtCCharType*/ + template class ZtCBoolStr + { + public: + /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ + typedef ZtCChars ZCChars; + /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ + static const ZCChars& GetMarkTrue () + { static const ZCChars SO_ZCChars; return SO_ZCChars; } + static const ZCChars& GetMarkFalse() + { static const ZCChars SO_ZCChars; return SO_ZCChars; } + /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ + static const ZCChars& GetMark(bool AB_Bool) + { + return AB_Bool ? GetMarkTrue() : GetMarkFalse(); + } + /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ + public: + }; + /*##############################################################################*/ + template + class ZtCBoolStr /*+++++++++++++++++++++++++++++++*/ + { + public: + /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ + typedef ZtCChars ZCChars; + /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ + static const ZCChars& GetMarkTrue () + { static const ZCChars SO_ZCChars("true" ); return SO_ZCChars; } + static const ZCChars& GetMarkFalse() + { static const ZCChars SO_ZCChars("false"); return SO_ZCChars; } + /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ + static const ZCChars& GetMark(bool AB_Bool) + { + return AB_Bool ? GetMarkTrue() : GetMarkFalse(); + } + /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ + public: + }; + /*::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::*/ + + template + class ZtCBoolStr /*++++++++++++++++++++++++++++*/ + { + public: + /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ + typedef ZtCChars ZCChars; + /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ + static const ZCChars& GetMarkTrue () + { static const ZCChars SO_ZCChars(L"true" ); return SO_ZCChars; } + static const ZCChars& GetMarkFalse() + { static const ZCChars SO_ZCChars(L"false"); return SO_ZCChars; } + /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ + static const ZCChars& GetMark(bool AB_Bool) + { + return AB_Bool ? GetMarkTrue() : GetMarkFalse(); + } + /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ + public: + }; + /*::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::*/ + + + namespace ZNsView { diff --git a/ZCppMain/ZtCMainChars.H b/ZCppMain/ZtCMainChars.H index 6337ff0..51025ea 100644 --- a/ZCppMain/ZtCMainChars.H +++ b/ZCppMain/ZtCMainChars.H @@ -194,13 +194,14 @@ namespace ZNsMain { public: typedef TTypeChar TypeChar ; - typedef TTypeLength TypeLength; // signed 형이어야 한다. - public: + typedef TTypeLength TypeLength; + /*++++++++++++++++++++++++++++++++++++++++++++++++++++*/ typedef const TypeChar TypeCharC ; typedef const TypeChar* TypeCharCP; - public: - typedef ZNsMain::ZtCChars ZCChars; - public: + /*++++++++++++++++++++++++++++++++++++++++++++++++++++*/ + typedef ZNsMain::ZtCChars + ZCChars; + /*++++++++++++++++++++++++++++++++++++++++++++++++++++*/ static TypeChar GetCharOfAnsi(char AC_AnsiChar) { diff --git a/ZCppMain/ZtCStringEx.H b/ZCppMain/ZtCStringEx.H index f1d402c..1a2bae4 100644 --- a/ZCppMain/ZtCStringEx.H +++ b/ZCppMain/ZtCStringEx.H @@ -1706,6 +1706,19 @@ namespace ZNsMain }/* ZCStringBase& operator()(double AD_DoubleParam)*/ + ZCStringBase& operator()(bool AB_Bool) + { + typedef typename TypeThis::TypeChar TypeChar ; + typedef typename TypeThis::TypeSize TypeSize ; + + typedef ZtCBoolStr + ZCBoolStr; + + return (*this)( ZCBoolStr::GetMark(AB_Bool) ); + }/* + ZCStringBase& operator()(bool AB_Bool)*/ + + ZCStringBase& operator()( TypeLength AL_AddSize, TypeCharC* APC_Format, ...) { @@ -7448,7 +7461,8 @@ namespace ZNsMain void erase(){ clear(); } - public:*/ + public: + /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ public: @@ -7551,7 +7565,8 @@ namespace ZNsMain { return ARR_SaveCStr(AR_DataCStr); } _ZCSTRINGBASE_ARG_ _ZCSTRINGBASE_& ZftMakeStr - ( _ZCSTRINGBASE_& ARR_SaveCStr, char AC_Char ) + ( _ZCSTRINGBASE_& ARR_SaveCStr, typename + _ZCSTRINGBASE_::TypeChar AC_Char ) { return ARR_SaveCStr(AC_Char ); } _ZCSTRINGBASE_ARG_ _ZCSTRINGBASE_& ZftMakeStr @@ -7569,13 +7584,15 @@ namespace ZNsMain _ZCSTRINGBASE_ARG_ _ZCSTRINGBASE_& ZftMakeStr ( _ZCSTRINGBASE_& ARR_SaveCStr, bool AB_Bool ) { - if (AB_Bool) - ARR_SaveCStr.append("true" ); - else ARR_SaveCStr.append("false"); + typedef typename _ZCSTRINGBASE_::TypeChar TypeChar; + typedef typename _ZCSTRINGBASE_::TypeSize TypeSize; - return ARR_SaveCStr; + typedef ZtCBoolStr ZCBoolStr; + + return ARR_SaveCStr(ZCBoolStr::GetMark(AB_Bool)); }/* - _ZCSTRINGBASE_& ZftMakeStr( _ZCSTRINGBASE_& ARR_SaveCStr, bool AB_Bool)*/ + _ZCSTRINGBASE_ARG_ _ZCSTRINGBASE_& ZftMakeStr + ( _ZCSTRINGBASE_& ARR_SaveCStr, bool AB_Bool ) */ #undef _ZCSTRINGBASE_ diff --git a/ZCppMain/ZtCStringStd.H b/ZCppMain/ZtCStringStd.H index 091a286..ebbb14a 100644 --- a/ZCppMain/ZtCStringStd.H +++ b/ZCppMain/ZtCStringStd.H @@ -45,9 +45,12 @@ namespace ZNsMain class ZtCStringStd : public TTypString { public: + typedef ZtCStringStd TypeThis; + /*+++++++++++++++++++++++++++++++++++++++++++++++++*/ typedef typename TTypString::traits_type::char_type TypeChar ; typedef typename TTypString::traits_type::int_type TypeCharInt ; - public: + typedef typename TTypString::size_type TypeLength ; + /*+++++++++++++++++++++++++++++++++++++++++++++++++*/ typedef ZNsChars::ZNsType:: ZtCTypeChars ZCTypeChars ; typedef ZNsChars:: @@ -57,12 +60,13 @@ namespace ZNsMain typedef const TypeChar* TypeCPChar ; typedef TTypString TypeBase ; typedef TTypString TypeStrStd ; - typedef ZTypLength TypeLength ; - typedef ZTypLength TypeSize ; + typedef TypeLength TypeSize ; + /*+++++++++++++++++++++++++++++++++++++++++++++++++*/ + typedef ZtCChars + ZCChars ; + typedef ZtCChars + ZCCharView ; /*+++++++++++++++++++++++++++++++++++++++++++++++++*/ - typedef ZtCChars ZCChars ; - typedef ZtCChars ZCCharView ; - public: ZtCStringStd(): TypeStrStd(){} ZtCStringStd(const ZtCStringStd& rhs): TypeStrStd(rhs){} @@ -389,6 +393,24 @@ namespace ZNsMain }/* ZtCStringStd& operator()(TypeChar AC_Data, TypeLength AI_Repeat=1)*/ + ZtCStringStd& operator()(const ZCCharView& AR_View) + { + this->append(AR_View.data(), AR_View.size()); return *this; + }/* + ZtCStringStd& operator()(const ZCCharView& AR_View)*/ + + ZtCStringStd& operator()(bool AB_Bool) + { + typedef typename TypeThis::TypeChar TypeChar ; + typedef typename TypeThis::TypeSize TypeSize ; + + typedef ZtCBoolStr + ZCBoolStr; + + return (*this)( ZCBoolStr::GetMark(AB_Bool) ); + }/* + ZtCStringStd& operator()(bool AB_Bool)*/ + ZtCStringStd& operator()(int AI_IntParam) { @@ -520,6 +542,58 @@ namespace ZNsMain class ZtCStringStd : public TTypString */ + typedef ZtCStringStd ZCStringStd ; + typedef ZtCStringStd ZCStringStdW; + + + #define _ZCSTRINGSTD_ ZtCStringStd< TTypString > + #define _ZCSTRINGSTD_ARG_ template< typename TTypString > + + _ZCSTRINGSTD_ARG_ _ZCSTRINGSTD_& ZftMakeStr + ( _ZCSTRINGSTD_& ARR_SaveCStr, const _ZCSTRINGSTD_& AR_DataCStr) + { return ARR_SaveCStr(AR_DataCStr); } + + _ZCSTRINGSTD_ARG_ _ZCSTRINGSTD_& ZftMakeStr + ( _ZCSTRINGSTD_& ARR_SaveCStr, const typename + _ZCSTRINGSTD_::ZCChars& AR_DataCStr ) + { return ARR_SaveCStr(AR_DataCStr); } + + _ZCSTRINGSTD_ARG_ _ZCSTRINGSTD_& ZftMakeStr + ( _ZCSTRINGSTD_& ARR_SaveCStr, typename + _ZCSTRINGSTD_::TypeChar AC_Char ) + { return ARR_SaveCStr(AC_Char ); } + + _ZCSTRINGSTD_ARG_ _ZCSTRINGSTD_& ZftMakeStr + ( _ZCSTRINGSTD_& ARR_SaveCStr, int AI_IntI ) + { return ARR_SaveCStr(AI_IntI ); } + + _ZCSTRINGSTD_ARG_ _ZCSTRINGSTD_& ZftMakeStr + ( _ZCSTRINGSTD_& ARR_SaveCStr, long AL_Long ) + { return ARR_SaveCStr(AL_Long ); } + + _ZCSTRINGSTD_ARG_ _ZCSTRINGSTD_& ZftMakeStr + ( _ZCSTRINGSTD_& ARR_SaveCStr, double AD_Double ) + { return ARR_SaveCStr(AD_Double ); } + + _ZCSTRINGSTD_ARG_ _ZCSTRINGSTD_& ZftMakeStr + ( _ZCSTRINGSTD_& ARR_SaveCStr, bool AB_Bool ) + { + typedef typename _ZCSTRINGSTD_::TypeChar TypeChar; + typedef typename _ZCSTRINGSTD_::TypeSize TypeSize; + + typedef ZtCBoolStr ZCBoolStr; + + return ARR_SaveCStr(ZCBoolStr::GetMark(AB_Bool)); + }/* + _ZCSTRINGSTD_ARG_ _ZCSTRINGSTD_& ZftMakeStr + ( _ZCSTRINGSTD_& ARR_SaveCStr, bool AB_Bool ) */ + + + #undef _ZCSTRINGSTD_ + #undef _ZCSTRINGSTD_ARG_ + + + template std::ostream& operator<< (std::ostream& AR_COStream, const ZtCStringStd& AR_DataCStr) { @@ -535,6 +609,48 @@ namespace ZNsMain (std::ostream& AR_COStream, const ZtCStringStd& AR_DataCStr)*/ + std::ostream& operator<< + (std::ostream& AR_COStream, const ZCStringStd& AR_DataCStr) + { + typedef ZCStringStd::TypeBase TypeBaseCStr; + + AR_COStream<< static_cast + ( AR_DataCStr ); + + return AR_COStream; /*********************/ + }/* + template std::ostream& operator<< + (std::ostream& AR_COStream, const ZtCStringStd& AR_DataCStr)*/ + + + std::ostream& operator<< + (std::ostream& AR_COStream, const ZCStringStdW& AR_DataCStr) + { + // ascii 코드 범위에서만 출력한다. + + typedef ZCStringStdW::TypeSize TypeLength ; + typedef ZCStringStdW::TypeCharInt TypeCharInt; + + ZTypCCharW* VP_Data = AR_DataCStr.data(); + TypeLength VI_Size = AR_DataCStr.size(); + + const int CI_AsciiMax = 127 ; + + __for0(TypeLength, i, VI_Size) + { + TypeCharInt VI_Code = TypeCharInt(*VP_Data++); + + if(VI_Code>0 && VI_Code<=CI_AsciiMax) + { AR_COStream.put( char(VI_Code) ); } + }/* + __for0(TypeLength, i, VI_Size)*/ + + return AR_COStream; /*********************/ + }/* + template std::ostream& operator<< + (std::ostream& AR_COStream, const ZtCStringStd& AR_DataCStr)*/ + + }/* namespace ZNsMain*/ diff --git a/ZCppMainTest/ZtCStringBase_000.cpp b/ZCppMainTest/ZtCStringBase_000.cpp index 550f748..d8cfbae 100644 --- a/ZCppMainTest/ZtCStringBase_000.cpp +++ b/ZCppMainTest/ZtCStringBase_000.cpp @@ -22,10 +22,12 @@ namespace ZNsMain typedef ZCStringBase ::ZCCharView ZCCharView ; typedef ZCStringBaseW::ZCCharView ZCCharViewW ; + typedef ZCStringStd ::ZCCharView ZCCharViewS ; + typedef ZCStringStdW ::ZCCharView ZCCharViewSW ; typedef ZtCCharType ZCCharType ; typedef ZtCCharType ZCCharTypeW ; - typedef ZtCCharType ZCCharTypeS ; - typedef ZtCCharType ZCCharTypeSW ; + typedef ZtCCharType ZCCharTypeS ; + typedef ZtCCharType ZCCharTypeSW ; typedef ZCCharType ::TypeChar TypeChar ; typedef ZCCharTypeW ::TypeChar TypeCharW ; @@ -123,7 +125,7 @@ namespace ZNsMain ZCStringBase VO_ZCStringStd(CO_ZCCharView); cout<<"# "<