8#ifndef HPP_ALIB_STRINGS_SUBSTRING
9#define HPP_ALIB_STRINGS_SUBSTRING 1
11#if !defined (HPP_ALIB_STRINGS_CSTRING)
15#if !defined (HPP_ALIB_STRINGS_ATRING)
20namespace alib {
namespace strings {
47template<
typename TChar>
51 #if !defined(ALIB_DOX)
95 whiteSpaces.
Buffer(), whiteSpaces.Length() );
121 whiteSpaces.Length() ) + 1;
152 template <
bool TCheck =
true,
156 if constexpr ( TCheck )
166 "Non checking but called on empty string" )
248 template <
bool TCheck=
true,
256 if constexpr ( TCheck )
264 "Non checking but called on empty string" )
288 template <
bool TCheck= true>
291 if constexpr ( TCheck )
293 if ( regionLength < 0 )
295 if ( target !=
nullptr )
305 "STRINGS",
"Non checking but regionLength out of bounds" )
308 if ( target !=
nullptr )
335 template <
bool TCheck= true>
338 if constexpr ( TCheck )
340 if ( regionLength < 0 )
342 if ( target !=
nullptr )
352 "STRINGS",
"Non checking but regionLength out of bounds" )
355 if ( target !=
nullptr )
387 template <
bool TCheck =
true,
396 if constexpr ( TCheck )
398 if ( separatorWidth < 0 )
401 if ( regionLength < 0 )
407 if ( regionLength < 0 )
415 "STRINGS",
"Non checking but separator width negative" )
418 "STRINGS",
"Non checking but regionLength out of bounds" )
421 target.template _<false>( *
this, 0, regionLength );
423 regionLength+= separatorWidth;
454 template <
bool TCheck = true>
459 if constexpr ( TCheck )
461 if ( separatorWidth < 0 )
464 if ( regionLength < 0 )
470 if ( regionLength < 0 )
477 "STRINGS",
"Non checking but separator width negative" )
480 "STRINGS",
"Non checking but regionLength out of bounds" )
485 regionLength+= separatorWidth;
516 template <
bool TCheck =
true,
525 if constexpr ( TCheck )
527 if ( separatorWidth < 0 ) separatorWidth= 0;
535 "STRINGS",
"Non checking but separator width negative" )
537 "STRINGS",
"Non checking but regionLength out of bounds" )
560 "STRINGS",
"ConsumeToken on nulled Substring" )
658 minChars=
static_cast<int>( consumable.
Length() );
660 if ( minChars == 0 || minChars > consumable.
Length() )
664 if( diff <
static_cast<integer>( minChars ) )
683 template< lang::Whitespaces TTrimBeforeConsume= lang::Whitespaces::Keep >
704 #if defined(ALIB_DOX)
717 template<
typename TIntegral>
721 template<
typename TIntegral>
727 result=
static_cast<TIntegral
>( resultImpl );
732 #if defined(ALIB_DOX)
750 template<
typename TIntegral>
754 template<
typename TIntegral>
760 result=
static_cast<TIntegral
>( resultImpl );
765 #if defined(ALIB_DOX)
786 template<
typename TIntegral>
790 template<
typename TIntegral>
796 result=
static_cast<TIntegral
>( resultImpl );
801 #if defined(ALIB_DOX)
818 template<
typename TIntegral>
822 template<
typename TIntegral>
828 result=
static_cast<TIntegral
>( resultImpl );
833 #if defined(ALIB_DOX)
851 template<
typename TIntegral>
855 template<
typename TIntegral>
861 result=
static_cast<TIntegral
>( resultImpl );
866 #if defined(ALIB_DOX)
884 template<
typename TIntegral>
888 template<
typename TIntegral>
894 result=
static_cast<TIntegral
>( resultImpl );
941 template <
bool TCheck= true>
946 if constexpr ( TCheck )
953 "STRINGS",
"Non checking but position out of bounds" )
955 "STRINGS",
"Non checking but position + separator width out of bounds" )
1056using Substring = strings::TSubstring<character>;
1059using NSubstring = strings::TSubstring<nchar>;
1062using WSubstring = strings::TSubstring<wchar>;
1065using XSubstring = strings::TSubstring<xchar>;
TAString & _(const TString< TChar > &src, integer regionStart, integer regionLength=MAX_LEN)
integer IndexOfSegmentEnd(TChar opener, TChar closer, integer idx) const
integer IndexOfFirstDifference(const TString &needle, lang::Case sensitivity=lang::Case::Sensitive, integer idx=0) const
constexpr integer Length() const
bool AdjustRegion(integer ®ionStart, integer ®ionLength) const
integer IndexOfOrLength(TChar needle) const
constexpr TString() noexcept=default
constexpr const TChar * Buffer() const
integer ConsumeChars(integer regionLength, TAString< TChar > &target, integer separatorWidth=0)
bool ConsumeStringFromEnd(const TString< TChar > &consumable)
TSubstring & Trim(const TCString< TChar > &whiteSpaces=TT_StringConstants< TChar >::DefaultWhitespaces())
TSubstring & TrimEnd(const TCString< TChar > &whiteSpaces=TT_StringConstants< TChar >::DefaultWhitespaces())
TString< TChar > ConsumeToken(TChar separator=',')
ALIB_API bool consumeDecDigitsImpl(uint64_t &result)
ALIB_API bool consumeBinImpl(uint64_t &result, TNumberFormat< TChar > *numberFormat)
TString< TChar > ConsumeField(TChar startChar, TChar endChar)
bool ConsumeString(const TString< TChar > &consumable)
TSubstring & Split(integer position, TSubstring &target, integer separatorWidth=0, bool trim=false)
bool ConsumeOct(TIntegral &result, TNumberFormat< TChar > *numberFormat=nullptr)
bool ConsumeHex(TIntegral &result, TNumberFormat< TChar > *numberFormat=nullptr)
ALIB_API bool ConsumeFloat(double &result, TNumberFormat< TChar > *numberFormat=nullptr)
TSubstring(const TString< TChar > &src)
integer ConsumeCharsFromEnd(integer regionLength, TSubstring *target=nullptr)
integer ConsumePartOf(const TString< TChar > &consumable, int minChars=1)
integer ConsumeChars(integer regionLength, TSubstring *target=nullptr)
TChar ConsumeCharFromEnd()
bool ConsumeBin(TIntegral &result, TNumberFormat< TChar > *numberFormat=nullptr)
bool ConsumeDec(TIntegral &result, TNumberFormat< TChar > *numberFormat=nullptr)
bool ConsumeDecDigits(TIntegral &result)
bool ConsumeInt(TIntegral &result, TNumberFormat< TChar > *numberFormat=nullptr)
TSubstring & TrimStart(const TCString< TChar > &whiteSpaces=TT_StringConstants< TChar >::DefaultWhitespaces())
integer ConsumeCharsFromEnd(integer regionLength, AString &target, integer separatorWidth=0)
ALIB_API bool consumeHexImpl(uint64_t &result, TNumberFormat< TChar > *numberFormat)
integer ConsumeChars(integer regionLength, TString< TChar > &target, integer separatorWidth=0)
ALIB_API bool consumeIntImpl(int64_t &result, TNumberFormat< TChar > *numberFormat)
ALIB_API bool consumeDecImpl(uint64_t &result, TNumberFormat< TChar > *numberFormat)
ALIB_API bool consumeOctImpl(uint64_t &result, TNumberFormat< TChar > *numberFormat)
bool ConsumeCharFromEnd(TChar consumable)
bool ConsumeChar(TChar consumable)
#define ALIB_WARNINGS_RESTORE
#define ALIB_ASSERT_ERROR(cond,...)
#define ALIB_WARNINGS_ALLOW_UNSAFE_BUFFER_USAGE
#define ATMP_T_IF(T, Cond)
@ Keep
Keep whitespaces in string.
@ Trim
Trim whitespaces away.
@ Clear
Chooses to clear existing data.
strings::TSubstring< character > Substring
Type alias in namespace alib.
strings::TSubstring< nchar > NSubstring
Type alias in namespace alib.
strings::TString< character > String
Type alias in namespace alib.
strings::TSubstring< wchar > WSubstring
Type alias in namespace alib.
strings::TSubstring< xchar > XSubstring
Type alias in namespace alib.
lang::integer integer
Type alias in namespace alib.
static integer LastIndexOfAnyExclude(const TChar *haystack, integer startIdx, const TChar *needles, integer needlesLength)
static integer IndexOfAnyExcluded(const TChar *haystack, integer haystackLength, const TChar *needles, integer needlesLength)