This class is the base class of all ALib string classes. Objects of this type represent character strings whose data is allocated outside their scope. In particular, the class does not allocate a character array buffer to store and manipulate string data.
Once constructed, objects of this class are immutable, except for the possibility to assign a complete new object value. This means there is no interface to change the single two data members buffer and length. The immutable nature of this type is lifted by derived types. While class Substring allows changing the start and length of the string represented, class AString holds a copy of the data and consequently allows modifying the string stored.
TChar | The character type of this string. Alias names for specializations along the different character types are provided in namespace alib with type definitions String, NString, WString, XString, ComplementString, and StrangeString. |
Definition at line 62 of file string.hpp.
#include <string.hpp>
Inner Type Index: | |
class | TRandomAccessIterator |
Public Type Index: | |
using | CharType = TChar |
Expose template parameter TChar to the outer world. | |
Public Method Index: | |
constexpr | TString () noexcept=default |
Defaulted default constructor. | |
constexpr | TString (const TChar *pBuffer, integer pLength) noexcept |
template<typename TCharArray > | |
constexpr | TString (const TCharArray &src) |
constexpr | TString (const TString &) noexcept=default |
Defaulted copy constructor. | |
TString (ConstIterator &start, ConstIterator &end) | |
template<typename TAllocator , typename TEnableIf = typename TAllocator::ChainedAllocator> | |
TString (TAllocator &allocator, const TString< TChar > ©) | |
constexpr | TString (TString &&) noexcept=default |
Defaulted move constructor. | |
template<typename TCharArray > | |
operator TCharArray () const | |
template<typename TCharArray > | |
operator TCharArray () const | |
TString & | operator= (const TString &) noexcept=default |
TString & | operator= (TString &&) noexcept=default |
Buffer Access, Length and State | |
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 |
Character Access | |
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 |
Hashing | |
std::size_t | Hashcode () const |
std::size_t | HashcodeIgnoreCase () const |
Comparison Methods | |
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 |
Search | |
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> | |
ALIB_WARNINGS_ALLOW_UNSAFE_BUFFER_USAGE integer | IndexOfOrLength (TChar needle, integer startIdx) const |
template<typename TCheck = CHK> | |
ALIB_WARNINGS_RESTORE 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 |
Parsing Numbers | |
ALIB_API uint64_t | ParseDecDigits (integer startIdx=0, integer *newIdx=nullptr) const |
ALIB_API 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_API 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_API 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_API 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_API 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_API 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 |
Conversion | |
integer | CopyTo (TChar *dest) const |
template<typename TAllocator > | |
void | Allocate (TAllocator &allocator, const TString< TChar > ©) |
template<typename TAllocator > | |
void | Free (TAllocator &allocator) |
std::iterator_traits | |
ConstIterator | begin () const |
ConstIterator | cbegin () const |
ALIB_WARNINGS_ALLOW_UNSAFE_BUFFER_USAGE ConstIterator | end () const |
ConstIterator | cend () const |
ALIB_WARNINGS_RESTORE ConstReverseIterator | rbegin () const |
ConstReverseIterator | rend () const |
ConstReverseIterator | crbegin () const |
ConstReverseIterator | crend () const |
Protected Field Index: | |
const TChar * | buffer |
integer | length |
Protected Method Index: | |
template<lang::Case TSensitivity = lang::Case::Sensitive> | |
ALIB_API integer | indexOfString (const TString &needle, integer startIdx, integer endIdx) const |
using CharType = TChar |
Expose template parameter TChar to the outer world.
Definition at line 67 of file string.hpp.
using ConstIterator = TRandomAccessIterator<const TChar> |
The constant iterator exposed by this character container. A Mutable version is found only in descendant classes (e.g., AString).
Definition at line 2292 of file string.hpp.
using ConstReverseIterator = std::reverse_iterator<ConstIterator> |
The constant reverse iterator exposed by this character container. A Mutable version is found only in descendant classes (e.g., AString).
Definition at line 2296 of file string.hpp.
|
protected |
Pointer to an array of constant character values. This array holds the string that an instance of this type is representing.
Read access to this field is granted with method Buffer.
For technical reasons, this documentation unfortunaltely omits the important fact that this field is part of an anonymous union declared like this:
union { const TChar* buffer; TChar* vbuffer; };
Hence, the field can also be interpreted as a pointer to an array of non-constant character values. Derived classes might use the sibling version vbuffer to modify the contents of the string if it is assured that such memory is writable. This is for example done extensively by the implementation of class AString.
Definition at line 117 of file string.hpp.
|
protected |
The length of the character string represented. Read access to this field is granted with method Length.
Definition at line 123 of file string.hpp.
|
inlineconstexprnoexcept |
Constructor accepting a pointer to a character array and a string length.
pBuffer | Pointer to the start of the character string to represent. |
pLength | The length of the character string to represent. |
Definition at line 155 of file string.hpp.
|
inlineconstexpr |
This templated constructor accepts various different kinds of source data. Unlike this documentation suggests, this constructor is internally implemented by a series of different constructors which are selected using template meta programming (i.e., std::enable_if
).
Together, the set of constructors provide maximum flexibility by allowing implicit construction with (and assignment of) any built-in or third-party character array type. Some of the constructors are defined using keyword explict
.
TCharArray | Type that comprises a character array. |
src | The source object. |
TString | ( | TAllocator & | allocator, |
const TString< TChar > & | copy ) |
Allocates memory and copies the given string's contents.
TAllocator | The type of the given allocator, as prototyped with Allocator. Deduced by the compiler. |
allocator | The allocator to use. |
copy | The string to copy to the new memory allocated. |
|
inline |
Constructs this string using start and end iterators.
start | An iterator referencing the start of the string. |
end | An iterator referencing the end of the string. |
Definition at line 2347 of file string.hpp.
|
inline |
Adjusts a region given as in/out parameters, to fit to this object's range [0..length].
[in,out] | regionStart | The proposed region start which might get adjusted to fit to range [0..length]. |
[in,out] | regionLength | The proposed region length which might get adjusted to fit to range [0..length]. |
true
, if the adjusted region is empty. Definition at line 2061 of file string.hpp.
|
inline |
Sets this String to a copy of the given string, allocated in given allocator.
TAllocator | The type of the given allocator, as prototyped with Allocator. Deduced by the compiler. |
allocator | The allocator to use. |
copy | The string to copy to the new memory allocated. |
Definition at line 2012 of file string.hpp.
|
inline |
Returns an iterator pointing to a constant character at the start of this string.
Definition at line 2305 of file string.hpp.
|
inlineconstexpr |
Returns a pointer to the first character of the string we are representing.
Definition at line 319 of file string.hpp.
|
inline |
Returns an iterator pointing to a constant character at the start of this string.
Definition at line 2309 of file string.hpp.
|
inline |
Returns an iterator pointing behind this string.
Definition at line 2318 of file string.hpp.
Retrieves the character at the given index. A range check is performed. If this fails, '\0'
is returned.
TCheck | Defaults to CHK, which is the normal invocation mode. If false is given, no range check is performed. |
idx | The index of the character to read. |
Definition at line 444 of file string.hpp.
|
inline |
Retrieves the last character. In case of an empty string, '\0' is returned.
TCheck | Defaults to CHK, which is the normal invocation mode. If false is given, no check for an empty or nulled object is performed. |
Definition at line 488 of file string.hpp.
|
inline |
Retrieves the first character. In case of an empty or nulled string, '\0' is returned.
TCheck | Defaults to CHK, which is the normal invocation mode. If false is given, no check for an empty string object is performed. |
Definition at line 466 of file string.hpp.
|
inline |
Compares a region of this object with a region of another string-like object.
TCheck | Defaults to CHK, which is the normal invocation mode. If false is given, no check for a nulled comparison object is performed and this string must not be empty. Furthermore, no check is performed whether the given regions fit to this object respectively the other region to the object given with parameter rhs. This also means that the default value of regionLength must not be used in this case. |
TSensitivity | Determines if comparison is case-sensitive (the default) or not. |
rhs | The string to compare this string with. |
rhsRegionStart | The start of the region in rhs to compare this object with. |
rhsRegionLength | The length of the region in rhs to compare this object with. |
regionStart | The start of the region in this object to compare with |
regionLength | The length of the region in this object to compare with. Defaults to MAX_LEN. |
Definition at line 731 of file string.hpp.
|
inline |
Compares this string with a region of another string-like object.
TCheck | Defaults to CHK, which is the normal invocation mode. If false is given, no check for a nulled comparison object is performed and this string must not be empty. Furthermore, no check is performed whether the given region fits to parameter rhs. This also means that the default value must not be used with TCheck==NC. |
TSensitivity | Determines if comparison is case-sensitive (the default) or not. |
rhs | The string to compare this string with. |
rhsRegionStart | The start of the region in rhs to compare this object with. |
rhsRegionLength | The length of the region in rhs to compare this object with. Defaults to MAX_LEN. |
Definition at line 681 of file string.hpp.
|
inline |
Compares this string with a string-like object.
TCheck | Defaults to CHK, which is the normal invocation mode. If false is given, no check for a nulled object (this) is performed and this string must not be of zero length (while rhs might be of zero length). |
TSensitivity | Determines if comparison is case-sensitive (the default) or not. |
rhs | The object to compare. |
Definition at line 631 of file string.hpp.
|
inline |
Returns true
, if the contents of the given string-like object is found at the given position.
false
is returned. (This check only done if TCheck equals CHK.)true
is returned.TCheck | Defaults to CHK, which is the normal invocation mode. If <false> is given, no check on parameter pos is performed and needle must not be nulled. |
TSensitivity | Determines if comparison is case-sensitive (the default) or not. |
needle | The string to compare with. If it is empty, true is returned. |
pos | The position to search for needle. |
true
if needle is found at the given position. False otherwise. Definition at line 777 of file string.hpp.
|
inline |
Copies this string's contents into a given character buffer. It is the caller's responsibility that dest is large enough, write-enabled, etc.
dest | The destination buffer. |
Definition at line 1992 of file string.hpp.
|
inline |
Counts all occurrences of needle, unless followed by omit, starting at startPos to the end of the string.
For empty strings needle, 0
is returned. Also, for empty strings omit, 0
is returned.
TSensitivity | Case sensitivity of the comparison. Optional and defaults to Case::Sensitive. |
TCheck | Defaults to CHK, which is the normal invocation mode. If false is given, parameter startPos must be valid and needle must not be empty. |
needle | The string to search for. |
omit | Omit occurrence if the given string follows. |
startPos | The index to start the counting. Optional and defaults to 0 . |
Definition at line 1430 of file string.hpp.
|
inline |
Counts all occurrences of needle from startPos to the end of the string.
For empty strings needle, 0
is returned.
TCheck | Defaults to CHK, which is the normal invocation mode. If false is given, parameter startIdx must be valid and needle must not be empty. |
TSensitivity | Case sensitivity of the comparison. Optional and defaults to Case::Sensitive. |
needle | The string to search for. |
startPos | The index to start the counting. Optional and defaults to 0 . |
Definition at line 1381 of file string.hpp.
|
inline |
Counts all occurrences of character needle in the range from startPos to the end of the string.
For empty strings needle, 0
is returned.
TCheck | Defaults to CHK, which is the normal invocation mode. If false is given, no range check is performed. |
needle | The character to search for. |
startPos | The index to start the counting. Optional and defaults to 0 . |
Definition at line 1288 of file string.hpp.
|
inline |
Counts all occurrences of character needle, unless followed by character omit in the range from startPos to the end of the string.
For empty strings needle, 0
is returned. Also, for empty strings omit, 0
is returned.
TCheck | Defaults to CHK, which is the normal invocation mode. If false is given, no range check is performed. |
needle | The character to search for. |
omit | Omit occurrence if the given character follows. |
startPos | The index to start the counting. |
Definition at line 1331 of file string.hpp.
|
inline |
Returns a reverse iterator pointing to a constant character at the end of this string.
Definition at line 2331 of file string.hpp.
|
inline |
Returns a reverse iterator pointing before the start of this string.
Definition at line 2335 of file string.hpp.
|
inline |
Returns an iterator pointing behind this string.
Definition at line 2314 of file string.hpp.
|
inline |
Returns true
, if this string ends with the string found in parameter needle. If needle is empty, true
is returned.
TSensitivity | Determines if comparison is case-sensitive (the default) or not. |
needle | The string to compare the end of this string with. If nulled or empty, true is returned. |
true
if needle is found at the end of this, false
otherwise. Definition at line 854 of file string.hpp.
|
inline |
Compares this string with a string-like object.
true
is returned if this and the compared string are nulled or empty. If only one is nulled or empty, false
is returned.
TCheck | Defaults to CHK, which is the normal invocation mode. If false is given, no check for a nulled is performed on this string as well as on rhs. |
TSensitivity | Determines if comparison is case-sensitive (the default) or not. |
rhs | The object to compare. |
true
, if contents of this string and the string representation of the given rhs are equal. Definition at line 580 of file string.hpp.
|
inline |
Deallocates this String's memory in allocator and sets this instance to nulled.
TAllocator | The type of the given allocator, as prototyped with Allocator. Deduced by the compiler. |
allocator | The allocator to use. |
Definition at line 2040 of file string.hpp.
std::size_t Hashcode | ( | ) | const |
Computes a hash number for the contained string.
std::hash<std::string_view<TChar>>
. Otherwise a compatible hash function is used. std::size_t HashcodeIgnoreCase | ( | ) | const |
Computes a hash number for the contained string converted to upper case letters.
|
inline |
Searches the given string-like object in this string.
If needle is empty, the adjusted value of startIdx is returned.
TSensitivity | Case sensitivity of the comparison. Optional and defaults to Case::Sensitive. |
TCheck | Defaults to CHK, which is the normal invocation mode. If false is given, parameter needle must not be empty and startIdx must be in the range of [0 ... Length() - needle.Length()]. This also implies that this string must not be empty. |
needle | The string to search for. |
startIdx | The index to start the search at. Optional and defaults to 0 . |
endIdx | The index where the search ends. Precisely, the index of the first character that is not found. Defaults to MAX_LEN. |
-1
is returned. Otherwise the index of the first occurrence of needle. Definition at line 1179 of file string.hpp.
|
inline |
Searches a character within a region of this.
TCheck | Defaults to CHK, which is the normal invocation mode. If false is given, no range check is performed. |
needle | The character to search for. |
regionStart | The start of the region to search the character in. |
regionLength | The length of the region to search the character in. |
-1
if the character needle is not found. Otherwise the index of its first occurrence. Definition at line 934 of file string.hpp.
|
inline |
Searches a character starting from a given position.
TCheck | Defaults to CHK, which is the normal invocation mode. If false is given, no range check is performed. |
needle | The character to search for. |
startIdx | The index in this to start searching the character. Defaults to 0 . |
-1
if the character needle is not found. Otherwise the index of its first occurrence. Definition at line 896 of file string.hpp.
|
inline |
Returns the index of the first character which is included, respectively not included in a set of characters given as a string-like object.
std::strpbrk()
respectively std::strspn()
) is available. So, if performance is important and repetitive calls are performed, it might be advisable to hold this string and the needles in a zero-terminated string buffer, for example in an AString.This method searches forwards. For backwards search, see LastIndexOf.
TInclusion | Denotes whether the search returns the first index that holds a value that is included or that is not excluded in the set of needle characters. |
TCheck | Defaults to CHK, which is the normal invocation mode. If <false> is given, no parameter checks are performed. |
needles | Pointer to a zero-terminated set of characters to be taken into account. |
startIdx | The index to start the search at. If the given value is less than 0, it is set to 0. If it exceeds the length of the string, the length of the string is returned. Defaults to 0. |
Definition at line 1090 of file string.hpp.
|
inline |
Searches the first difference of a substring of this string and a string-like object given with parameter needle. If no difference is found, then the index of the first character behind the substring is returned.
TCheck | Defaults to CHK, which is the normal invocation mode. If false is given, no range check is performed. |
needle | The substring to search for. |
sensitivity | Letter case sensitivity of the comparison. Optional and defaults to Case::Sensitive. |
startIdx | The index in this string to start the comparison with needle. Optional and defaults to 0 . |
Definition at line 1225 of file string.hpp.
|
inline |
Like IndexOf but in case the character is not found, this method returns the length of this string instead of -1
. Depending on the invocation context, the choice for the right version of this method may lead to shorter and more efficient code.
needle | The character to search for. |
Definition at line 972 of file string.hpp.
|
inline |
Like IndexOf but in case the character is not found, this method returns the length of this string instead of -1
. Depending on the invocation context, the choice for the right version of this method may lead to shorter and more efficient code.
TCheck | Defaults to CHK, which is the normal invocation mode. If false is given, no range check is performed. |
needle | The character to search for. |
startIdx | The index in this to start searching the character. |
Definition at line 996 of file string.hpp.
integer IndexOfSegmentEnd | ( | TChar | opener, |
TChar | closer, | ||
integer | idx ) const |
The method searches the next matching closer-character while taking nested pairs of opener and closer characters into account.
Before the invocation of this method, the initial opener has to be known already and the given idx has to point to the first character behind the opener, where the search for an according closer is to be started.
This method is useful to scan a string for pairs of opening and closing brackets, while the found segment may contain nested pairs of the same brackets.
opener | The character that represents the opening bracket, e.g., '{' . |
closer | The character that represents the closing bracket, e.g., '}' . |
idx | Index pointing to first character behind the (first) opener. |
|
protected |
Implementation of the substring search function.
1
. TSensitivity | The letter case sensitivity of the search. |
needle | The substring to search. |
startIdx | The start index of the search. |
endIdx | The index where the search ends. Precisely, the index of the first character that is not found. |
-1
if not found.
|
inlineconstexpr |
Returns true
if this string is of zero length. Note that a nulled string is also considered empty.
true
if the actual length equals zero. Definition at line 383 of file string.hpp.
|
inlineconstexpr |
Returns true
if this string has a length of 1
or more.
true
if the actual length does not equal zero. Definition at line 389 of file string.hpp.
|
inlineconstexpr |
Returns true
if field buffer does not equal nullptr
, false
otherwise.
Definition at line 371 of file string.hpp.
|
inlineconstexpr |
Returns true
if field buffer equals nullptr
, false
otherwise. Note that a nulled string is also considered empty.
true
if no buffer is allocated. Definition at line 364 of file string.hpp.
|
inline |
Searches a character starting backwards from the end or a given start index.
TCheck | Defaults to CHK, which is the normal invocation mode. If false is given, no range check is performed. Consequently, in this case, optional parameter startIndex must be provided. |
needle | The character to search for. |
startIndex | The index within this string to start searching the character. Defaults to MAX_LEN. |
-1
if the character needle is not found. Otherwise, the index of its last occurrence. Definition at line 1034 of file string.hpp.
|
inline |
Returns the index of the last character which is included, respectively not included in set of characters given as a string-like object.
This method searches backwards starting at the given index. For forwards search, see IndexOfAny.
TInclusion | Denotes whether the search returns the first index that holds a value that is included or that is not excluded in the set of needle characters. |
TCheck | Defaults to CHK, which is the normal invocation mode. If <false> is given, no parameter checks are performed. |
needles | Pointer to a zero-terminated set of characters to be searched for. |
startIdx | The index to start the search at. The value is cropped to be in the bounds of 0 and the length of this object minus one. Defaults to MAX_LEN. |
Definition at line 1137 of file string.hpp.
|
inlineconstexpr |
Returns the length of the string that this object represents.
Definition at line 326 of file string.hpp.
|
inline |
Implicit cast operator to objects of templated type TCharArray.
This operator is available for all custom types that have an accordingly specialized version of TMP struct T_CharArray defined.
TCharArray | The custom type to implicitly convert this object to. |
Definition at line 199 of file string.hpp.
|
inlineexplicit |
Explicit cast operator to objects of templated type TCharArray.
This operator is available for all custom types that have an accordingly specialized version of TMP struct T_CharArray defined.
TCharArray | The custom type to explicitly convert this object to. |
Definition at line 217 of file string.hpp.
Defaulted copy assignment operator.
this
instance. Defaulted move assignment operator.
this
instance.
|
inline |
Reads a character at a given index.
const
) version of this operator, returning a a reference to the character to provide write access. Such reference to a character could not be given if the index was out of range. This way, a check in the derived type could likewise not be implemented.false>
. For safe access to characters in the buffer use CharAt (with template parameter TCheck being CHK) which returns '\0'
in the case of that idx is out of bounds.idx | The index of the character within this object's buffer. |
Definition at line 525 of file string.hpp.
|
inline |
Overloaded version of ParseBin providing default values for omitted parameters.
[out] | newIdx | Optional output variable that will point to the first character in this string after the number parsed. On failure, it will be set to the initial value 0 . |
Definition at line 1712 of file string.hpp.
Overloaded version of ParseBin providing default values for omitted parameters.
startIdx | The start index for parsing. Optional and defaults to 0 . | |
[out] | newIdx | Optional output variable that will point to the first character in this string after the number parsed. On failure, it will be set to the initial value startIdx. |
Definition at line 1731 of file string.hpp.
ALIB_API uint64_t ParseBin | ( | integer | startIdx = 0, |
TNumberFormat< TChar > * | numberFormat = nullptr, | ||
integer * | newIdx = nullptr ) const |
Reads an unsigned 64-bit integer in binary format at the given position from this string.
Parameter numberFormat defaults to nullptr
. This denotes static singleton NumberFormat::Computational which is configured to not using - and therefore also not parsing - grouping characters.
Optional output parameter newIdx may be used to detect if parsing was successful. If not, it receives the value of startIdx, even if leading whitespaces had been read.
For more information on number conversion, see class NumberFormat. All number-parsing interface methods have a corresponding implementation within this class.
startIdx | The start index for parsing. Optional and defaults to 0 . | |
numberFormat | The format definition. Defaults to nullptr . | |
[out] | newIdx | Optional output variable that will point to the first character in this string after the number parsed. On failure, it will be set to the initial value startIdx. |
|
inline |
Overloaded version of ParseBin providing default values for omitted parameters.
numberFormat | The format definition. Defaults to nullptr . | |
[out] | newIdx | Optional output variable that will point to the first character in this string after the number parsed. On failure, it will be set to the initial value 0 . |
Definition at line 1696 of file string.hpp.
|
inline |
Overloaded version of ParseDec providing default values for omitted parameters.
[out] | newIdx | Optional output variable that will point to the first character in this string after the number parsed. On failure, it will be set to the initial value 0 . |
Definition at line 1630 of file string.hpp.
Overloaded version of ParseDec providing default values for omitted parameters.
startIdx | The start index for parsing. Optional and defaults to 0 . | |
[out] | newIdx | Optional output variable that will point to the first character in this string after the number parsed. On failure, it will be set to the initial value startIdx. |
Definition at line 1649 of file string.hpp.
ALIB_API uint64_t ParseDec | ( | integer | startIdx = 0, |
TNumberFormat< TChar > * | numberFormat = nullptr, | ||
integer * | newIdx = nullptr ) const |
Reads an unsigned 64-bit integer in standard decimal format at the given position from this AString.
Parameter numberFormat defaults to nullptr
. This denotes static singleton TNumberFormat::Computational which is configured to not using - and therefore also not parsing - grouping characters.
Optional output parameter newIdx may be used to detect if parsing was successful. If not, it receives the value of startIdx, even if leading whitespaces had been read.
Sign literals '-'
or '+'
are not accepted and parsing will fail. For reading signed integral values, see methods ParseInt, for floating point numbers ParseFloat.
For more information on number conversion, see class NumberFormat. All number-parsing interface methods have a corresponding implementation within this class.
startIdx | The start index for parsing. Optional and defaults to 0 . | |
numberFormat | The format definition. Defaults to nullptr . | |
[out] | newIdx | Optional output variable that will point to the first character in this string after the number parsed. On failure, it will be set to the initial value startIdx. |
|
inline |
Overloaded version of ParseDec providing default values for omitted parameters.
numberFormat | The format definition. Defaults to nullptr . | |
[out] | newIdx | Optional output variable that will point to the first character in this string after the number parsed. On failure, it will be set to the initial value 0 . |
Definition at line 1614 of file string.hpp.
ALIB_API uint64_t ParseDecDigits | ( | integer | startIdx = 0, |
integer * | newIdx = nullptr ) const |
Parses an integral value consisting of characters '0'
to '9'
from this string.
Unlike with ParseInt or ParseDec, no sign, whitespaces or group characters are accepted.
startIdx | The start index from where the integral value is tried to be parsed. Optional and defaults to 0 . | |
[out] | newIdx | Optional output variable that will point to the first character in this string after the float number that was parsed. If parsing fails, it will be set to the value of parameter startIdx. Therefore, this parameter can be used to check if a value was found. |
|
inline |
Overloaded version of ParseFloat providing default values for omitted parameters.
[out] | newIdx | Optional output variable that will point to the first character in this string after the number parsed. On failure, it will be set to the initial value 0 . |
Definition at line 1957 of file string.hpp.
Overloaded version of ParseFloat providing default values for omitted parameters.
startIdx | The start index for parsing. Optional and defaults to 0 . | |
[out] | newIdx | Optional output variable that will point to the first character in this string after the number parsed. On failure, it will be set to the initial value startIdx. |
Definition at line 1976 of file string.hpp.
ALIB_API double ParseFloat | ( | integer | startIdx = 0, |
TNumberFormat< TChar > * | numberFormat = nullptr, | ||
integer * | newIdx = nullptr ) const |
Reads a floating point number at the given position from this string.
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.
Optional output parameter newIdx may be used to detect if parsing was successful. If not, it receives the value of startIdx, even if leading whitespaces had been read.
For more information on number conversion, see class NumberFormat. All number-parsing interface methods have a corresponding implementation within this class.
startIdx | The start index for parsing. Optional and defaults to 0 . | |
numberFormat | The format definition. Defaults to nullptr . | |
[out] | newIdx | Optional output variable that will point to the first character in this string after the number parsed. On failure, it will be set to the initial value startIdx. |
|
inline |
Overloaded version of ParseFloat providing default values for omitted parameters.
numberFormat | The format definition. Defaults to nullptr . | |
[out] | newIdx | Optional output variable that will point to the first character in this string after the number parsed. On failure, it will be set to the initial value 0 . |
Definition at line 1941 of file string.hpp.
|
inline |
Overloaded version of ParseHex providing default values for omitted parameters.
[out] | newIdx | Optional output variable that will point to the first character in this string after the number parsed. On failure, it will be set to the initial value 0 . |
Definition at line 1794 of file string.hpp.
Overloaded version of ParseHex providing default values for omitted parameters.
startIdx | The start index for parsing. Optional and defaults to 0 . | |
[out] | newIdx | Optional output variable that will point to the first character in this string after the number parsed. On failure, it will be set to the initial value startIdx. |
Definition at line 1813 of file string.hpp.
ALIB_API uint64_t ParseHex | ( | integer | startIdx = 0, |
TNumberFormat< TChar > * | numberFormat = nullptr, | ||
integer * | newIdx = nullptr ) const |
Reads an unsigned 64-bit integer in hexadecimal format at the given position from this string.
Parameter numberFormat defaults to nullptr
. This denotes static singleton NumberFormat::Computational which is configured to not using - and therefore also not parsing - grouping characters.
Optional output parameter newIdx may be used to detect if parsing was successful. If not, it receives the value of startIdx, even if leading whitespaces had been read.
For more information on number conversion, see class NumberFormat. All number-parsing interface methods have a corresponding implementation within this class.
startIdx | The start index for parsing. Optional and defaults to 0 . | |
numberFormat | The format definition. Defaults to nullptr . | |
[out] | newIdx | Optional output variable that will point to the first character in this string after the number parsed. On failure, it will be set to the initial value startIdx. |
|
inline |
Overloaded version of ParseHex providing default values for omitted parameters.
numberFormat | The format definition. Defaults to nullptr . | |
[out] | newIdx | Optional output variable that will point to the first character in this string after the number parsed. On failure, it will be set to the initial value 0 . |
Definition at line 1778 of file string.hpp.
|
inline |
Overloaded version of ParseInt providing default values for omitted parameters.
[out] | newIdx | Optional output variable that will point to the first character in this string after the number parsed. On failure, it will be set to the initial value 0 . |
Definition at line 1545 of file string.hpp.
Overloaded version of ParseInt providing default values for omitted parameters.
startIdx | The start index for parsing. Optional and defaults to 0 . | |
[out] | newIdx | Optional output variable that will point to the first character in this string after the number parsed. On failure, it will be set to the initial value startIdx. |
Definition at line 1564 of file string.hpp.
ALIB_API int64_t ParseInt | ( | integer | startIdx = 0, |
TNumberFormat< TChar > * | numberFormat = nullptr, | ||
integer * | newIdx = nullptr ) const |
Parses 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 - and therefore also not parsing - grouping characters.
Optional output parameter newIdx may be used to detect if parsing was successful. If not, it receives the value of startIdx, even if leading whitespaces had been read.
For more information on number conversion, see class NumberFormat. All of its interface methods have a corresponding implementation within class AString.
startIdx | The start index for parsing. Optional and defaults to 0 . | |
numberFormat | The format definition. Defaults to nullptr . | |
[out] | newIdx | Optional output variable that will point to the first character in this string after the number parsed. On failure, it will be set to the initial value startIdx. |
|
inline |
Overloaded version of ParseInt providing default values for omitted parameters.
numberFormat | The format definition. Defaults to nullptr . | |
[out] | newIdx | Optional output variable that will point to the first character in this string after the number parsed. On failure, it will be set to the initial value 0 . |
Definition at line 1529 of file string.hpp.
|
inline |
Overloaded version of ParseOct providing default values for omitted parameters.
[out] | newIdx | Optional output variable that will point to the first character in this string after the number parsed. On failure, it will be set to the initial value 0 . |
Definition at line 1876 of file string.hpp.
Overloaded version of ParseOct providing default values for omitted parameters.
startIdx | The start index for parsing. Optional and defaults to 0 . | |
[out] | newIdx | Optional output variable that will point to the first character in this string after the number parsed. On failure, it will be set to the initial value startIdx. |
Definition at line 1895 of file string.hpp.
ALIB_API uint64_t ParseOct | ( | integer | startIdx = 0, |
TNumberFormat< TChar > * | numberFormat = nullptr, | ||
integer * | newIdx = nullptr ) const |
Reads an unsigned 64-bit integer in octal format at the given position from this string.
Parameter numberFormat defaults to nullptr
. This denotes static singleton NumberFormat::Computational which is configured to not using - and therefore also not parsing - grouping characters.
Optional output parameter newIdx may be used to detect if parsing was successful. If not, it receives the value of startIdx, even if leading whitespaces had been read.
For more information on number conversion, see class NumberFormat. All number-parsing interface methods have a corresponding implementation within this class.
startIdx | The start index for parsing. Optional and defaults to 0 . | |
numberFormat | The format definition. Defaults to nullptr . | |
[out] | newIdx | Optional output variable that will point to the first character in this string after the number parsed. On failure, it will be set to the initial value startIdx. |
|
inline |
Overloaded version of ParseOct providing default values for omitted parameters.
numberFormat | The format definition. Defaults to nullptr . | |
[out] | newIdx | Optional output variable that will point to the first character in this string after the number parsed. On failure, it will be set to the initial value 0 . |
Definition at line 1860 of file string.hpp.
|
inline |
Returns a reverse iterator pointing to a constant character at the end of this string.
Definition at line 2323 of file string.hpp.
|
inline |
Returns a reverse iterator pointing before the start of this string.
Definition at line 2327 of file string.hpp.
|
inline |
Returns true
, if this string starts with the contents of the string-like object given with parameter needle. In the special case that needle is empty, true
is returned.
TSensitivity | Determines if comparison is case-sensitive (the default) or not. |
TCheck | Defaults to CHK, which is the normal invocation mode. If <false> is given, the given needle must not be empty and must not be longer than this string! pos is performed and needle must not be nulled. |
needle | The string to compare the start of this string with. If nulled or empty, true is returned. |
true
if needle is found at the start of this string, false
otherwise. Definition at line 820 of file string.hpp.
|
inline |
Returns a new string object representing a substring of the string that this object represents.
TCheck | Defaults to CHK, which is the normal invocation mode. If false is given, no range check is performed. |
regionStart | The start of the substring within this string. |
regionLength | The length of the substring to return. Defaults to MAX_LEN. |
Definition at line 406 of file string.hpp.
integer WStringLength | ( | ) | const |
Returns the length of the string if represented as a wide character string. If template parameter TChar equals wchar
, then this is identical with Length. Otherwise the calculation is done using
If the conversion fails, -1
is returned.