8#ifndef HPP_ALIB_STRINGS_CSTRING
9#define HPP_ALIB_STRINGS_CSTRING 1
16 #pragma warning( push )
17 #pragma warning( disable : 4127 )
20namespace alib {
namespace strings {
34template<
typename TChar>
35class TCString :
public TString<TChar>
67 :
base( pBuffer, contentLength )
73 "Error: Explicit construction of CString with unterminated string." )
101 template <
typename TZTCharArray>
121 template<
typename TZTCharArray>
123 operator TZTCharArray ()
const
140 template<
typename TZTCharArray>
142 operator TZTCharArray ()
const
156 template <
typename T,
167 "Error: Implicit construction of CString with unterminated string." )
181 "Error: Implicit construction of CString with unterminated string." )
196 "Error: Explicit construction of CString with unterminated string." )
211 "Error: Explicit construction of CString with unterminated string." )
220 :
base( characters::T_ZTCharArray<
ATMP_RCV(T),TChar>::
Buffer( const_cast<T&>( src ) ),
221 characters::T_ZTCharArray<
ATMP_RCV(T),TChar>::
Length( const_cast<T&>( src ) ) )
226 "Error: Construction of CString (from mutable object) with unterminated string." )
241 "Error: Construction of CString (from mutable object) with unterminated string." )
266 && characters::T_ZTCharArray<T,TChar>::Construction
276 && characters::T_ZTCharArray<T,TChar>::Construction
300 template<
typename TAllocator,
typename TEnableIf=
typename TAllocator::ChainedAllocator>
309 auto* newBuf= allocator().template AllocArray<TChar>( copy.
Length() + 1);
332 "Index out of bounds" )
375 typename TCheck=
CHK >
381 if ( startIdx < 0 ) startIdx= 0;
388 && needles.Length() != 0,
"STRINGS",
389 "Non checking and illegal parameters" )
397 return idx >= 0 ? idx + startIdx : -1;
403 return idx < 0 || *( haystack + idx ) ==
'\0' ? -1 : startIdx + idx;
422 template<
typename TAllocator>
431 auto* newBuf= allocator().template AllocArray<TChar>(
base::length + 1);
451 template<
typename TAllocator>
452 void Free( TAllocator& allocator )
const
529template<>
struct TT_CStringConstants<
wchar>
542template<>
struct TT_CStringConstants<
xchar>
621 #pragma warning( pop )
integer IndexOfAny(const TCString &needles, integer startIdx=0) const
constexpr TCString()
Default constructor creating a 6.1 Nulled Strings "nulled" c-string.
void Allocate(TAllocator &allocator, const TString< TChar > ©)
TCString(TAllocator &allocator, const TString< TChar > ©)
void Free(TAllocator &allocator) const
constexpr TCString(const TChar *pBuffer, integer contentLength)
TChar operator[](integer op) const
TString< TChar > base
Shortcut to the base type.
constexpr TCString(const TTerminatable &src)
constexpr bool IsNull() const
constexpr integer Length() const
integer CopyTo(TChar *dest) const
constexpr const TChar * Buffer() const
#define ALIB_WARNINGS_RESTORE
#define ALIB_ASSERT_ERROR(cond,...)
#define ALIB_WARNINGS_ALLOW_UNSAFE_BUFFER_USAGE
#define ATMP_SELECT_IF_1TP(TParam, ...)
integer IndexOfAnyIncludedZT(const TChar *haystack, const TChar *needles)
integer IndexOfAnyExcludedZT(const TChar *haystack, const TChar *needles)
@ ExplicitOnly
Allows explicit construction of objects from character array data.
@ Implicit
Allows implicit (and explicit) construction of objects from character array data.
@ ExplicitOnly
Allows explicit access of the character array data from mutable or constant objects.
@ MutableOnly
Allows explicit access of the character array data from mutable objects.
Inclusion
Denotes how members of a set something should be taken into account.
@ Include
Chooses inclusion.
constexpr WCString WDEFAULT_WHITESPACES
A zero-terminated string of default whitespace characters.
constexpr StrangeCString STRANGE_DEFAULT_WHITESPACES
A zero-terminated string of default whitespace characters.
constexpr CString DEFAULT_WHITESPACES
A zero-terminated string of default whitespace characters.
constexpr NCString EMPTY_NCSTRING
A zero-terminated, empty string.
characters::wchar wchar
Type alias in namespace alib.
constexpr NCString NNEW_LINE
A zero-terminated string containing the new-line character sequence.
constexpr NCString NDEFAULT_WHITESPACES
A zero-terminated string of default whitespace characters.
constexpr XCString EMPTY_XCSTRING
A zero-terminated, empty string.
constexpr WCString EMPTY_WCSTRING
A zero-terminated, empty string.
constexpr WCString WNEW_LINE
A zero-terminated string containing the new-line character sequence.
characters::xchar xchar
Type alias in namespace alib.
constexpr ComplementCString COMPLEMENT_NEW_LINE
A zero-terminated string containing the new-line character sequence.
constexpr ComplementCString COMPLEMENT_DEFAULT_WHITESPACES
A zero-terminated string of default whitespace characters.
constexpr ComplementCString EMPTY_COMPLEMENT_CSTRING
A zero-terminated, empty string.
constexpr StrangeCString EMPTY_STRANGE_CSTRING
A zero-terminated, empty string.
constexpr CString EMPTY_CSTRING
A zero-terminated, empty string.
constexpr CString NEW_LINE
A zero-terminated string containing the new-line character sequence.
strings::TCString< nchar > NCString
Type alias in namespace alib.
characters::nchar nchar
Type alias in namespace alib.
constexpr XCString XDEFAULT_WHITESPACES
A zero-terminated string of default whitespace characters.
constexpr StrangeCString STRANGE_NEW_LINE
A zero-terminated string containing the new-line character sequence.
strings::TCString< xchar > XCString
Type alias in namespace alib.
lang::integer integer
Type alias in namespace alib.
strings::TCString< wchar > WCString
Type alias in namespace alib.
constexpr XCString XNEW_LINE
A zero-terminated string containing the new-line character sequence.
static constexpr ConstructionType Construction
static TString Construct(const TChar *array, integer length)
static TString Construct(const TChar *array, integer length)
static constexpr CString< TChar > NewLine
static constexpr CString< TChar > DefaultWhitespaces())
"carriage return" and "tabulator", hence " \n\r\t".
static constexpr CString< TChar > EmptyString()