ALib C++ Library
Library Version: 2510 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
alib::strings::TSubstring< TChar > Class Template Reference

Description:

template<typename TChar>
class alib::strings::TSubstring< TChar >

This class specializes parent class String to allow reduction of the length of the represented string by cutting characters from the front or the end. Such reduction does not affect the character array represented, but only its representation by instances of this type.

In other words, the difference to base class String is, that this type allows increasing the pointer to the character array's start and to decrease its stored length. In all other respects, this class has the same lightweight nature and performance as its base. Furthermore, the flexible template programming mechanics for seamless construction are exposed from the base class and likewise available.

Like base class String, the class cannot, and therefore does not, verify that the underlying buffer is (still) properly allocated and contains valid data. It is up to the user of this class to make sure the buffer stays intact until any referencing object of this type is disposed.

Template Parameters
TCharThe character type of this string-type. Alias names for specializations along the different character types are provided in namespace alib with type definitions Substring, NSubstring, WSubstring, XSubstring, ComplementSubstring, and StrangeSubstring.

Definition at line 38 of file substring.inl.

Inheritance diagram for alib::strings::TSubstring< TChar >:
[legend]
Collaboration diagram for alib::strings::TSubstring< TChar >:
[legend]

Public Method Index:

 TSubstring ()
 Default constructor creating a 6.1 Nulled Strings "nulled" substring.
 
 TSubstring (const TString< TChar > &src)
 
TSubstringClear ()
 
bool ConsumeBin (std::integral auto &result, TNumberFormat< TChar > *numberFormat=nullptr)
 
template<typename TCheck = CHK, lang::Whitespaces TTrimBeforeConsume = lang::Whitespaces::Keep>
TChar ConsumeChar ()
 
template<lang::Case TSensitivity = lang::Case::Sensitive, lang::Whitespaces TTrimBeforeConsume = lang::Whitespaces::Keep>
bool ConsumeChar (TChar consumable)
 
template<typename TCheck = CHK, lang::Whitespaces TTrimBeforeConsume = lang::Whitespaces::Keep>
TChar ConsumeCharFromEnd ()
 
template<lang::Case TSensitivity = lang::Case::Sensitive, lang::Whitespaces TTrimBeforeConsume = lang::Whitespaces::Keep>
bool ConsumeCharFromEnd (TChar consumable)
 
template<typename TCheck = CHK, lang::CurrentData TTargetData = lang::CurrentData::Clear, typename TAllocator>
integer ConsumeChars (integer regionLength, TAString< TChar, TAllocator > &target, integer separatorWidth=0)
 
template<typename TCheck = CHK>
integer ConsumeChars (integer regionLength, TString< TChar > &target, integer separatorWidth=0)
 
template<typename TCheck = CHK>
integer ConsumeChars (integer regionLength, TSubstring *target=nullptr)
 
template<typename TCheck = CHK, lang::CurrentData TTargetData = lang::CurrentData::Clear, typename TAllocator>
integer ConsumeCharsFromEnd (integer regionLength, TAString< TChar, TAllocator > &target, integer separatorWidth=0)
 
template<typename TCheck = CHK>
integer ConsumeCharsFromEnd (integer regionLength, TSubstring *target=nullptr)
 
bool ConsumeDec (std::integral auto &result, TNumberFormat< TChar > *numberFormat=nullptr)
 
bool ConsumeDecDigits (std::integral auto &result)
 
template<lang::Whitespaces TTrimBeforeConsume = lang::Whitespaces::Keep>
TString< TChar > ConsumeField (TChar startChar, TChar endChar)
 
ALIB_DLL bool ConsumeFloat (double &result, TNumberFormat< TChar > *numberFormat=nullptr)
 
bool ConsumeHex (std::integral auto &result, TNumberFormat< TChar > *numberFormat=nullptr)
 
bool ConsumeInt (std::integral auto &result, TNumberFormat< TChar > *numberFormat=nullptr)
 
bool ConsumeOct (std::integral auto &result, TNumberFormat< TChar > *numberFormat=nullptr)
 
template<lang::Case TSensitivity = lang::Case::Ignore, lang::Whitespaces TTrimBeforeConsume = lang::Whitespaces::Keep>
integer ConsumePartOf (const TString< TChar > &consumable, int minChars=1)
 
template<lang::Case TSensitivity = lang::Case::Sensitive, lang::Whitespaces TTrimBeforeConsume = lang::Whitespaces::Keep>
bool ConsumeString (const TString< TChar > &consumable)
 
template<lang::Case TSensitivity = lang::Case::Sensitive, lang::Whitespaces TTrimBeforeConsume = lang::Whitespaces::Keep>
bool ConsumeStringFromEnd (const TString< TChar > &consumable)
 
TString< TChar > ConsumeToken (TChar separator=',', lang::Inclusion includeSeparator=lang::Inclusion::Include)
 
template<typename TCheck = CHK>
TSubstringSplit (integer position, TSubstring &target, integer separatorWidth=0, bool trim=false)
 
