1 #ifndef CORELIB___NCBISTR__HPP
2 #define CORELIB___NCBISTR__HPP
59 #define NcbiEmptyCStr NCBI_NS_NCBI::kEmptyCStr
61 #if defined(HAVE_WSTRING)
63 #define NcbiEmptyWCStr NCBI_NS_NCBI::kEmptyWCStr
67 #if defined(NCBI_OS_MSWIN) \
68 || (defined(NCBI_OS_LINUX) \
69 && (defined(NCBI_COMPILER_GCC) || defined(NCBI_COMPILER_ANY_CLANG)))
75 static const string&
Get(
void)
77 static string empty_str;
81 #if defined(HAVE_WSTRING)
86 static const wstring&
Get(
void)
88 static wstring empty_str;
98 static const string&
Get(
void);
102 static const string& FirstGet(
void);
103 static const string* m_Str;
106 # if defined(HAVE_WSTRING)
111 static const wstring&
Get(
void);
115 static const wstring& FirstGet(
void);
116 static const wstring* m_Str;
122 #define NcbiEmptyString NCBI_NS_NCBI::CNcbiEmptyString::Get()
123 #define kEmptyStr NcbiEmptyString
125 #if defined(HAVE_WSTRING)
126 # define NcbiEmptyWString NCBI_NS_NCBI::CNcbiEmptyWString::Get()
127 # define kEmptyWStr NcbiEmptyWString
133 #define NPOS NCBI_NS_STD::string::npos
145 #if defined(NCBI_OS_MSWIN) && defined(_UNICODE)
151 # define _TX(x) L ## x
155 # define _T_XSTRING(x) \
156 ncbi::CUtf8::AsBasicString<ncbi::TXChar>(x, NULL, ncbi::CUtf8::eValidate)
158 # define _T_XSTRING(x) \
159 ncbi::CUtf8::AsBasicString<ncbi::TXChar>(x, NULL, ncbi::CUtf8::eNoValidate)
161 # define _T_STDSTRING(x) ncbi::CUtf8::AsUTF8(x)
162 # define _T_XCSTRING(x) _T_XSTRING(x).c_str()
163 # define _T_CSTRING(x) _T_STDSTRING(x).c_str()
165 # define NcbiEmptyXCStr NcbiEmptyWCStr
166 # define NcbiEmptyXString NcbiEmptyWString
167 # define kEmptyXStr kEmptyWStr
168 # define kEmptyXCStr kEmptyWCStr
179 # define _T_XSTRING(x) (x)
180 # define _T_STDSTRING(x) (x)
181 # define _T_XCSTRING(x) ncbi::impl_ToCString(x)
182 # define _T_CSTRING(x) (x)
184 # define NcbiEmptyXCStr NcbiEmptyCStr
185 # define NcbiEmptyXString NcbiEmptyString
186 # define kEmptyXStr kEmptyStr
187 # define kEmptyXCStr kEmptyCStr
198 #if defined(NCBI_CUTF8_ENCODING_CLASSIC) || !defined(HAVE_ENUM_CLASS)
227 #define eEncoding_Unknown EEncoding::Unknown
228 #define eEncoding_UTF8 EEncoding::UTF8
229 #define eEncoding_Ascii EEncoding::Ascii
230 #define eEncoding_ISO8859_1 EEncoding::ISO8859_1
231 #define eEncoding_Windows_1252 EEncoding::Windows_1252
232 #define eEncoding_CESU8 EEncoding::CESU8
251 fUseLowercase = (1 << 4),
252 fWithRadix = (1 << 5),
253 fWithSign = (1 << 6),
254 fWithCommas = (1 << 7),
255 fDoubleFixed = (1 << 8),
256 fDoubleScientific = (1 << 9),
257 fDoublePosix = (1 << 10),
258 fDoubleGeneral = fDoubleFixed | fDoubleScientific,
260 fDS_Binary = (1 << 11),
261 fDS_NoDecimalPoint = (1 << 12),
262 fDS_PutSpaceBeforeSuffix = (1 << 13),
263 fDS_ShortSuffix = (1 << 14),
264 fDS_PutBSuffixToo = (1 << 15)
285 fConvErr_NoThrow = (1 << 0),
291 fConvErr_NoErrMessage = (1 << 2),
292 fMandatorySign = (1 << 17),
293 fAllowCommas = (1 << 18),
294 fAllowLeadingSpaces = (1 << 19),
295 fAllowLeadingSymbols = (1 << 20) | fAllowLeadingSpaces,
297 fAllowTrailingSpaces = (1 << 21),
298 fAllowTrailingSymbols = (1 << 22) | fAllowTrailingSpaces,
300 fDecimalPosix = (1 << 23),
301 fDecimalPosixOrLocal = (1 << 24),
302 fDecimalPosixFinite = (1 << 25),
306 fDS_ForceBinary = (1 << 26),
307 fDS_ProhibitFractions = (1 << 27),
308 fDS_ProhibitSpaceBeforeSuffix = (1 << 28)
329 template <
typename TNumeric>
334 return x_StringToNumeric<TNumeric>(
str,
flags, base);
355 template <
typename TNumeric>
382 return StringToNonNegativeInt(
str);
401 TStringToNumFlags
flags = 0,
420 TStringToNumFlags
flags = 0,
439 TStringToNumFlags
flags = 0,
458 TStringToNumFlags
flags = 0,
490 static double StringToDoublePosix(
const char*
str,
char** endptr=0,
491 TStringToNumFlags
flags=0);
511 TStringToNumFlags
flags = 0);
518 static double StringToDoubleEx(
const char*
str,
size_t size,
519 TStringToNumFlags
flags = 0);
537 TStringToNumFlags
flags = 0,
556 TStringToNumFlags
flags = 0,
583 TStringToNumFlags
flags = 0);
611 TStringToNumFlags
flags,
630 TStringToNumFlags
flags = 0,
654 static int HexChar(
char ch);
671 template<
typename TNumeric>
679 template <
typename TStrictId>
683 return NumericToString(
value.Get(),
flags, base);
703 template<
typename TNumeric>
707 x_NumericToString(out_str,
value,
flags, base);
724 static string IntToString(
int value, TNumToStringFlags
flags = 0,
727 static string IntToString(
unsigned int value, TNumToStringFlags
flags = 0,
746 static void IntToString(
string& out_str,
int value,
747 TNumToStringFlags
flags = 0,
750 static void IntToString(
string& out_str,
unsigned int value,
751 TNumToStringFlags
flags = 0,
768 static string UIntToString(
unsigned int value,
769 TNumToStringFlags
flags = 0,
772 static string UIntToString(
int value,
773 TNumToStringFlags
flags = 0,
792 static void UIntToString(
string& out_str,
unsigned int value,
793 TNumToStringFlags
flags = 0,
796 static void UIntToString(
string& out_str,
int value,
797 TNumToStringFlags
flags = 0,
814 static string LongToString(
long value, TNumToStringFlags
flags = 0,
833 static void LongToString(
string& out_str,
long value,
834 TNumToStringFlags
flags = 0,
851 static string ULongToString(
unsigned long value,
852 TNumToStringFlags
flags = 0,
871 static void ULongToString(
string& out_str,
unsigned long value,
872 TNumToStringFlags
flags = 0,
890 TNumToStringFlags
flags = 0,
910 TNumToStringFlags
flags = 0,
928 TNumToStringFlags
flags = 0,
947 static void UInt8ToString(
string& out_str,
Uint8 value,
948 TNumToStringFlags
flags = 0,
979 static string UInt8ToString_DataSize(
Uint8 value,
980 TNumToStringFlags
flags = 0,
981 unsigned int max_digits = 3);
996 static void UInt8ToString_DataSize(
string& out_str,
998 TNumToStringFlags
flags = 0,
999 unsigned int max_digits = 3);
1020 TNumToStringFlags
flags = 0);
1043 static void DoubleToString(
string& out_str,
double value,
1045 TNumToStringFlags
flags = 0);
1069 TNumToStringFlags
flags = 0);
1129 int* dec,
int* sign);
1145 static string SizetToString(
size_t value,
1146 TNumToStringFlags
flags = 0,
1159 static void PtrToString(
string& out_str,
const void* ptr);
1169 static string PtrToString(
const void* ptr);
1179 static const string BoolToString(
bool value);
1200 static string FormatVarargs(
const char*
format, va_list args);
1275 static int CompareCase(
const char* s1,
const char* s2);
1380 const char* s2, ECase use_case = eCase);
1421 static int Compare(
const char* s1,
const char* s2,
1422 ECase use_case = eCase);
1441 ECase use_case = eCase);
1492 static bool EqualCase(
const char* s1,
const char* s2);
1556 static bool EqualNocase(
const char* s1,
const char* s2);
1591 const char* s2, ECase use_case = eCase);
1631 static bool Equal(
const char* s1,
const char* s2,
1632 ECase use_case = eCase);
1649 ECase use_case = eCase);
1666 static int strcmp(
const char* s1,
const char* s2);
1682 static int strncmp(
const char* s1,
const char* s2,
size_t n);
1696 static int strcasecmp(
const char* s1,
const char* s2);
1711 static int strncasecmp(
const char* s1,
const char* s2,
size_t n);
1715 static size_t strftime(
char* s,
size_t maxsize,
const char*
format,
1716 const struct tm* timeptr);
1820 static string& ToLower(
string&
str);
1828 static char* ToLower(
char*
str);
1836 static string& ToUpper(
string&
str);
1844 static char* ToUpper(
char*
str);
1867 ECase use_case = eCase);
1879 ECase use_case = eCase);
1891 ECase use_case = eCase);
1903 ECase use_case = eCase);
1972 ECase use_case = eCase,
1973 EDirection direction = eForwardSearch,
2027 EOccurrence which = eFirst,
2028 ECase use_case = eCase);
2033 {
return FindCase(
str, pattern, start); }
2091 EOccurrence which = eFirst);
2150 EOccurrence which = eFirst);
2158 static const string* Find (
const list<string>& lst,
2160 ECase use_case = eCase);
2162 static const string* FindCase (
const list<string>& lst,
2165 static const string* FindNoCase(
const list<string>& lst,
2168 static const string* Find (
const vector<string>& vec,
2170 ECase use_case = eCase);
2172 static const string* FindCase (
const vector<string>& vec,
2175 static const string* FindNoCase(
const vector<string>& vec,
2196 ECase use_case = eCase,
2197 EDirection direction = eForwardSearch);
2233 ECase use_case = eCase) {
2234 return FindWord(
str, word, use_case, which == eFirst ? eForwardSearch : eReverseSearch);
2254 static string TruncateSpaces(
const string&
str,
2255 ETrunc where = eTrunc_Both);
2273 ETrunc where = eTrunc_Both);
2280 ETrunc where = eTrunc_Both) {
2281 return TruncateSpaces_Unsafe(
str, where);
2289 ETrunc where = eTrunc_Both) {
2290 return TruncateSpaces_Unsafe(
str, where);
2300 static void TruncateSpacesInPlace(
string&
str, ETrunc where = eTrunc_Both);
2301 static void TruncateSpacesInPlace(
CTempString&, ETrunc where = eTrunc_Both);
2315 ECase use_case = eCase);
2317 ECase use_case = eCase);
2339 ECase use_case = eCase);
2352 ECase use_case = eCase);
2354 ECase use_case = eCase);
2376 ECase use_case = eCase);
2407 static string& Replace(
const string& src,
2408 const string& search,
2409 const string& replace,
2444 static string Replace(
const string& src,
2445 const string& search,
2446 const string& replace,
2480 static string& ReplaceInPlace(
string& src,
2481 const string& search,
2482 const string& replace,
2498 fSplit_MergeDelimiters = 1 << 0,
2499 fSplit_Truncate_Begin = 1 << 1,
2500 fSplit_Truncate_End = 1 << 2,
2501 fSplit_Truncate = fSplit_Truncate_Begin | fSplit_Truncate_End,
2502 fSplit_ByPattern = 1 << 3,
2503 fSplit_CanEscape = 1 << 4,
2504 fSplit_CanSingleQuote = 1 << 5,
2505 fSplit_CanDoubleQuote = 1 << 6,
2506 fSplit_CanQuote = fSplit_CanSingleQuote | fSplit_CanDoubleQuote,
2508 fSplit_Tokenize = fSplit_MergeDelimiters | fSplit_Truncate
2515 eMergeDelims = fSplit_MergeDelimiters | fSplit_Truncate,
2546 TSplitFlags
flags = 0,
2547 vector<SIZE_TYPE>* token_pos =
NULL);
2549 static vector<string>& Split(
2552 vector<string>&
arr,
2553 TSplitFlags
flags = 0,
2554 vector<SIZE_TYPE>* token_pos =
NULL);
2556 static list<CTempString>& Split(
2559 list<CTempString>&
arr,
2560 TSplitFlags
flags = 0,
2561 vector<SIZE_TYPE>* token_pos =
NULL,
2564 static vector<CTempString>& Split(
2567 vector<CTempString>&
arr,
2568 TSplitFlags
flags = 0,
2569 vector<SIZE_TYPE>* token_pos =
NULL,
2572 static list<CTempStringEx>& Split(
2575 list<CTempStringEx>&
arr,
2576 TSplitFlags
flags = 0,
2577 vector<SIZE_TYPE>* token_pos =
NULL,
2580 static vector<CTempStringEx>& Split(
2583 vector<CTempStringEx>&
arr,
2584 TSplitFlags
flags = 0,
2585 vector<SIZE_TYPE>* token_pos =
NULL,
2620 TSplitFlags
flags = 0);
2626 TSplitFlags
flags = 0,
2633 TSplitFlags
flags = 0,
2639 static list<string>& SplitByPattern(
2643 TSplitFlags
flags = 0,
2644 vector<SIZE_TYPE>* token_pos =
NULL);
2646 static vector<string>& SplitByPattern(
2649 vector<string>&
arr,
2650 TSplitFlags
flags = 0,
2651 vector<SIZE_TYPE>* token_pos =
NULL);
2653 static list<CTempString>& SplitByPattern(
2656 list<CTempString>&
arr,
2657 TSplitFlags
flags = 0,
2658 vector<SIZE_TYPE>* token_pos =
NULL,
2661 static vector<CTempString>& SplitByPattern(
2664 vector<CTempString>&
arr,
2665 TSplitFlags
flags = 0,
2666 vector<SIZE_TYPE>* token_pos =
NULL,
2669 static list<CTempStringEx>& SplitByPattern(
2672 list<CTempStringEx>&
arr,
2673 TSplitFlags
flags = 0,
2674 vector<SIZE_TYPE>* token_pos =
NULL,
2677 static vector<CTempStringEx>& SplitByPattern(
2680 vector<CTempStringEx>&
arr,
2681 TSplitFlags
flags = 0,
2682 vector<SIZE_TYPE>* token_pos =
NULL,
2695 template<
typename TContainer>
2699 return x_Join(begin(
arr), end(
arr), delim);
2701 template<
typename TValue>
2705 return x_Join(begin(
arr), end(
arr), delim);
2707 template<
typename TInputIterator>
2711 return x_Join(from, to, delim);
2713 template<
typename TInputIterator>
2717 return x_Join( from, to, delim);
2719 template<
typename TIterator,
typename FTransform>
2729 eNewLine_Quote = fNewLine_Quote,
2730 fNewLine_Passthru = 1,
2731 eNewLine_Passthru = fNewLine_Passthru,
2732 fNonAscii_Passthru = 0,
2733 fNonAscii_Quote = 2,
2734 fPrintable_Full = 64
2781 char escape_char =
'\\');
2794 static string Unescape(
const CTempString str,
char escape_char =
'\\');
2816 static string Quote(
const CTempString str,
char quote_char =
'"',
char escape_char =
'\\');
2829 static string Unquote(
const CTempString str,
char escape_char =
'\\');
2843 fSS_Reject = 1 << 11,
2847 fSS_Remove = 1 << 12,
2848 fSS_NoMerge = 1 << 13,
2849 fSS_NoTruncate_Begin = 1 << 14,
2850 fSS_NoTruncate_End = 1 << 15,
2851 fSS_NoTruncate = fSS_NoTruncate_Begin | fSS_NoTruncate_End
2930 char reject_replacement =
' ',
2931 TSS_Flags
flags = 0);
2939 eEscSeqRange_Standard,
2941 eEscSeqRange_FirstByte,
2971 EEscSeqRange
mode = eEscSeqRange_Standard,
2972 char user_char =
'?');
3000 static string CEncode(
const CTempString str, EQuoted quoted = eQuoted);
3027 eXmlEnc_Contents = 0,
3030 eXmlEnc_CommentSafe = 1 << 0,
3034 eXmlEnc_Unsafe_Skip = 1 << 1,
3035 eXmlEnc_Unsafe_Throw = 1 << 2
3048 fHtmlEnc_EncodeAll = 0,
3049 fHtmlEnc_SkipLiteralEntities = 1 << 1,
3050 fHtmlEnc_SkipNumericEntities = 1 << 2,
3051 fHtmlEnc_SkipEntities = fHtmlEnc_SkipLiteralEntities | fHtmlEnc_SkipNumericEntities,
3052 fHtmlEnc_CheckPreencoded = 1 << 3
3067 fHtmlDec_CharRef_Entity = 1,
3068 fHtmlDec_CharRef_Numeric = 1 << 1,
3069 fHtmlDec_Encoding_Changed = 1 << 2
3113 static string JsonEncode(
const CTempString str, EJsonEncode encoding = eJsonEnc_UTF8);
3138 static string ShellEncode(
const string&
str);
3193 {
return SQLEncode(
str, eSqlEnc_Plain); }
3198 static void URLDecodeInPlace(
string&
str,
EUrlDecode flag = eUrlDec_All);
3211 static string Base64Encode(
const CTempString str,
size_t line_len = 0);
3228 fWrap_Hyphenate = 0x1,
3229 fWrap_HTMLPre = 0x2,
3230 fWrap_FlatFile = 0x4
3262 template<
typename _D>
3265 const string*
prefix = 0,
3266 const string* prefix1 = 0);
3284 m_list.push_back(s);
3294 IWrapDest& dest, TWrapFlags
flags,
3296 const string* prefix1);
3298 static list<string>& Wrap(
const string&
str,
SIZE_TYPE width,
3299 list<string>&
arr, TWrapFlags
flags = 0,
3300 const string*
prefix = 0,
3301 const string* prefix1 = 0);
3303 static list<string>& Wrap(
const string&
str,
SIZE_TYPE width,
3304 list<string>&
arr, TWrapFlags
flags,
3306 const string* prefix1 = 0);
3308 static list<string>& Wrap(
const string&
str,
SIZE_TYPE width,
3309 list<string>&
arr, TWrapFlags
flags,
3311 const string& prefix1);
3343 static list<string>& WrapList(
const list<string>& l,
SIZE_TYPE width,
3344 const string& delim, list<string>&
arr,
3345 TWrapFlags
flags = 0,
3346 const string*
prefix = 0,
3347 const string* prefix1 = 0);
3349 static list<string>& WrapList(
const list<string>& l,
SIZE_TYPE width,
3350 const string& delim, list<string>&
arr,
3353 const string* prefix1 = 0);
3355 static list<string>& WrapList(
const list<string>& l,
SIZE_TYPE width,
3356 const string& delim, list<string>&
arr,
3359 const string& prefix1);
3407 fDedent_NormalizeEmptyLines = 1 << 0,
3411 fDedent_SkipFirstLine = 1 << 1,
3412 fDedent_SkipEmptyFirstLine = 1 << 2,
3546 template<
typename TNumeric,
typename TSource>
3550 return x_ReportLimitsError(
str,
flags);
3554 template<
typename TNumeric,
typename TSource>
3559 return x_ReportLimitsError(
str,
flags);
3564 template <
typename TNumeric>
3569 return x_VerifyIntLimits<TNumeric>(
n,
str,
flags) ? (TNumeric)
n : 0;
3571 template <
typename TNumeric>
3575 unsigned int n = StringToUInt(
str,
flags, base);
3576 return x_VerifyIntLimits<TNumeric>(
n,
str,
flags) ? (TNumeric)
n : 0;
3579 template <
typename TNumeric>
3583 return StringToInt(
str,
flags, base);
3585 template <
typename TNumeric>
3589 return StringToUInt(
str,
flags, base);
3591 template <
typename TNumeric>
3595 return StringToLong(
str,
flags, base);
3597 template <
typename TNumeric>
3601 return StringToULong(
str,
flags, base);
3603 template <
typename TNumeric>
3609 template <
typename TNumeric>
3613 return StringToUInt8(
str,
flags, base);
3615 template <
typename TStrictId>
3619 return TStrictId(StringToNumeric<typename TStrictId::TId>(
str,
flags, base));
3622 template <
typename TNumeric>
3627 return x_VerifyFloatLimits<TNumeric>(
n,
str,
flags) ? (TNumeric)
n : 0;
3629 template <
typename TNumeric>
3636 template <
typename TNumeric>
3642 if (( !
n && errno ) || !x_VerifyIntLimits<TNumeric>(
n,
str,
flags)) {
3648 template <
typename TNumeric>
3652 unsigned int n = StringToUInt(
str,
flags, base);
3654 if (( !
n && errno ) || !x_VerifyIntLimits<TNumeric>(
n,
str,
flags)) {
3660 template <
typename TNumeric>
3665 return (*
value || !errno);
3667 template <
typename TNumeric>
3672 return (*
value || !errno);
3678 return (*
value || !errno);
3684 return (*
value || !errno);
3686 template <
typename TNumeric>
3691 return (*
value || !errno);
3693 template <
typename TNumeric>
3698 return (*
value || !errno);
3705 if (( !
n && errno ) || !x_VerifyFloatLimits<float>(
n,
str,
flags)) {
3715 return (*
value || !errno);
3717 template <
typename TStrictId>
3725 template<
typename TNumeric>
3731 template<
typename TNumeric>
3747 #if NCBI_COMPILER_MSVC && (_MSC_VER < 1900)
3749 x_NumericToString(
string& out_str,
Int8 value, TNumToStringFlags
flags,
int base)
3754 x_NumericToString(
string& out_str,
Uint8 value, TNumToStringFlags
flags,
int base)
3759 template<
typename TNumeric>
3765 template<
typename TNumeric>
3771 template<
typename TNumeric>
3777 template <
typename TStrictId>
3781 return x_NumericToString(out_str,
value.Get(),
flags, base);
3786 template<
typename TIterator>
3789 template<
typename TIterator>
3797 template<
typename TIterator>
3802 return xx_Join(from, to, delim);
3805 template<
typename TValue>
3809 return xx_Join(from, to, delim);
3812 template<
typename TIterator>
3817 return TransformJoin( from, to, delim, [](
const typename TIterator::value_type&
i){
return NumericToString(
i);});
3820 template<
typename TValue>
3824 return TransformJoin( from, to, delim, [](
const TValue&
i){
return NumericToString(
i);});
3834 #define NCBITOOLKIT_USE_LONG_UCS4 (SIZEOF_LONG == 4)
3835 #if NCBITOOLKIT_USE_LONG_UCS4
3893 return x_Append(u8,src,encoding,
validate);
3896 #if defined(HAVE_WSTRING)
3906 return x_Append(u8,src,lcl);
3916 template <
typename TChar>
3921 return x_Append(u8, src.data(), src.size());
3931 template <
typename TChar>
3936 return x_Append(u8, src, tchar_count);
3947 template <
typename TChar>
3951 return x_Append(dest, src.data(), src.size());
3965 template <
typename TChar>
3969 return x_Append(dest, src, tchar_count);
3980 template <
typename TChar>
3984 return x_Append(dest, &ch, 1);
4004 return x_Append(dest,src,encoding,
validate);
4007 #if defined(HAVE_WSTRING)
4022 return x_Append(dest,src,lcl);
4046 #if defined(HAVE_WSTRING)
4081 static string AsSingleByteString
4083 const char* substitute_on_error = 0, EValidate
validate = eNoValidate);
4085 #if defined(HAVE_WSTRING)
4086 static string AsSingleByteString
4088 const char* substitute_on_error = 0, EValidate
validate = eNoValidate);
4105 template <
typename TChar>
4109 return x_AsBasicString(src,substitute_on_error,
validate);
4112 template <
typename TChar>
4116 return x_AsBasicString<TChar>(src,
nullptr,eNoValidate);
4160 return x_EvalFirst(ch, more);
4170 return x_EvalNext(ch);
4200 static string EncodingToString(
EEncoding encoding);
4221 #if defined(HAVE_WSTRING)
4243 #if defined(HAVE_WSTRING)
4314 #ifndef NCBI_COMPILER_WORKSHOP
4354 #if defined(HAVE_WSTRING)
4357 template <
typename TChar>
4359 template <
typename TChar>
4362 template <
typename TChar>
4363 static basic_string<TChar> x_AsBasicString
4367 template <
typename TIterator>
4371 static bool x_EvalFirst(
char ch,
SIZE_TYPE& more);
4372 static bool x_EvalNext(
char ch);
4394 template <
class TBase>
4407 case eErr:
return "eErr";
4417 EErrCode err_code,
const string& message,
4419 : TBase(
info, prev_exception, message, severity, 0),
m_Pos(pos)
4443 out <<
"m_Pos = " << (
unsigned long)
m_Pos;
4450 {
return "CParseTemplException"; }
4467 const string& message,
4469 : TBase(
info, prev_exception, message, severity,
flags),
m_Pos(pos)
4515 virtual const char* GetErrCodeString(
void)
const override;
4591 template<
class TContainer>
4732 ITERATE(list<string>, it, lst) {
4772 const string& arg_sep,
4773 const string& val_sep,
4780 if ( !ret.empty() ) {
4789 ret += it->first + val_sep + it->second;
4838 {
return IsEncoded() ? *m_Encoded : m_Original; }
4841 bool IsEmpty(
void)
const {
return m_Original.empty(); }
4861 template <
typename T>
4865 int Compare(
const T& s1,
const T& s2)
const;
4868 bool Less(
const T& s1,
const T& s2)
const;
4871 bool Equals(
const T& s1,
const T& s2)
const;
4891 template <
typename T>
4921 template <
typename T>
4935 int Compare(
const T& s1,
const T& s2)
const;
4938 bool Less(
const T& s1,
const T& s2)
const;
4941 bool Equals(
const T& s1,
const T& s2)
const;
4962 template <
typename T>
4970 return this->
Equals(s1, s2);
4988 template <
typename T>
5002 return this->
Equals(s1, s2);
5021 size_t len1 = s1.
size(), len2 = s2.
size();
5022 return len1 < len2 ||
5023 (len1 == len2 && ::memcmp(s1.
data(), s2.
data(), len1) < 0);
5034 template<
class Arg1,
class Arg2,
class Pred>
5038 return pr.Equals(x, y);
5056 #if !defined(NCBI_OS_MSWIN) && \
5057 !(defined(NCBI_OS_LINUX) && \
5058 (defined(NCBI_COMPILER_GCC) || defined(NCBI_COMPILER_ANY_CLANG)))
5062 const string*
str = m_Str;
5063 return str ? *
str: FirstGet();
5066 # ifdef HAVE_WSTRING
5070 const wstring*
str = m_Str;
5071 return str ? *
str: FirstGet();
5178 unsigned int max_digits )
5197 unsigned int rc = ch -
'0';
5201 rc = (ch |
' ') -
'a';
5202 return rc <= 5 ?
int(rc + 10) : -1;
5221 #if defined(HAVE_STRICMP)
5222 #if NCBI_COMPILER_MSVC && (_MSC_VER >= 1400)
5223 return ::_stricmp(s1, s2);
5225 return ::stricmp(s1, s2);
5228 #elif defined(HAVE_STRCASECMP_LC)
5233 for ( ;; ++s1, ++s2) {
5236 diff =
tolower((
unsigned char) c1) -
tolower((
unsigned char)(*s2));
5248 #if defined(HAVE_STRICMP)
5249 #if NCBI_COMPILER_MSVC && (_MSC_VER >= 1400)
5250 return ::_strnicmp(s1, s2,
n);
5252 return ::strnicmp(s1, s2,
n);
5255 #elif defined(HAVE_STRCASECMP_LC)
5260 for ( ; ; ++s1, ++s2, --
n) {
5265 diff =
tolower((
unsigned char) c1) -
tolower((
unsigned char)(*s2));
5276 const struct tm* timeptr)
5280 return ::strftime(s, maxsize, x_format.c_str(), timeptr);
5297 const char* s2,
ECase use_case)
5326 return s1.
substr(pos,
n) == s2;
5332 return s1.
substr(pos,
n) == s2;
5338 size_t n = strlen(s1);
5339 if (
n != strlen(s2)) {
5366 size_t n = strlen(s1);
5367 if (
n != strlen(s2)) {
5384 const char* s2,
ECase use_case)