HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ustring Class Reference

#include <ustring.h>

Classes

struct  TableRep
 

Public Types

typedef char value_type
 
typedef value_typepointer
 
typedef value_typereference
 
typedef const value_typeconst_reference
 
typedef size_t size_type
 
typedef std::string::const_iterator const_iterator
 
typedef
std::string::const_reverse_iterator 
const_reverse_iterator
 

Public Member Functions

 ustring (void) noexcept
 Default ctr for ustring – make an empty string. More...
 
 ustring (const char *str)
 Construct a ustring from a null-terminated C string (char *). More...
 
 ustring (string_view str)
 
 ustring (const char *str, size_type pos, size_type n)
 
 ustring (const char *str, size_type n)
 Construct a ustring from the first n characters of str. More...
 
 ustring (size_type n, char c)
 Construct a ustring from n copies of character c. More...
 
 ustring (const std::string &str, size_type pos, size_type n=npos)
 Construct a ustring from an indexed substring of a std::string. More...
 
 ustring (const ustring &str) noexcept
 Copy construct a ustring from another ustring. More...
 
 ustring (const ustring &str, size_type pos, size_type n=npos)
 Construct a ustring from an indexed substring of a ustring. More...
 
 ~ustring () noexcept
 ustring destructor. More...
 
 operator string_view () const noexcept
 Conversion to string_view. More...
 
 operator std::string () const noexcept
 Conversion to std::string (explicit only!). More...
 
const ustringassign (const ustring &str)
 Assign a ustring to *this. More...
 
const ustringassign (const ustring &str, size_type pos, size_type n=npos)
 Assign a substring of a ustring to *this. More...
 
const ustringassign (const std::string &str)
 Assign a std::string to *this. More...
 
const ustringassign (const std::string &str, size_type pos, size_type n=npos)
 Assign a substring of a std::string to *this. More...
 
const ustringassign (const char *str)
 Assign a null-terminated C string (char*) to *this. More...
 
const ustringassign (const char *str, size_type n)
 Assign the first n characters of str to *this. More...
 
const ustringassign (size_type n, char c)
 Assign n copies of c to *this. More...
 
const ustringassign (string_view str)
 Assign a string_view to *this. More...
 
const ustringoperator= (const ustring &str)
 Assign a ustring to another ustring. More...
 
const ustringoperator= (const char *str)
 Assign a null-terminated C string (char *) to a ustring. More...
 
const ustringoperator= (const std::string &str)
 Assign a C++ std::string to a ustring. More...
 
const ustringoperator= (string_view str)
 Assign a string_view to a ustring. More...
 
const ustringoperator= (char c)
 Assign a single char to a ustring. More...
 
const char * c_str () const noexcept
 Return a C string representation of a ustring. More...
 
const char * data () const noexcept
 Return a C string representation of a ustring. More...
 
const std::string & string () const noexcept
 Return a C++ std::string representation of a ustring. More...
 
void clear (void) noexcept
 Reset to an empty string. More...
 
size_t length (void) const noexcept
 Return the number of characters in the string. More...
 
size_t hash (void) const noexcept
 Return a hashed version of the string. More...
 
size_t size (void) const noexcept
 Return the number of characters in the string. More...
 
bool empty (void) const noexcept
 
const_iterator begin () const noexcept
 
const_iterator end () const noexcept
 
const_reverse_iterator rbegin () const noexcept
 
const_reverse_iterator rend () const noexcept
 
const_reference operator[] (size_type pos) const noexcept
 
size_type copy (char *s, size_type n, size_type pos=0) const
 
ustring substr (size_type pos=0, size_type n=npos) const
 
size_type find (const ustring &str, size_type pos=0) const noexcept
 
size_type find (const std::string &str, size_type pos=0) const noexcept
 
size_type find (const char *s, size_type pos, size_type n) const
 
size_type find (const char *s, size_type pos=0) const
 
size_type find (char c, size_type pos=0) const noexcept
 
size_type rfind (const ustring &str, size_type pos=npos) const noexcept
 
size_type rfind (const std::string &str, size_type pos=npos) const noexcept
 
size_type rfind (const char *s, size_type pos, size_type n) const
 
