37#if defined(ONIXS_CONFLATEDTCP_HAS_STRING_VIEW)
44#if defined(ONIXS_CONFLATEDTCP_HAS_STRING_VIEW)
46using StrRef = std::basic_string_view<Char>;
55void throwInvalidIndex(
size_t,
size_t);
98 size_ = numericCast<size_type>(strnlen(chars, maxLen));
100 assert(size_ < maxLen);
105 : items_(string.c_str())
108 assert(
string.
length() <= (std::numeric_limits<size_type>::max)());
155 return (items_ + size_);
204 assert(index < size_);
207 return items_[index];
217 return items_[index];
219 throwInvalidIndex(index, size_);
233 return (*
this)[size_ - 1];
239 std::swap(items_, other.items_);
241 std::swap(size_, other.size_);
245 operator std::basic_string<Char>()
const
247 return std::basic_string<Char>(
data(),
size());
268 assert(right.
empty());
273 assert(right.
data());
284 return !(left == right);
312 return (right < left);
317std::ostream& operator <<(std::ostream& stream,
const StrRef& text)
319 stream.write(text.
data(), text.
size());
330bool operator ==(
const StrRef& ref,
const std::string& str)
338bool operator !=(
const StrRef& ref,
const std::string& str)
346bool operator ==(
const std::string& str,
const StrRef& ref)
354bool operator !=(
const std::string& str,
const StrRef& ref)
411template <
size_t Size>
418 return StrRef(value, Size - 1);
421template <
size_t Size>
428 return StrRef(value, Size);
436 return std::string(ref.
data(), ref.
size());
#define ONIXS_CONFLATEDTCP_LTWT_CLASS
#define ONIXS_CONFLATEDTCP_MESSAGING_NAMESPACE_BEGIN
#define ONIXS_CONFLATEDTCP_MESSAGING_NAMESPACE_END
#define ONIXS_CONFLATEDTCP_NORETURN
#define ONIXS_CONFLATEDTCP_CONSTEXPR
#define ONIXS_CONFLATEDTCP_EXPORTED
#define ONIXS_CONFLATEDTCP_NULLPTR
#define ONIXS_CONFLATEDTCP_CONST_OR_CONSTEXPR
#define ONIXS_CONFLATEDTCP_NOTHROW
#define ONIXS_CONFLATEDTCP_NODISCARD
#define ONIXS_CONFLATEDTCP_COLDPATH
const_iterator begin() const noexcept
STL-like begin().
constexpr StrRef()
Initializes the instance referring to nothing.
const Char & back() const noexcept
void swap(StrRef &other) noexcept
Swaps the content with the given instance.
bool empty() const noexcept
std::reverse_iterator< const_iterator > const_reverse_iterator
constexpr size_type size() const noexcept
const_iterator end() const noexcept
STL-like end().
StrRef(const Char *chars) noexcept
Explicit initialization.
const_reverse_iterator reverse_iterator
constexpr StrRef(const Char *chars, size_t size)
Explicit initialization.
StrRef(const std::string &string)
Explicit initialization.
const_iterator cend() const noexcept
STL-like cend().
constexpr const Char * data() const noexcept
const Char & front() const noexcept
const_reverse_iterator crbegin() const noexcept
STL-like crbegin().
const_iterator cbegin() const noexcept
STL-like cbegin().
const_reverse_iterator rend() const noexcept
STL-like rend().
constexpr size_type length() const noexcept
const_reverse_iterator crend() const noexcept
STL-like crend().
const Char & at(size_type index) const
Provides the bound-checked per-item access.
const Char * const_iterator
STL-like iterators.
const_reverse_iterator rbegin() const noexcept
STL-like rbegin().
constexpr StrRef constructStrRef(const char(&value)[Size]) noexcept
char Char
Character type alias.
constexpr StrRef strRefFromCharArray(const char(&value)[Size]) noexcept
StrRef toStrRef(const std::string &)
Constructs a StrRef instance over th std::string content.
void toStr(std::string &str, const Negotiate200 &obj)
Serializes into a string.