TSubstringTrim (const TCString< TChar > &whiteSpaces=CStringConstantsTraits< TChar >::DefaultWhitespaces())
 
TSubstringTrimEnd (const TCString< TChar > &whiteSpaces=CStringConstantsTraits< TChar >::DefaultWhitespaces())
 
TSubstringTrimStart (const TCString< TChar > &whiteSpaces=CStringConstantsTraits< TChar >::DefaultWhitespaces())
 
- Public Method Index: inherited from alib::strings::TString< TChar >
constexpr TString () noexcept=default
 
template<typename T>
requires alib::characters::IsImplicitArraySource<T, TChar>
constexpr TString (const T &src) noexcept
 
template<typename T>
requires alib::characters::IsExplicitArraySource<T, TChar>
constexpr TString (const T &src) noexcept
 
constexpr TString (const TChar *pBuffer, integer pLength) noexcept
 
constexpr TString (const TString &) noexcept=default
 Defaulted copy constructor.
 
 TString (const_iterator &start, const_iterator &end)
 
constexpr TString (lang::IsNullptr auto const &) noexcept
 Constructor accepting nullptr. Constructs a nulled string.
 
template<typename T>
requires alib::characters::IsMutableArraySource<T, TChar>
constexpr TString (T &src) noexcept
 
template<typename TAllocator>
requires alib::lang::IsAllocator<TAllocator>
 TString (TAllocator &allocator, const TString< TChar > &copy)
 
constexpr TString (TString &&) noexcept=default
 Defaulted move constructor.
 
template<typename T>
requires ( alib::characters::IsImplicitArrayCast<T, TChar> && !alib::strings::NoAutoCastTraits< TString<TChar>, characters::Policy::Implicit, std::remove_cv_t<T> >::value )
constexpr operator T () const
 
template<typename T>
requires ( alib::characters::IsExplicitArrayCast<T, TChar> && !alib::strings::NoAutoCastTraits< TString<TChar>, characters::Policy::ExplicitOnly, std::remove_cv_t<T> >::value )
constexpr operator T () const
 
constexpr TStringoperator= (const TString &) noexcept=default
 
constexpr TStringoperator= (TString &&) noexcept=default
 
constexpr const TChar * Buffer () const
 
constexpr integer Length () const
 
integer WStringLength () const
 
constexpr bool IsNull () const
 
constexpr bool IsNotNull () const
 
constexpr bool IsEmpty () const
 
constexpr bool IsNotEmpty () const
 
template<typename TCheck = CHK>
TString< TChar > Substring (integer regionStart, integer regionLength=MAX_LEN) const
 
template<typename TCheck = CHK>
TChar CharAt (integer idx) const
 
template<typename TCheck = CHK>
TChar CharAtStart () const
 
template<typename TCheck = CHK>
TChar CharAtEnd () const
 
TChar operator[] (integer idx) const
 
std::size_t Hashcode () const
 
std::size_t HashcodeIgnoreCase () const
 
template<typename TCheck = CHK, lang::Case TSensitivity = lang::Case::Sensitive>
bool Equals (const TString< TChar > &rhs) const
 
template<typename TCheck = CHK, lang::Case TSensitivity = lang::Case::Sensitive>
int CompareTo (const TString< TChar > &rhs) const
 
template<typename TCheck = CHK, lang::Case TSensitivity = lang::Case::Sensitive>
int CompareTo (const TString &rhs, integer rhsRegionStart, integer rhsRegionLength=MAX_LEN) const
 
template<typename TCheck = CHK, lang::Case TSensitivity = lang::Case::Sensitive>
int CompareTo (const TString &rhs, integer rhsRegionStart, integer rhsRegionLength, integer regionStart, integer regionLength=MAX_LEN) const
 
template<typename TCheck = CHK, lang::Case TSensitivity = lang::Case::Sensitive>
bool ContainsAt (const TString &needle, integer pos) const
 
template<typename TCheck = CHK, lang::Case TSensitivity = lang::Case::Sensitive>
bool StartsWith (const TString &needle) const
 
template<typename TCheck = CHK, lang::Case TSensitivity = lang::Case::Sensitive>
bool EndsWith (const TString &needle) const
 
template<typename TCheck = CHK>
integer IndexOf (TChar needle, integer startIdx=0) const
 
template<typename TCheck = CHK>
integer IndexOf (TChar needle, integer regionStart, integer regionLength) const
 
integer IndexOfOrLength (TChar needle) const
 
template<typename TCheck = CHK>
integer IndexOfOrLength (TChar needle, integer startIdx) const
 
template<typename TCheck = CHK>
integer LastIndexOf (TChar needle, integer startIndex=MAX_LEN) const
 
template<lang::Inclusion TInclusion, typename TCheck = CHK>
integer IndexOfAny (const TString &needles, integer startIdx=0) const
 
template<lang::Inclusion TInclusion, typename TCheck = CHK>
integer LastIndexOfAny (const TString &needles, integer startIdx=MAX_LEN) const
 
