8#ifndef HPP_ALIB_STRINGS_SUBSTRING
9#define HPP_ALIB_STRINGS_SUBSTRING 1
14namespace alib {
namespace strings {
43template<
typename TChar>
97 whiteSpaces.Length() );
122 whiteSpaces.Buffer(),
123 whiteSpaces.Length() ) + 1;
154 template <
typename TCheck =
CHK,
158 if constexpr ( TCheck::value )
168 "Non checking but called on empty string" )
250 template <
typename TCheck=
CHK,
258 if constexpr ( TCheck::value )
266 "Non checking but called on empty string" )
290 template <
typename TCheck= CHK>
293 if constexpr ( TCheck::value )
295 if ( regionLength < 0 )
297 if ( target !=
nullptr )
307 "STRINGS",
"Non checking but regionLength out of bounds" )
310 if ( target !=
nullptr )
311 *target= this->base::template
Substring<NC>( 0, regionLength );
337 template <
typename TCheck= CHK>
340 if constexpr ( TCheck::value )
342 if ( regionLength < 0 )
344 if ( target !=
nullptr )
354 "STRINGS",
"Non checking but regionLength out of bounds" )
357 if ( target !=
nullptr )
390 template <
typename TCheck =
CHK,
392 typename TAllocator >
400 if constexpr ( TCheck::value )
402 if ( separatorWidth < 0 )
405 if ( regionLength < 0 )
411 if ( regionLength < 0 )
419 "STRINGS",
"Non checking but separator width negative" )
422 "STRINGS",
"Non checking but regionLength out of bounds" )
425 target.template _<NC>( *
this, 0, regionLength );
427 regionLength+= separatorWidth;
458 template <
typename TCheck = CHK>
463 if constexpr ( TCheck::value )
465 if ( separatorWidth < 0 )
468 if ( regionLength < 0 )
474 if ( regionLength < 0 )
481 "STRINGS",
"Non checking but separator width negative" )
484 "STRINGS",
"Non checking but regionLength out of bounds" )
489 regionLength+= separatorWidth;
520 template <
typename TCheck =
CHK,
529 if constexpr ( TCheck::value )
531 if ( separatorWidth < 0 ) separatorWidth= 0;
539 "STRINGS",
"Non checking but separator width negative" )
541 "STRINGS",
"Non checking but regionLength out of bounds" )
566 "STRINGS",
"ConsumeToken on nulled Substring" )
666 minChars=
static_cast<int>( consumable.
Length() );
668 if ( minChars == 0 || minChars > consumable.
Length() )
672 if( diff <
static_cast<integer>( minChars ) )
691 template< lang::Whitespaces TTrimBeforeConsume= lang::Whitespaces::Keep >
725 template<
typename TIntegral>
729 template<
typename TIntegral>
735 result=
static_cast<TIntegral
>( resultImpl );
758 template<
typename TIntegral>
762 template<
typename TIntegral>
768 result=
static_cast<TIntegral
>( resultImpl );
794 template<
typename TIntegral>
798 template<
typename TIntegral>
804 result=
static_cast<TIntegral
>( resultImpl );
826 template<
typename TIntegral>
830 template<
typename TIntegral>
836 result=
static_cast<TIntegral
>( resultImpl );
859 template<
typename TIntegral>
863 template<
typename TIntegral>
869 result=
static_cast<TIntegral
>( resultImpl );
892 template<
typename TIntegral>
896 template<
typename TIntegral>
902 result=
static_cast<TIntegral
>( resultImpl );
949 template <
typename TCheck= CHK>
954 if constexpr ( TCheck::value )
959 "STRINGS",
"Non checking but position out of bounds" )
961 "STRINGS",
"Non checking but position + separator width out of bounds" )
964 target= this->base::template
Substring<NC>( position + separatorWidth,
1060using Substring = strings::TSubstring<character>;
1063using NSubstring = strings::TSubstring<nchar>;
1066using WSubstring = strings::TSubstring<wchar>;
1069using XSubstring = strings::TSubstring<xchar>;
TAString & _(const TString< TChar > &src, integer regionStart, integer regionLength=MAX_LEN)
constexpr bool IsEmpty() const
integer IndexOfSegmentEnd(TChar opener, TChar closer, integer idx) const
constexpr integer Length() const
integer IndexOfFirstDifference(const TString &needle, lang::Case sensitivity=lang::Case::Sensitive, integer startIdx=0) const
TChar CharAtStart() const
constexpr bool IsNotNull() const
bool AdjustRegion(integer ®ionStart, integer ®ionLength) const
integer IndexOfOrLength(TChar needle) const
bool EndsWith(const TString &needle) const
bool StartsWith(const TString &needle) const
constexpr TString() noexcept=default
Defaulted default constructor.
bool ConsumeStringFromEnd(const TString< TChar > &consumable)
ALIB_API bool consumeDecDigitsImpl(uint64_t &result)
TSubstring()
Default constructor creating a 6.1 Nulled Strings "nulled" substring.
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)
TSubstring & TrimEnd(const TCString< TChar > &whiteSpaces=TT_CStringConstants< TChar >::DefaultWhitespaces())
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()
TSubstring & TrimStart(const TCString< TChar > &whiteSpaces=TT_CStringConstants< TChar >::DefaultWhitespaces())
bool ConsumeBin(TIntegral &result, TNumberFormat< TChar > *numberFormat=nullptr)
bool ConsumeDec(TIntegral &result, TNumberFormat< TChar > *numberFormat=nullptr)
TString< TChar > base
The base string-type.
bool ConsumeDecDigits(TIntegral &result)
bool ConsumeInt(TIntegral &result, TNumberFormat< TChar > *numberFormat=nullptr)
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)
TString< TChar > ConsumeToken(TChar separator=',', lang::Inclusion includeSeparator=lang::Inclusion::Include)
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)
TSubstring & Trim(const TCString< TChar > &whiteSpaces=TT_CStringConstants< TChar >::DefaultWhitespaces())
bool ConsumeChar(TChar consumable)
integer ConsumeChars(integer regionLength, TAString< TChar, TAllocator > &target, integer separatorWidth=0)
#define ALIB_WARNINGS_RESTORE
#define ALIB_ASSERT_ERROR(cond,...)
#define ALIB_WARNINGS_ALLOW_UNSAFE_BUFFER_USAGE
#define ATMP_T_IF(T, Cond)
integer IndexOfAnyExcluded(const TChar *haystack, integer haystackLength, const TChar *needles, integer needlesLength)
integer LastIndexOfAnyExclude(const TChar *haystack, integer startIdx, const TChar *needles, integer needlesLength)
Inclusion
Denotes how members of a set something should be taken into account.
@ Include
Chooses inclusion.
Whitespaces
Denotes whether a string is trimmed or not.
@ Keep
Keep whitespaces in string.
@ Trim
Trim whitespaces away.
@ Clear
Chooses to clear existing data.
Case
Denotes upper and lower case character treatment.
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.