37#if defined(ONIXS_EURONEXT_OPTIQMDG_HAS_STRING_VIEW)
44#if defined(ONIXS_EURONEXT_OPTIQMDG_HAS_STRING_VIEW)
46using StrRef = std::basic_string_view<Char>;
55void 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())
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_EURONEXT_OPTIQMDG_EXPORTED
#define ONIXS_EURONEXT_OPTIQMDG_MESSAGING_NAMESPACE_BEGIN
#define ONIXS_EURONEXT_OPTIQMDG_MESSAGING_NAMESPACE_END
#define ONIXS_EURONEXT_OPTIQMDG_LTWT_CLASS
#define ONIXS_EURONEXT_OPTIQMDG_NODISCARD
#define ONIXS_EURONEXT_OPTIQMDG_NOTHROW
#define ONIXS_EURONEXT_OPTIQMDG_CONST_OR_CONSTEXPR
#define ONIXS_EURONEXT_OPTIQMDG_NULLPTR
#define ONIXS_EURONEXT_OPTIQMDG_CONSTEXPR
#define ONIXS_EURONEXT_OPTIQMDG_COLDPATH
#define ONIXS_EURONEXT_OPTIQMDG_NORETURN
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
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().
constexpr StrRef(const Char *chars, size_t size) noexcept
Explicit initialization.
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, Char character)
Appends the character to the given std::string instance.