size_type rfind (const char *s, size_type pos=npos) const
 
size_type rfind (char c, size_type pos=npos) const noexcept
 
size_type find_first_of (const ustring &str, size_type pos=0) const noexcept
 
size_type find_first_of (const std::string &str, size_type pos=0) const noexcept
 
size_type find_first_of (const char *s, size_type pos, size_type n) const
 
size_type find_first_of (const char *s, size_type pos=0) const
 
size_type find_first_of (char c, size_type pos=0) const noexcept
 
size_type find_last_of (const ustring &str, size_type pos=npos) const noexcept
 
size_type find_last_of (const std::string &str, size_type pos=npos) const noexcept
 
size_type find_last_of (const char *s, size_type pos, size_type n) const
 
size_type find_last_of (const char *s, size_type pos=npos) const
 
size_type find_last_of (char c, size_type pos=npos) const noexcept
 
size_type find_first_not_of (const ustring &str, size_type pos=0) const noexcept
 
size_type find_first_not_of (const std::string &str, size_type pos=0) const noexcept
 
size_type find_first_not_of (const char *s, size_type pos, size_type n) const
 
size_type find_first_not_of (const char *s, size_type pos=0) const
 
size_type find_first_not_of (char c, size_type pos=0) const noexcept
 
size_type find_last_not_of (const ustring &str, size_type pos=npos) const noexcept
 
size_type find_last_not_of (const std::string &str, size_type pos=npos) const noexcept
 
size_type find_last_not_of (const char *s, size_type pos, size_type n) const
 
size_type find_last_not_of (const char *s, size_type pos=npos) const
 
size_type find_last_not_of (char c, size_type pos=npos) const noexcept
 
int compare (string_view str) const noexcept
 
int compare (const char *str) const noexcept
 
bool operator== (const ustring &str) const noexcept
 
bool operator!= (const ustring &str) const noexcept
 
bool operator== (const std::string &x) const noexcept
 
bool operator== (string_view x) const noexcept
 
bool operator== (const char *x) const noexcept
 Test a ustring (this) for lexicographic equality with char x. More...
 
bool operator!= (const std::string &x) const noexcept
 
bool operator!= (string_view x) const noexcept
 
bool operator!= (const char *x) const noexcept
 
bool operator< (const ustring &x) const noexcept
 

Static Public Member Functions

template<typename... Args>
static ustring sprintf (const char *fmt, const Args &...args)
 
template<typename... Args>
static ustring fmtformat (const char *fmt, const Args &...args)
 
template<typename... Args>
static OIIO_FORMAT_DEPRECATED
ustring 
format (const char *fmt, const Args &...args)
 
static ustring concat (string_view s, string_view t)
 
static std::string getstats (bool verbose=true)
 Return the statistics output as a string. More...
 
static size_t memory ()
 Return the amount of memory consumed by the ustring table. More...
 
static size_t total_ustrings ()
 Return the total number of ustrings in the internal table. More...
 
static size_t hash_collisions (std::vector< ustring > *collisions=nullptr)
 
static const char * make_unique (string_view str)
 
static bool is_unique (const char *str)
 
static ustring from_unique (const char *unique)
 

Static Public Attributes

static const size_type npos = static_cast<size_type>(-1)
 

Friends

int compare (const std::string &a, const ustring &b) noexcept
 
bool operator== (const std::string &a, const ustring &b) noexcept
 
bool operator== (string_view a, const ustring &b) noexcept
 
bool operator== (const char *a, const ustring &b) noexcept
 
bool operator!= (const std::string &a, const ustring &b) noexcept
 
bool operator!= (string_view a, const ustring &b) noexcept
 
bool operator!= (const char *a, const ustring &b) noexcept
 
std::ostream & operator<< (std::ostream &out, const ustring &str)
 Generic stream output of a ustring. More...
 

Detailed Description

A ustring is an alternative to char* or std::string for storing strings, in which the character sequence is unique (allowing many speed advantages for assignment, equality testing, and inequality testing).

The implementation is that behind the scenes there is a hash set of allocated strings, so the characters of each string are unique. A ustring itself is a pointer to the characters of one of these canonical strings. Therefore, assignment and equality testing is just a single 32- or 64-bit int operation, the only mutex is when a ustring is created from raw characters, and the only malloc is the first time each canonical ustring is created.

