37 #if defined(ONIXS_EURONEXT_OPTIQMDG_HAS_STRING_VIEW) 38 #include <string_view> 44 #if defined(ONIXS_EURONEXT_OPTIQMDG_HAS_STRING_VIEW) 46 using StrRef = std::basic_string_view<Char>;
55 void throwInvalidIndex(
size_t,
size_t);
85 , size_((ONIXS_EURONEXT_OPTIQMDG_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)());
155 return (items_ + size_);
176 return const_reverse_iterator(end());
183 return const_reverse_iterator(begin());
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);
319 stream.write(text.
data(), text.
size());
411 template <
size_t Size>
416 ONIXS_EURONEXT_OPTIQMDG_NOTHROW
418 return StrRef(value, Size - 1);
421 template <
size_t Size>
426 ONIXS_EURONEXT_OPTIQMDG_NOTHROW
428 return StrRef(value, Size);
436 return std::string(ref.
data(), ref.
size());
constexpr StrRef()
Initializes the instance referring to nothing.
#define ONIXS_EURONEXT_OPTIQMDG_MESSAGING_NAMESPACE_END
const_reverse_iterator crend() const noexcept
STL-like crend().
const Char & back() const noexcept
const Char * const_iterator
STL-like iterators.
const Char & at(size_type index) const
Provides the bound-checked per-item access.
#define ONIXS_EURONEXT_OPTIQMDG_CONST_OR_CONSTEXPR
#define ONIXS_EURONEXT_OPTIQMDG_LTWT_CLASS
StrRef toStrRef(const Char *) noexcept
Initializes the instance from a zero-terminated/C-like string.
const_reverse_iterator rend() const noexcept
STL-like rend().
#define ONIXS_EURONEXT_OPTIQMDG_NOTHROW
const Char & front() const noexcept
const_reverse_iterator reverse_iterator
#define ONIXS_EURONEXT_OPTIQMDG_EXPORTED
#define ONIXS_EURONEXT_OPTIQMDG_CONSTEXPR
bool empty() const noexcept
#define ONIXS_EURONEXT_OPTIQMDG_NORETURN
bool operator!=(const Char *str, const StrRef &ref)
Compares StrRef with a zero-terminated/C-like string.
bool operator==(const Char *str, const StrRef &ref)
Compares StrRef with a zero-terminated/C-like string.
#define ONIXS_EURONEXT_OPTIQMDG_NODISCARD
void swap(StrRef &other) noexcept
Swaps the content with the given instance.
#define ONIXS_EURONEXT_OPTIQMDG_MESSAGING_NAMESPACE_BEGIN
constexpr StrRef strRefFromCharArray(const char(&value)[Size]) noexcept
const_iterator end() const noexcept
STL-like end().
constexpr size_type size() const noexcept
constexpr const Char * data() const noexcept
const_iterator cend() const noexcept
STL-like cend().
std::ostream & operator<<(std::ostream &stream, const StrRef &text)
StrRef serialization operator.
std::reverse_iterator< const_iterator > const_reverse_iterator
const_iterator begin() const noexcept
STL-like begin().
constexpr StrRef constructStrRef(const char(&value)[Size]) noexcept
#define ONIXS_EURONEXT_OPTIQMDG_COLDPATH
bool operator>(const StrRef &left, const StrRef &right)
Compares instances.
const_reverse_iterator rbegin() const noexcept
STL-like rbegin().
bool operator<(const StrRef &left, const StrRef &right)
Compares instances.
const_iterator cbegin() const noexcept
STL-like cbegin().
#define ONIXS_EURONEXT_OPTIQMDG_NULLPTR
const_reverse_iterator crbegin() const noexcept
STL-like crbegin().
StrRef(const Char *chars) noexcept
Explicit initialization.
void toStr(std::string &str, const StrRef &ref)
Appends the text referenced by StrRef to the given std::string instance.
constexpr StrRef(const Char *chars, size_t size) noexcept
Explicit initialization.
constexpr size_type length() const noexcept
char Char
Character type alias.
StrRef(const std::string &string)
Explicit initialization.