10template<
typename TChar>
class TCString;
29template<
typename TChar>
51 :
base( pBuffer, contentLength ) {
55 "Error: Explicit construction of CString with unterminated string." )
80 #if ALIB_DEBUG && !ALIB_DEBUG_ASSERTION_PRINTABLES
83 "Error: Implicit construction of CString with unterminated string." )
106 "Error: Implicit construction of CString with unterminated string." )
121 template <
typename T>
129 "Error: Explicit construction of CString with unterminated string." )
145 template <
typename T>
153 "Error: Explicit construction of CString with unterminated string." )
169 template <
typename T>
173 characters::ZTArrayTraits<std::remove_cv_t<T>,TChar>::
Length(const_cast<T&>( src )) ) {
177 "Error: Construction of CString (from mutable object) with unterminated string." )
193 template <
typename T>
201 "Error: Construction of CString (from mutable object) with unterminated string." )
218 template<
typename TAllocator>
226 auto* newBuf= allocator().template AllocArray<TChar>( copy.
Length() + 1);
246 template<
typename T>
250 std::remove_cv_t<T> >::value )
251 constexpr operator T()
const
267 template<
typename T>
273 std::remove_cv_t<T> >::value )
275 constexpr explicit operator T()
const
293 template<
typename T>
294 requires ( !alib::characters::IsImplicitArrayCast <T, TChar>
298 std::remove_cv_t<T> >::value )
300 constexpr operator T()
const
317 template<
typename T>
322 std::remove_cv_t<T> >::value )
323 constexpr explicit operator T()
const
339 "Index out of bounds: 0 <= {} < {}.", op,
base::length )
378 typename TCheck=
CHK >
382 if ( startIdx < 0 ) startIdx= 0;
387 && needles.
Length() != 0,
"STRINGS",
388 "Non checking and illegal parameters: 0 <= {} < {}, needles: {}",
395 return idx >= 0 ? idx + startIdx : -1;
399 return idx < 0 || *( haystack + idx ) ==
'\0' ? -1 : startIdx + idx;
414 template<
typename TAllocator>
422 auto* newBuf= allocator().template AllocArray<TChar>(
base::length + 1);
436 template<
typename TAllocator>
438 void Free( TAllocator& allocator )
const {
450template<
typename TChar>
struct ZTArrayTraits<strings::TCString<TChar>, TChar>
452 using T= strings::TCString<TChar>;
455 static constexpr const TChar*
Buffer(
const T& src) {
return src.Buffer(); }
456 static constexpr integer Length(
const T& src) {
return src.Length(); }
457 static constexpr T
Construct(
const TChar* b,
integer l ) {
return T(b, l); }
460template<
typename TChar>
struct ArrayTraits<strings::TCString<TChar>, TChar>
462 using T= strings::TCString<TChar>;
465 static constexpr const TChar*
Buffer(
const T& src) {
return src.Buffer(); }
466 static constexpr integer Length(
const T& src) {
return src.Length(); }
530template<
typename TChar>
666template<
typename TChar>
667bool operator== (
const TCString<TChar>& lhs,
const TCString<TChar>& rhs)
668{
return lhs.
template Equals <CHK, lang::Case::Sensitive>(rhs); }
671template<
typename TChar,
typename T>
672requires (!std::is_same_v<T, TCString<TChar>>)
674{
return lhs.
template Equals <CHK, lang::Case::Sensitive>(rhs); }
677template<
typename TChar>
679{
return lhs.
template CompareTo<CHK, lang::Case::Sensitive>(rhs); }
682template<
typename TChar,
typename T>
683requires (!std::same_as<TCString<TChar>, T>)
685{
return lhs.
template CompareTo<CHK, lang::Case::Sensitive>(rhs); }
void Free(TAllocator &allocator) const
constexpr TCString(const T &src)
TCString(TAllocator &allocator, const TString< TChar > ©)
TString< TChar > base
Shortcut to the base type.
constexpr TCString(T &src)
constexpr TCString(const TChar *pBuffer, integer contentLength)
constexpr TCString(const T *src)
TChar operator[](integer op) const
integer IndexOfAny(const TCString &needles, integer startIdx=0) const
constexpr TCString()=default
Defaulted default constructor. Leaves this instance uninitialized and undefined.
constexpr TCString(T *src)
constexpr TCString(T *src)
constexpr TCString(T &src)
void Allocate(TAllocator &allocator, const TString< TChar > ©)
constexpr TCString(lang::IsNullptr auto const &) noexcept
Constructor accepting nullptr. Constructs a nulled string.
integer CopyTo(TChar *dest) const
constexpr integer Length() const
constexpr const character * Buffer() const
constexpr TString() noexcept=default
constexpr bool IsNull() const
#define ALIB_WARNINGS_RESTORE
#define ALIB_WARNINGS_IGNORE_DOCS
#define ALIB_ASSERT_ERROR(cond, domain,...)
integer IndexOfAnyIncludedZT(const TChar *haystack, const TChar *needles)
integer IndexOfAnyExcludedZT(const TChar *haystack, const TChar *needles)
Inclusion
Denotes how members of a set something should be taken into account.
@ Include
Chooses inclusion.
auto operator<=>(const String &lhs, const String &rhs)
constexpr StrangeCString EMPTY_STRANGE_CSTRING
A zero-terminated, empty string.
constexpr StrangeCString STRANGE_NEW_LINE
A zero-terminated string containing the new-line character sequence.
strings::TCString< strangeChar > StrangeCString
Type alias in namespace alib.
constexpr WCString WNEW_LINE
A zero-terminated string containing the new-line character sequence.
constexpr ComplementCString COMPLEMENT_DEFAULT_WHITESPACES
A zero-terminated string of default whitespace characters.
strings::TCString< complementChar > ComplementCString
Type alias in namespace alib.
constexpr CString NEW_LINE
A zero-terminated string containing the new-line character sequence.
constexpr CString EMPTY_CSTRING
A zero-terminated, empty string.
strings::TCString< character > CString
Type alias in namespace alib.
characters::wchar wchar
Type alias in namespace alib.
lang::integer integer
Type alias in namespace alib.
strings::TCString< xchar > XCString
Type alias in namespace alib.
constexpr NCString NNEW_LINE
A zero-terminated string containing the new-line character sequence.
constexpr XCString XNEW_LINE
A zero-terminated string containing the new-line character sequence.
strings::TCString< wchar > WCString
Type alias in namespace alib.
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 CString DEFAULT_WHITESPACES
A zero-terminated string of default whitespace characters.
constexpr NCString NDEFAULT_WHITESPACES
A zero-terminated string of default whitespace characters.
constexpr StrangeCString STRANGE_DEFAULT_WHITESPACES
A zero-terminated string of default whitespace characters.
constexpr WCString WDEFAULT_WHITESPACES
A zero-terminated string of default whitespace characters.
characters::xchar xchar
Type alias in namespace alib.
constexpr ComplementCString EMPTY_COMPLEMENT_CSTRING
A zero-terminated, empty string.
constexpr XCString EMPTY_XCSTRING
A zero-terminated, empty string.
constexpr WCString EMPTY_WCSTRING
A zero-terminated, empty string.
constexpr NCString EMPTY_NCSTRING
A zero-terminated, empty string.
constexpr ComplementCString COMPLEMENT_NEW_LINE
A zero-terminated string containing the new-line character sequence.
static constexpr Policy Access
static integer Length(const TStringSource &src)
static TStringSource Construct(const TChar *array, integer length)
static constexpr Policy Construction
static const TChar * Buffer(const TStringSource &src)
static constexpr Policy Construction
static constexpr Policy Access
static const TChar * Buffer(const TStringSource &src)
static TStringSource Construct(const TChar *array, integer length)
static integer Length(const TStringSource &src)
static constexpr CString< TChar > DefaultWhitespaces())
"carriage return" and "tabulator", hence " \n\r\t".
static constexpr CString< TChar > NewLine
static constexpr CString< TChar > EmptyString()