1 #ifndef CORELIB___NCBISTR__HPP
2 #define CORELIB___NCBISTR__HPP
59 #define NcbiEmptyCStr ncbi::kEmptyCStr
61 #if defined(HAVE_WSTRING)
63 #define NcbiEmptyWCStr ncbi::kEmptyWCStr
72 static const string&
Get(
void)
74 static string empty_str;
78 #if defined(HAVE_WSTRING)
83 static const wstring&
Get(
void)
85 static wstring empty_str;
92 #define NcbiEmptyString ncbi::CNcbiEmptyString::Get()
93 #define kEmptyStr NcbiEmptyString
95 #if defined(HAVE_WSTRING)
96 # define NcbiEmptyWString ncbi::CNcbiEmptyWString::Get()
97 # define kEmptyWStr NcbiEmptyWString
103 #define NPOS std::string::npos
115 #if defined(NCBI_OS_MSWIN) && defined(_UNICODE)
121 # define _TX(x) L ## x
125 # define _T_XSTRING(x) \
126 ncbi::CUtf8::AsBasicString<ncbi::TXChar>(x, NULL, ncbi::CUtf8::eValidate)
128 # define _T_XSTRING(x) \
129 ncbi::CUtf8::AsBasicString<ncbi::TXChar>(x, NULL, ncbi::CUtf8::eNoValidate)
131 # define _T_STDSTRING(x) ncbi::CUtf8::AsUTF8(x)
132 # define _T_XCSTRING(x) _T_XSTRING(x).c_str()
133 # define _T_CSTRING(x) _T_STDSTRING(x).c_str()
135 # define NcbiEmptyXCStr NcbiEmptyWCStr
136 # define NcbiEmptyXString NcbiEmptyWString
137 # define kEmptyXStr kEmptyWStr
138 # define kEmptyXCStr kEmptyWCStr
149 # define _T_XSTRING(x) (x)
150 # define _T_STDSTRING(x) (x)
151 # define _T_XCSTRING(x) ncbi::impl_ToCString(x)
152 # define _T_CSTRING(x) (x)
154 # define NcbiEmptyXCStr NcbiEmptyCStr
155 # define NcbiEmptyXString NcbiEmptyString
156 # define kEmptyXStr kEmptyStr
157 # define kEmptyXCStr kEmptyCStr
168 #if defined(NCBI_CUTF8_ENCODING_CLASSIC) || !defined(HAVE_ENUM_CLASS)
197 #define eEncoding_Unknown EEncoding::Unknown
198 #define eEncoding_UTF8 EEncoding::UTF8
199 #define eEncoding_Ascii EEncoding::Ascii
200 #define eEncoding_ISO8859_1 EEncoding::ISO8859_1
201 #define eEncoding_Windows_1252 EEncoding::Windows_1252
202 #define eEncoding_CESU8 EEncoding::CESU8
221 fUseLowercase = (1 << 4),
222 fWithRadix = (1 << 5),
223 fWithSign = (1 << 6),
224 fWithCommas = (1 << 7),
225 fDoubleFixed = (1 << 8),
226 fDoubleScientific = (1 << 9),
227 fDoublePosix = (1 << 10),
228 fDoubleGeneral = fDoubleFixed | fDoubleScientific,
230 fDS_Binary = (1 << 11),
231 fDS_NoDecimalPoint = (1 << 12),
232 fDS_PutSpaceBeforeSuffix = (1 << 13),
233 fDS_ShortSuffix = (1 << 14),
234 fDS_PutBSuffixToo = (1 << 15)
255 fConvErr_NoThrow = (1 << 0),
261 fConvErr_NoErrMessage = (1 << 2),
262 fMandatorySign = (1 << 17),
263 fAllowCommas = (1 << 18),
264 fAllowLeadingSpaces = (1 << 19),
265 fAllowLeadingSymbols = (1 << 20) | fAllowLeadingSpaces,
267 fAllowTrailingSpaces = (1 << 21),
268 fAllowTrailingSymbols = (1 << 22) | fAllowTrailingSpaces,
270 fDecimalPosix = (1 << 23),
271 fDecimalPosixOrLocal = (1 << 24),
272 fDecimalPosixFinite = (1 << 25),
276 fDS_ForceBinary = (1 << 26),
277 fDS_ProhibitFractions = (1 << 27),
278 fDS_ProhibitSpaceBeforeSuffix = (1 << 28)
299 template <
typename TNumeric>
304 return x_StringToNumeric<TNumeric>(
str,
flags, base);
325 template <
typename TNumeric>
352 return StringToNonNegativeInt(
str);
371 TStringToNumFlags
flags = 0,
390 TStringToNumFlags
flags = 0,
409 TStringToNumFlags
flags = 0,
428 TStringToNumFlags
flags = 0,
460 static double StringToDoublePosix(
const char*
str,
char** endptr=0,
461 TStringToNumFlags
flags=0);
481 TStringToNumFlags
flags = 0);
488 static double StringToDoubleEx(
const char*
str,
size_t size,
489 TStringToNumFlags
flags = 0);
507 TStringToNumFlags
flags = 0,
526 TStringToNumFlags
flags = 0,
553 TStringToNumFlags
flags = 0);
581 TStringToNumFlags
flags,
600 TStringToNumFlags
flags = 0,
624 static int HexChar(
char ch);
641 template<
typename TNumeric>
642 requires std::integral<TNumeric> || std::floating_point<TNumeric> || std::convertible_to<TNumeric, Int8>
650 template <
typename TStrictId>
654 return NumericToString(
value.Get(),
flags, base);
674 template<
typename TNumeric>
678 x_NumericToString(out_str,
value,
flags, base);
695 static string IntToString(
int value, TNumToStringFlags
flags = 0,
698 static string IntToString(
unsigned int value, TNumToStringFlags
flags = 0,
717 static void IntToString(
string& out_str,
int value,
718 TNumToStringFlags
flags = 0,
721 static void IntToString(
string& out_str,
unsigned int value,
722 TNumToStringFlags
flags = 0,
739 static string UIntToString(
unsigned int value,
740 TNumToStringFlags
flags = 0,
743 static string UIntToString(
int value,
744 TNumToStringFlags
flags = 0,
763 static void UIntToString(
string& out_str,
unsigned int value,
764 TNumToStringFlags
flags = 0,
767 static void UIntToString(
string& out_str,
int value,
768 TNumToStringFlags
flags = 0,
785 static string LongToString(
long value, TNumToStringFlags
flags = 0,
804 static void LongToString(
string& out_str,
long value,
805 TNumToStringFlags
flags = 0,
822 static string ULongToString(
unsigned long value,
823 TNumToStringFlags
flags = 0,
842 static void ULongToString(
string& out_str,
unsigned long value,
843 TNumToStringFlags
flags = 0,
861 TNumToStringFlags
flags = 0,
881 TNumToStringFlags
flags = 0,
899 TNumToStringFlags
flags = 0,
918 static void UInt8ToString(
string& out_str,
Uint8 value,
919 TNumToStringFlags
flags = 0,
950 static string UInt8ToString_DataSize(
Uint8 value,
951 TNumToStringFlags
flags = 0,
952 unsigned int max_digits = 3);
967 static void UInt8ToString_DataSize(
string& out_str,
969 TNumToStringFlags
flags = 0,
970 unsigned int max_digits = 3);
991 TNumToStringFlags
flags = 0);
1014 static void DoubleToString(
string& out_str,
double value,
1016 TNumToStringFlags
flags = 0);
1040 TNumToStringFlags
flags = 0);
1100 int* dec,
int* sign);
1116 static string SizetToString(
size_t value,
1117 TNumToStringFlags
flags = 0,
1130 static void PtrToString(
string& out_str,
const void* ptr);
1140 static string PtrToString(
const void* ptr);
1150 static const string BoolToString(
bool value);
1246 static int CompareCase(
const char* s1,
const char* s2);
1351 const char* s2, ECase use_case = eCase);
1392 static int Compare(
const char* s1,
const char* s2,
1393 ECase use_case = eCase);
1412 ECase use_case = eCase);
1463 static bool EqualCase(
const char* s1,
const char* s2);
1527 static bool EqualNocase(
const char* s1,
const char* s2);
1562 const char* s2, ECase use_case = eCase);
1602 static bool Equal(
const char* s1,
const char* s2,
1603 ECase use_case = eCase);
1620 ECase use_case = eCase);
1637 static int strcmp(
const char* s1,
const char* s2);
1653 static int strncmp(
const char* s1,
const char* s2,
size_t n);
1667 static int strcasecmp(
const char* s1,
const char* s2);
1682 static int strncasecmp(
const char* s1,
const char* s2,
size_t n);
1686 static size_t strftime(
char* s,
size_t maxsize,
const char*
format,
1687 const struct tm* timeptr);
1791 static string& ToLower(
string&
str);
1799 static char* ToLower(
char*
str);
1807 static string& ToUpper(
string&
str);
1815 static char* ToUpper(
char*
str);
1838 ECase use_case = eCase);
1850 ECase use_case = eCase);
1862 ECase use_case = eCase);
1874 ECase use_case = eCase);
1943 ECase use_case = eCase,
1944 EDirection direction = eForwardSearch,
1998 EOccurrence which = eFirst,
1999 ECase use_case = eCase);
2004 {
return FindCase(
str, pattern, start); }
2062 EOccurrence which = eFirst);
2121 EOccurrence which = eFirst);
2129 static const string* Find (
const list<string>& lst,
2131 ECase use_case = eCase);
2133 static const string* FindCase (
const list<string>& lst,
2136 static const string* FindNoCase(
const list<string>& lst,
2139 static const string* Find (
const vector<string>& vec,
2141 ECase use_case = eCase);
2143 static const string* FindCase (
const vector<string>& vec,
2146 static const string* FindNoCase(
const vector<string>& vec,
2167 ECase use_case = eCase,
2168 EDirection direction = eForwardSearch);
2204 ECase use_case = eCase) {
2205 return FindWord(
str, word, use_case, which == eFirst ? eForwardSearch : eReverseSearch);
2225 static string TruncateSpaces(
const string&
str,
2226 ETrunc where = eTrunc_Both);
2244 ETrunc where = eTrunc_Both);
2251 ETrunc where = eTrunc_Both) {
2252 return TruncateSpaces_Unsafe(
str, where);
2260 ETrunc where = eTrunc_Both) {
2261 return TruncateSpaces_Unsafe(
str, where);
2272 static void TruncateSpacesInPlace(
string&
str, ETrunc where = eTrunc_Both);
2273 static void TruncateSpacesInPlace(
CTempString&, ETrunc where = eTrunc_Both);
2287 static void TrimPrefixInPlace(
string&
str,
const CTempString prefix,
2288 ECase use_case = eCase);
2290 ECase use_case = eCase);
2312 ECase use_case = eCase);
2324 static void TrimSuffixInPlace(
string&
str,
const CTempString suffix,
2325 ECase use_case = eCase);
2327 ECase use_case = eCase);
2349 ECase use_case = eCase);
2380 static string& Replace(
const string& src,
2381 const string& search,
2382 const string& replace,
2417 static string Replace(
const string& src,
2418 const string& search,
2419 const string& replace,
2453 static string& ReplaceInPlace(
string& src,
2454 const string& search,
2455 const string& replace,
2471 fSplit_MergeDelimiters = 1 << 0,
2472 fSplit_Truncate_Begin = 1 << 1,
2473 fSplit_Truncate_End = 1 << 2,
2474 fSplit_Truncate = fSplit_Truncate_Begin | fSplit_Truncate_End,
2475 fSplit_ByPattern = 1 << 3,
2476 fSplit_CanEscape = 1 << 4,
2477 fSplit_CanSingleQuote = 1 << 5,
2478 fSplit_CanDoubleQuote = 1 << 6,
2479 fSplit_CanQuote = fSplit_CanSingleQuote | fSplit_CanDoubleQuote,
2481 fSplit_Tokenize = fSplit_MergeDelimiters | fSplit_Truncate
2488 eMergeDelims = fSplit_MergeDelimiters | fSplit_Truncate,
2519 TSplitFlags
flags = 0,
2520 vector<SIZE_TYPE>* token_pos =
NULL);
2522 static vector<string>& Split(
2525 vector<string>&
arr,
2526 TSplitFlags
flags = 0,
2527 vector<SIZE_TYPE>* token_pos =
NULL);
2529 static list<CTempString>& Split(
2532 list<CTempString>&
arr,
2533 TSplitFlags
flags = 0,
2534 vector<SIZE_TYPE>* token_pos =
NULL,
2537 static vector<CTempString>& Split(
2540 vector<CTempString>&
arr,
2541 TSplitFlags
flags = 0,
2542 vector<SIZE_TYPE>* token_pos =
NULL,
2545 static list<CTempStringEx>& Split(
2548 list<CTempStringEx>&
arr,
2549 TSplitFlags
flags = 0,
2550 vector<SIZE_TYPE>* token_pos =
NULL,
2553 static vector<CTempStringEx>& Split(
2556 vector<CTempStringEx>&
arr,
2557 TSplitFlags
flags = 0,
2558 vector<SIZE_TYPE>* token_pos =
NULL,
2593 TSplitFlags
flags = 0);
2599 TSplitFlags
flags = 0,
2606 TSplitFlags
flags = 0,
2612 static list<string>& SplitByPattern(
2616 TSplitFlags
flags = 0,
2617 vector<SIZE_TYPE>* token_pos =
NULL);
2619 static vector<string>& SplitByPattern(
2622 vector<string>&
arr,
2623 TSplitFlags
flags = 0,
2624 vector<SIZE_TYPE>* token_pos =
NULL);
2626 static list<CTempString>& SplitByPattern(
2629 list<CTempString>&
arr,
2630 TSplitFlags
flags = 0,
2631 vector<SIZE_TYPE>* token_pos =
NULL,
2634 static vector<CTempString>& SplitByPattern(
2637 vector<CTempString>&
arr,
2638 TSplitFlags
flags = 0,
2639 vector<SIZE_TYPE>* token_pos =
NULL,
2642 static list<CTempStringEx>& SplitByPattern(
2645 list<CTempStringEx>&
arr,
2646 TSplitFlags
flags = 0,
2647 vector<SIZE_TYPE>* token_pos =
NULL,
2650 static vector<CTempStringEx>& SplitByPattern(
2653 vector<CTempStringEx>&
arr,
2654 TSplitFlags
flags = 0,
2655 vector<SIZE_TYPE>* token_pos =
NULL,
2668 template<
typename TContainer>
2672 return x_Join(begin(
arr), end(
arr), delim);
2674 template<
typename TValue>
2678 return x_Join(begin(
arr), end(
arr), delim);
2680 template<
typename TInputIterator>
2684 return x_Join(from, to, delim);
2686 template<
typename TInputIterator>
2690 return x_Join( from, to, delim);
2692 template<
typename TIterator,
typename FTransform>
2702 eNewLine_Quote = fNewLine_Quote,
2703 fNewLine_Passthru = 1,
2704 eNewLine_Passthru = fNewLine_Passthru,
2705 fNonAscii_Passthru = 0,
2706 fNonAscii_Quote = 2,
2707 fPrintable_Full = 64
2754 char escape_char =
'\\');
2767 static string Unescape(
const CTempString str,
char escape_char =
'\\');
2789 static string Quote(
const CTempString str,
char quote_char =
'"',
char escape_char =
'\\');
2802 static string Unquote(
const CTempString str,
char escape_char =
'\\');
2816 fSS_Reject = 1 << 11,
2820 fSS_Remove = 1 << 12,
2821 fSS_NoMerge = 1 << 13,
2822 fSS_NoTruncate_Begin = 1 << 14,
2823 fSS_NoTruncate_End = 1 << 15,
2824 fSS_NoTruncate = fSS_NoTruncate_Begin | fSS_NoTruncate_End
2903 char reject_replacement =
' ',
2904 TSS_Flags
flags = 0);
2912 eEscSeqRange_Standard,
2914 eEscSeqRange_FirstByte,
2944 EEscSeqRange
mode = eEscSeqRange_Standard,
2945 char user_char =
'?');
2973 static string CEncode(
const CTempString str, EQuoted quoted = eQuoted);
3000 eXmlEnc_Contents = 0,
3003 eXmlEnc_CommentSafe = 1 << 0,
3007 eXmlEnc_Unsafe_Skip = 1 << 1,
3008 eXmlEnc_Unsafe_Throw = 1 << 2
3021 fHtmlEnc_EncodeAll = 0,
3022 fHtmlEnc_SkipLiteralEntities = 1 << 1,
3023 fHtmlEnc_SkipNumericEntities = 1 << 2,
3024 fHtmlEnc_SkipEntities = fHtmlEnc_SkipLiteralEntities | fHtmlEnc_SkipNumericEntities,
3025 fHtmlEnc_CheckPreencoded = 1 << 3
3040 fHtmlDec_CharRef_Entity = 1,
3041 fHtmlDec_CharRef_Numeric = 1 << 1,
3042 fHtmlDec_Encoding_Changed = 1 << 2
3086 static string JsonEncode(
const CTempString str, EJsonEncode encoding = eJsonEnc_UTF8);
3111 static string ShellEncode(
const string&
str);
3166 {
return SQLEncode(
str, eSqlEnc_Plain); }
3171 static void URLDecodeInPlace(
string&
str,
EUrlDecode flag = eUrlDec_All);
3186 static string Base64Encode(
const CTempString str,
size_t line_len = 0);
3203 fWrap_Hyphenate = 0x1,
3204 fWrap_HTMLPre = 0x2,
3205 fWrap_FlatFile = 0x4
3237 template<
typename _D>
3240 const string* prefix = 0,
3241 const string* prefix1 = 0);
3259 m_list.push_back(s);
3269 IWrapDest& dest, TWrapFlags
flags,
3270 const string* prefix,
3271 const string* prefix1);
3273 static list<string>& Wrap(
const string&
str,
SIZE_TYPE width,
3274 list<string>&
arr, TWrapFlags
flags = 0,
3275 const string* prefix = 0,
3276 const string* prefix1 = 0);
3278 static list<string>& Wrap(
const string&
str,
SIZE_TYPE width,
3279 list<string>&
arr, TWrapFlags
flags,
3280 const string& prefix,
3281 const string* prefix1 = 0);
3283 static list<string>& Wrap(
const string&
str,
SIZE_TYPE width,
3284 list<string>&
arr, TWrapFlags
flags,
3285 const string& prefix,
3286 const string& prefix1);
3318 static list<string>& WrapList(
const list<string>&
l,
SIZE_TYPE width,
3319 const string& delim, list<string>&
arr,
3320 TWrapFlags
flags = 0,
3321 const string* prefix = 0,
3322 const string* prefix1 = 0);
3324 static list<string>& WrapList(
const list<string>&
l,
SIZE_TYPE width,
3325 const string& delim, list<string>&
arr,
3327 const string& prefix,
3328 const string* prefix1 = 0);
3330 static list<string>& WrapList(
const list<string>&
l,
SIZE_TYPE width,
3331 const string& delim, list<string>&
arr,
3333 const string& prefix,
3334 const string& prefix1);
3383 fDedent_NormalizeEmptyLines = 1 << 0,
3387 fDedent_SkipFirstLine = 1 << 1,
3388 fDedent_SkipEmptyFirstLine = 1 << 2,
3522 template<
typename TNumeric,
typename TSource>
3526 return x_ReportLimitsError(
str,
flags);
3530 template<
typename TNumeric,
typename TSource>
3535 return x_ReportLimitsError(
str,
flags);
3540 template <
typename TNumeric>
3541 requires std::signed_integral<TNumeric> && (
sizeof(TNumeric) <
sizeof(
int))
3546 return x_VerifyIntLimits<TNumeric>(
n,
str,
flags) ? (TNumeric)
n : 0;
3548 template <
typename TNumeric>
3549 requires std::unsigned_integral<TNumeric> && (
sizeof(TNumeric) <
sizeof(
unsigned int))
3553 unsigned int n = StringToUInt(
str,
flags, base);
3554 return x_VerifyIntLimits<TNumeric>(
n,
str,
flags) ? (TNumeric)
n : 0;
3557 template <
typename TNumeric>
3558 requires std::signed_integral<TNumeric> && (
sizeof(TNumeric) ==
sizeof(
int)) && (!std::same_as<TNumeric, long>)
3562 return StringToInt(
str,
flags, base);
3564 template <
typename TNumeric>
3565 requires std::unsigned_integral<TNumeric> && (
sizeof(TNumeric) ==
sizeof(
unsigned int)) && (!std::same_as<TNumeric, unsigned long>)
3569 return StringToUInt(
str,
flags, base);
3571 template <
typename TNumeric>
3572 requires std::same_as<TNumeric, long>
3576 return StringToLong(
str,
flags, base);
3578 template <
typename TNumeric>
3579 requires std::same_as<TNumeric, unsigned long>
3583 return StringToULong(
str,
flags, base);
3585 template <
typename TNumeric>
3586 requires std::signed_integral<TNumeric> && (
sizeof(TNumeric) ==
sizeof(
Int8)) && (!std::same_as<TNumeric, long>)
3592 template <
typename TNumeric>
3593 requires std::unsigned_integral<TNumeric> && (
sizeof(TNumeric) ==
sizeof(
Uint8)) && (!std::same_as<TNumeric, unsigned long>)
3597 return StringToUInt8(
str,
flags, base);
3599 template <
typename TStrictId>
3603 return TStrictId(StringToNumeric<typename TStrictId::TId>(
str,
flags, base));
3606 template <
typename TNumeric>
3607 requires std::same_as<TNumeric, float>
3612 return x_VerifyFloatLimits<TNumeric>(
n,
str,
flags) ? (TNumeric)
n : 0;
3614 template <
typename TNumeric>
3615 requires std::same_as<TNumeric, double>
3622 template <
typename TNumeric>
3623 requires std::signed_integral<TNumeric> && (
sizeof(TNumeric) <
sizeof(
int))
3629 if (( !
n && errno ) || !x_VerifyIntLimits<TNumeric>(
n,
str,
flags)) {
3635 template <
typename TNumeric>
3636 requires std::unsigned_integral<TNumeric> && (
sizeof(TNumeric) <
sizeof(
unsigned int))
3640 unsigned int n = StringToUInt(
str,
flags, base);
3642 if (( !
n && errno ) || !x_VerifyIntLimits<TNumeric>(
n,
str,
flags)) {
3648 template <
typename TNumeric>
3649 requires std::signed_integral<TNumeric> && (
sizeof(TNumeric) ==
sizeof(
int)) && (!std::same_as<TNumeric, long>)
3654 return (*
value || !errno);
3656 template <
typename TNumeric>
3657 requires std::unsigned_integral<TNumeric> && (
sizeof(TNumeric) ==
sizeof(
unsigned int)) && (!std::same_as<TNumeric, unsigned long>)
3662 return (*
value || !errno);
3668 return (*
value || !errno);
3674 return (*
value || !errno);
3676 template <
typename TNumeric>
3677 requires std::signed_integral<TNumeric> && (
sizeof(TNumeric) ==
sizeof(
Int8)) && (!std::same_as<TNumeric, long>)
3682 return (*
value || !errno);
3684 template <
typename TNumeric>
3685 requires std::unsigned_integral<TNumeric> && (
sizeof(TNumeric) ==
sizeof(
Uint8)) && (!std::same_as<TNumeric, unsigned long>)
3690 return (*
value || !errno);
3697 if (( !
n && errno ) || !x_VerifyFloatLimits<float>(
n,
str,
flags)) {
3707 return (*
value || !errno);
3709 template <
typename TStrictId>
3717 template<
typename TNumeric>
3718 requires std::signed_integral<TNumeric> && (
sizeof(TNumeric) <=
sizeof(
int)) && (!std::same_as<TNumeric, long>)
3724 template<
typename TNumeric>
3725 requires std::unsigned_integral<TNumeric> && (
sizeof(TNumeric) <=
sizeof(
unsigned int)) && (!std::same_as<TNumeric, unsigned long>)
3727 x_NumericToString(
string& out_str, TNumeric
value, TNumToStringFlags
flags,
int base)
3732 x_NumericToString(
string& out_str,
long value, TNumToStringFlags
flags,
int base)
3737 x_NumericToString(
string& out_str,
unsigned long value, TNumToStringFlags
flags,
int base)
3741 #if NCBI_COMPILER_MSVC && (_MSC_VER < 1900)
3743 x_NumericToString(
string& out_str,
Int8 value, TNumToStringFlags
flags,
int base)
3748 x_NumericToString(
string& out_str,
Uint8 value, TNumToStringFlags
flags,
int base)
3753 template<
typename TNumeric>
3754 requires std::signed_integral<TNumeric> && (
sizeof(TNumeric) ==
sizeof(
Int8)) && (!std::same_as<TNumeric, long>)
3756 x_NumericToString(
string& out_str, TNumeric
value, TNumToStringFlags
flags,
int base)
3760 template<
typename TNumeric>
3761 requires std::unsigned_integral<TNumeric> && (
sizeof(TNumeric) ==
sizeof(
Uint8)) && (!std::same_as<TNumeric, unsigned long>)
3763 x_NumericToString(
string& out_str, TNumeric
value, TNumToStringFlags
flags,
int base)
3767 template<
typename TNumeric>
3768 requires std::floating_point<TNumeric>
3770 x_NumericToString(
string& out_str, TNumeric
value, TNumToStringFlags
flags,
int )
3774 template <
typename TStrictId>
3778 return x_NumericToString(out_str,
value.Get(),
flags, base);
3783 template<
typename TIterator>
3786 template<
typename TIterator>
3787 requires std::same_as<typename TIterator::iterator_category, std::input_iterator_tag> &&
3788 std::convertible_to<typename TIterator::value_type, string>
3795 template<
typename TIterator>
3796 requires std::convertible_to<typename TIterator::iterator_category, std::forward_iterator_tag> &&
3797 std::convertible_to<typename TIterator::value_type, string>
3801 return xx_Join(from, to, delim);
3804 template<
typename TValue>
3805 requires std::convertible_to<TValue, string>
3809 return xx_Join(from, to, delim);
3812 template<
typename TIterator>
3813 requires (std::integral<typename TIterator::value_type> || std::floating_point<typename TIterator::value_type>) &&
3814 std::convertible_to<typename TIterator::iterator_category, std::input_iterator_tag>
3818 return TransformJoin( from, to, delim, [](
const typename TIterator::value_type&
i){
return NumericToString(
i);});
3821 template<
typename TValue>
3822 requires std::integral<TValue> || std::floating_point<TValue>
3826 return TransformJoin( from, to, delim, [](
const TValue&
i){
return NumericToString(
i);});
3887 return x_Append(u8,src,encoding,
validate);
3890 #if defined(HAVE_WSTRING)
3900 return x_Append(u8,src,lcl);
3910 template <
typename TChar>
3911 requires integral<TChar> && (
sizeof(
TChar) > 1)
3916 return x_Append(u8, src.data(), src.size());
3926 template <
typename TChar>
3927 requires integral<TChar> && (
sizeof(
TChar) > 1)
3932 return x_Append(u8, src, tchar_count);
3943 template <
typename TChar>
3944 requires integral<TChar> && (
sizeof(
TChar) > 1)
3948 return x_Append(dest, src.data(), src.size());
3962 template <
typename TChar>
3963 requires integral<TChar> && (
sizeof(
TChar) > 1)
3967 return x_Append(dest, src, tchar_count);
3978 template <
typename TChar>
3979 requires integral<TChar> && (
sizeof(
TChar) > 1)
3983 return x_Append(dest, &ch, 1);
4003 return x_Append(dest,src,encoding,
validate);
4006 #if defined(HAVE_WSTRING)
4021 return x_Append(dest,src,lcl);
4045 #if defined(HAVE_WSTRING)
4080 static string AsSingleByteString
4082 const char* substitute_on_error = 0, EValidate
validate = eNoValidate);
4084 #if defined(HAVE_WSTRING)
4085 static string AsSingleByteString
4087 const char* substitute_on_error = 0, EValidate
validate = eNoValidate);
4104 template <
typename TChar>
4105 requires integral<TChar> && (
sizeof(
TChar) > 1)
4109 return x_AsBasicString(src,substitute_on_error,
validate);
4112 template <
typename TChar>
4113 requires integral<TChar> && (
sizeof(
TChar) > 1)
4117 return x_AsBasicString<TChar>(src,
nullptr,eNoValidate);
4161 return x_EvalFirst(ch, more);
4171 return x_EvalNext(ch);
4201 static string EncodingToString(
EEncoding encoding);
4222 #if defined(HAVE_WSTRING)
4244 #if defined(HAVE_WSTRING)
4353 #if defined(HAVE_WSTRING)
4356 template <
typename TChar>
4358 template <
typename TChar>
4361 template <
typename TChar>
4362 static basic_string<TChar> x_AsBasicString
4366 template <
typename TIterator>
4370 static bool x_EvalFirst(
char ch,
SIZE_TYPE& more);
4371 static bool x_EvalNext(
char ch);
4393 template <
class TBase>
4406 case eErr:
return "eErr";
4416 EErrCode err_code,
const string& message,
4418 : TBase(
info, prev_exception, message, severity, 0),
m_Pos(pos)
4442 out <<
"m_Pos = " << (
unsigned long)
m_Pos;
4449 {
return "CParseTemplException"; }
4466 const string& message,
4468 : TBase(
info, prev_exception, message, severity,
flags),
m_Pos(pos)
4514 virtual const char* GetErrCodeString(
void)
const override;
4590 template<
class TContainer>
4731 ITERATE(list<string>, it, lst) {
4771 const string& arg_sep,
4772 const string& val_sep,
4779 if ( !ret.empty() ) {
4788 ret += it->first + val_sep + it->second;
4837 {
return IsEncoded() ? *m_Encoded : m_Original; }
4840 bool IsEmpty(
void)
const {
return m_Original.empty(); }
4860 template <
typename T>
4864 int Compare(
const T& s1,
const T& s2)
const;
4867 bool Less(
const T& s1,
const T& s2)
const;
4870 bool Equals(
const T& s1,
const T& s2)
const;
4890 template <
typename T>
4920 template <
typename T>
4934 int Compare(
const T& s1,
const T& s2)
const;
4937 bool Less(
const T& s1,
const T& s2)
const;
4940 bool Equals(
const T& s1,
const T& s2)
const;
4961 template <
typename T>
4969 return this->
Equals(s1, s2);
4987 template <
typename T>
5001 return this->
Equals(s1, s2);
5020 size_t len1 = s1.
size(), len2 = s2.
size();
5021 return len1 < len2 ||
5022 (len1 == len2 && ::memcmp(s1.
data(), s2.
data(), len1) < 0);
5033 template<
class Arg1,
class Arg2,
class Pred>
5037 return pr.Equals(x, y);
5152 unsigned int max_digits )
5171 unsigned int rc = ch -
'0';
5175 rc = (ch |
' ') -
'a';
5176 return rc <= 5 ?
int(rc + 10) : -1;
5195 #if defined(HAVE_STRICMP)
5196 #if NCBI_COMPILER_MSVC && (_MSC_VER >= 1400)
5197 return ::_stricmp(s1, s2);
5199 return ::stricmp(s1, s2);
5202 #elif defined(HAVE_STRCASECMP_LC)
5207 for ( ;; ++s1, ++s2) {
5210 diff =
tolower((
unsigned char) c1) -
tolower((
unsigned char)(*s2));
5222 #if defined(HAVE_STRICMP)
5223 #if NCBI_COMPILER_MSVC && (_MSC_VER >= 1400)
5224 return ::_strnicmp(s1, s2,
n);
5226 return ::strnicmp(s1, s2,
n);
5229 #elif defined(HAVE_STRCASECMP_LC)
5234 for ( ; ; ++s1, ++s2, --
n) {
5239 diff =
tolower((
unsigned char) c1) -
tolower((
unsigned char)(*s2));
5250 const struct tm* timeptr)
5254 return ::strftime(s, maxsize, x_format.c_str(), timeptr);
5271 const char* s2,
ECase use_case)
5300 return s1.
substr(pos,
n) == s2;
5306 return s1.
substr(pos,
n) == s2;
5312 size_t n = strlen(s1);
5313 if (
n != strlen(s2)) {
5340 size_t n = strlen(s1);
5341 if (
n != strlen(s2)) {
5358 const char* s2,
ECase use_case)
5387 return str.size() >= start.
size() &&
5394 return !
str.empty() &&
5395 (use_case ==
eCase ? (
str[0] == start)
5396 : (
str[0] == start ||
5405 return str.size() >= end.
size() &&
5414 return use_case ==
eCase ? (
last == end)
5427 if (s1[
i] != s2[
i]) {
5441 if (s1[len1 -
i] != s2[len2 -
i]) {
5468 return (pos ==
NPOS || (pos + pattern.
length()) > end) ?
NPOS : pos;
5471 return (pos ==
NPOS || pos < start) ?
NPOS : pos;
5531 template<
typename TIterator,
typename FTransform>
5538 string result(fnTransform(*from++));
5539 for ( ; from != to; ++from) {
5540 result.append(delim).append(fnTransform(*from));
5545 template<
typename TIterator>
5553 size_t sz_all = 0, sz_delim = delim.
size();
5555 sz_all +=
string(*f).size() + sz_delim;
5558 for ( ; from != to; ++from) {
5559 result.append(delim).append(
string(*from));
5567 const string* prefix1)
5575 const string& prefix1)
5582 const string& delim, list<string>&
arr,
5584 const string* prefix1)
5591 const string& delim, list<string>&
arr,
5593 const string& prefix1)
5611 return Justify(
str, width, par, &pfx, &pfx1);
5633 return (err-src.
begin());
5653 template <
typename TChar> basic_string<TChar>
5661 basic_string<TChar>
result;
5662 result.reserve(CUtf8::GetSymbolCount(
str) + 1);
5665 for (; src != to; ++src) {
5667 if (
sizeof(
TChar) > 2 && ch >= 0xD800 && ch <= 0xDBFF) {
5669 ch = (ch - 0xD800) * 0x400 + (
ch2 - 0xDC00) + 0x10000;
5671 if (ch > max_char) {
5672 if (
sizeof(
TChar) == 2) {
5685 "Failed to convert symbol to wide character",
5686 (src -
str.begin()));
5694 template <
typename TChar>
bool
5697 if ( *src >= 0xD800 && *src <= 0xDBFF &&
5698 *(src+1) >= 0xDC00 && *(src+1) <= 0xDFFF &&
sizeof(
TChar) == 2) {
5699 ch = (*(src) - 0xD800) * 0x400 + (*(src+1) - 0xDC00) + 0x10000;
5709 const TChar* srcBuf;
5713 for (pos=0, srcBuf=src;
5714 (to ==
NPOS) ? (*srcBuf != 0) : (pos<to); ++pos, ++srcBuf) {
5725 u8str.reserve(
max(u8str.capacity(),u8str.length()+needed+1));
5726 for (pos=0, srcBuf=src;
5727 (to ==
NPOS) ? (*srcBuf != 0) : (pos<to); ++pos, ++srcBuf) {
5753 template <
typename T>
5760 template <
typename T>
5767 template <
typename T>
5774 template <
typename T>
5778 return Less(s1, s2);
5788 template <
typename T>
5795 template <
typename T>
5802 template <
typename T>
5809 template <
typename T>
5813 return Less(s1, s2);
5820 template <
typename T>
5823 : m_CaseSensitive(cs)
5826 template <
typename T>
5833 template <
typename T>
5840 template <
typename T>
5847 template <
typename T>
5851 return Less(s1, s2);
void x_Assign(CObject_id &dst, const CObject_id &src)
Incapsulate compile time information such as __FILE__, __LINE__, NCBI_MODULE, current function.
CParseTemplException –.
URL-decoder for string pairs parser.
URL-encoder for string pairs parser.
Template for parsing string into pairs of name and value or merging them back into a single string.
Helper class to allocate memory for CTempString[Ex] on demand in the functions which need to modify t...
CTempString implements a light-weight string on top of a storage buffer whose lifetime management is ...
Encoder interface. Names and values can be encoded with different rules.
requires static std::same_as< TNumeric, float > TNumeric x_StringToNumeric(const CTempString str, TStringToNumFlags flags, int)
requires std::signed_integral< TNumeric > TStrictId ::type x_StringToNumeric(const CTempString str, TStringToNumFlags flags, int base)
requires std::convertible_to< typename TIterator::iterator_category, std::forward_iterator_tag > &&static std::convertible_to< typename TIterator::value_type, string > string x_Join(TIterator from, TIterator to, const CTempString &delim)
requires std::integral< TValue > static std::floating_point< TValue > string x_Join(TValue *from, TValue *to, const CTempString &delim)
Define Case-insensitive string equality (not less-than) comparison method Case sensitivity can be tur...
Define Case-insensitive string equality (not less-than) comparison method.
Define Case-insensitive string comparison methods.
static vector< string > arr
std::ofstream out("events_result.xml")
main entry point for tests
static DLIST_TYPE *DLIST_NAME() last(DLIST_LIST_TYPE *list)
static const char * str(char *buf, int n)
static const char * validate(DSNINFO *di)
Go looking for trouble.
void reset() noexcept
Reset will delete the old pointer (if owned)
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
element_type * get(void) const noexcept
Get pointer.
@ eTakeOwnership
An object can take ownership of another.
@ eNoOwnership
No ownership is assumed.
EDiagSev
Severity level for the posted diagnostics.
@ eDiag_Error
Error message.
#define NCBI_THROW2(exception_class, err_code, message, extra)
Throw exception with extra parameter.
EErrCode
Error types that an application can generate.
virtual const char * GetErrCodeString(void) const
Get error code interpreted as text.
#define EXCEPTION_VIRTUAL_BASE
Do not use virtual base classes in exception declaration at all, because in this case derived class s...
@ eInvalid
To be used ONLY as a return value; please, NEVER throw an exception with this code.
sequence::ECompare Compare(const CSeq_loc &loc1, const CSeq_loc &loc2, CScope *scope)
Returns the sequence::ECompare containment relationship between CSeq_locs.
#define NCBI_ATTRIBUTE_PRINTF(fmt, args)
int64_t Int8
8-byte (64-bit) signed integer
uint64_t Uint8
8-byte (64-bit) unsigned integer
IO_PREFIX::ostream CNcbiOstream
Portable alias for ostream.
EStringToNumFlags EConvErrFlags
Formerly split out.
EJsonEncode
Json-encode flags.
CParseTemplException(const CDiagCompileInfo &info, const CException *prev_exception, const string &message, string::size_type pos, EDiagSev severity, CException::TFlags flags)
bool operator()(const CTempString s1, const CTempString s2) const
static void NumericToString(string &out_str, TNumeric value, TNumToStringFlags flags=0, int base=10)
Convert numeric value to string.
std::string::size_type SIZE_TYPE
static bool x_TCharToUnicodeSymbol(TUnicodeSymbol &u, const TChar *src)
static void x_Validate(const CTempString &str)
virtual void Append(const string &s)=0
static string SizetToString(size_t value, TNumToStringFlags flags=0, int base=10)
Convert size_t to string.
CParseTemplException(void)
Constructor.
PEqualNocase_Generic< const char * > PEqualNocase_CStr
vector< pair< string, string > > TStringPairsVector
static TUnicodeSymbol x_Decode(TIterator &src)
static bool x_VerifyIntLimits(TSource v, const CTempString str, TStringToNumFlags flags)
EPrintableMode
How to display printable strings.
static string Int8ToString(Int8 value, TNumToStringFlags flags=0, int base=10)
Convert Int8 to string.
requires static std::same_as< TNumeric, unsigned long > TNumeric x_StringToNumeric(const CTempString str, TStringToNumFlags flags, int base)
EDedentFlags
Flags for Dedent() method.
int Compare(const T &s1, const T &s2) const
Return difference between "s1" and "s2".
PCase_Generic< string > PCase
PNocase_Generic< const char * > PNocase_CStr
ESS_Flags
Flags for Sanitize().
int TDedentFlags
Bitwise OR of EDedentFlags.
EStringToNumFlags
String to number conversion flags.
string::size_type m_Pos
Error position.
EErrCode
Error types that for exception class.
void Parse(const CTempString str, NStr::EMergeDelims merge_argsep=NStr::eMergeDelims)
Parse the string.
static CStringUTF8 & x_Append(CStringUTF8 &u8str, const CTempString &src, EEncoding encoding, EValidate validate)
CStringPairs(IStringDecoder *decoder=NULL, EOwnership own_decoder=eTakeOwnership, IStringEncoder *encoder=NULL, EOwnership own_encoder=eTakeOwnership)
Create parser with the specified decoder/encoder and default separators.
static string DoubleToString(double value, int precision=-1, TNumToStringFlags flags=0)
Convert double to string.
string Merge(void) const
Merge name-value pairs into a single string using the currently set separators and the provided encod...
CParseTemplException(const CDiagCompileInfo &info, const CException *prev_exception, EErrCode err_code, const string &message, string::size_type pos, EDiagSev severity=eDiag_Error)
Constructor.
static bool StringToNumeric(const CTempString str, TNumeric *value, TStringToNumFlags flags=0, int base=10)
Convert string to a numeric value.
char16_t TCharUCS2
Type for character in UCS-2 encoding.
ESqlEncode
SQL encode flags.
ESplitFlags
Flags for Split*() methods.
EWrapFlags
How to wrap the words in a string to a new line.
static int CompareNocase(const CTempString s1, SIZE_TYPE pos, SIZE_TYPE n, const char *s2)
Case-insensitive compare of a substring with another string.
CNcbiOstream & operator<<(CNcbiOstream &os, const TStringUCS2 &str)
Operator for writing TStringUCS2 to stream.
EUrlEncode
URL-encode flags.
EMergeDelims
Whether to merge adjacent delimiters.
AutoPtr< IStringDecoder > m_Decoder
CWrapDestStringList(list< string > &l)
EOccurrence
Whether it is the first or last occurrence.
static string Merge(const TStrPairs &pairs, const string &arg_sep, const string &val_sep, IStringEncoder *encoder=NULL, EOwnership own=eTakeOwnership)
Merge name-value pairs from the provided container, separators and encoder.
const string & GetEncodedString(void) const
Get encoded string.
int TPrintableMode
Bitwise OR of EPrintableMode flags.
TStrPairs & GetPairs(void)
Get non-const data.
int TNumToStringFlags
Bitwise OR of "ENumToStringFlags".
static list< string > & Split(const CTempString str, const CTempString delim, list< string > &arr, TSplitFlags flags=0, vector< SIZE_TYPE > *token_pos=NULL)
Split a string using specified delimiters.
virtual string Encode(const CTempString src, EStringType stype) const =0
Encode the string.
void SetDecoder(IStringDecoder *decoder, EOwnership own=eTakeOwnership)
Set string decoder.
CParseTemplException(const CParseTemplException< TBase > &other)
Constructor.
const char * impl_ToCString(const char *s)
CStringPairs(const CTempString arg_sep, const CTempString val_sep, IStringDecoder *decoder=NULL, EOwnership own_decoder=eTakeOwnership, IStringEncoder *encoder=NULL, EOwnership own_encoder=eTakeOwnership)
Create parser with the specified parameters.
EUrlDecode
URL decode flags.
static SIZE_TYPE FindNoCase(const CTempString str, const CTempString pattern, SIZE_TYPE start, SIZE_TYPE end, EOccurrence which=eFirst)
Find the pattern in the specified range of a string using a case insensitive search.
bool Less(const T &s1, const T &s2) const
Return TRUE if s1 < s2.
static CTempString TruncateSpaces_Unsafe(const CTempString &str, NStr::ETrunc side=NStr::eTrunc_Both)
Truncate whitespace in the string.
static bool EndsWith(const CTempString str, const CTempString end, ECase use_case=eCase)
Check if a string ends with a specified suffix value.
requires std::signed_integral< TNumeric > TStringToNumFlags flags
static SIZE_TYPE x_BytesNeeded(TUnicodeSymbol ch)
static string LongToString(long value, TNumToStringFlags flags=0, int base=10)
Convert Int to string.
unique_ptr< string > m_Encoded
static int strcmp(const char *s1, const char *s2)
String compare.
EDirection
Search direction for Find() methods.
requires std::signed_integral< TNumeric > void ::type x_NumericToString(string &out_str, TStrictId value, TNumToStringFlags flags, int base)
EXmlEncode
XML-encode flags.
NStr::ECase m_CaseSensitive
case sensitive when TRUE
static bool EvaluateNext(char ch)
Check that the character is valid continuation byte of an UTF8 byte sequence.
PEqualNocase_Conditional_Generic< string > PEqualNocase_Conditional
bool IsEmpty(void) const
Check if the string is empty.
virtual void Append(const CTempString &s)
static string TransformJoin(TIterator from, TIterator to, const CTempString &delim, FTransform fnTransform)
static int strncasecmp(const char *s1, const char *s2, size_t n)
Case-insensitive comparison of two zero-terminated strings, narrowed to the specified number of chara...
static CTempString TruncateSpaces(const CTempString str, ETrunc where=eTrunc_Both)
IStringEncoder * GetEncoder(void)
Get encoder or NULL. Does not affect encoder ownership.
static string Join(const initializer_list< TValue > &arr, const CTempString &delim)
PEqualNocase_Generic< string > PEqualNocase
static TNumeric StringToNumeric(const CTempString str, TStringToNumFlags flags=0, int base=10)
Convert string to a numeric value.
static string Join(TInputIterator from, TInputIterator to, const CTempString &delim)
static string JoinNumeric(TInputIterator from, TInputIterator to, const CTempString &delim)
ENumToStringFlags
Number to string conversion flags.
static string IntToString(int value, TNumToStringFlags flags=0, int base=10)
Convert int to string.
static CStringUTF8 TruncateSpaces(const CTempString &str, NStr::ETrunc side=NStr::eTrunc_Both)
Truncate whitespace in the string.
static SIZE_TYPE CommonSuffixSize(const CTempString s1, const CTempString s2)
Determine the common suffix of two strings.
virtual const char * GetType(void) const override
Get exception class type.
string::size_type GetPos(void) const noexcept
Get error position.
int Compare(const T &s1, const T &s2) const
Return difference between "s1" and "s2".
virtual void ReportExtra(ostream &out) const override
Report error position.
void SetEncoder(IStringEncoder *encoder, EOwnership own=eTakeOwnership)
Set string encoder.
static string DedentR(const CTempString str)
const string & GetOriginalString(void) const
Get the original unencoded string.
NCBI_EXCEPTION_DEFAULT2(CStringException, CParseTemplException< CCoreException >, std::string::size_type)
requires std::integral< TNumeric > std::floating_point< TNumeric > static std::convertible_to< TNumeric, Int8 > string NumericToString(TNumeric value, TNumToStringFlags flags=0, int base=10)
Convert numeric value to string.
CStringPairs(NStr::EUrlDecode decode_flag, NStr::EUrlEncode encode_flag)
Create parser with the selected URL-encoding/decoding options and default separators.
static string Dedent(const CTempString str, TDedentFlags flags=0)
Dedent multi-line string, removing common whitespace prefix for each line.
EErrCode
Error types that string classes can generate.
static SIZE_TYPE Find(const CTempString str, const CTempString pattern, ECase use_case=eCase, EDirection direction=eForwardSearch, SIZE_TYPE occurrence=0)
Find the pattern in the string.
static CStringUTF8 AsUTF8(const CTempString &src, const locale &lcl)
Convert into UTF8 from a C/C++ string.
PNocase_Generic< string > PNocase
const char * const_iterator
static SIZE_TYPE GetValidSymbolCount(const CTempString &src)
Get the number of valid UTF-8 symbols (code points) in buffer.
static int HexChar(char ch)
Convert character to integer.
static void ToUpper(const char *)
Privatized ToUpper() with const char* parameter to prevent passing of constant strings.
static string Join(const TContainer &arr, const CTempString &delim)
Join strings using the specified delimiter.
static void Parse(TStrPairs &pairs, const CTempString str, const CTempString arg_sep, const CTempString val_sep, IStringDecoder *decoder=NULL, EOwnership own=eTakeOwnership, NStr::EMergeDelims merge_argsep=NStr::eMergeDelims)
Parse the string using the provided decoder, put data into the container.
virtual ~IStringEncoder(void)
virtual ~IStringDecoder(void)
int TSplitFlags
Bitwise OR of ESplitFlags.
static enable_if< is_integral< typename TStrictId::TId >::value &&is_member_function_pointer< decltype(&TStrictId::Get)>::value, string >::type NumericToString(TStrictId value, TNumToStringFlags flags=0, int base=10)
ETrunc
Which end to truncate a string.
static bool EqualCase(const CTempString s1, SIZE_TYPE pos, SIZE_TYPE n, const char *s2)
Case-sensitive equality of a substring with another string.
static basic_string< TChar > x_AsBasicString(const CTempString &src, const TChar *substitute_on_error, EValidate validate)
const char * data(void) const
Return a pointer to the array represented.
static string UInt8ToString_DataSize(Uint8 value, TNumToStringFlags flags=0, unsigned int max_digits=3)
Convert UInt8 to string using "software" qualifiers.
virtual ~CParseTemplException(void) noexcept
Destructor.
AutoPtr< IStringEncoder > m_Encoder
basic_string< TUnicodeSymbol > TStringUnicode
Unicode string.
const wchar_t *const kEmptyWCStr
char32_t TUnicodeSymbol
Unicode character.
bool operator()(const T &s1, const T &s2) const
Return TRUE if s1 < s2 ignoring case.
static TUnicodeSymbol DecodeFirst(char ch, SIZE_TYPE &more)
Begin converting first character of UTF8 sequence into Unicode.
static int strcasecmp(const char *s1, const char *s2)
Case-insensitive comparison of two zero-terminated strings.
EStringType
Type of string to be decoded.
TStringUnicode TStringUCS4
static bool x_VerifyFloatLimits(TSource v, const CTempString str, TStringToNumFlags flags)
bool AStrEquiv(const Arg1 &x, const Arg2 &y, Pred pr)
Check equivalence of arguments using predicate.
static string & Replace(const string &src, const string &search, const string &replace, string &dst, SIZE_TYPE start_pos=0, SIZE_TYPE max_replace=0, SIZE_TYPE *num_replace=0)
Replace occurrences of a substring within a string.
virtual ~CStringPairs(void)
static SIZE_TYPE FindCase(const CTempString str, const CTempString pattern, SIZE_TYPE start, SIZE_TYPE end, EOccurrence which=eFirst)
Find the pattern in the specified range of a string using a case sensitive search.
CStringPairs< TStringPairsVector > CStringPairsParser
static int Compare(const CTempString s1, SIZE_TYPE pos, SIZE_TYPE n, const char *s2, ECase use_case=eCase)
Compare of a substring with another string.
static size_t strftime(char *s, size_t maxsize, const char *format, const struct tm *timeptr)
Wrapper for the function strftime() that corrects handling D and T time formats on MS Windows.
static CStringUTF8 SQLEncode(const CStringUTF8 &str)
virtual const CException * x_Clone(void) const override
Helper clone method.
static CStringUTF8 & x_AppendChar(CStringUTF8 &u8str, TUnicodeSymbol ch)
virtual void Append(const string &s)
static CStringUTF8 AsUTF8(const CTempString &src, EEncoding encoding, EValidate validate=eNoValidate)
Convert into UTF8 from a C/C++ string.
bool Equals(const T &s1, const T &s2) const
Return TRUE if s1 == s2.
requires integral< TChar > const TChar * substitute_on_error
basic_string< TCharUCS2 > TStringUCS2
Type for string in UCS-2 encoding.
EQuoted
Define that string is quoted or not.
IStringDecoder * GetDecoder(void)
Get decoder or NULL. Does not affect decoder ownership.
static list< string > & WrapList(const list< string > &l, SIZE_TYPE width, const string &delim, list< string > &arr, TWrapFlags flags=0, const string *prefix=0, const string *prefix1=0)
Wrap the list using the specified criteria.
static string xx_Join(TIterator from, TIterator to, const CTempString &delim)
return x_VerifyIntLimits< TNumeric >(n, str, flags) ?(TNumeric) n requires std::signed_integral< TNumeric > static long TNumeric x_StringToNumeric(const CTempString str, TStringToNumFlags flags, int base)
requires std::signed_integral< TNumeric > bool ::type x_StringToNumeric(const CTempString str, TStrictId *value, TStringToNumFlags flags, int base)
virtual void Append(const CTempString &s)=0
EStringType
Type of string to be decoded.
virtual string Decode(const CTempString src, EStringType stype) const =0
Decode the string.
static SIZE_TYPE x_GetValidSymbolCount(const CTempString &src, CTempString::const_iterator &err)
static string UIntToString(unsigned int value, TNumToStringFlags flags=0, int base=10)
Convert UInt to string.
static bool StartsWith(const CTempString str, const CTempString start, ECase use_case=eCase)
Check if a string starts with a specified prefix value.
PNocase_Conditional_Generic(NStr::ECase case_sens=NStr::eCase)
Construction.
const TStrPairs & GetPairs(void) const
Read data.
bool IsEncoded(void) const
Check if the original string was encoded.
EHtmlEncode
HTML-decode flags.
bool Equals(const T &s1, const T &s2) const
Return TRUE if s1 == s2.
bool operator()(const T &s1, const T &s2) const
Return TRUE if s1 < s2.
static TUnicodeSymbol DecodeNext(TUnicodeSymbol chU, char ch)
Convert next character of UTF8 sequence into Unicode.
static SIZE_TYPE FindWord(const CTempString str, const CTempString word, EOccurrence which, ECase use_case=eCase)
Find given word in the string.
requires(std::integral< typename TIterator::value_type >||std::floating_point< typename TIterator::value_type >) &&std
requires integral< TChar > const TChar EValidate validate
static bool SplitInTwo(const CTempString str, const CTempString delim, string &str1, string &str2, TSplitFlags flags=0)
Split a string into two pieces using the specified delimiters.
bool Less(const T &s1, const T &s2) const
Return TRUE if s1 < s2.
size_type length(void) const
Return the length of the represented array.
bool Equals(const T &s1, const T &s2) const
Return TRUE if s1 == s2.
static string ULongToString(unsigned long value, TNumToStringFlags flags=0, int base=10)
Convert unsigned long to string.
TContainer::value_type TStrPair
The container's value type must be pair<string, string> or a compatible type.
int TSS_Flags
Bitwise OR of ESS_Flags.
static list< string > & Justify(const CTempString str, SIZE_TYPE width, list< string > &par, const CTempString *pfx=0, const CTempString *pfx1=0)
Justify the specified string into a series of lines of the same width.
static const wstring & Get(void)
Get string.
requires std::same_as< typename TIterator::iterator_category, std::input_iterator_tag > &&static std::convertible_to< typename TIterator::value_type, string > string x_Join(TIterator from, TIterator to, const CTempString &delim)
static string Sanitize(CTempString str, TSS_Flags flags=fSS_print)
Sanitize a string, allowing only specified classes of characters.
PNocase_Conditional_Generic< string > PNocase_Conditional
CTempString substr(size_type pos) const
Obtain a substring from this string, beginning at a given offset.
requires std::signed_integral< TNumeric > TNumeric * value
requires static std::convertible_to< TValue, string > string x_Join(TValue *from, TValue *to, const CTempString &delim)
bool operator()(const T &s1, const T &s2) const
Return TRUE if s1 < s2 ignoring case.
static CTempString TruncateSpaces(const char *str, ETrunc where=eTrunc_Both)
static void ToLower(const char *)
Privatized ToLower() with const char* parameter to prevent passing of constant strings.
static TUnicodeSymbol Decode(const char *&src)
Convert sequence of UTF8 code units into Unicode code point.
static bool EqualNocase(const CTempString s1, SIZE_TYPE pos, SIZE_TYPE n, const char *s2)
Case-insensitive equality of a substring with another string.
EHtmlDecode
HTML-decode flags.
void SetCase(NStr::ECase case_sens)
Set comparison type.
ECase
Which type of string comparison.
static int strncmp(const char *s1, const char *s2, size_t n)
String compare up to specified number of characters.
TErrCode GetErrCode(void) const
Get error code.
int TWrapFlags
Bitwise OR of "EWrapFlags".
int TStringToNumFlags
Bitwise OR of "EStringToNumFlags".
bool Less(const T &s1, const T &s2) const
Return TRUE if s1 < s2.
NStr::ECase GetCase() const
Get comparison type.
static SIZE_TYPE GetValidBytesCount(const CTempString &src)
Get the number of valid UTF-8 bytes (code units) in buffer.
static void Wrap(const string &str, SIZE_TYPE width, IWrapDest &dest, TWrapFlags flags, const string *prefix, const string *prefix1)
int Compare(const T &s1, const T &s2) const
Return difference between "s1" and "s2".
static bool Equal(const CTempString s1, SIZE_TYPE pos, SIZE_TYPE n, const char *s2, ECase use_case=eCase)
Test for equality of a substring with another string.
EValidate
How to verify character encoding of the source data.
static const string & Get(void)
Get string.
static string & ReplaceInPlace(string &src, const string &search, const string &replace, SIZE_TYPE start_pos=0, SIZE_TYPE max_replace=0, SIZE_TYPE *num_replace=0)
Replace occurrences of a substring within a string.
bool operator()(const T &s1, const T &s2) const
Return TRUE if s1 < s2 ignoring case.
const char *const kEmptyCStr
Empty "C" string (points to a '\0').
PNocase_Conditional_Generic< const char * > PNocase_Conditional_CStr
bool operator()(const T &s1, const T &s2) const
Return TRUE if s1 < s2 ignoring case.
static SIZE_TYPE Find(const CTempString str, const CTempString pattern, SIZE_TYPE start)
Wrapper for backward-compatibility.
size_type size(void) const
Return the length of the represented array.
PCase_Generic< const char * > PCase_CStr
static int CompareCase(const CTempString s1, SIZE_TYPE pos, SIZE_TYPE n, const char *s2)
Case-sensitive compare of a substring with another string.
static string UInt8ToString(Uint8 value, TNumToStringFlags flags=0, int base=10)
Convert UInt8 to string.
TStringToNumFlags TConvErrFlags
Formerly split out.
PEqualNocase_Conditional_Generic< const char * > PEqualNocase_Conditional_CStr
PEqualNocase_Conditional_Generic(NStr::ECase case_sens=NStr::eCase)
Construction.
EEscSeqRange
C-style escape sequences parsing mode.
static bool EvaluateFirst(char ch, SIZE_TYPE &more)
Check that the character is valid first byte of an UTF8 byte sequence.
static SIZE_TYPE CommonPrefixSize(const CTempString s1, const CTempString s2)
Determine the common prefix of two strings.
requires std::signed_integral< TNumeric > TStringToNumFlags int base
const_iterator begin() const
Return an iterator to the string's starting position.
virtual const char * GetErrCodeString(void) const override
Translate from the error code value to its string representation.
static int StringToNumeric(const string &str)
@ eEncoding_ISO8859_1
Note: From the point of view of the C++.
@ fDedent_SkipEmptyFirstLine
Ignore first line and skip it from the result, if it is empty only.
@ eSqlEnc_Plain
Always produce '...', with no tag.
@ eUrlEnc_ProcessMarkChars
Convert all non-alphanumeric chars, spaces are converted to '+'.
@ eUrlEnc_URIQueryValue
Encode query part of an URI, arg value.
@ eUrlEnc_PercentOnly
Convert all non-alphanumeric chars including space and '' to %## format.
@ eUrlEnc_URIHost
Encode host part of an URI.
@ eUrlEnc_URIQueryName
Encode query part of an URI, arg name.
@ eUrlEnc_URIPath
Encode path part of an URI.
@ eUrlEnc_Path
Same as ProcessMarkChars but preserves valid path characters ('/', '.')
@ eUrlEnc_URIScheme
Encode scheme part of an URI.
@ eUrlEnc_URIUserinfo
Encode userinfo part of an URI.
@ eUrlEnc_SkipMarkChars
Do not convert chars like '!', '(' etc.
@ eUrlEnc_Cookie
Same as SkipMarkChars with encoded ','.
@ eUrlEnc_URIFragment
Encode fragment part of an URI.
@ eFirst
First occurrence.
@ eUrlDec_All
Decode '+' to space.
@ eReverseSearch
Search in a backward direction.
@ eForwardSearch
Search in a forward direction.
@ eConvert
Failure to convert string.
@ eBadArgs
Bad arguments to string methods.
@ eTrunc_Both
Truncate whitespace at both begin and end of string.
@ eTrunc_End
Truncate trailing whitespace only.
@ eTrunc_Begin
Truncate leading whitespace only.
@ eQuoted
String is quoted.
@ eNocase
Case insensitive compare.
@ eCase
Case sensitive compare.
@ eEscSeqRange_Throw
Throw an exception.
@ eEscSeqRange_Errno
Set errno to ERANGE, return empty string.
enum ENcbiOwnership EOwnership
Ownership relations between objects.
#define NCBI_XNCBI_EXPORT
unsigned int
A callback function used to compare two keys in a database.
The blob sat and sat key Both must be positive integers</td > n< td > Non empty string The interpretation of the blob id depends on a processor Cassandra n processor expects the following format
vector< CSeq_align const * >::const_iterator TIterator
const TYPE & Get(const CNamedParameterList *param)
constexpr int CompareNocase(const std::string_view &l, const std::string_view &r)
double value_type
The numeric datatype used by the parser.
const struct ncbi::grid::netcache::search::fields::SIZE size
const GenericPointer< typename T::ValueType > T2 value
int strncmp(const char *str1, const char *str2, size_t count)
int strcmp(const char *str1, const char *str2)
static const BitmapCharRec ch2
Defines NCBI C++ Toolkit portable error codes.
static bool IsWhiteSpace(char c)
static const char * locale
static const char delimiter[]
static SLJIT_INLINE sljit_ins l(sljit_gpr r, sljit_s32 d, sljit_gpr x, sljit_gpr b)
Define Case-sensitive string comparison methods.
Define Case-insensitive string comparison methods.
PQuickStringLess implements an ordering of strings, that is more efficient than usual lexicographical...
void Encode(const CRawScoreVector< Key, Score > &, vector< char > &)
void Decode(const vector< char > &, CRawScoreVector< Key, Score > &)