67 using Traits = std::char_traits<charT>;
80 using traits = std::char_traits<charT>;
84 constexpr
string_view() noexcept : m_chars(
nullptr), m_len(0) { }
88 : m_chars(copy.
data()), m_len(copy.
size()) { }
92 : m_chars(chars), m_len(len) { }
96 : m_chars(chars), m_len(chars ?
Traits::
length(chars) : 0) { }
103 : m_chars(str.data()), m_len(str.size()) { }
131 const char* c_str()
const;
141 constexpr
iterator end() const noexcept {
return m_chars + m_len; }
156 constexpr
bool empty() const noexcept {
return m_len == 0; }
165 throw(std::out_of_range(
"OpenImageIO::string_view::at"));
192 if (
n == npos || pos +
n >
size())
200 return cmp != 0 ? cmp :
int(m_len -
x.m_len);
209 size_type
copy(CharT* dest, size_type
count, size_type pos = 0)
const;
220 return i == this->cend() ? npos :
std::distance(this->cbegin(), i);
228 const_iterator i = std::find_if (this->cbegin()+pos, this->cend(),
230 return i == this->cend() ? npos :
std::distance (this->cbegin(), i);
241 return i == e ? npos : (reverse_distance(this->crbegin(),i) - s.
size() + 1);
252 return i == e ? npos : reverse_distance (this->crbegin(),i);
262 const_iterator i = std::find_first_of (this->cbegin()+pos, this->cend(),
264 return i == this->cend() ? npos :
std::distance (this->cbegin(), i);
270 size_t off =
size()-pos;
273 return i == this->crend() ? npos : reverse_distance (this->crbegin(), i);
279 const_iterator i = find_not_of (this->cbegin()+pos, this->cend(), s);
280 return i == this->cend() ? npos :
std::distance (this->cbegin(), i);
286 for (
const_iterator i = this->cbegin()+pos; i != this->cend(); ++i)
287 if (! traits::eq (c, *i))
295 size_t off =
size()-pos;
297 return i == this->crend() ? npos : reverse_distance (this->crbegin(), i);
303 size_t off =
size()-pos;
305 if (! traits::eq (c, *i))
306 return reverse_distance (this->crbegin(), i);
311 const charT* m_chars =
nullptr;
320 template<
typename r_iter>
321 size_type reverse_distance(r_iter
first, r_iter
last)
const noexcept
326 template<
typename iter>
337 constexpr traits_eq (charT ch) noexcept : ch(ch) {}
338 constexpr
bool operator () (charT
val)
const noexcept {
return traits::eq (ch,
val); }
345 inline OIIO_CONSTEXPR17
bool
348 return x.size() ==
y.size() ? (
x.compare(
y) == 0) :
false;
351 inline OIIO_CONSTEXPR17
bool
354 return x.size() ==
y.size() ? (
x.compare(
y) != 0) :
true;
357 inline OIIO_CONSTEXPR17
bool
360 return x.compare(
y) < 0;
363 inline OIIO_CONSTEXPR17
bool
366 return x.compare(
y) > 0;
369 inline OIIO_CONSTEXPR17
bool
372 return x.compare(
y) <= 0;
375 inline OIIO_CONSTEXPR17
bool
378 return x.compare(
y) >= 0;
405 #if OIIO_CPLUSPLUS_VERSION < 17
409 #if OIIO_CPLUSPLUS_VERSION < 20
411 return static_cast<ptrdiff_t
>(c.size());
417 #define OIIO_STRING_VIEW_HAS_STD_SIZE 1
constexpr const_reference operator[](size_type pos) const
typedef int(APIENTRYP RE_PFNGLXSWAPINTERVALSGIPROC)(int)
OIIO_CONSTEXPR17 const_reverse_iterator crend() const noexcept
constexpr size_t size(const OIIO::span< T, E > &c)
OIIO_CONSTEXPR14 void clear() noexcept
size_type find_last_not_of(charT c, size_t pos=npos) const noexcept
constexpr string_view(const string_view ©)
Copy ctr.
const_reverse_iterator reverse_iterator
const_pointer const_iterator
OIIO_CONSTEXPR14 string_view substr(size_type pos, size_type n=npos) const noexcept
size_type rfind(string_view s, size_t pos=npos) const noexcept
OIIO_UTIL_API bool copy(string_view from, string_view to, std::string &err)
GLsizei const GLchar *const * string
size_type find(string_view s, size_t pos=0) const noexcept
OIIO_CONSTEXPR14 void remove_prefix(size_type n) noexcept
GLuint GLsizei GLsizei * length
bool OIIO_UTIL_API ends_with(string_view a, string_view b)
Does 'a' end with the string 'b', with a case-sensitive comparison?
ImageBuf OIIO_API min(Image_or_Const A, Image_or_Const B, ROI roi={}, int nthreads=0)
size_type find_first_not_of(charT c, size_t pos=0) const noexcept
constexpr const_pointer data() const noexcept
IMATH_HOSTDEVICE constexpr int cmp(T a, T b) IMATH_NOEXCEPT
basic_string_view< char > string_view
constexpr size_type size() const noexcept
size_type find_last_not_of(string_view s, size_t pos=npos) const noexcept
CompareResults OIIO_API compare(const ImageBuf &A, const ImageBuf &B, float failthresh, float warnthresh, ROI roi={}, int nthreads=0)
OIIO_CONSTEXPR17 reverse_iterator rbegin() const noexcept
constexpr const_iterator cbegin() const noexcept
size_type find(charT c, size_t pos=0) const noexcept
size_t OIIO_UTIL_API rfind(string_view a, string_view b)
OIIO_CONSTEXPR17 reverse_iterator rend() const noexcept
std::ostream & operator<<(std::ostream &out, const string_view &str)
constexpr const_reference front() const
bool operator!=(const Mat3< T0 > &m0, const Mat3< T1 > &m1)
Inequality operator, does exact floating point comparisons.
constexpr size_type max_size() const noexcept
OIIO_CONSTEXPR17 string_view(const charT *chars)
Construct from char*, use strlen to determine length.
PUGI__NS_END PUGI__NS_BEGIN PUGI__FN bool starts_with(const char_t *string, const char_t *pattern)
constexpr const_reference back() const
OIIO_CONSTEXPR17 bool operator<=(string_view x, string_view y) noexcept
const charT & const_reference
size_type rfind(charT c, size_t pos=npos) const noexcept
GLboolean GLboolean GLboolean b
size_type find_last_of(string_view s, size_t pos=npos) const noexcept
OIIO_CONSTEXPR14 void remove_suffix(size_type n) noexcept
OIIO_CONSTEXPR17 bool operator<(string_view x, string_view y) noexcept
constexpr size_t size(const OIIO::string_view &c)
size_type find_last_of(charT c, size_t pos=npos) const noexcept
std::reverse_iterator< const_iterator > const_reverse_iterator
OIIO_CONSTEXPR17 bool operator>(string_view x, string_view y) noexcept
auto search(const T &set, const V &val) -> std::pair< bool, decltype(std::begin(detail::smart_deref(set)))>
A search function.
OIIO_CONSTEXPR17 const_reverse_iterator crbegin() const noexcept
__hostdev__ uint64_t last(uint32_t i) const
std::string str() const
Convert a string_view to a std::string.
constexpr string_view() noexcept
Default ctr.
ptrdiff_t difference_type
OIIO_CONSTEXPR17 int compare(string_view x) const noexcept
OIIO_CONSTEXPR17 const_reference at(size_t pos) const
Element access with bounds checking and exception if out of bounds.
constexpr iterator begin() const noexcept
constexpr string_view(const charT *chars, size_t len)
Construct from char* and length.
constexpr const_iterator cend() const noexcept
LeafData & operator=(const LeafData &)=delete
constexpr size_type length() const noexcept
const charT * const_pointer
constexpr iterator end() const noexcept
OIIO_CONSTEXPR17 bool operator>=(string_view x, string_view y) noexcept
ImageBuf OIIO_API max(Image_or_Const A, Image_or_Const B, ROI roi={}, int nthreads=0)
size_type find_first_not_of(string_view s, size_t pos=0) const noexcept
std::char_traits< charT > Traits
std::char_traits< charT > traits
constexpr ptrdiff_t ssize(const OIIO::span< T, E > &c)
#define OIIO_NAMESPACE_END
SIM_API const UT_StringHolder distance
size_type find_first_of(string_view s, size_t pos=0) const noexcept
bool operator==(const Mat3< T0 > &m0, const Mat3< T1 > &m1)
Equality operator, does exact floating point comparisons.
constexpr bool empty() const noexcept
Is the string_view empty, containing no characters?
FMT_CONSTEXPR auto find(Ptr first, Ptr last, T value, Ptr &out) -> bool
string_view(const std::string &str) noexcept
#define OIIO_NAMESPACE_BEGIN
size_type find_first_of(charT c, size_t pos=0) const noexcept
PcpNodeRef_ChildrenIterator begin(const PcpNodeRef::child_const_range &r)
Support for range-based for loops for PcpNodeRef children ranges.