The internal table also contains a std::string version and the length of the string, so converting a ustring to a std::string (via ustring::string()) or querying the number of characters (via ustring::size() or ustring::length()) is extremely inexpensive, and does not involve creation/allocation of a new std::string or a call to strlen.

We try very hard to completely mimic the API of std::string, including all the constructors, comparisons, iterations, etc. Of course, the charaters of a ustring are non-modifiable, so we do not replicate any of the non-const methods of std::string. But in most other ways it looks and acts like a std::string and so most templated algorthms that would work on a "const std::string &" will also work on a ustring.

Usage guidelines:

Compared to standard strings, ustrings have several advantages:

  • Each individual ustring is very small – in fact, we guarantee that a ustring is the same size and memory layout as an ordinary char*.
  • Storage is frugal, since there is only one allocated copy of each unique character sequence, throughout the lifetime of the program.
  • Assignment from one ustring to another is just copy of the pointer; no allocation, no character copying, no reference counting.
  • Equality testing (do the strings contain the same characters) is a single operation, the comparison of the pointer.
  • Memory allocation only occurs when a new ustring is constructed from raw characters the FIRST time – subsequent constructions of the same string just finds it in the canonical string set, but doesn't need to allocate new storage. Destruction of a ustring is trivial, there is no de-allocation because the canonical version stays in the set. Also, therefore, no user code mistake can lead to memory leaks.

But there are some problems, too. Canonical strings are never freed from the table. So in some sense all the strings "leak", but they only leak one copy for each unique string that the program ever comes across. Also, creation of unique strings from raw characters is more expensive than for standard strings, due to hashing, table queries, and other overhead.

On the whole, ustrings are a really great string representation

  • if you tend to have (relatively) few unique strings, but many copies of those strings;
  • if the creation of strings from raw characters is relatively rare compared to copying or comparing to existing strings;
  • if you tend to make the same strings over and over again, and if it's relatively rare that a single unique character sequence is used only once in the entire lifetime of the program;
  • if your most common string operations are assignment and equality testing and you want them to be as fast as possible;
  • if you are doing relatively little character-by-character assembly of strings, string concatenation, or other "string manipulation" (other than equality testing).

ustrings are not so hot

  • if your program tends to have very few copies of each character sequence over the entire lifetime of the program;
  • if your program tends to generate a huge variety of unique strings over its lifetime, each of which is used only a short time and then discarded, never to be needed again;
  • if you don't need to do a lot of string assignment or equality testing, but lots of more complex string manipulation.

Definition at line 108 of file ustring.h.

Member Typedef Documentation

typedef std::string::const_iterator ustring::const_iterator

Definition at line 116 of file ustring.h.

Definition at line 113 of file ustring.h.

typedef std::string::const_reverse_iterator ustring::const_reverse_iterator

Definition at line 117 of file ustring.h.

Definition at line 111 of file ustring.h.

Definition at line 112 of file ustring.h.

typedef size_t ustring::size_type

Definition at line 114 of file ustring.h.

typedef char ustring::value_type

Definition at line 110 of file ustring.h.

Constructor & Destructor Documentation

ustring::ustring ( void  )
inlinenoexcept

Default ctr for ustring – make an empty string.

Definition at line 120 of file ustring.h.

ustring::ustring ( const char *  str)
inlineexplicit

Construct a ustring from a null-terminated C string (char *).

Definition at line 126 of file ustring.h.

ustring::ustring ( string_view  str)
inlineexplicit

Construct a ustring from a string_view, which can be auto-converted from either a null-terminated C string (char *) or a C++ std::string.

Definition at line 134 of file ustring.h.

ustring::ustring ( const char *  str,
size_type  pos,
size_type  n 
)
inline

Construct a ustring from at most n characters of str, starting at position pos.

Definition at line 141 of file ustring.h.

ustring::ustring ( const char *  str,
size_type  n 
)
inline

Construct a ustring from the first n characters of str.

Definition at line 147 of file ustring.h.

ustring::ustring ( size_type  n,
char  c 
)
inline