template<typename TCheck = CHK, lang::Case TSensitivity = lang::Case::Sensitive>
integer IndexOf (const TString &needle, integer startIdx=0, integer endIdx=strings::MAX_LEN) const
 
template<typename TCheck = CHK>
integer IndexOfFirstDifference (const TString &needle, lang::Case sensitivity=lang::Case::Sensitive, integer startIdx=0) const
 
integer IndexOfSegmentEnd (TChar opener, TChar closer, integer idx) const
 
template<typename TCheck = CHK>
integer CountChar (TChar needle, integer startPos=0) const
 
template<typename TCheck = CHK>
integer CountChar (TChar needle, TChar omit, integer startPos) const
 
template<typename TCheck = CHK, lang::Case TSensitivity = lang::Case::Sensitive>
integer Count (const TString &needle, integer startPos=0) const
 
template<typename TCheck = CHK, lang::Case TSensitivity = lang::Case::Sensitive>
integer Count (const TString &needle, const TString &omit, integer startPos=0) const
 
ALIB_DLL uint64_t ParseDecDigits (integer startIdx=0, integer *newIdx=nullptr) const
 
ALIB_DLL int64_t ParseInt (integer startIdx=0, TNumberFormat< TChar > *numberFormat=nullptr, integer *newIdx=nullptr) const
 
int64_t ParseInt (TNumberFormat< TChar > *numberFormat, integer *newIdx=nullptr) const
 
int64_t ParseInt (integer *newIdx) const
 
int64_t ParseInt (integer startIdx, integer *newIdx) const
 
ALIB_DLL uint64_t ParseDec (integer startIdx=0, TNumberFormat< TChar > *numberFormat=nullptr, integer *newIdx=nullptr) const
 
uint64_t ParseDec (TNumberFormat< TChar > *numberFormat, integer *newIdx=nullptr) const
 
uint64_t ParseDec (integer *newIdx) const
 
uint64_t ParseDec (integer startIdx, integer *newIdx) const
 
ALIB_DLL uint64_t ParseBin (integer startIdx=0, TNumberFormat< TChar > *numberFormat=nullptr, integer *newIdx=nullptr) const
 
uint64_t ParseBin (TNumberFormat< TChar > *numberFormat, integer *newIdx=nullptr) const
 
uint64_t ParseBin (integer *newIdx) const
 
uint64_t ParseBin (integer startIdx, integer *newIdx) const
 
ALIB_DLL uint64_t ParseHex (integer startIdx=0, TNumberFormat< TChar > *numberFormat=nullptr, integer *newIdx=nullptr) const
 
uint64_t ParseHex (TNumberFormat< TChar > *numberFormat, integer *newIdx=nullptr) const
 
uint64_t ParseHex (integer *newIdx) const
 
uint64_t ParseHex (integer startIdx, integer *newIdx) const
 
ALIB_DLL uint64_t ParseOct (integer startIdx=0, TNumberFormat< TChar > *numberFormat=nullptr, integer *newIdx=nullptr) const
 
uint64_t ParseOct (TNumberFormat< TChar > *numberFormat, integer *newIdx=nullptr) const
 
uint64_t ParseOct (integer *newIdx) const
 
uint64_t ParseOct (integer startIdx, integer *newIdx) const
 
ALIB_DLL double ParseFloat (integer startIdx=0, TNumberFormat< TChar > *numberFormat=nullptr, integer *newIdx=nullptr) const
 
double ParseFloat (TNumberFormat< TChar > *numberFormat, integer *newIdx=nullptr) const
 
double ParseFloat (integer *newIdx) const
 
double ParseFloat (integer startIdx, integer *newIdx) const
 
integer CopyTo (TChar *dest) const
 
template<typename TAllocator>
requires alib::lang::IsAllocator<TAllocator>
void Allocate (TAllocator &allocator, const TString< TChar > &copy)
 
template<typename TAllocator>
requires alib::lang::IsAllocator<TAllocator>
void Free (TAllocator &allocator)
 
const_iterator begin () const
 
const_iterator cbegin () const
 
const_iterator end () const
 
const_iterator cend () const
 
const_reverse_iterator rbegin () const
 
const_reverse_iterator rend () const
 
const_reverse_iterator crbegin () const
 
const_reverse_iterator crend () const
 
size_type size () const
 
bool AdjustRegion (integer &regionStart, integer &regionLength) const
 

Protected Type Index:

using base = TString<TChar>
 The base string-type.
 

Protected Method Index:

ALIB_DLL bool consumeBinImpl (uint64_t &result, TNumberFormat< TChar > *numberFormat)
 
ALIB_DLL bool consumeDecDigitsImpl (uint64_t &result)
 
ALIB_DLL bool consumeDecImpl (uint64_t &result, TNumberFormat< TChar > *numberFormat)
 
ALIB_DLL bool consumeHexImpl (uint64_t &result, TNumberFormat< TChar > *numberFormat)
 
