commit 2025-10-09 01:41 bug fix of operator()(long), (long long) etc : ZCppMain/ZtCStringStd.H

This commit is contained in:
2025-10-09 01:41:26 +09:00
parent 0100406f3f
commit 5a1dba2a38
3 changed files with 154 additions and 72 deletions

View File

@ -1575,88 +1575,118 @@ namespace ZNsMain
}/* }/*
ZCStringBase& operator()(const ZCChars& AR_CChars)*/ ZCStringBase& operator()(const ZCChars& AR_CChars)*/
ZCStringBase& operator()(int AI_IntParam) ZCStringBase& operator()(int AI_IntParam)
{ {
const int CI_BuffSize=21; char VCA_BuffParam[CI_BuffSize]; const int CI_BuffSize= 21; TypeChar VCA_BuffParam[CI_BuffSize] ;
int VI_ResultSize = ::sprintf(VCA_BuffParam, "%d", AI_IntParam); int VI_ResultSize = /*::::::::::::::::::::::::::::::::::::::::*/
(
return (*this)(VCA_BuffParam, VI_ResultSize); sizeof(TypeChar)<=1
? ::sprintf ((char* )VCA_BuffParam, /*+++++++*/ "%d", AI_IntParam)
: ::swprintf((wchar_t*)VCA_BuffParam, CI_BuffSize, L"%d", AI_IntParam)
);
return (*this)(VCA_BuffParam, VI_ResultSize); /*::::::::::::::*/
}/* }/*
ZCStringBase& operator()(int AI_IntParam)*/ ZCStringBase& operator()(int AI_IntParam)*/
ZCStringBase& operator()(ZTypUInt AUI_UIntParam) ZCStringBase& operator()(ZTypUInt AUI_UIntParam)
{ {
const int CI_BuffSize=21; char VCA_BuffParam[CI_BuffSize]; const int CI_BuffSize= 21; TypeChar VCA_BuffParam[CI_BuffSize] ;
int VI_ResultSize = ::sprintf(VCA_BuffParam, "%u", AUI_UIntParam); int VI_ResultSize = /*::::::::::::::::::::::::::::::::::::::::*/
(
return (*this)(VCA_BuffParam, VI_ResultSize); sizeof(TypeChar)<=1
? ::sprintf ((char* )VCA_BuffParam, /*++++++++*/ "%u", AUI_UIntParam)
: ::swprintf((wchar_t*)VCA_BuffParam, CI_BuffSize, L"%u", AUI_UIntParam)
);
return (*this)(VCA_BuffParam, VI_ResultSize); /*::::::::::::::*/
}/* }/*
ZCStringBase& operator()(ZTypUInt AUI_UIntParam)*/ ZCStringBase& operator()(ZTypUInt AUI_UIntParam)*/
ZCStringBase& operator()(ZTypLong AL_LongParam) ZCStringBase& operator()(ZTypLong AL_LongParam)
{ {
const int CI_BuffSize=31; char VCA_BuffParam[CI_BuffSize]; const int CI_BuffSize= 31; TypeChar VCA_BuffParam[CI_BuffSize] ;
int VI_ResultSize = ::sprintf(VCA_BuffParam, "%ld", AL_LongParam); int VI_ResultSize = /*::::::::::::::::::::::::::::::::::::::::*/
(
return (*this)(VCA_BuffParam, VI_ResultSize); sizeof(TypeChar)<=1
? ::sprintf ((char* )VCA_BuffParam, /*++++++++*/ "%ld", AL_LongParam)
: ::swprintf((wchar_t*)VCA_BuffParam, CI_BuffSize, L"%ld", AL_LongParam)
);
return (*this)(VCA_BuffParam, VI_ResultSize); /*::::::::::::::*/
}/* }/*
ZCStringBase& operator()(ZTypLong AL_LongParam)*/ ZCStringBase& operator()(ZTypLong AL_LongParam)*/
ZCStringBase& operator()(ZTypULong AUL_ULongParam) ZCStringBase& operator()(ZTypULong AUL_ULongParam)
{ {
const int CI_BuffSize=31; char VCA_BuffParam[CI_BuffSize]; const int CI_BuffSize= 31; TypeChar VCA_BuffParam[CI_BuffSize] ;
int VI_ResultSize = ::sprintf(VCA_BuffParam, "%lu", AUL_ULongParam); int VI_ResultSize = /*::::::::::::::::::::::::::::::::::::::::*/
(
return (*this)(VCA_BuffParam, VI_ResultSize); sizeof(TypeChar)<=1
? ::sprintf ((char* )VCA_BuffParam, /*++++++++*/ "%lu", AUL_ULongParam)
: ::swprintf((wchar_t*)VCA_BuffParam, CI_BuffSize, L"%lu", AUL_ULongParam)
);
return (*this)(VCA_BuffParam, VI_ResultSize); /*::::::::::::::*/
}/* }/*
ZCStringBase& operator()(ZTypULong AUL_ULongParam)*/ ZCStringBase& operator()(ZTypULong AUL_ULongParam)*/
ZCStringBase& operator()(ZTypLLong ALL_LLongParam) ZCStringBase& operator()(ZTypLLong ALL_LLongParam)
{ {
const int CI_BuffSize=41; char VCA_BuffParam[CI_BuffSize]; const int CI_BuffSize= 41; TypeChar VCA_BuffParam[CI_BuffSize] ;
#ifdef _WIN #ifdef _WIN
int VI_ResultSize = ::sprintf(VCA_BuffParam, "%I64d", ALL_LLongParam); int VI_ResultSize = /*::::::::::::::::::::::::::::::::::::::::*/
(
sizeof(TypeChar)<=1
? ::sprintf ((char* )VCA_BuffParam, /*++++++++*/ "%I64d", ALL_LLongParam)
: ::swprintf((wchar_t*)VCA_BuffParam, CI_BuffSize, L"%I64d", ALL_LLongParam)
);
#else #else
int VI_ResultSize = ::sprintf(VCA_BuffParam, "%lld" , ALL_LLongParam); int VI_ResultSize =
(
sizeof(TypeChar)<=1
? ::sprintf ((char* )VCA_BuffParam, /*++++++++*/ "%lld" , ALL_LLongParam)
: ::swprintf((wchar_t*)VCA_BuffParam, CI_BuffSize, L"%lld" , ALL_LLongParam)
);
#endif #endif
return (*this)(VCA_BuffParam, VI_ResultSize); /*::::::::::::::*/
return (*this)(VCA_BuffParam, VI_ResultSize);
}/* }/*
ZCStringBase& operator()(ZTypLLong ALL_LLongParam)*/ ZCStringBase& operator()(ZTypLLong ALL_LLongParam)*/
ZCStringBase& operator()(ZTypULLong AULL_LLongParam) ZCStringBase& operator()(ZTypULLong AULL_LLongParam)
{ {
const int CI_BuffSize=41; char VCA_BuffParam[CI_BuffSize]; const int CI_BuffSize= 41; TypeChar VCA_BuffParam[CI_BuffSize] ;
#ifdef _WIN #ifdef _WIN
int VI_ResultSize = ::sprintf(VCA_BuffParam, "%I64u", AULL_LLongParam); int VI_ResultSize = /*::::::::::::::::::::::::::::::::::::::::*/
(
sizeof(TypeChar)<=1
? ::sprintf ((char* )VCA_BuffParam, /*+++++++*/ "%I64u", AULL_LLongParam)
: ::swprintf((wchar_t*)VCA_BuffParam, CI_BuffSize, L"%I64u", AULL_LLongParam)
);
#else #else
int VI_ResultSize = ::sprintf(VCA_BuffParam, "%llu" , AULL_LLongParam); int VI_ResultSize = /*::::::::::::::::::::::::::::::::::::::::*/
(
sizeof(TypeChar)<=1
? ::sprintf ((char* )VCA_BuffParam, /*++++++++*/ "%llu" , AULL_LLongParam)
: ::swprintf((wchar_t*)VCA_BuffParam, CI_BuffSize, L"%llu" , AULL_LLongParam)
);
#endif #endif
return (*this)(VCA_BuffParam, VI_ResultSize); /*::::::::::::::*/
return (*this)(VCA_BuffParam, VI_ResultSize);
}/* }/*
ZCStringBase& operator()(ZTypULLong AULL_LLongParam)*/ ZCStringBase& operator()(ZTypULLong AULL_LLongParam)*/
ZCStringBase& operator()(double AD_DoubleParam) ZCStringBase& operator()(double AD_DoubleParam)
{ {
const int CI_BuffSize=51 ; const int CI_BuffSize= 51; TypeChar VCA_BuffParam[CI_BuffSize] ;
char VCA_BuffParam[CI_BuffSize];
int VI_ResultSize = ::sprintf int VI_ResultSize = /*::::::::::::::::::::::::::::::::::::::::*/
( (
VCA_BuffParam, "%f", AD_DoubleParam sizeof(TypeChar)<=1
? ::sprintf ((char* )VCA_BuffParam, /*++++++++*/ "%f", AD_DoubleParam)
: ::swprintf((wchar_t*)VCA_BuffParam, CI_BuffSize, L"%f", AD_DoubleParam)
); );
///////////////////////////// return (*this)(VCA_BuffParam, VI_ResultSize); /*::::::::::::::*/
TrimDecimalZero(VCA_BuffParam, VI_ResultSize);
return (*this)(VCA_BuffParam);
}/* }/*
ZCStringBase& operator()(double AD_DoubleParam)*/ ZCStringBase& operator()(double AD_DoubleParam)*/

View File

@ -345,84 +345,115 @@ namespace ZNsMain
ZtCStringStd& operator()(int AI_IntParam) ZtCStringStd& operator()(int AI_IntParam)
{ {
const int CI_BuffSize=21; char VCA_BuffParam[CI_BuffSize]; const int CI_BuffSize= 21; TypeChar VCA_BuffParam[CI_BuffSize] ;
int VI_ResultSize = ::sprintf(VCA_BuffParam, "%d", AI_IntParam); int VI_ResultSize = /*::::::::::::::::::::::::::::::::::::::::*/
(
return (*this)(VCA_BuffParam, VI_ResultSize); sizeof(TypeChar)<=1
? ::sprintf ((char* )VCA_BuffParam, /*+++++++*/ "%d", AI_IntParam)
: ::swprintf((wchar_t*)VCA_BuffParam, CI_BuffSize, L"%d", AI_IntParam)
);
return (*this)(VCA_BuffParam, VI_ResultSize); /*::::::::::::::*/
}/* }/*
ZtCStringStd& operator()(int AI_IntParam)*/ ZtCStringStd& operator()(int AI_IntParam)*/
ZtCStringStd& operator()(ZTypUInt AUI_UIntParam) ZtCStringStd& operator()(ZTypUInt AUI_UIntParam)
{ {
const int CI_BuffSize=21; char VCA_BuffParam[CI_BuffSize]; const int CI_BuffSize= 21; TypeChar VCA_BuffParam[CI_BuffSize] ;
int VI_ResultSize = ::sprintf(VCA_BuffParam, "%u", AUI_UIntParam); int VI_ResultSize = /*::::::::::::::::::::::::::::::::::::::::*/
(
return (*this)(VCA_BuffParam, VI_ResultSize); sizeof(TypeChar)<=1
? ::sprintf ((char* )VCA_BuffParam, /*++++++++*/ "%u", AUI_UIntParam)
: ::swprintf((wchar_t*)VCA_BuffParam, CI_BuffSize, L"%u", AUI_UIntParam)
);
return (*this)(VCA_BuffParam, VI_ResultSize); /*::::::::::::::*/
}/* }/*
ZtCStringStd& operator()(ZTypUInt AUI_UIntParam)*/ ZtCStringStd& operator()(ZTypUInt AUI_UIntParam)*/
ZtCStringStd& operator()(long AL_LongParam) ZtCStringStd& operator()(long AL_LongParam)
{ {
const int CI_BuffSize=31; char VCA_BuffParam[CI_BuffSize]; const int CI_BuffSize= 31; TypeChar VCA_BuffParam[CI_BuffSize] ;
int VI_ResultSize = ::sprintf(VCA_BuffParam, "%ld", AL_LongParam); int VI_ResultSize = /*::::::::::::::::::::::::::::::::::::::::*/
(
return (*this)(VCA_BuffParam, VI_ResultSize); sizeof(TypeChar)<=1
? ::sprintf ((char* )VCA_BuffParam, /*++++++++*/ "%ld", AL_LongParam)
: ::swprintf((wchar_t*)VCA_BuffParam, CI_BuffSize, L"%ld", AL_LongParam)
);
return (*this)(VCA_BuffParam, VI_ResultSize); /*::::::::::::::*/
}/* }/*
ZtCStringStd& operator()(long AL_LongParam)*/ ZtCStringStd& operator()(long AL_LongParam)*/
ZtCStringStd& operator()(ZTypULong AUL_ULongParam) ZtCStringStd& operator()(ZTypULong AUL_ULongParam)
{ {
const int CI_BuffSize=31; char VCA_BuffParam[CI_BuffSize]; const int CI_BuffSize= 31; TypeChar VCA_BuffParam[CI_BuffSize] ;
int VI_ResultSize = ::sprintf(VCA_BuffParam, "%lu", AUL_ULongParam); int VI_ResultSize = /*::::::::::::::::::::::::::::::::::::::::*/
(
return (*this)(VCA_BuffParam, VI_ResultSize); sizeof(TypeChar)<=1
? ::sprintf ((char* )VCA_BuffParam, /*++++++++*/ "%lu", AUL_ULongParam)
: ::swprintf((wchar_t*)VCA_BuffParam, CI_BuffSize, L"%lu", AUL_ULongParam)
);
return (*this)(VCA_BuffParam, VI_ResultSize); /*::::::::::::::*/
}/* }/*
ZtCStringStd& operator()(ZTypULong AUL_ULongParam)*/ ZtCStringStd& operator()(ZTypULong AUL_ULongParam)*/
ZtCStringStd& operator()(ZTypLLong ALL_LLongParam) ZtCStringStd& operator()(ZTypLLong ALL_LLongParam)
{ {
const int CI_BuffSize=41; char VCA_BuffParam[CI_BuffSize]; const int CI_BuffSize= 41; TypeChar VCA_BuffParam[CI_BuffSize] ;
#ifdef _WIN #ifdef _WIN
int VI_ResultSize = ::sprintf(VCA_BuffParam, "%I64d", ALL_LLongParam); int VI_ResultSize = /*::::::::::::::::::::::::::::::::::::::::*/
(
sizeof(TypeChar)<=1
? ::sprintf ((char* )VCA_BuffParam, /*++++++++*/ "%I64d", ALL_LLongParam)
: ::swprintf((wchar_t*)VCA_BuffParam, CI_BuffSize, L"%I64d", ALL_LLongParam)
);
#else #else
int VI_ResultSize = ::sprintf(VCA_BuffParam, "%lld" , ALL_LLongParam); int VI_ResultSize =
(
sizeof(TypeChar)<=1
? ::sprintf ((char* )VCA_BuffParam, /*++++++++*/ "%lld" , ALL_LLongParam)
: ::swprintf((wchar_t*)VCA_BuffParam, CI_BuffSize, L"%lld" , ALL_LLongParam)
);
#endif #endif
return (*this)(VCA_BuffParam, VI_ResultSize); /*::::::::::::::*/
return (*this)(VCA_BuffParam, VI_ResultSize);
}/* }/*
ZtCStringStd& operator()(ZTypLLong ALL_LLongParam)*/ ZtCStringStd& operator()(ZTypLLong ALL_LLongParam)*/
ZtCStringStd& operator()(ZTypULLong AULL_LLongParam) ZtCStringStd& operator()(ZTypULLong AULL_LLongParam)
{ {
const int CI_BuffSize=41; char VCA_BuffParam[CI_BuffSize]; const int CI_BuffSize= 41; TypeChar VCA_BuffParam[CI_BuffSize] ;
#ifdef _WIN #ifdef _WIN
int VI_ResultSize = ::sprintf(VCA_BuffParam, "%I64u", AULL_LLongParam); int VI_ResultSize = /*::::::::::::::::::::::::::::::::::::::::*/
(
sizeof(TypeChar)<=1
? ::sprintf ((char* )VCA_BuffParam, /*+++++++*/ "%I64u", AULL_LLongParam)
: ::swprintf((wchar_t*)VCA_BuffParam, CI_BuffSize, L"%I64u", AULL_LLongParam)
);
#else #else
int VI_ResultSize = ::sprintf(VCA_BuffParam, "%llu" , AULL_LLongParam); int VI_ResultSize = /*::::::::::::::::::::::::::::::::::::::::*/
(
sizeof(TypeChar)<=1
? ::sprintf ((char* )VCA_BuffParam, /*++++++++*/ "%llu" , AULL_LLongParam)
: ::swprintf((wchar_t*)VCA_BuffParam, CI_BuffSize, L"%llu" , AULL_LLongParam)
);
#endif #endif
return (*this)(VCA_BuffParam, VI_ResultSize); /*::::::::::::::*/
return (*this)(VCA_BuffParam, VI_ResultSize);
}/* }/*
ZtCStringStd& operator()(ZTypULLong AULL_LLongParam)*/ ZtCStringStd& operator()(ZTypULLong AULL_LLongParam)*/
ZtCStringStd& operator()(double AD_DoubleParam) ZtCStringStd& operator()(double AD_DoubleParam)
{ {
const int CI_BuffSize=51 ; const int CI_BuffSize= 51; TypeChar VCA_BuffParam[CI_BuffSize] ;
char VCA_BuffParam[CI_BuffSize];
int VI_ResultSize = ::sprintf int VI_ResultSize = /*::::::::::::::::::::::::::::::::::::::::*/
( (
VCA_BuffParam, "%f", AD_DoubleParam sizeof(TypeChar)<=1
? ::sprintf ((char* )VCA_BuffParam, /*++++++++*/ "%f", AD_DoubleParam)
: ::swprintf((wchar_t*)VCA_BuffParam, CI_BuffSize, L"%f", AD_DoubleParam)
); );
///////////////////////////// return (*this)(VCA_BuffParam, VI_ResultSize); /*::::::::::::::*/
return (*this)(VCA_BuffParam);
}/* }/*
ZtCStringStd& operator()(double AD_DoubleParam)*/ ZtCStringStd& operator()(double AD_DoubleParam)*/

View File

@ -3,6 +3,7 @@
#include <string> #include <string>
#include <iostream> #include <iostream>
#include "ZCppMain/ZtCStringEx.H" #include "ZCppMain/ZtCStringEx.H"
#include "ZCppMain/ZtCStringStd.H"
using namespace std; using namespace std;
@ -13,6 +14,9 @@ namespace ZNsMain
namespace ZNsExam namespace ZNsExam
{ {
typedef ZtCStringStd<string> ZCStringStd ;
typedef ZtCStringStd<wstring> ZCStringStdW ;
typedef ZtCStringBase<char> ZCStringBase ; typedef ZtCStringBase<char> ZCStringBase ;
typedef ZtCStringBase<wchar_t> ZCStringBaseW ; typedef ZtCStringBase<wchar_t> ZCStringBaseW ;
@ -54,6 +58,23 @@ namespace ZNsMain
cout<<"# ZCStringBaseW::traits_type="<<typeid(ZCStringBaseW::traits_type).name()<<endl; cout<<"# ZCStringBaseW::traits_type="<<typeid(ZCStringBaseW::traits_type).name()<<endl;
cout<<"*****************************************************"<<endl; cout<<"*****************************************************"<<endl;
ZCStringBaseW VO_ZCStringBaseW;
ZCStringStdW VO_ZCStringStdW ;
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;
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;
const ZCCharView CO_ZCCharView("1234AA5678AA90abcAAss"); const ZCCharView CO_ZCCharView("1234AA5678AA90abcAAss");