Construct a ustring from n copies of character c.

Definition at line 153 of file ustring.h.

ustring::ustring ( const std::string str,
size_type  pos,
size_type  n = npos 
)
inline

Construct a ustring from an indexed substring of a std::string.

Definition at line 159 of file ustring.h.

ustring::ustring ( const ustring str)
inlinenoexcept

Copy construct a ustring from another ustring.

Definition at line 167 of file ustring.h.

ustring::ustring ( const ustring str,
size_type  pos,
size_type  n = npos 
)
inline

Construct a ustring from an indexed substring of a ustring.

Definition at line 173 of file ustring.h.

ustring::~ustring ( )
inlinenoexcept

ustring destructor.

Definition at line 181 of file ustring.h.

Member Function Documentation

const ustring& ustring::assign ( const ustring str)
inline

Assign a ustring to *this.

Definition at line 193 of file ustring.h.

const ustring& ustring::assign ( const ustring str,
size_type  pos,
size_type  n = npos 
)
inline

Assign a substring of a ustring to *this.

Definition at line 200 of file ustring.h.

const ustring& ustring::assign ( const std::string str)
inline

Assign a std::string to *this.

Definition at line 207 of file ustring.h.

const ustring& ustring::assign ( const std::string str,
size_type  pos,
size_type  n = npos 
)
inline

Assign a substring of a std::string to *this.

Definition at line 214 of file ustring.h.

const ustring& ustring::assign ( const char *  str)
inline

Assign a null-terminated C string (char*) to *this.

Definition at line 222 of file ustring.h.

const ustring& ustring::assign ( const char *  str,
size_type  n 
)
inline

Assign the first n characters of str to *this.

Definition at line 229 of file ustring.h.

const ustring& ustring::assign ( size_type  n,
char  c 
)
inline

Assign n copies of c to *this.

Definition at line 236 of file ustring.h.

const ustring& ustring::assign ( string_view  str)
inline

Assign a string_view to *this.

Definition at line 243 of file ustring.h.

const_iterator ustring::begin ( void  ) const
inlinenoexcept

Return a const_iterator that references the first character of the string.

Definition at line 317 of file ustring.h.

const char* ustring::c_str ( void  ) const
inlinenoexcept

Return a C string representation of a ustring.

Definition at line 272 of file ustring.h.

void ustring::clear ( void  )
inlinenoexcept

Reset to an empty string.

Definition at line 288 of file ustring.h.

int ustring::compare ( string_view  str) const
inlinenoexcept

Return 0 if *this is lexicographically equal to str, -1 if *this is lexicographically earlier than str, 1 if *this is lexicographically after str.

Definition at line 521 of file ustring.h.

int ustring::compare ( const char *  str) const
inlinenoexcept

Return 0 if *this is lexicographically equal to str, -1 if *this is lexicographically earlier than str, 1 if *this is lexicographically after str.

Definition at line 529 of file ustring.h.

static ustring ustring::concat ( string_view  s,
string_view  t 
)
static

Concatenate two strings, returning a ustring, implemented carefully to not perform any redundant copies or allocations. This is semantically equivalent to ustring::sprintf("%s%s", s, t), but is more efficient.

size_type ustring::copy ( char *  s,
size_type  n,
size_type  pos = 0 
) const
inline

Dump into character array s the characters of this ustring, beginning with position pos and copying at most n characters.

Definition at line 341 of file ustring.h.

const char* ustring::data ( ) const
inlinenoexcept

Return a C string representation of a ustring.

Definition at line 275 of file ustring.h.

bool ustring::empty ( void  ) const
inlinenoexcept

Is the string empty – i.e., is it nullptr or does it point to an empty string?

Definition at line 313 of file ustring.h.

const_iterator ustring::end ( void  ) const
inlinenoexcept

Return a const_iterator that references the end of a traversal of the characters of the string.

Definition at line 321 of file ustring.h.

size_type ustring::find ( const ustring str,
size_type  pos = 0 
) const
inlinenoexcept

Definition at line 360 of file ustring.h.

size_type ustring::find ( const std::string str,
size_type  pos = 0 
) const
inlinenoexcept