ALIB_DLL bool consumeIntImpl (int64_t &result, TNumberFormat< TChar > *numberFormat)
 
ALIB_DLL bool consumeOctImpl (uint64_t &result, TNumberFormat< TChar > *numberFormat)
 
- Protected Method Index: inherited from alib::strings::TString< TChar >
template<lang::Case TSensitivity = lang::Case::Sensitive>
ALIB_DLL integer indexOfString (const TString &needle, integer startIdx, integer endIdx) const
 

Additional Inherited Members

- Public Type Index: inherited from alib::strings::TString< TChar >
using size_type = integer
 The type defining sizes of strings.
 
using value_type = TChar
 Exposes template parameter TChar to the outer world in a std compatible way.
 
using const_iterator = TRandomAccessIterator<const TChar>
 
using const_reverse_iterator = std::reverse_iterator<const_iterator>
 
- Protected Field Index: inherited from alib::strings::TString< TChar >
const TChar * buffer
 
integer length
 

Type Definition Details:

◆ base

template<typename TChar>
using alib::strings::TSubstring< TChar >::base = TString<TChar>
protected

The base string-type.

Definition at line 42 of file substring.inl.

Constructor(s) / Destructor Details:

◆ TSubstring() [1/2]

template<typename TChar>
alib::strings::TSubstring< TChar >::TSubstring ( )
inline

Default constructor creating a 6.1 Nulled Strings "nulled" substring.

Definition at line 53 of file substring.inl.

◆ TSubstring() [2/2]

template<typename TChar>
alib::strings::TSubstring< TChar >::TSubstring ( const TString< TChar > & src)
inline

Constructor using a string reference.

Parameters
srcThe source string.

Definition at line 59 of file substring.inl.

Method Details:

◆ Clear()

template<typename TChar>
TSubstring & alib::strings::TSubstring< TChar >::Clear ( )
inline

Sets this object to zero length.

Returns
*this to allow concatenated calls.

Definition at line 65 of file substring.inl.

◆ ConsumeBin()

template<typename TChar>
bool alib::strings::TSubstring< TChar >::ConsumeBin ( std::integral auto & result,
TNumberFormat< TChar > * numberFormat = nullptr )
inline

Consumes an unsigned integer in binary format from the start of this string.

Parameter numberFormat defaults to nullptr. This denotes static singleton NumberFormat::Computational which is configured to not using (not allowing) grouping characters.

For more information on number conversion, see class NumberFormat.

Parameters
[out]resultA reference to the result value.
numberFormatThe number format to use. Defaults to nullptr.
Returns
true if a number was found and consumed, false otherwise.

Definition at line 727 of file substring.inl.

◆ consumeBinImpl()

template<typename TChar>
template ALIB_DLL bool alib::strings::TSubstring< TChar >::consumeBinImpl ( uint64_t & result,
TNumberFormat< TChar > * numberFormat )
protected

Implementation of ConsumeBin (the non-inline part).

Parameters
[out]resultA reference to the result value.
numberFormatThe number format to use.
Returns
true if a number was found and consumed, false otherwise.

Definition at line 82 of file substring.cpp.

Here is the call graph for this function:

◆ ConsumeChar() [1/2]

template<typename TChar>
template<typename TCheck = CHK, lang::Whitespaces TTrimBeforeConsume = lang::Whitespaces::Keep>
TChar alib::strings::TSubstring< TChar >::ConsumeChar ( )
inline

Retrieve and remove the first character from the substring.

Template Parameters
TTrimBeforeConsumeDetermines if the string should be (left-) trimmed before the consume operation. Defaults to Whitespaces::Keep.
TCheckDefaults to CHK, which is the normal invocation mode. If <false> is added to the method name, no parameter check is performed.
Returns
The character at the start of the represented region. If this Substring is empty or nulled, '\0' is returned.

Definition at line 135 of file substring.inl.

◆ ConsumeChar() [2/2]

template<typename TChar>
template<lang::Case TSensitivity = lang::Case::Sensitive, lang::Whitespaces TTrimBeforeConsume = lang::Whitespaces::Keep>
bool alib::strings::TSubstring< TChar >::ConsumeChar ( TChar consumable)
inline

Checks if this object starts with the given character consumable. If it does, this character is cut from this object.

Template Parameters
TSensitivityThe sensitivity of the comparison. Defaults to Case::Sensitive.
TTrimBeforeConsumeDetermines if the string should be (left-) trimmed before the consume operation. Defaults to Whitespaces::Keep.
Parameters
consumableThe consumable character.
Returns
true, if this object was starting with consumable and consequently the string was cut by one, false otherwise.

Definition at line 167 of file substring.inl.

◆ ConsumeCharFromEnd() [1/2]

template<typename TChar>
template<typename TCheck = CHK, lang::Whitespaces TTrimBeforeConsume = lang::Whitespaces::Keep>
TChar alib::strings::TSubstring< TChar >::ConsumeCharFromEnd ( )
inline

Retrieve and remove the last character in the substring.

