7 #define OPENIMAGEIO_USTRING_H
15 # pragma warning(disable : 4251 4996)
128 m_chars = str ? make_unique(str) :
nullptr;
136 m_chars = str.
data() ? make_unique(str) :
nullptr;
142 : m_chars(make_unique(std::
string(str, pos, n).c_str()))
154 : m_chars(make_unique(std::
string(n, c).c_str()))
163 m_chars = make_unique(sref);
168 : m_chars(str.m_chars)
177 m_chars = make_unique(sref);
195 m_chars = str.m_chars;
224 m_chars = str ? make_unique(str) :
nullptr;
245 m_chars = str.
length() ? make_unique(str) :
nullptr;
272 const char*
c_str() const noexcept {
return m_chars; }
275 const char*
data() const noexcept {
return c_str(); }
284 return empty_std_string;
288 void clear(
void) noexcept { m_chars =
nullptr; }
300 size_t hash(
void) const noexcept
313 bool empty(
void) const noexcept {
return (
size() == 0); }
343 if (m_chars ==
nullptr) {
347 char*
c = strncpy(s, c_str() + pos, n);
367 return string().find(str, pos);
372 return string().find(s, pos, n);
377 return string().find(s, pos);
382 return string().find(c, pos);
392 return string().rfind(str, pos);
397 return string().rfind(s, pos, n);
402 return string().rfind(s, pos);
407 return string().rfind(c, pos);
419 return string().find_first_of(str, pos);
424 return string().find_first_of(s, pos, n);
429 return string().find_first_of(s, pos);
434 return string().find_first_of(c, pos);
446 return string().find_last_of(str, pos);
451 return string().find_last_of(s, pos, n);
456 return string().find_last_of(s, pos);
461 return string().find_last_of(c, pos);
473 return string().find_first_not_of(str, pos);
478 return string().find_first_not_of(s, pos, n);
483 return string().find_first_not_of(s, pos);
488 return string().find_first_not_of(c, pos);
500 return string().find_last_not_of(str, pos);
505 return string().find_last_not_of(s, pos, n);
510 return string().find_last_not_of(s, pos);
515 return string().find_last_not_of(c, pos);
531 return strcmp(c_str() ? c_str() :
"", str ? str :
"");
548 return c_str() == str.c_str();
557 return c_str() != str.c_str();
578 return b.compare(
a) == 0;
585 return b.compare(
a) == 0;
592 return b.compare(
a) == 0;
614 return b.compare(
a) != 0;
621 return b.compare(
a) != 0;
628 return b.compare(
a) != 0;
641 template<
typename... Args>
653 template<
typename... Args>
662 template<
typename... Args>
678 if (str.
c_str() && out.good())
690 static size_t total_ustrings();
695 static size_t hash_collisions(std::vector<ustring>* collisions =
nullptr);
709 return str ==
nullptr || make_unique(str) == str;
742 const char*
c_str() const noexcept {
return (
const char*)(
this + 1); }
777 return size_t(
a.data()) <
size_t(
b.data());
GLsizei GLenum GLsizei GLsizei GLuint memory
const ustring & assign(const char *str)
Assign a null-terminated C string (char*) to *this.
std::string::const_iterator const_iterator
bool operator==(const ustring &str) const noexcept
static OIIO_FORMAT_DEPRECATED ustring format(const char *fmt, const Args &...args)
size_type find_last_of(const char *s, size_type pos, size_type n) const
bool OIIO_UTIL_API iequals(string_view a, string_view b)
size_type find_last_of(const std::string &str, size_type pos=npos) const noexcept
bool operator==(const char *x) const noexcept
Test a ustring (this) for lexicographic equality with char x.
size_type find(const char *s, size_type pos=0) const
size_type copy(char *s, size_type n, size_type pos=0) const
size_type find_first_not_of(char c, size_type pos=0) const noexcept
void clear(void) noexcept
Reset to an empty string.
friend bool operator!=(string_view a, const ustring &b) noexcept
size_t length(void) const noexcept
Return the number of characters in the string.
const ustring & assign(string_view str)
Assign a string_view to *this.
const value_type & const_reference
size_type find_first_of(const char *s, size_type pos, size_type n) const
OIIO_CONSTEXPR14 string_view substr(size_type pos, size_type n=npos) const noexcept
size_type rfind(char c, size_type pos=npos) const noexcept
size_type find_last_not_of(char c, size_type pos=npos) const noexcept
std::string format(const Str &fmt, Args &&...args)
size_type rfind(const char *s, size_type pos=npos) const
GLsizei const GLchar *const * string
static bool is_unique(const char *str)
bool operator!=(const char *x) const noexcept
const ustring & operator=(const char *str)
Assign a null-terminated C string (char *) to a ustring.
std::string to_string(const T &value)
GLboolean GLboolean GLboolean GLboolean a
GLuint GLsizei GLsizei * length
size_type find_last_of(char c, size_type pos=npos) const noexcept
ustring(size_type n, char c)
Construct a ustring from n copies of character c.
const ustring & operator=(char c)
Assign a single char to a ustring.
bool operator!=(const std::string &x) const noexcept
bool operator!=(string_view x) const noexcept
ustring substr(size_type pos=0, size_type n=npos) const
const ustring & assign(const std::string &str, size_type pos, size_type n=npos)
Assign a substring of a std::string to *this.
String-related utilities, all in namespace Strutil.
bool operator==(const std::string &x) const noexcept
friend bool operator!=(const std::string &a, const ustring &b) noexcept
const ustring & operator=(string_view str)
Assign a string_view to a ustring.
ustring(const std::string &str, size_type pos, size_type n=npos)
Construct a ustring from an indexed substring of a std::string.
constexpr const_pointer data() const noexcept
size_t hash(void) const noexcept
Return a hashed version of the string.
OIIO_UTIL_API float stof(string_view s, size_t *pos=0)
basic_string_view< char > string_view
bool empty(void) const noexcept
size_t operator()(ustring a, ustring b) const noexcept
const_iterator begin() const noexcept
CompareResults OIIO_API compare(const ImageBuf &A, const ImageBuf &B, float failthresh, float warnthresh, ROI roi={}, int nthreads=0)
size_type find_last_not_of(const char *s, size_type pos, size_type n) const
const_reverse_iterator rend() const noexcept
size_type find_last_not_of(const ustring &str, size_type pos=npos) const noexcept
size_type find(const ustring &str, size_type pos=0) const noexcept
static ustring fmtformat(const char *fmt, const Args &...args)
FMT_CONSTEXPR_CHAR_TRAITS auto compare(basic_string_view other) const -> int
const_reverse_iterator rbegin() const noexcept
ustring(const char *str, size_type pos, size_type n)
size_type find_first_of(const char *s, size_type pos=0) const
const_reference operator[](size_type pos) const noexcept
friend std::ostream & operator<<(std::ostream &out, const ustring &str)
Generic stream output of a ustring.
size_type find_first_not_of(const ustring &str, size_type pos=0) const noexcept
size_t operator()(ustring a, ustring b) const noexcept
size_type find_first_not_of(const char *s, size_type pos, size_type n) const
~ustring() noexcept
ustring destructor.
size_type rfind(const char *s, size_type pos, size_type n) const
const ustring & assign(const char *str, size_type n)
Assign the first n characters of str to *this.
size_type find(const char *s, size_type pos, size_type n) const
static ustring sprintf(const char *fmt, const Args &...args)
GLint GLint GLsizei GLint GLenum format
const ustring & assign(size_type n, char c)
Assign n copies of c to *this.
int compare(string_view str) const noexcept
ustring(const ustring &str, size_type pos, size_type n=npos)
Construct a ustring from an indexed substring of a ustring.
size_t operator()(const ustring &s) const noexcept
ustring(void) noexcept
Default ctr for ustring – make an empty string.
ustring(const char *str)
Construct a ustring from a null-terminated C string (char *).
GLboolean GLboolean GLboolean b
const ustring & assign(const ustring &str)
Assign a ustring to *this.
bool operator<(const ustring &x) const noexcept
const ustring & assign(const std::string &str)
Assign a std::string to *this.
friend bool operator==(const std::string &a, const ustring &b) noexcept
const_iterator end() const noexcept
bool operator!=(const ustring &str) const noexcept
size_type rfind(const std::string &str, size_type pos=npos) const noexcept
size_type find(const std::string &str, size_type pos=0) const noexcept
ustring(const char *str, size_type n)
Construct a ustring from the first n characters of str.
size_type find_first_not_of(const std::string &str, size_type pos=0) const noexcept
const ustring & assign(const ustring &str, size_type pos, size_type n=npos)
Assign a substring of a ustring to *this.
size_type find_last_of(const char *s, size_type pos=npos) const
size_type find_last_not_of(const std::string &str, size_type pos=npos) const noexcept
bool operator==(string_view x) const noexcept
size_type find_first_of(char c, size_type pos=0) const noexcept
size_type find_first_of(const ustring &str, size_type pos=0) const noexcept
operator std::string() const noexcept
Conversion to std::string (explicit only!).
size_type rfind(const ustring &str, size_type pos=npos) const noexcept
constexpr size_type length() const noexcept
ustring(const ustring &str) noexcept
Copy construct a ustring from another ustring.
bool iequals(ustring a, ustring b)
**If you just want to fire and args
friend bool operator==(const char *a, const ustring &b) noexcept
size_type find_last_of(const ustring &str, size_type pos=npos) const noexcept
size_type find(char c, size_type pos=0) const noexcept
int compare(const char *str) const noexcept
friend bool operator!=(const char *a, const ustring &b) noexcept
#define OIIO_FORMAT_DEPRECATED
static ustring from_unique(const char *unique)
#define OIIO_NAMESPACE_END
auto sprintf(const S &fmt, const T &...args) -> std::basic_string< Char >
size_t size(void) const noexcept
Return the number of characters in the string.
size_type find_first_not_of(const char *s, size_type pos=0) const
size_type find_last_not_of(const char *s, size_type pos=npos) const
std::string::const_reverse_iterator const_reverse_iterator
const char * data() const noexcept
Return a C string representation of a ustring.
const char * c_str() const noexcept
const std::string & string() const noexcept
Return a C++ std::string representation of a ustring.
std::string OIIO_UTIL_API concat(string_view s, string_view t)
const char * c_str() const noexcept
Return a C string representation of a ustring.
const ustring & operator=(const ustring &str)
Assign a ustring to another ustring.
friend bool operator==(string_view a, const ustring &b) noexcept
const ustring & operator=(const std::string &str)
Assign a C++ std::string to a ustring.
#define OIIO_NAMESPACE_BEGIN
size_type find_first_of(const std::string &str, size_type pos=0) const noexcept
friend int compare(const std::string &a, const ustring &b) noexcept