10template<
typename TChar>
class TCString;
29template<
typename TChar>
51 :
base( pBuffer, contentLength )
56 "Error: Explicit construction of CString with unterminated string." )
82 #if ALIB_DEBUG && !ALIB_DEBUG_ASSERTION_PRINTABLES
85 "Error: Implicit construction of CString with unterminated string." )
101 template <
typename T>
109 "Error: Implicit construction of CString with unterminated string." )
124 template <
typename T>
133 "Error: Explicit construction of CString with unterminated string." )
149 template <
typename T>
158 "Error: Explicit construction of CString with unterminated string." )
174 template <
typename T>
178 characters::ZTArrayTraits<std::remove_cv_t<T>,TChar>::
Length( const_cast<T&>( src ) ) )
183 "Error: Construction of CString (from mutable object) with unterminated string." )
199 template <
typename T>
208 "Error: Construction of CString (from mutable object) with unterminated string." )
225 template<
typename TAllocator>
235 auto* newBuf= allocator().template AllocArray<TChar>( copy.
Length() + 1);
255 template<
typename T>
259 std::remove_cv_t<T> >::value )
261 constexpr operator T()
const
277 template<
typename T>
283 std::remove_cv_t<T> >::value )
285 constexpr explicit operator T()
const
303 template<
typename T>
304 requires ( !alib::characters::IsImplicitArrayCast <T, TChar>
308 std::remove_cv_t<T> >::value )
310 constexpr operator T()
const
327 template<
typename T>
332 std::remove_cv_t<T> >::value )
333 constexpr explicit operator T()
const
352 "Index out of bounds: 0 <= {} < {}.", op,
base::length )
393 typename TCheck=
CHK >
399 if ( startIdx < 0 ) startIdx= 0;
406 && needles.
Length() != 0,
"STRINGS",
407 "Non checking and illegal parameters: 0 <= {} < {}, needles: {}",
415 return idx >= 0 ? idx + startIdx : -1;
421 return idx < 0 || *( haystack + idx ) ==
'\0' ? -1 : startIdx + idx;
439 template<
typename TAllocator>
449 auto* newBuf= allocator().template AllocArray<TChar>(
base::length + 1);
463 template<
typename TAllocator>
465 void Free( TAllocator& allocator )
const
478template<
typename TChar>
struct ZTArrayTraits<strings::TCString<TChar>, TChar>
480 using T= strings::TCString<TChar>;
483 static constexpr const TChar*
Buffer(
const T& src) {
return src.Buffer(); }
484 static constexpr integer Length(
const T& src) {
return src.Length(); }
485 static constexpr T
Construct(
const TChar* b,
integer l ) {
return T(b, l); }
488template<
typename TChar>
struct ArrayTraits<strings::TCString<TChar>, TChar>
490 using T= strings::TCString<TChar>;
493 static constexpr const TChar*
Buffer(
const T& src) {
return src.Buffer(); }
494 static constexpr integer Length(
const T& src) {
return src.Length(); }
558template<
typename TChar>
694template<
typename TChar>
695bool operator== (
const TCString<TChar>& lhs,
const TCString<TChar>& rhs)
696{
return lhs.
template Equals <CHK, lang::Case::Sensitive>(rhs); }
699template<
typename TChar,
typename T>
700requires (!std::is_same_v<T, TCString<TChar>>)
702{
return lhs.
template Equals <CHK, lang::Case::Sensitive>(rhs); }
705template<
typename TChar>
707{
return lhs.
template CompareTo<CHK, lang::Case::Sensitive>(rhs); }
710template<
typename TChar,
typename T>
711requires (!std::same_as<TCString<TChar>, T>)
713{
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()