ALib C++ Library
Library Version: 2402 R1
Documentation generated by doxygen
Loading...
Searching...
No Matches
TCString< TChar > Class Template Reference

Description:

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

This class specializes its base class String in that respect that the character strings represented are guaranteed to be zero-terminated.
Zero-terminated strings are widely used by programming language C and are often called "C-strings", what gave the class its name.

See also
For an introduction into the ALib string classes see this module's Programmer's Manual.
Template Parameters
TCharThe character type.
Alias names for specializations of this class using character types character , nchar , wchar , xchar , complementChar and strangeChar are provided in namespace alib with type definitions CString , NCString , WCString , XCString , ComplementCString and StrangeCString .

Definition at line 36 of file strings/fwds.hpp.

#include <cstring.hpp>

Inheritance diagram for TCString< TChar >:
[legend]
Collaboration diagram for TCString< TChar >:
[legend]

Public Method Index:

constexpr TCString ()
 
constexpr TCString (const TChar *pBuffer, integer contentLength)
 
template<typename TZTCharArray >
constexpr TCString (const TTerminatable &src)
 
template<lang::Inclusion TInclusion, bool TCheck = true>
integer IndexOfAny (const TCString &needles, integer startIdx=0) const
 
template<typename TZTCharArray >
 operator TZTCharArray () const
 
template<typename TZTCharArray >
 operator TZTCharArray () const
 
TChar operator[] (integer op) const
 
- Public Method Index: inherited from TString< TChar >
constexpr TString () noexcept=default
 
constexpr TString (const TString &) noexcept=default
 
constexpr TString (TString &&) noexcept=default
 
TStringoperator= (const TString &) noexcept=default
 
TStringoperator= (TString &&) noexcept=default
 
constexpr TString (const TChar *pBuffer, integer pLength) noexcept
 
template<typename TCharArray >
constexpr TString (const TCharArray &src)
 
template<typename TCharArray >
 operator TCharArray () const
 
template<typename TCharArray >
 operator TCharArray () const
 
template<bool TCheck = true>
TString< TChar > Substring (integer regionStart, integer regionLength=MAX_LEN) const
 
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<bool TCheck = true>
TChar CharAt (integer idx) const
 
template<bool TCheck = true>
TChar CharAtStart () const
 
template<bool TCheck = true>
TChar CharAtEnd () const
 
TChar operator[] (integer idx) const
 
std::size_t Hashcode () const
 
std::size_t HashcodeIgnoreCase () const
 
template<bool TCheck = true, lang::Case TSensitivity = lang::Case::Sensitive>
bool Equals (const TString< TChar > &rhs) const
 
template<bool TCheck = true, lang::Case TSensitivity = lang::Case::Sensitive>
int CompareTo (const TString< TChar > &rhs) const
 
template<bool TCheck = true, lang::Case TSensitivity = lang::Case::Sensitive>
int CompareTo (const TString &rhs, integer rhsRegionStart, integer rhsRegionLength=MAX_LEN) const
 
template<bool TCheck = true, lang::Case TSensitivity = lang::Case::Sensitive>
int CompareTo (const TString &rhs, integer rhsRegionStart, integer rhsRegionLength, integer regionStart, integer regionLength=MAX_LEN) const
 
template<bool TCheck = true, lang::Case TSensitivity = lang::Case::Sensitive>
bool ContainsAt (const TString &needle, integer pos) const
 
template<bool TCheck = true, lang::Case TSensitivity = lang::Case::Sensitive>
bool StartsWith (const TString &needle) const
 
template<bool TCheck = true, lang::Case TSensitivity = lang::Case::Sensitive>
bool EndsWith (const TString &needle) const
 
template<bool TCheck = true>
integer IndexOf (TChar needle, integer startIdx=0) const
 
template<bool TCheck = true>
integer IndexOf (TChar needle, integer regionStart, integer regionLength) const
 
integer IndexOfOrLength (TChar needle) const
 
template<bool TCheck = true>
ALIB_WARNINGS_ALLOW_UNSAFE_BUFFER_USAGE integer IndexOfOrLength (TChar needle, integer startIdx) const
 
template<bool TCheck = true>
ALIB_WARNINGS_RESTORE integer LastIndexOf (TChar needle, integer startIndex=MAX_LEN) const
 
template<lang::Inclusion TInclusion, bool TCheck = true>
integer IndexOfAny (const TString &needles, integer startIdx=0) const
 
template<lang::Inclusion TInclusion, bool TCheck = true>
integer LastIndexOfAny (const TString &needles, integer startIdx=MAX_LEN) const
 
template<bool TCheck = true, lang::Case TSensitivity = lang::Case::Sensitive>
integer IndexOf (const TString &needle, integer startIdx=0) const
 
template<bool TCheck = true>
integer IndexOfFirstDifference (const TString &needle, lang::Case sensitivity=lang::Case::Sensitive, integer idx=0) const
 
integer IndexOfSegmentEnd (TChar opener, TChar closer, integer idx) const
 
template<bool TCheck = true>
integer CountChar (TChar needle, integer startPos=0) const
 
