10template<
typename TChar>
class TCString;
29template<
typename TChar>
51 :
base( pBuffer, contentLength ) {
55 "Error: Explicit construction of CString with unterminated string." )
89 #if ALIB_DEBUG && !ALIB_DEBUG_ASSERTION_PRINTABLES
92 "Error: Implicit construction of CString with unterminated string." )
103 "Error: Implicit construction of CString with unterminated string." )
106 template <
typename T>
114 "Error: Explicit construction of CString with unterminated string." )
118 template <
typename T>
121 :
base( characters::ZTArrayTraits<std::remove_cv_t<T>,TChar>::
Buffer( *src ),
122 characters::ZTArrayTraits<std::remove_cv_t<T>,TChar>::
Length( *src ) ) {
126 "Error: Explicit construction of CString with unterminated string." )
130 template <
typename T>
131 requires alib::characters::IsMutableZTArraySource<T, TChar>
133 :
base( characters::ZTArrayTraits<std::remove_cv_t<T>,TChar>::
Buffer(const_cast<T&>( src )),
134 characters::ZTArrayTraits<std::remove_cv_t<T>,TChar>::
Length(const_cast<T&>( src )) ) {
138 "Error: Construction of CString (from mutable object) with unterminated string." )
142 template <
typename T>
143 requires alib::characters::IsMutableZTArraySource<T, TChar>
145 :
base( characters::ZTArrayTraits<std::remove_cv_t<T>,TChar>::
Buffer( *src ),
146 characters::ZTArrayTraits<std::remove_cv_t<T>,TChar>::
Length( *src ) ) {
150 "Error: Construction of CString (from mutable object) with unterminated string." )
168 template<
typename TAllocator>
169 requires alib::lang::IsAllocator<TAllocator>
176 auto* newBuf= allocator().template AllocArray<TChar>( copy.
Length() + 1);
198 template<
typename T>
199 constexpr operator T()
const;
201 template<
typename T>
205 std::remove_cv_t<T> >::value )
206 constexpr operator T()
const
209 template<
typename T>
215 std::remove_cv_t<T> >::value )
217 constexpr explicit operator T()
const
220 template<
typename T>
221 requires ( !alib::characters::IsImplicitArrayCast <T, TChar>
225 std::remove_cv_t<T> >::value )
227 constexpr operator T()
const
231 template<
typename T>
236 std::remove_cv_t<T> >::value )
237 constexpr explicit operator T()
const
253 "Index out of bounds: 0 <= {} < {}.", op,
base::length )
292 typename TCheck=
CHK >
296 if ( startIdx < 0 ) startIdx= 0;
301 && needles.
Length() != 0,
"STRINGS",
302 "Non checking and illegal parameters: 0 <= {} < {}, needles: {}",
309 return idx >= 0 ? idx + startIdx : -1;
313 return idx < 0 || *( haystack + idx ) ==
'\0' ? -1 : startIdx + idx;
328 template<
typename TAllocator>
336 auto* newBuf= allocator().template AllocArray<TChar>(
base::length + 1);
350 template<
typename TAllocator>
352 void Free( TAllocator& allocator )
const {
366template<
typename TChar>
367struct NoAutoCastTraits< TCString<TChar>,
369 std::basic_string<TChar> > : std::true_type {};
372template<
typename TChar>
struct ZTArrayTraits<strings::TCString<TChar>, TChar>
374 using T= strings::TCString<TChar>;
377 static constexpr const TChar*
Buffer(
const T& src) {
return src.Buffer(); }
378 static constexpr integer Length(
const T& src) {
return src.Length(); }
379 static constexpr T
Construct(
const TChar* b,
integer l ) {
return T(b, l); }
382template<
typename TChar>
struct ArrayTraits<strings::TCString<TChar>, TChar>
384 using T= strings::TCString<TChar>;
387 static constexpr const TChar*
Buffer(
const T& src) {
return src.Buffer(); }
388 static constexpr integer Length(
const T& src) {
return src.Length(); }
454template<
typename TChar>
590template<
typename TChar>
591bool operator== (
const TCString<TChar>& lhs,
const TCString<TChar>& rhs)
592{
return lhs.
template Equals <CHK, lang::Case::Sensitive>(rhs); }
595template<
typename TChar,
typename T>
596requires (!std::is_same_v<T, TCString<TChar>>)
598{
return lhs.
template Equals <CHK, lang::Case::Sensitive>(rhs); }
601template<
typename TChar>
603{
return lhs.
template CompareTo<CHK, lang::Case::Sensitive>(rhs); }
606template<
typename TChar,
typename T>
607requires (!std::same_as<TCString<TChar>, T>)
609{
return lhs.
template CompareTo<CHK, lang::Case::Sensitive>(rhs); }
#define ALIB_POP_ALLOWANCE
#define ALIB_ASSERT_ERROR(cond, domain,...)
TString< TChar > base
Shortcut to the base type.
void Allocate(TAllocator &allocator, const TString< TChar > ©)
constexpr TCString(const TChar *pBuffer, integer contentLength)
constexpr TCString(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.
TCString(TAllocator &allocator, const TString< TChar > ©)
void Free(TAllocator &allocator) const
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
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< wchar > WCString
Type alias in namespace alib.
strings::TCString< character > CString
Type alias in namespace alib.
constexpr WCString WNEW_LINE
A zero-terminated string containing the new-line character sequence.
strings::TCString< nchar > NCString
Type alias in namespace alib.
constexpr ComplementCString COMPLEMENT_DEFAULT_WHITESPACES
A zero-terminated string of default whitespace characters.
constexpr CString NEW_LINE
A zero-terminated string containing the new-line character sequence.
constexpr CString EMPTY_CSTRING
A zero-terminated, empty string.
characters::wchar wchar
Type alias in namespace alib.
lang::integer integer
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.
characters::nchar nchar
Type alias in namespace alib.
constexpr XCString XDEFAULT_WHITESPACES
A zero-terminated string of default whitespace characters.
strings::TCString< xchar > XCString
Type alias in namespace alib.
constexpr CString DEFAULT_WHITESPACES
A zero-terminated string of default whitespace characters.
constexpr NCString NDEFAULT_WHITESPACES
A zero-terminated string of default whitespace characters.
strings::TCString< complementChar > ComplementCString
Type alias in namespace alib.
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.
strings::TCString< strangeChar > StrangeCString
Type alias in namespace alib.
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()