12#ifndef ARCCORE_BASE_STRINGVIEW_H
13#define ARCCORE_BASE_STRINGVIEW_H
51 :
StringView(str ? std::string_view(str) : std::string_view()) {}
54 : m_v(
reinterpret_cast<const Byte*
>(str.data()), str.size()) {}
65 operator=(str ? std::string_view(str) : std::string_view());
96 constexpr Int64 length() const ARCCORE_NOEXCEPT {
return m_v.size(); }
99 constexpr Int64 size() const ARCCORE_NOEXCEPT {
return m_v.size(); }
102 constexpr bool empty() const ARCCORE_NOEXCEPT {
return size() == 0; }
111 return std::string_view(
reinterpret_cast<const char*
>(m_v.data()), m_v.size());
141 friend ARCCORE_BASE_EXPORT
bool operator==(
const char* a,
const StringView& b);
157 friend ARCCORE_BASE_EXPORT
bool operator==(
const StringView& a,
const char* b);
181 void writeBytes(std::ostream& o)
const;
Declarations of types for the 'base' component of Arccore.
Types and functions associated with the classes SpanImpl, SmallSpan and Span.
View of an array of elements of type T.
View of a UTF-8 character string.
constexpr StringView & operator=(const StringView &str)=default
Copies the view str into this instance.
constexpr StringView(Span< const Byte > str) ARCCORE_NOEXCEPT
Creates a string from str in UTF-8 encoding.
constexpr Int64 size() const ARCCORE_NOEXCEPT
Length in bytes of the character string.
constexpr Span< const Byte > bytes() const ARCCORE_NOEXCEPT
Returns the conversion of the instance in UTF-8 encoding.
friend bool operator!=(const char *a, const StringView &b)
Compares two Unicode strings.
std::string_view toStdStringView() const ARCCORE_NOEXCEPT
Returns an STL view of the current view.
~StringView()=default
Frees resources.
StringView(std::string_view str) ARCCORE_NOEXCEPT
Creates a string from str in UTF-8 encoding.
constexpr Int64 length() const ARCCORE_NOEXCEPT
Length in bytes of the character string.
friend bool operator==(const StringView &a, const StringView &b)
Compares two views.
StringView & operator=(std::string_view str) ARCCORE_NOEXCEPT
Creates a view from str encoded in UTF-8.
friend bool operator!=(const StringView &a, const StringView &b)
Compares two Unicode strings.
constexpr StringView & operator=(Span< const Byte > str) ARCCORE_NOEXCEPT
Creates a view from str encoded in UTF-8.
StringView(const char *str) ARCCORE_NOEXCEPT
Creates a view from str encoded in UTF-8. str may be null.
constexpr bool empty() const ARCCORE_NOEXCEPT
True if the string is null or empty.
friend bool operator!=(const StringView &a, const char *b)
Compares two Unicode strings.
StringView & operator=(const char *str) ARCCORE_NOEXCEPT
Creates a view from str encoded in UTF-8.
StringView()=default
Creates a view of an empty string.
constexpr StringView(const StringView &str)=default
Copy constructor.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
std::int64_t Int64
Signed integer type of 64 bits.
bool operator<(const Item &item1, const Item &item2)
Compare two entities.
unsigned char Byte
Type of a byte.
std::ostream & operator<<(std::ostream &ostr, eItemKind item_kind)
Output operator for a stream.