template<bool TCheck = true>
integer CountChar (TChar needle, TChar omit, integer startPos) const
 
template<bool TCheck = true, lang::Case TSensitivity = lang::Case::Sensitive>
integer Count (const TString &needle, integer startPos=0) const
 
template<bool TCheck = true, lang::Case TSensitivity = lang::Case::Sensitive>
integer Count (const TString &needle, const TString &omit, integer startPos=0) const
 
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
 
integer CopyTo (TChar *dest) const
 
bool AdjustRegion (integer &regionStart, integer &regionLength) const
 
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
 
 TString (ConstIterator &start, ConstIterator &end)
 

Additional Inherited Members

- Public Type Index: inherited from TString< TChar >
using CharType = TChar
 
using ConstIterator = TRandomAccessIterator<const TChar>
 
using ConstReverseIterator = std::reverse_iterator<ConstIterator>
 

Constructor(s) / Destructor Details::

◆ TCString() [1/3]

template<typename TChar >
constexpr TCString ( )
inlineconstexpr

Default constructor creating a 6.1 Nulled Strings "nulled" c-string.

Definition at line 51 of file cstring.hpp.

◆ TCString() [2/3]

template<typename TChar >
constexpr TCString ( const TChar * pBuffer,
integer contentLength )
inlineexplicitconstexpr

Constructor accepting a pointer to a character array and a string length.

Note
It is a user's responsibility to ensure that the character array provided includes a terminating '\0' character.
In debug-compilations a run-time assertion is raised if the provided buffer is not zero-terminated.
Parameters
pBufferThe buffer to use.
contentLengthThe length of the content in the given buffer.

Definition at line 70 of file cstring.hpp.

◆ TCString() [3/3]

template<typename TChar >
template<typename TZTCharArray >
constexpr TCString ( const TTerminatable & src)
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.

In debug-compilations a run-time assertion is raised if the provided buffer is not zero-terminated.

See also
More information about construction of this type is provided with chapter 3.1.2 CString Construction of the Programmer's Manual of module ALib Strings .
Template Parameters
TZTCharArrayType that comprises a zero-terminated character array.
Parameters
srcThe source object.

Method Details:

◆ IndexOfAny()

template<typename TChar >
template<lang::Inclusion TInclusion, bool TCheck = true>
integer IndexOfAny ( const TCString< TChar > & needles,
integer startIdx = 0 ) const
inline

Returns the index of the first character which is included, respectively not included in a given set of characters.

This method searches forwards. For backwards search, see String::LastIndexOfAny .

Note
This method overrides method String::IndexOf . This implementation however expects a CString with parameter needles (beside the fact that it has to be invoked on a CString itself). If no zero-terminated needle string is available, the parent's original method needs to be invoked. This has to be done by explicitly naming the parent class in the invocation, like for example in
   myCString.TString::IndexOfAny<Inclusion::Include>( myString );
On most platforms, this zero-terminated version should perform slightly faster than the original method in class String.
Template Parameters
TCheckDefaults to true which is the normal invocation mode. If <false> is added to the method name, no parameter checks are performed and the needles must not be empty.
TInclusionDenotes 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.
Parameters
needlesSet of characters to be taken into account.
startIdxThe 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.
Returns
The index of the first character found which is included, respectively not included, in the given set of characters. If nothing is found, -1 is returned.

Definition at line 346 of file cstring.hpp.

Here is the call graph for this function:

◆ operator TZTCharArray() [1/2]

template<typename TChar >
template<typename TZTCharArray >
operator TZTCharArray ( ) const
inline

Implicit cast operator to objects of type TZTCharArray .
This operator is available for all custom types that have an accordingly specialized version of TMP struct T_CharArray and/or T_ZTCharArray defined.

See also
More information about casting ALib string types to built-in C++ types or custom types is provided with chapter 3.2.2 Casting From CString of the Programmer's Manual of module ALib Strings .
Template Parameters
TZTCharArrayThe custom type to implicitly convert this object to.
Returns
A value of custom string type.

Definition at line 127 of file cstring.hpp.

◆ operator TZTCharArray() [2/2]

template<typename TChar >
template<typename TZTCharArray >
operator TZTCharArray ( ) const
inlineexplicit

Explicit cast operator to objects of type TZTCharArray .
This operator is available for all custom types that have an accordingly specialized version of TMP struct T_CharArray and/or T_ZTCharArray defined.

See also
More information about casting ALib string types to built-in C++ types or custom types is provided with chapter 3.2.2 Casting From CString of the Programmer's Manual of module ALib Strings .
Template Parameters
TZTCharArrayThe custom type to explicitly convert this object to.
Returns
A value of custom string type.

Definition at line 146 of file cstring.hpp.

◆ operator[]()

template<typename TChar >
TChar operator[] ( integer op) const
inline

Reads a character at a given index.
Overrides String::operator[] to change the debug assertion to allow inclusion of the termination character.

Attention
No parameter check is performed (other than an assertions in debug-compilation of ALib ). See String::operator[] for details.
Parameters
opThe index of the character within this object's buffer.
Returns
If the character contained at index op .

Definition at line 299 of file cstring.hpp.


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