Definition at line 365 of file ustring.h.

size_type ustring::find ( const char *  s,
size_type  pos,
size_type  n 
) const
inline

Definition at line 370 of file ustring.h.

size_type ustring::find ( const char *  s,
size_type  pos = 0 
) const
inline

Definition at line 375 of file ustring.h.

size_type ustring::find ( char  c,
size_type  pos = 0 
) const
inlinenoexcept

Definition at line 380 of file ustring.h.

size_type ustring::find_first_not_of ( const ustring str,
size_type  pos = 0 
) const
inlinenoexcept

Definition at line 464 of file ustring.h.

size_type ustring::find_first_not_of ( const std::string str,
size_type  pos = 0 
) const
inlinenoexcept

Definition at line 470 of file ustring.h.

size_type ustring::find_first_not_of ( const char *  s,
size_type  pos,
size_type  n 
) const
inline

Definition at line 476 of file ustring.h.

size_type ustring::find_first_not_of ( const char *  s,
size_type  pos = 0 
) const
inline

Definition at line 481 of file ustring.h.

size_type ustring::find_first_not_of ( char  c,
size_type  pos = 0 
) const
inlinenoexcept

Definition at line 486 of file ustring.h.

size_type ustring::find_first_of ( const ustring str,
size_type  pos = 0 
) const
inlinenoexcept

Definition at line 410 of file ustring.h.

size_type ustring::find_first_of ( const std::string str,
size_type  pos = 0 
) const
inlinenoexcept

Definition at line 416 of file ustring.h.

size_type ustring::find_first_of ( const char *  s,
size_type  pos,
size_type  n 
) const
inline

Definition at line 422 of file ustring.h.

size_type ustring::find_first_of ( const char *  s,
size_type  pos = 0 
) const
inline

Definition at line 427 of file ustring.h.

size_type ustring::find_first_of ( char  c,
size_type  pos = 0 
) const
inlinenoexcept

Definition at line 432 of file ustring.h.

size_type ustring::find_last_not_of ( const ustring str,
size_type  pos = npos 
) const
inlinenoexcept

Definition at line 491 of file ustring.h.

size_type ustring::find_last_not_of ( const std::string str,
size_type  pos = npos 
) const
inlinenoexcept

Definition at line 497 of file ustring.h.

size_type ustring::find_last_not_of ( const char *  s,
size_type  pos,
size_type  n 
) const
inline

Definition at line 503 of file ustring.h.

size_type ustring::find_last_not_of ( const char *  s,
size_type  pos = npos 
) const
inline

Definition at line 508 of file ustring.h.

size_type ustring::find_last_not_of ( char  c,
size_type  pos = npos 
) const
inlinenoexcept

Definition at line 513 of file ustring.h.

size_type ustring::find_last_of ( const ustring str,
size_type  pos = npos 
) const
inlinenoexcept

Definition at line 437 of file ustring.h.

size_type ustring::find_last_of ( const std::string str,
size_type  pos = npos 
) const
inlinenoexcept

Definition at line 443 of file ustring.h.

size_type ustring::find_last_of ( const char *  s,
size_type  pos,
size_type  n 
) const
inline

Definition at line 449 of file ustring.h.

size_type ustring::find_last_of ( const char *  s,
size_type  pos = npos 
) const
inline

Definition at line 454 of file ustring.h.

size_type ustring::find_last_of ( char  c,
size_type  pos = npos 
) const
inlinenoexcept

Definition at line 459 of file ustring.h.

template<typename... Args>
static ustring ustring::fmtformat ( const char *  fmt,
const Args &...  args 
)
inlinestatic

Construct a ustring in a fmt::format-like fashion. In other words, something like: ustring s = ustring::fmtformat("blah {} {}", (int)foo, (float)bar); The argument list is fully typesafe. The formatting of the string will always use the classic "C" locale conventions (in particular, '.' as decimal separator for float values).

Definition at line 654 of file ustring.h.

template<typename... Args>
static OIIO_FORMAT_DEPRECATED ustring ustring::format ( const char *  fmt,
const Args &...  args 
)
inlinestatic

NOTE: Semi-DEPRECATED! This will someday switch to behave like fmt::format (or future std::format) but for now, it is back compatible and equivalent to sprintf.

