37 #if defined(ONIXS_B3_UMDF_MD_HAS_STRING_VIEW) 38 #include <string_view> 44 #if defined(ONIXS_B3_UMDF_MD_HAS_STRING_VIEW) 46 using StrRef = std::basic_string_view<Char>;
53 ONIXS_B3_UMDF_MD_COLDPATH
54 ONIXS_B3_UMDF_MD_NORETURN
55 void throwInvalidIndex(
size_t,
size_t);
85 , size_((
ONIXS_B3_UMDF_MD_ASSERT(size <= (std::numeric_limits<size_type>::max)()), static_cast<size_type>(size)))
98 size_ = numericCast<size_type>(strnlen(chars, maxLen));
100 assert(size_ < maxLen);
105 : items_(string.c_str())
106 , size_(static_cast<size_type>(string.length()))
108 assert(
string.length() <= (std::numeric_limits<size_type>::max)());
112 ONIXS_B3_UMDF_MD_NODISCARD
119 ONIXS_B3_UMDF_MD_NODISCARD
127 ONIXS_B3_UMDF_MD_NODISCARD
135 ONIXS_B3_UMDF_MD_NODISCARD
143 ONIXS_B3_UMDF_MD_NODISCARD
151 ONIXS_B3_UMDF_MD_NODISCARD
155 return (items_ + size_);
159 ONIXS_B3_UMDF_MD_NODISCARD
166 ONIXS_B3_UMDF_MD_NODISCARD
173 ONIXS_B3_UMDF_MD_NODISCARD
176 return const_reverse_iterator(end());
180 ONIXS_B3_UMDF_MD_NODISCARD
183 return const_reverse_iterator(begin());
187 ONIXS_B3_UMDF_MD_NODISCARD
194 ONIXS_B3_UMDF_MD_NODISCARD
201 ONIXS_B3_UMDF_MD_NODISCARD
204 assert(index < size_);
207 return items_[index];
211 ONIXS_B3_UMDF_MD_NODISCARD
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());
259 ONIXS_B3_UMDF_MD_NODISCARD
268 assert(right.
empty());
273 assert(right.
data());
280 ONIXS_B3_UMDF_MD_NODISCARD
284 return !(left == right);
288 ONIXS_B3_UMDF_MD_NODISCARD
308 ONIXS_B3_UMDF_MD_NODISCARD
312 return (right < left);
319 stream.write(text.
data(), text.
size());
328 ONIXS_B3_UMDF_MD_NODISCARD
336 ONIXS_B3_UMDF_MD_NODISCARD
344 ONIXS_B3_UMDF_MD_NODISCARD
352 ONIXS_B3_UMDF_MD_NODISCARD
360 ONIXS_B3_UMDF_MD_NODISCARD
368 ONIXS_B3_UMDF_MD_NODISCARD
376 ONIXS_B3_UMDF_MD_NODISCARD
384 ONIXS_B3_UMDF_MD_NODISCARD
394 ONIXS_B3_UMDF_MD_NODISCARD
401 ONIXS_B3_UMDF_MD_NODISCARD
411 template <
size_t Size>
412 ONIXS_B3_UMDF_MD_NODISCARD
416 ONIXS_B3_UMDF_MD_NOTHROW
418 return StrRef(value, Size - 1);
421 template <
size_t Size>
422 ONIXS_B3_UMDF_MD_NODISCARD
426 ONIXS_B3_UMDF_MD_NOTHROW
428 return StrRef(value, Size);
432 ONIXS_B3_UMDF_MD_NODISCARD
436 return std::string(ref.
data(), ref.
size());
const Char & back() const
ONIXS_B3_UMDF_MD_NODISCARD const_reverse_iterator crend() const
STL-like crend().
#define ONIXS_B3_UMDF_MD_NOTHROW
const Char & front() const
std::reverse_iterator< const_iterator > const_reverse_iterator
#define ONIXS_B3_UMDF_MD_CONSTEXPR
void toStr(std::string &str, const StrRef &ref)
Appends the text referenced by StrRef to the given std::string instance.
ONIXS_B3_UMDF_MD_NODISCARD const_iterator cbegin() const
STL-like cbegin().
#define ONIXS_B3_UMDF_MD_EXPORTED
#define ONIXS_B3_UMDF_MD_NULLPTR
#define ONIXS_B3_UMDF_MD_ASSERT(CHECK)
ONIXS_B3_UMDF_MD_NODISCARD bool operator<(const StrRef &left, const StrRef &right)
Compares instances.
#define ONIXS_B3_UMDF_MD_CONST_OR_CONSTEXPR
ONIXS_B3_UMDF_MD_NODISCARD const Char * data() const
ONIXS_B3_UMDF_MD_NODISCARD size_type length() const
ONIXS_B3_UMDF_MD_NODISCARD const_iterator cend() const
STL-like cend().
ONIXS_B3_UMDF_MD_NODISCARD StrRef toStrRef(const Char *)
Initializes the instance from a zero-terminated/C-like string.
ONIXS_B3_UMDF_MD_NODISCARD const_reverse_iterator crbegin() const
STL-like crbegin().
ONIXS_B3_UMDF_MD_NODISCARD bool operator!=(const Char *str, const StrRef &ref)
Compares StrRef with a zero-terminated/C-like string.
StrRef(const Char *chars)
Explicit initialization.
ONIXS_B3_UMDF_MD_NODISCARD bool operator==(const Char *str, const StrRef &ref)
Compares StrRef with a zero-terminated/C-like string.
StrRef(const std::string &string)
Explicit initialization.
char Char
Character type alias.
#define ONIXS_B3_UMDF_MD_MESSAGING_NAMESPACE_END
const Char * const_iterator
STL-like iterators.
ONIXS_B3_UMDF_MD_NODISCARD bool empty() const
ONIXS_B3_UMDF_MD_NODISCARD const_reverse_iterator rbegin() const
STL-like rbegin().
ONIXS_B3_UMDF_MD_NODISCARD StrRef constructStrRef(const char(&value)[Size])
ONIXS_B3_UMDF_MD_NODISCARD StrRef strRefFromCharArray(const char(&value)[Size])
ONIXS_B3_UMDF_MD_NODISCARD size_type size() const
const_reverse_iterator reverse_iterator
#define ONIXS_B3_UMDF_MD_MESSAGING_NAMESPACE_BEGIN
ONIXS_B3_UMDF_MD_NODISCARD const Char & at(size_type index) const
Provides the bound-checked per-item access.
#define ONIXS_B3_UMDF_MD_LTWT_CLASS
ONIXS_B3_UMDF_MD_NODISCARD const_iterator begin() const
STL-like begin().
std::ostream & operator<<(std::ostream &stream, const StrRef &text)
StrRef serialization operator.
ONIXS_B3_UMDF_MD_NODISCARD bool operator>(const StrRef &left, const StrRef &right)
Compares instances.
ONIXS_B3_UMDF_MD_NODISCARD const_iterator end() const
STL-like end().
StrRef(const Char *chars, size_t size)
Explicit initialization.
ONIXS_B3_UMDF_MD_NODISCARD const_reverse_iterator rend() const
STL-like rend().
void swap(StrRef &other)
Swaps the content with the given instance.
StrRef()
Initializes the instance referring to nothing.