Template Parameters
TCheckDefaults to CHK, which is the normal invocation mode. If <false> is added to the method name, no check whether this string is empty is performed.
TTrimBeforeConsumeDetermines if the string should be (right-) trimmed before the consume operation. Defaults to Whitespaces::Keep.
Returns
The character at the start of the represented region. If this Substring is empty or nulled, '\0' is returned.

Definition at line 220 of file substring.inl.

◆ ConsumeCharFromEnd() [2/2]

template<typename TChar>
template<lang::Case TSensitivity = lang::Case::Sensitive, lang::Whitespaces TTrimBeforeConsume = lang::Whitespaces::Keep>
bool alib::strings::TSubstring< TChar >::ConsumeCharFromEnd ( TChar consumable)
inline

Checks if this object ends with the given character consumable. If it does, this character is cut from the end of object.

Template Parameters
TSensitivityThe sensitivity of the comparison. Defaults to Case::Sensitive.
TTrimBeforeConsumeDetermines if the string should be (left-) trimmed before the consume operation. Defaults to Whitespaces::Keep.
Parameters
consumableThe consumable character.
Returns
true, if this object was starting with consumable and consequently the string was cut by one.

Definition at line 195 of file substring.inl.

◆ ConsumeChars() [1/3]

template<typename TChar>
template<typename TCheck = CHK, lang::CurrentData TTargetData = lang::CurrentData::Clear, typename TAllocator>
integer alib::strings::TSubstring< TChar >::ConsumeChars ( integer regionLength,
TAString< TChar, TAllocator > & target,
integer separatorWidth = 0 )
inline

Cuts the given number of characters from the beginning of the Substring and optionally places the portion that was cut in parameter target.
Parameter regionLength is checked to be between 0 and length. If negative, nothing is cut and target is set empty, respectively left untouched depending on TTargetData.

If regionLength is greater than this object's length, all contents is 'moved' to target.

Template Parameters
TCheckDefaults to CHK, which is the normal invocation mode. If <false> is added to the method name, no parameter check is performed.
TTargetDataIf CurrentData::Keep, AString target is not cleared before the result is written. Defaults to CurrentData::Clear.
TAllocatorThe allocation type of the target string, as prototyped with Allocator. Deduced by the compiler.
Parameters
regionLengthThe length of the region at the start to delete.
targetA target AString that receives the portion that is cut from this object.
separatorWidthThis width is added to what is cut from this string, while target still receives the portion defined by regionLength. Defaults to 0.
Returns
The new length of the substring.

Definition at line 351 of file substring.inl.

◆ ConsumeChars() [2/3]

template<typename TChar>
template<typename TCheck = CHK>
integer alib::strings::TSubstring< TChar >::ConsumeChars ( integer regionLength,
TString< TChar > & target,
integer separatorWidth = 0 )
inline

Cuts the given number of characters from the beginning of the Substring and optionally places the portion that was cut in parameter target.
Parameter regionLength is checked to be between 0 and length. If negative, nothing is cut and target is set empty, respectively left untouched depending on TTargetData.

If regionLength is greater than this object's length, all contents is 'moved' to target.

Template Parameters
TCheckDefaults to CHK, which is the normal invocation mode. If <false> is added to the method name, no parameter check is performed.
Parameters
regionLengthThe length of the region at the start to delete.
targetA target String that receives the portion that is cut from this object.
separatorWidthThis width is added to what is cut from this string, while target still receives the portion defined by regionLength. Defaults to 0.
Returns
The new length of the substring.

Definition at line 414 of file substring.inl.

◆ ConsumeChars() [3/3]

template<typename TChar>
template<typename TCheck = CHK>
integer alib::strings::TSubstring< TChar >::ConsumeChars ( integer regionLength,
TSubstring< TChar > * target = nullptr )
inline

Cuts the given number of characters from the beginning of the Substring and optionally places the portion that was cut in parameter target (if provided).

If parameter regionLength is negative, nothing is cut and optional argument target is set empty. If regionLength is equal or greater than this object's length, all contents is 'moved' to target.

Template Parameters
TCheckDefaults to CHK, which is the normal invocation mode. If <false>, parameter regionLength has to be in the range of this object's size.
Parameters
regionLengthThe length of the region at the start to delete.
targetAn optional target Substring that receives the portion that is cut from this object. Defaults to nullptr.
Returns
The new length of the substring.

Definition at line 254 of file substring.inl.

◆ ConsumeCharsFromEnd() [1/2]

template<typename TChar>
template<typename TCheck = CHK, lang::CurrentData TTargetData = lang::CurrentData::Clear, typename TAllocator>
integer alib::strings::TSubstring< TChar >::ConsumeCharsFromEnd ( integer regionLength,
TAString< TChar, TAllocator > & target,
integer separatorWidth = 0 )
inline

Cuts the given number of characters from the end of the substring and places the portion that was cut in parameter target.
Parameter regionLength is checked to be between 0 and length. If negative, nothing is cut and target is set empty, respectively left untouched depending on If regionLength is greater than this object's length, all contents is 'moved' to target.