Definition at line 663 of file ustring.h.

static ustring ustring::from_unique ( const char *  unique)
inlinestatic

Create a ustring from characters guaranteed to already be ustring-clean, without having to run through the hash yet again. Use with extreme caution!!!

Definition at line 715 of file ustring.h.

static std::string ustring::getstats ( bool  verbose = true)
static

Return the statistics output as a string.

size_t ustring::hash ( void  ) const
inlinenoexcept

Return a hashed version of the string.

Definition at line 300 of file ustring.h.

static size_t ustring::hash_collisions ( std::vector< ustring > *  collisions = nullptr)
static

Return the total number ustrings that have the exact hash as another ustring. If collisions is passed, store all the colliding ustrings in the vector.

static bool ustring::is_unique ( const char *  str)
inlinestatic

Is this character pointer a unique ustring representation of those characters? Useful for diagnostics and debugging.

Definition at line 707 of file ustring.h.

size_t ustring::length ( void  ) const
inlinenoexcept

Return the number of characters in the string.

Definition at line 291 of file ustring.h.

static const char* ustring::make_unique ( string_view  str)
static

Given a string_view, return a pointer to the unique version kept in the internal table (creating a new table entry if we haven't seen this sequence of characters before). N.B.: this is equivalent to ustring(str).c_str(). It's also the routine that is used directly by ustring's internals to generate the canonical unique copy of the characters.

static size_t ustring::memory ( )
static

Return the amount of memory consumed by the ustring table.

ustring::operator std::string ( ) const
inlineexplicitnoexcept

Conversion to std::string (explicit only!).

Definition at line 190 of file ustring.h.

ustring::operator string_view ( ) const
inlinenoexcept

Conversion to string_view.

Definition at line 184 of file ustring.h.

bool ustring::operator!= ( const ustring str) const
inlinenoexcept

Test two ustrings for inequality – are they comprised of different sequences of characters. Note that because ustrings are unique, this is a trivial pointer comparison, not a char-by-char loop as would be the case with a char* or a std::string.

Definition at line 555 of file ustring.h.

bool ustring::operator!= ( const std::string x) const
inlinenoexcept

Test a ustring (*this) for lexicographic inequality with std::string x.

Definition at line 597 of file ustring.h.

bool ustring::operator!= ( string_view  x) const
inlinenoexcept

Test a ustring (*this) for lexicographic inequality with string_view x.

Definition at line 604 of file ustring.h.

bool ustring::operator!= ( const char *  x) const
inlinenoexcept

Test a ustring (this) for lexicographic inequality with char x.

Definition at line 608 of file ustring.h.

bool ustring::operator< ( const ustring x) const
inlinenoexcept

Test for lexicographic 'less', comes in handy for lots of STL containers and algorithms.

Definition at line 633 of file ustring.h.

const ustring& ustring::operator= ( const ustring str)
inline

Assign a ustring to another ustring.

Definition at line 250 of file ustring.h.

const ustring& ustring::operator= ( const char *  str)
inline

Assign a null-terminated C string (char *) to a ustring.

Definition at line 253 of file ustring.h.

const ustring& ustring::operator= ( const std::string str)
inline

Assign a C++ std::string to a ustring.

Definition at line 256 of file ustring.h.

const ustring& ustring::operator= ( string_view  str)
inline

Assign a string_view to a ustring.

Definition at line 259 of file ustring.h.

const ustring& ustring::operator= ( char  c)
inline

Assign a single char to a ustring.

Definition at line 262 of file ustring.h.

bool ustring::operator== ( const ustring str) const
inlinenoexcept

Test two ustrings for equality – are they comprised of the same sequence of characters. Note that because ustrings are unique, this is a trivial pointer comparison, not a char-by-char loop as would be the case with a char* or a std::string.

Definition at line 546 of file ustring.h.

bool ustring::operator== ( const std::string x) const
inlinenoexcept

Test a ustring (*this) for lexicographic equality with std::string x.

Definition at line 562 of file ustring.h.

bool ustring::operator== ( string_view  x) const
inlinenoexcept

Test a ustring (*this) for lexicographic equality with string_view x.

Definition at line 569 of file ustring.h.

bool ustring::operator== ( const char *  x) const
inlinenoexcept

Test a ustring (this) for lexicographic equality with char x.

Definition at line 572 of file ustring.h.

const_reference ustring::operator[] ( size_type  pos) const
inlinenoexcept

Return a reference to the character at the given position. Note that it's up to the caller to be sure pos is within the size of the string.

Definition at line 334 of file ustring.h.

const_reverse_iterator ustring::rbegin ( ) const
inlinenoexcept

Return a const_reverse_iterator that references the last character of the string.

Definition at line 325 of file ustring.h.

const_reverse_iterator ustring::rend ( ) const
inlinenoexcept

Return a const_reverse_iterator that references the end of a reverse traversal of the characters of the string.

Definition at line 329 of file ustring.h.

size_type ustring::rfind ( const ustring str,
size_type  pos = npos 
) const
inlinenoexcept

Definition at line 385 of file ustring.h.

size_type ustring::rfind ( const std::string str,
size_type  pos = npos 
) const
inlinenoexcept

Definition at line 390 of file ustring.h.

size_type ustring::rfind ( const char *  s,
size_type  pos,
size_type  n 
) const
inline

Definition at line 395 of file ustring.h.

size_type ustring::rfind ( const char *  s,
size_type  pos = npos 
) const
inline

Definition at line 400 of file ustring.h.

size_type ustring::rfind ( char  c,
size_type  pos = npos 
) const
inlinenoexcept

Definition at line 405 of file ustring.h.

size_t ustring::size ( void  ) const
inlinenoexcept

Return the number of characters in the string.

Definition at line 309 of file ustring.h.

template<typename... Args>
static ustring ustring::sprintf ( const char *  fmt,
const Args &...  args 
)
inlinestatic

Construct a ustring in a printf-like fashion. In other words, something like: ustring s = ustring::sprintf("blah %d %g", (int)foo, (float)bar); The argument list is fully typesafe. The formatting of the string will always use the classic "C" locale conventions (in particular, '.' as decimal separator for float values).

Definition at line 642 of file ustring.h.

const std::string& ustring::string ( void  ) const
inlinenoexcept

Return a C++ std::string representation of a ustring.

Definition at line 278 of file ustring.h.

ustring ustring::substr ( size_type  pos = 0,
size_type  n = npos 
) const
inline

Returns a substring of the ustring object consisting of n characters starting at position pos.

Definition at line 353 of file ustring.h.

static size_t ustring::total_ustrings ( )
static

Return the total number of ustrings in the internal table.

Friends And Related Function Documentation

int compare ( const std::string a,
const ustring b 
)
friend

Return 0 if a is lexicographically equal to b, -1 if a is lexicographically earlier than b, 1 if a is lexicographically after b.

Definition at line 537 of file ustring.h.

bool operator!= ( const std::string a,
const ustring b 
)
friend

Test for lexicographic inequality between std::string a and ustring b.

Definition at line 612 of file ustring.h.

bool operator!= ( string_view  a,
const ustring b 
)
friend

Test for lexicographic inequality between string_view a and ustring b.

Definition at line 619 of file ustring.h.

bool operator!= ( const char *  a,
const ustring b 
)
friend

Test for lexicographic inequality between char* a and ustring b.

Definition at line 626 of file ustring.h.

std::ostream& operator<< ( std::ostream &  out,
const ustring str 
)
friend

Generic stream output of a ustring.

Definition at line 676 of file ustring.h.

bool operator== ( const std::string a,
const ustring b 
)
friend

Test for lexicographic equality between std::string a and ustring b.

Definition at line 576 of file ustring.h.

bool operator== ( string_view  a,
const ustring b 
)
friend

Test for lexicographic equality between string_view a and ustring b.

Definition at line 583 of file ustring.h.

bool operator== ( const char *  a,
const ustring b 
)
friend

Test for lexicographic equality between char* a and ustring b.

Definition at line 590 of file ustring.h.

Member Data Documentation

const size_type ustring::npos = static_cast<size_type>(-1)
static

Definition at line 115 of file ustring.h.


The documentation for this class was generated from the following file: