37template<
typename TChar>
75 whiteSpaces.Length() );
95 whiteSpaces.Length() ) + 1;
121 template <
typename TCheck =
CHK,
124 if constexpr ( TCheck::value ) {
199 template <
typename TCheck=
CHK,
205 if constexpr ( TCheck::value ) {
230 template <
typename TCheck= CHK>
232 if constexpr ( TCheck::value ) {
233 if ( regionLength < 0 ) {
234 if ( target !=
nullptr )
242 "Non checking and index out of range: 0 <= {} <= {}.", regionLength,
base::length )
246 if ( target !=
nullptr )
247 *target= this->base::template
Substring<NC>( 0, regionLength );
269 template <
typename TCheck= CHK>
271 if constexpr ( TCheck::value ) {
272 if ( regionLength < 0 ) {
273 if ( target !=
nullptr )
281 "Non checking and index out of range: 0 <= {} <= {}.", regionLength,
base::length )
284 if ( target !=
nullptr )
315 template <
typename TCheck =
CHK,
317 typename TAllocator >
324 if constexpr ( TCheck::value ) {
325 if ( separatorWidth < 0 )
328 if ( regionLength < 0 )
333 if ( regionLength < 0 )
339 "Non checking but separator width negative: ", separatorWidth )
341 && regionLength + separatorWidth <=
base::length,
"STRINGS",
342 "Non checking but regionLength out of bounds: 0 <= {}, {} <= {}.",
343 regionLength, regionLength + separatorWidth,
base::length )
346 target.template _<NC>( *
this, 0, regionLength );
348 regionLength+= separatorWidth;
375 template <
typename TCheck = CHK>
379 if constexpr ( TCheck::value ) {
380 if ( separatorWidth < 0 )
383 if ( regionLength < 0 )
388 if ( regionLength < 0 )
393 "STRINGS",
"Non checking but separator width negative" )
395 && regionLength + separatorWidth <=
base::length,
"STRINGS",
396 "Non checking but regionLength out of bounds: 0 <= {}, {} <= {}.",
397 regionLength, regionLength + separatorWidth,
base::length )
402 regionLength+= separatorWidth;
431 template <
typename TCheck =
CHK,
433 typename TAllocator >
440 if constexpr ( TCheck::value ) {
441 if ( separatorWidth < 0 ) separatorWidth= 0;
447 "STRINGS",
"Non checking but separator width negative" )
449 "STRINGS",
"Non checking but regionLength out of bounds: 0 <= {}, {} <= {}.",
450 regionLength, regionLength + separatorWidth,
base::length )
453 target.template _<NC>( *
this,
base::length - regionLength, regionLength );
558 minChars= int( consumable.
Length() );
560 if ( minChars == 0 || minChars > consumable.
Length() )
564 if( diff <
integer( minChars ) )
581 template< lang::Whitespaces TTrimBeforeConsume= lang::Whitespaces::Keep >
610 result=
static_cast<std::remove_reference_t<decltype(result)
>>(resultImpl);
632 result=
static_cast<std::remove_reference_t<decltype(result)
>>( resultImpl );
656 result=
static_cast<std::remove_reference_t<decltype(result)
>>( resultImpl );
675 result=
static_cast<std::remove_reference_t<decltype(result)
>>( resultImpl );
696 result=
static_cast<std::remove_reference_t<decltype(result)
>>( resultImpl );
717 result=
static_cast<std::remove_reference_t<decltype(result)
>>( resultImpl );
759 template <
typename TCheck= CHK>
762 if constexpr ( TCheck::value )
766 "Non checking but position out of bounds: 0 <= {} < {}.", position,
base::length )
768 "Non checking but position + separator width out of bounds: {} <= {}.",
772 target= this->base::template
Substring<NC>( position + separatorWidth,
855template<
typename TChar>
856struct ArrayTraits<
strings::TSubstring<TChar>, TChar> {
860 static constexpr const TChar*
Buffer (
const T& src) {
return src.
Buffer(); }
861 static constexpr integer Length (
const T& src) {
return src.Length(); }
905template<
typename TChar>
906bool operator== (
const TSubstring<TChar>& lhs,
const TSubstring<TChar>& rhs)
907{
return lhs.
template Equals <CHK, lang::Case::Sensitive>(rhs); }
910template<
typename TChar,
typename T>
911requires (!std::is_same_v<T, TSubstring<TChar>>)
912bool operator== (
const TSubstring<TChar>& lhs,
const T& rhs)
913{
return lhs.
template Equals <CHK, lang::Case::Sensitive>(rhs); }
916template<
typename TChar>
917auto operator<=> (
const TSubstring<TChar>& lhs,
const TSubstring<TChar>& rhs)
918{
return lhs.
template CompareTo<CHK, lang::Case::Sensitive>(rhs); }
921template<
typename TChar,
typename T>
922requires (!std::same_as<TSubstring<TChar>, T>)
923auto operator<=> (
const TSubstring<TChar>& lhs,
const T& rhs)
924{
return lhs.
template CompareTo<CHK, lang::Case::Sensitive>(rhs); }
#define ALIB_ASSERT_ERROR(cond, domain,...)
constexpr integer Length() const
constexpr bool IsEmpty() const
bool EndsWith(const TString &needle) const
character CharAtStart() const
constexpr bool IsNotNull() const
integer IndexOfFirstDifference(const TString &needle, lang::Case sensitivity=lang::Case::Sensitive, integer startIdx=0) const
bool AdjustRegion(integer ®ionStart, integer ®ionLength) const
constexpr const TChar * Buffer() const
character CharAtEnd() const
constexpr TString() noexcept=default
integer IndexOfSegmentEnd(character opener, character closer, integer idx) const
bool StartsWith(const TString &needle) const
integer IndexOfOrLength(TChar needle) const
TString< TChar > ConsumeField(TChar startChar, TChar endChar)
TChar ConsumeCharFromEnd()
bool ConsumeString(const TString< TChar > &consumable)
TSubstring & TrimStart(const TCString< TChar > &whiteSpaces=CStringConstantsTraits< TChar >::DefaultWhitespaces())
TSubstring & Split(integer position, TSubstring &target, integer separatorWidth=0, bool trim=false)
integer ConsumeChars(integer regionLength, TAString< TChar, TAllocator > &target, integer separatorWidth=0)
bool ConsumeBin(std::integral auto &result, TNumberFormat< TChar > *numberFormat=nullptr)
bool ConsumeOct(std::integral auto &result, TNumberFormat< TChar > *numberFormat=nullptr)
bool consumeDecImpl(uint64_t &result, TNumberFormat< TChar > *numberFormat)
integer ConsumePartOf(const TString< TChar > &consumable, int minChars=1)
bool ConsumeDecDigits(std::integral auto &result)
bool consumeDecDigitsImpl(uint64_t &result)
TString< TChar > base
The base string-type.
bool consumeIntImpl(int64_t &result, TNumberFormat< TChar > *numberFormat)
bool ConsumeCharFromEnd(TChar consumable)
integer ConsumeChars(integer regionLength, TString< TChar > &target, integer separatorWidth=0)
TSubstring(const TString< TChar > &src)
bool ConsumeInt(std::integral auto &result, TNumberFormat< TChar > *numberFormat=nullptr)
bool ConsumeDec(std::integral auto &result, TNumberFormat< TChar > *numberFormat=nullptr)
integer ConsumeChars(integer regionLength, TSubstring *target=nullptr)
bool ConsumeStringFromEnd(const TString< TChar > &consumable)
bool consumeOctImpl(uint64_t &result, TNumberFormat< TChar > *numberFormat)
TSubstring & Trim(const TCString< TChar > &whiteSpaces=CStringConstantsTraits< TChar >::DefaultWhitespaces())
bool ConsumeFloat(double &result, TNumberFormat< TChar > *numberFormat=nullptr)
bool consumeHexImpl(uint64_t &result, TNumberFormat< TChar > *numberFormat)
bool ConsumeHex(std::integral auto &result, TNumberFormat< TChar > *numberFormat=nullptr)
integer ConsumeCharsFromEnd(integer regionLength, TSubstring *target=nullptr)
bool ConsumeChar(TChar consumable)
integer ConsumeCharsFromEnd(integer regionLength, TAString< TChar, TAllocator > &target, integer separatorWidth=0)
bool consumeBinImpl(uint64_t &result, TNumberFormat< TChar > *numberFormat)
TString< TChar > ConsumeToken(TChar separator=',', lang::Inclusion includeSeparator=lang::Inclusion::Include)
TSubstring & TrimEnd(const TCString< TChar > &whiteSpaces=CStringConstantsTraits< TChar >::DefaultWhitespaces())
TSubstring()
Default constructor creating a #"alib_strings_details_nulled" "nulled" substring.
integer LastIndexOfAnyExclude(const TChar *haystack, integer startIdx, const TChar *needles, integer needlesLength)
integer IndexOfAnyExcluded(const TChar *haystack, integer haystackLength, const TChar *needles, integer needlesLength)
Case
Denotes upper and lower case character treatment.
@ Clear
Chooses to clear existing data.
Whitespaces
Denotes whether a string is trimmed or not.
@ Keep
Keep whitespaces in string.
@ Trim
Trim whitespaces away.
Inclusion
Denotes how members of a set something should be taken into account.
@ Include
Chooses inclusion.
lang::integer integer
Type alias in namespace #"%alib".
strings::TString< character > String
Type alias in namespace #"%alib".
strings::TSubstring< character > Substring
Type alias in namespace #"%alib".
strings::TSubstring< nchar > NSubstring
Type alias in namespace #"%alib".
strings::TSubstring< xchar > XSubstring
Type alias in namespace #"%alib".
strings::TSubstring< wchar > WSubstring
Type alias in namespace #"%alib".
strings::TSubstring< complementChar > ComplementSubstring
Type alias in namespace #"%alib".
strings::TSubstring< strangeChar > StrangeSubstring
Type alias in namespace #"%alib".
static constexpr Policy Access
static integer Length(const TStringSource &src)
static TStringSource Construct(const TChar *array, integer length)
static constexpr Policy Construction
static const TChar * Buffer(const TStringSource &src)
static constexpr CString< TChar > DefaultWhitespaces())
"carriage return" and "tabulator", hence " \n\r\t".