Template Parameters
TCheckDefaults to CHK, which is the normal invocation mode. If <false> is added to the method name, no parameter check is performed.
TTargetDataIf CurrentData::Keep, the parameter target is not cleared before the result is written. Defaults to CurrentData::Clear.
TAllocatorThe allocator-type of the target. Deduced by the compiler.
Parameters
regionLengthThe length of the region at the start to delete.
targetA target AString that receives the portion that is cut from this object.
separatorWidthThis width is added to what is cut from this string, while target still receives the portion defined by regionLength. Defaults to 0.
Returns
The new length of the substring.

Definition at line 477 of file substring.inl.

◆ ConsumeCharsFromEnd() [2/2]

template<typename TChar>
template<typename TCheck = CHK>
integer alib::strings::TSubstring< TChar >::ConsumeCharsFromEnd ( integer regionLength,
TSubstring< TChar > * target = nullptr )
inline

Cuts the given number of characters from the end of the Substring and optionally places the portion that was cut in parameter target (if provided).
Parameter regionLength is checked to be between 0 and length. If negative, nothing is cut and target is set empty. If regionLength is greater than this object's length, all contents is 'moved' to target.

Template Parameters
TCheckDefaults to CHK, which is the normal invocation mode. If <false> is added to the method name, no parameter check is performed.
Parameters
regionLengthThe length of the region at the start to delete.
targetAn optional target Substring that receives the portion that is cut from this object. Defaults to nullptr.
Returns
The new length of the substring.

Definition at line 298 of file substring.inl.

◆ ConsumeDec()

template<typename TChar>
bool alib::strings::TSubstring< TChar >::ConsumeDec ( std::integral auto & result,
TNumberFormat< TChar > * numberFormat = nullptr )
inline

Consumes an unsigned integer in standard decimal format from the start of this AString.

Parameter numberFormat defaults to nullptr. This denotes static singleton NumberFormat::Computational which is configured to not using (not allowing) grouping characters.

Sign literals '-' or '+' are not accepted and parsing will fail. For reading signed integral values, see methods ConsumeInt, for floating point numbers ConsumeFloat.

For more information on number conversion, see class NumberFormat.

Parameters
[out]resultA reference to a variable of an integral type which receives the result value.
numberFormatThe number format to use. Defaults to nullptr.
Returns
true if a number was found and consumed, false otherwise.

Definition at line 707 of file substring.inl.

◆ ConsumeDecDigits()

template<typename TChar>
bool alib::strings::TSubstring< TChar >::ConsumeDecDigits ( std::integral auto & result)
inline

Consumes all characters '0' to '9' at the start of this object and stores the value they represent in result.
Unlike methods ConsumeInt or ConsumeDec, this method does not consume (respectively accept) sign-, whitespace- or group-characters.

Parameters
[out]resultA reference to a variable of an integral type which receives the result value.
Returns
true if a number was found and consumed, false otherwise.

Definition at line 659 of file substring.inl.

◆ consumeDecDigitsImpl()

template<typename TChar>
template ALIB_DLL bool alib::strings::TSubstring< TChar >::consumeDecDigitsImpl ( uint64_t & result)
protected

Implementation of ConsumeDecDigits (the non-inline part).

Parameters
[out]resultA reference to the result value.
Returns
true if a number was found and consumed, false otherwise.

Definition at line 37 of file substring.cpp.

Here is the call graph for this function:

◆ consumeDecImpl()

template<typename TChar>
template ALIB_DLL bool alib::strings::TSubstring< TChar >::consumeDecImpl ( uint64_t & result,
TNumberFormat< TChar > * numberFormat )
protected

Implementation of ConsumeDec (the non-inline part).

Parameters
[out]resultA reference to the result value.
numberFormatThe number format to use.
Returns
true if a number was found and consumed, false otherwise.

Definition at line 66 of file substring.cpp.

Here is the call graph for this function:

◆ ConsumeField()

template<typename TChar>
template<lang::Whitespaces TTrimBeforeConsume = lang::Whitespaces::Keep>
TString< TChar > alib::strings::TSubstring< TChar >::ConsumeField ( TChar startChar,
TChar endChar )
inline

Consumes a field from the beginning of this substring, which is surrounded by given start end end character identifiers. If both are the same, e.g., '"', then the first occurrence of the end character is used. If they are not the same, e.g. '<' and '>', then repeated start characters are counted and consumption only ends when a corresponding amount of end characters has been found.

Template Parameters
TTrimBeforeConsumeDetermines if the string should be (left-) trimmed before the consume operation. Defaults to Whitespaces::Keep.
Parameters
startCharThe start character of the field to consume.
endCharThe end character of the field to consume.
Returns
The string consumed. NULL_STRING on error (start/end character not found)

Definition at line 633 of file substring.inl.

◆ ConsumeFloat()

template<typename TChar>
template ALIB_DLL bool alib::strings::TSubstring< TChar >::ConsumeFloat ( double & result,
TNumberFormat< TChar > * numberFormat = nullptr )

Consumes a floating point number from the start of this string.

on the given numberFormat instance.
Parameter numberFormat defaults to nullptr. This denotes static singleton NumberFormat::Computational which is configured to 'international' settings (not using the locale) and therefore also not parsing grouping characters.

For more information on parsing options for floating point numbers and number conversion in general, see class NumberFormat.

Parameters
[out]resultA reference to the result value.
numberFormatThe number format to use. Defaults to nullptr.
Returns
true if a number was found and consumed, false otherwise.

Definition at line 130 of file substring.cpp.

Here is the call graph for this function:

◆ ConsumeHex()

template<typename TChar>
bool alib::strings::TSubstring< TChar >::ConsumeHex ( std::integral auto & result,
TNumberFormat< TChar > * numberFormat = nullptr )
inline

Consumes an unsigned integer in hexadecimal format from the start of this string.

Parameter numberFormat defaults to nullptr. This denotes static singleton NumberFormat::Computational which is configured to not using (not allowing) grouping characters.

For more information on number conversion, see class NumberFormat.

Parameters
[out]resultA reference to a variable of an integral type which receives the result value.
numberFormatThe number format to use. Defaults to nullptr.
Returns
true if a number was found and consumed, false otherwise.

Definition at line 749 of file substring.inl.

◆ consumeHexImpl()

template<typename TChar>
template ALIB_DLL bool alib::strings::TSubstring< TChar >::consumeHexImpl ( uint64_t & result,
TNumberFormat< TChar > * numberFormat )
protected

Implementation of ConsumeHex (the non-inline part).

Parameters
[out]resultA reference to the result value.
numberFormatThe number format to use.
Returns
true if a number was found and consumed, false otherwise.

Definition at line 98 of file substring.cpp.

Here is the call graph for this function:

◆ ConsumeInt()

template<typename TChar>
bool alib::strings::TSubstring< TChar >::ConsumeInt ( std::integral auto & result,
TNumberFormat< TChar > * numberFormat = nullptr )
inline

Consumes an integral value in decimal, binary, hexadecimal or octal format from the string.

Parameter numberFormat defaults to nullptr. This denotes static singleton NumberFormat::Computational which is configured to not using (not allowing) grouping characters.

For more information on number conversion, see class NumberFormat.

Parameters
[out]resultA reference to a variable of an integral type which receives the result value.
numberFormatThe number format to use. Defaults to nullptr.
Returns
true if a number was found and consumed, false otherwise.

Definition at line 682 of file substring.inl.

◆ consumeIntImpl()

template<typename TChar>
template ALIB_DLL bool alib::strings::TSubstring< TChar >::consumeIntImpl ( int64_t & result,
TNumberFormat< TChar > * numberFormat )
protected

Implementation of ConsumeInt (the non-inline part).

Parameters
[out]resultA reference to the result value.
numberFormatThe number format to use.
Returns
true if a number was found and consumed, false otherwise.

Definition at line 50 of file substring.cpp.

Here is the call graph for this function:

◆ ConsumeOct()

template<typename TChar>
bool alib::strings::TSubstring< TChar >::ConsumeOct ( std::integral auto & result,
TNumberFormat< TChar > * numberFormat = nullptr )
inline

Consumes an unsigned integer in octal format from the start of this string.

Parameter numberFormat defaults to nullptr. This denotes static singleton NumberFormat::Computational which is configured to not use (not allow) grouping characters.

For more information on number conversion, see class NumberFormat.

Parameters
[out]resultA reference to a variable of an integral type which receives the result value.
numberFormatThe number format to use. Defaults to nullptr.
Returns
true if a number was found and consumed, false otherwise.

Definition at line 771 of file substring.inl.

◆ consumeOctImpl()

template<typename TChar>
template ALIB_DLL bool alib::strings::TSubstring< TChar >::consumeOctImpl ( uint64_t & result,
TNumberFormat< TChar > * numberFormat )
protected

Implementation of ConsumeOct (the non-inline part).

Parameters
[out]resultA reference to the result value.
numberFormatThe number format to use.
Returns
true if a number was found and consumed, false otherwise.

Definition at line 114 of file substring.cpp.

Here is the call graph for this function:

◆ ConsumePartOf()

template<typename TChar>
template<lang::Case TSensitivity = lang::Case::Ignore, lang::Whitespaces TTrimBeforeConsume = lang::Whitespaces::Keep>
integer alib::strings::TSubstring< TChar >::ConsumePartOf ( const TString< TChar > & consumable,
int minChars = 1 )
inline

Consumes a minimum of minChars of string consumable from the start of this substring. If the minimum characters could not be found, nothing is consumed, otherwise, the method consumes as much as possible.

This method is useful read "tokens" from a string that may be abbreviated. Within ALib this method is for example used with deserialization of enumeration elements.

Template Parameters
TSensitivityThe sensitivity of the comparison. Defaults to Case::Ignore.
TTrimBeforeConsumeDetermines if the string should be (left-) trimmed before the first character consume operation. Defaults to Whitespaces::Keep.
Parameters
consumableThe consumable string.
minCharsThe minimum amount of characters to consume. If 0 or negative, the length of consumable is chosen. Optional and defaults to 1.
Returns
The amount of characters consumed.

Definition at line 603 of file substring.inl.

◆ ConsumeString()

template<typename TChar>
template<lang::Case TSensitivity = lang::Case::Sensitive, lang::Whitespaces TTrimBeforeConsume = lang::Whitespaces::Keep>
bool alib::strings::TSubstring< TChar >::ConsumeString ( const TString< TChar > & consumable)
inline

Checks if this object starts with the given string consumable. If it does, this string is cut from this object.

Template Parameters
TSensitivityThe sensitivity of the comparison. Defaults to Case::Sensitive.
TTrimBeforeConsumeDetermines if the string should be (left-) trimmed before the consume operation. Defaults to Whitespaces::Keep.
Parameters
consumableThe consumable string.
Returns
true, if this object was starting with consumable and consequently the string was cut.

Definition at line 547 of file substring.inl.

◆ ConsumeStringFromEnd()

template<typename TChar>
template<lang::Case TSensitivity = lang::Case::Sensitive, lang::Whitespaces TTrimBeforeConsume = lang::Whitespaces::Keep>
bool alib::strings::TSubstring< TChar >::ConsumeStringFromEnd ( const TString< TChar > & consumable)
inline

Checks if this object ends with the given string consumable. If it does, this string is cut from the end of object.

Template Parameters
TSensitivityThe sensitivity of the comparison. Defaults to Case::Sensitive.
TTrimBeforeConsumeDetermines if the string should be (left-) trimmed before the consume operation. Defaults to Whitespaces::Keep.
Parameters
consumableThe consumable string
Returns
true, if this object was starting with consumable and consequently the string was cut.

Definition at line 572 of file substring.inl.

◆ ConsumeToken()

template<typename TChar>
TString< TChar > alib::strings::TSubstring< TChar >::ConsumeToken ( TChar separator = ',',
lang::Inclusion includeSeparator = lang::Inclusion::Include )
inline

Searches separator and cuts the beginning of this string. What was consumed is returned.

If the separator is not found, all of this string is consumed and returned.

Parameters
separatorThe separator to search. Defaults to ','.
includeSeparatorDetermines if the separator should be consumed as well. defaults to Include
Returns
The token consumed.

Definition at line 516 of file substring.inl.

◆ Split()

template<typename TChar>
template<typename TCheck = CHK>
TSubstring & alib::strings::TSubstring< TChar >::Split ( integer position,
TSubstring< TChar > & target,
integer separatorWidth = 0,
bool trim = false )
inline

Splits this substring into two parts. What remains in this object is the region from 0 to position. target receives the rest. If separatorWidth is given, this is subtracted from the front of target.

Template Parameters
TCheckDefaults to CHK, which is the normal invocation mode. If <false> is added to the method name, no parameter check is performed.
Parameters
positionThe index where this object is split.
targetThe target substring to receive the right part of the string.
separatorWidthThis does not change what remains in this object, but defines the number of characters that are cut from the front of the target. Defaults to 0.
trimIf true, both substrings will be trimmed.
Returns
*this to allow concatenated calls.

Definition at line 818 of file substring.inl.

◆ Trim()

template<typename TChar>
TSubstring & alib::strings::TSubstring< TChar >::Trim ( const TCString< TChar > & whiteSpaces = CStringConstantsTraits<TChar>::DefaultWhitespaces())
inline

Invokes TrimStart and TrimEnd .

Parameters
whiteSpacesThe characters used for trimming. Defaults to alib::DEFAULT_WHITESPACES
Returns
*this to allow concatenated calls.

Definition at line 116 of file substring.inl.

◆ TrimEnd()

template<typename TChar>
TSubstring & alib::strings::TSubstring< TChar >::TrimEnd ( const TCString< TChar > & whiteSpaces = CStringConstantsTraits<TChar>::DefaultWhitespaces())
inline

Moves the start to the first character not found in given character set whiteSpaces.

Parameters
whiteSpacesThe characters used for trimming. Defaults to alib::DEFAULT_WHITESPACES
Returns
*this to allow concatenated calls.

Definition at line 98 of file substring.inl.

◆ TrimStart()

template<typename TChar>
TSubstring & alib::strings::TSubstring< TChar >::TrimStart ( const TCString< TChar > & whiteSpaces = CStringConstantsTraits<TChar>::DefaultWhitespaces())
inline

Moves the start to the first character not found in given character set whiteSpaces.

Parameters
whiteSpacesThe characters used for trimming. Defaults to alib::DEFAULT_WHITESPACES
Returns
*this to allow concatenated calls.

Definition at line 76 of file substring.inl.


The documentation for this class was generated from the following files: