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

#include <UT_StringHolder.h>

+ Inheritance diagram for UT_StringRef:

Classes

class  Holder
 
struct  NumberedCompare
 

Public Types

enum  StorageMode { STORE_EXTERNAL, STORE_NEW, STORE_MALLOC, STORE_INLINE }
 
typedef char value_type
 
typedef const char * const_iterator
 Iterators. More...
 

Public Member Functions

SYS_FORCE_INLINE UT_StringRef ()
 
SYS_FORCE_INLINE UT_StringRef (const char *str)
 Will make a shallow reference. More...
 
SYS_FORCE_INLINE UT_StringRef (const UT_StringLit &lit)
 Construct from string literal. More...
 
SYS_FORCE_INLINE UT_StringRef (const std::string &str)
 This will make a shallow reference to the contents of the string. More...
 
 UT_StringRef (const UT_WorkBuffer &str)
 This will make a shallow reference to the contents of the string. More...
 
SYS_FORCE_INLINE UT_StringRef (const UT_String &str)
 This will make a shallow reference to the contents of the string. More...
 
SYS_FORCE_INLINE UT_StringRef (const UT_StringRef &s)
 Shares a reference with the source. More...
 
SYS_FORCE_INLINE UT_StringRef (UT_StringRef &&s) SYS_NOEXCEPT
 Move constructor. Steals the working data from the original. More...
 
SYS_FORCE_INLINE ~UT_StringRef ()
 
UT_StringRefoperator= (const UT_StringRef &s)
 Shares a reference with the source. More...
 
SYS_FORCE_INLINE UT_StringRefoperator= (UT_StringRef &&s)
 
bool operator== (const UT_StringRef &s) const
 
bool operator== (const char *s) const
 
bool operator== (const UT_String &s) const
 
bool operator!= (const UT_StringRef &s) const
 
bool operator!= (const char *s) const
 
bool operator!= (const UT_String &s) const
 
bool operator< (const UT_StringRef &k) const
 
bool operator<= (const UT_StringRef &k) const
 
bool operator> (const UT_StringRef &k) const
 
bool operator>= (const UT_StringRef &k) const
 
int compare (const UT_StringRef &str, bool ignore_case=false) const
 
bool equal (const UT_StringRef &str, bool ignore_case=false) const
 
SYS_FORCE_INLINE SYS_SAFE_BOOL operator bool () const
 Test whether the string is defined or not. More...
 
bool startsWith (const char *prefix, bool case_sense=true, exint len=-1) const
 Imported from UT_String. More...
 
bool endsWith (const char *prefix, bool case_sense=true, exint len=-1) const
 
unsigned match (const char *pattern, int caseSensitive=1) const
 
bool contains (const char *pattern, bool case_sensitive=true) const
 
unsigned multiMatch (const char *pattern, int caseSensitive, char separator) const
 
unsigned multiMatch (const char *pattern, int caseSensitive=1, const char *separators=", ", bool *explicitlyExcluded=0, int *matchIndex=0, ut_PatternRecord *pattern_record=NULL) const
 
unsigned multiMatch (const UT_StringMMPattern &pattern, bool *explicitlyExcluded=0, int *matchIndex=0, ut_PatternRecord *pattern_record=NULL) const
 
int toInt () const
 
fpreal toFloat () const
 
unsigned isFloat (int skip_spaces=0, int loose=0) const
 Determine if string can be seen as a single floating point number. More...
 
unsigned isInteger (int skip_spaces=0) const
 Determine if string can be seen as a single integer number. More...
 
SYS_FORCE_INLINE operator const char * () const
 
SYS_FORCE_INLINE const char * buffer () const
 
SYS_FORCE_INLINE const char * nonNullBuffer () const
 
SYS_FORCE_INLINE const_iterator begin () const
 
SYS_FORCE_INLINE const_iterator end () const
 
std::string toStdString () const
 
SYS_FORCE_INLINE void swap (UT_StringRef &other)
 
SYS_FORCE_INLINE bool isstring () const
 
SYS_FORCE_INLINE bool hasNonSpace () const
 
SYS_FORCE_INLINE int findChar (char c) const
 
SYS_FORCE_INLINE int findChar (const char *str) const
 
SYS_FORCE_INLINE int findChar (char c, exint start_offset) const
 
SYS_FORCE_INLINE int findChar (const char *str, exint start_offset) const
 
SYS_FORCE_INLINE int lastChar (char c, int occurance_number=1) const
 
SYS_FORCE_INLINE int countChar (char c) const
 
SYS_FORCE_INLINE void clear ()
 
SYS_FORCE_INLINE const char * c_str () const
 
exint length () const
 
bool isEmpty () const
 
unsigned hash () const
 
void reference (const char *src)
 
void fastReferenceWithStrlen (const char *src, exint length)
 
int64 getMemoryUsage (bool inclusive) const
 
UT_StringRefoperator+= (const UT_StringRef &src)
 
bool trimBoundingSpace ()
 
bool trimSpace (bool leave_single_space_between_words=false)
 
UT_StringRef toLower () const
 
void harden (const char *src)
 
void adoptFromMalloc (const char *str, exint length=-1)
 
void adoptFromNew (const char *str, exint length=-1)
 
void adoptFromString (UT_String &str)
 
char * stealAsMalloc ()
 
void saveBinary (std::ostream &os) const
 Save string to binary stream. More...
 
void saveAscii (std::ostream &os) const
 

Static Public Member Functions

static SYS_FORCE_INLINE unsigned hash_string (const char *str, exint len)
 
static bool verifyStringLit ()
 

Friends

class UT_StringHolder
 
void swap (UT_StringRef &a, UT_StringRef &b)
 Friend specialization of std::swap() to use UT_StringRef::swap() More...
 
UT_API std::ostream & operator<< (std::ostream &os, const UT_StringRef &d)
 
UT_API UT_OStreamoperator<< (UT_OStream &os, const UT_StringRef &d)
 
enum  UT_StringSentinelType { SENTINEL }
 
SYS_FORCE_INLINE UT_StringRef (UT_StringSentinelType)
 
SYS_FORCE_INLINE bool isSentinel () const
 
SYS_FORCE_INLINE void makeSentinel ()
 

Detailed Description

A holder for a string, which stores the length and caches the hash value. A UT_StringRef does not necessarily own the string, and it is therefore not safe to e.g. store a UT_StringRef in a container or member variable.

See Also
UT_StringHolder
UTmakeUnsafeRef
Examples:
packedshareddata/GU_PackedSharedData.C, and packedsphere/GU_PackedSphere.C.

Definition at line 101 of file UT_StringHolder.h.

Member Typedef Documentation

Iterators.

Definition at line 483 of file UT_StringHolder.h.

Definition at line 104 of file UT_StringHolder.h.

Member Enumeration Documentation

Enumerator
STORE_EXTERNAL 
STORE_NEW 
STORE_MALLOC 
STORE_INLINE 

Definition at line 106 of file UT_StringHolder.h.

Special sentinel value support

Enumerator
SENTINEL 

Definition at line 313 of file UT_StringHolder.h.

Constructor & Destructor Documentation

SYS_FORCE_INLINE UT_StringRef::UT_StringRef ( )
inline

Definition at line 237 of file UT_StringHolder.h.

SYS_FORCE_INLINE UT_StringRef::UT_StringRef ( const char *  str)
inline

Will make a shallow reference.

Definition at line 244 of file UT_StringHolder.h.

SYS_FORCE_INLINE UT_StringRef::UT_StringRef ( const UT_StringLit lit)
inlineexplicit

Construct from string literal.

Definition at line 255 of file UT_StringHolder.h.

SYS_FORCE_INLINE UT_StringRef::UT_StringRef ( const std::string str)
inline

This will make a shallow reference to the contents of the string.

Definition at line 262 of file UT_StringHolder.h.

UT_StringRef::UT_StringRef ( const UT_WorkBuffer str)

This will make a shallow reference to the contents of the string.

SYS_FORCE_INLINE UT_StringRef::UT_StringRef ( const UT_String str)
inline

This will make a shallow reference to the contents of the string.

Definition at line 277 of file UT_StringHolder.h.

SYS_FORCE_INLINE UT_StringRef::UT_StringRef ( const UT_StringRef s)
inline

Shares a reference with the source.

Definition at line 286 of file UT_StringHolder.h.

SYS_FORCE_INLINE UT_StringRef::UT_StringRef ( UT_StringRef &&  s)
inline

Move constructor. Steals the working data from the original.

Definition at line 297 of file UT_StringHolder.h.

SYS_FORCE_INLINE UT_StringRef::~UT_StringRef ( )
inline

Definition at line 304 of file UT_StringHolder.h.

SYS_FORCE_INLINE UT_StringRef::UT_StringRef ( UT_StringSentinelType  )
inlineexplicit

Special sentinel value support

Definition at line 316 of file UT_StringHolder.h.

Member Function Documentation

void UT_StringRef::adoptFromMalloc ( const char *  str,
exint  length = -1 
)
inline

Definition at line 791 of file UT_StringHolder.h.

void UT_StringRef::adoptFromNew ( const char *  str,
exint  length = -1 
)
inline

Definition at line 807 of file UT_StringHolder.h.

void UT_StringRef::adoptFromString ( UT_String str)
inline

Definition at line 823 of file UT_StringHolder.h.

SYS_FORCE_INLINE const_iterator UT_StringRef::begin ( void  ) const
inline

Definition at line 486 of file UT_StringHolder.h.

SYS_FORCE_INLINE const char* UT_StringRef::buffer ( ) const
inline
Examples:
SOP/SOP_BouncyAgent.C.

Definition at line 475 of file UT_StringHolder.h.

SYS_FORCE_INLINE const char* UT_StringRef::c_str ( void  ) const
inline
Examples:
RAY/RAY_DemoFile.C, and VOP/VOP_CustomContext.C.

Definition at line 628 of file UT_StringHolder.h.

SYS_FORCE_INLINE void UT_StringRef::clear ( void  )
inline

Definition at line 616 of file UT_StringHolder.h.

int UT_StringRef::compare ( const UT_StringRef str,
bool  ignore_case = false 
) const
inline

Definition at line 415 of file UT_StringHolder.h.

bool UT_StringRef::contains ( const char *  pattern,
bool  case_sensitive = true 
) const
inline

Definition at line 441 of file UT_StringHolder.h.

SYS_FORCE_INLINE int UT_StringRef::countChar ( char  c) const
inline

Definition at line 602 of file UT_StringHolder.h.

SYS_FORCE_INLINE const_iterator UT_StringRef::end ( void  ) const
inline

Definition at line 489 of file UT_StringHolder.h.

bool UT_StringRef::endsWith ( const char *  prefix,
bool  case_sense = true,
exint  len = -1 
) const
inline

Definition at line 434 of file UT_StringHolder.h.

bool UT_StringRef::equal ( const UT_StringRef str,
bool  ignore_case = false 
) const
inline

Definition at line 420 of file UT_StringHolder.h.

void UT_StringRef::fastReferenceWithStrlen ( const char *  src,
exint  length 
)
inline

Fast reference that takes the length of the string. This is NOT a string view, the string must actually null terminate at the given length or later functions will be confused.

Definition at line 722 of file UT_StringHolder.h.

SYS_FORCE_INLINE int UT_StringRef::findChar ( char  c) const
inline

Definition at line 528 of file UT_StringHolder.h.

SYS_FORCE_INLINE int UT_StringRef::findChar ( const char *  str) const
inline

Definition at line 538 of file UT_StringHolder.h.

SYS_FORCE_INLINE int UT_StringRef::findChar ( char  c,
exint  start_offset 
) const
inline

Definition at line 556 of file UT_StringHolder.h.

SYS_FORCE_INLINE int UT_StringRef::findChar ( const char *  str,
exint  start_offset 
) const
inline

Definition at line 566 of file UT_StringHolder.h.

int64 UT_StringRef::getMemoryUsage ( bool  inclusive) const
inline

Definition at line 751 of file UT_StringHolder.h.

void UT_StringRef::harden ( const char *  src)

Often people reflexively use this from UT_String days to this increases code compataibility.

unsigned UT_StringRef::hash ( ) const
inline

Definition at line 671 of file UT_StringHolder.h.

static SYS_FORCE_INLINE unsigned UT_StringRef::hash_string ( const char *  str,
exint  len 
)
inlinestatic

Definition at line 764 of file UT_StringHolder.h.

SYS_FORCE_INLINE bool UT_StringRef::hasNonSpace ( ) const
inline

Definition at line 518 of file UT_StringHolder.h.

bool UT_StringRef::isEmpty ( ) const
inline

Definition at line 666 of file UT_StringHolder.h.

unsigned UT_StringRef::isFloat ( int  skip_spaces = 0,
int  loose = 0 
) const
inline

Determine if string can be seen as a single floating point number.

Definition at line 464 of file UT_StringHolder.h.

unsigned UT_StringRef::isInteger ( int  skip_spaces = 0) const
inline

Determine if string can be seen as a single integer number.

Definition at line 467 of file UT_StringHolder.h.

SYS_FORCE_INLINE bool UT_StringRef::isSentinel ( ) const
inline

Special sentinel value support

Definition at line 324 of file UT_StringHolder.h.

SYS_FORCE_INLINE bool UT_StringRef::isstring ( ) const
inline
Examples:
RAY/RAY_DemoFile.C, and RAY/RAY_DemoSprite.C.

Definition at line 510 of file UT_StringHolder.h.

SYS_FORCE_INLINE int UT_StringRef::lastChar ( char  c,
int  occurance_number = 1 
) const
inline

Definition at line 584 of file UT_StringHolder.h.

exint UT_StringRef::length ( void  ) const
inline
Examples:
VOP/VOP_CustomContext.C.

Definition at line 649 of file UT_StringHolder.h.

SYS_FORCE_INLINE void UT_StringRef::makeSentinel ( )
inline

Special sentinel value support

Definition at line 330 of file UT_StringHolder.h.

unsigned UT_StringRef::match ( const char *  pattern,
int  caseSensitive = 1 
) const
inline

Definition at line 439 of file UT_StringHolder.h.

unsigned UT_StringRef::multiMatch ( const char *  pattern,
int  caseSensitive,
char  separator 
) const
inline

Definition at line 443 of file UT_StringHolder.h.

unsigned UT_StringRef::multiMatch ( const char *  pattern,
int  caseSensitive = 1,
const char *  separators = ", ",
bool *  explicitlyExcluded = 0,
int matchIndex = 0,
ut_PatternRecord *  pattern_record = NULL 
) const
inline

Definition at line 446 of file UT_StringHolder.h.

unsigned UT_StringRef::multiMatch ( const UT_StringMMPattern pattern,
bool *  explicitlyExcluded = 0,
int matchIndex = 0,
ut_PatternRecord *  pattern_record = NULL 
) const
inline

Definition at line 452 of file UT_StringHolder.h.

SYS_FORCE_INLINE const char* UT_StringRef::nonNullBuffer ( ) const
inline

Definition at line 479 of file UT_StringHolder.h.

SYS_FORCE_INLINE SYS_SAFE_BOOL UT_StringRef::operator bool ( ) const
inline

Test whether the string is defined or not.

Definition at line 426 of file UT_StringHolder.h.

SYS_FORCE_INLINE UT_StringRef::operator const char * ( ) const
inline

Definition at line 471 of file UT_StringHolder.h.

bool UT_StringRef::operator!= ( const UT_StringRef s) const
inline

Definition at line 400 of file UT_StringHolder.h.

bool UT_StringRef::operator!= ( const char *  s) const
inline

Definition at line 402 of file UT_StringHolder.h.

bool UT_StringRef::operator!= ( const UT_String s) const
inline

Definition at line 404 of file UT_StringHolder.h.

UT_StringRef& UT_StringRef::operator+= ( const UT_StringRef src)
bool UT_StringRef::operator< ( const UT_StringRef k) const
inline

Definition at line 407 of file UT_StringHolder.h.

bool UT_StringRef::operator<= ( const UT_StringRef k) const
inline

Definition at line 409 of file UT_StringHolder.h.

UT_StringRef& UT_StringRef::operator= ( const UT_StringRef s)
inline

Shares a reference with the source.

Definition at line 342 of file UT_StringHolder.h.

SYS_FORCE_INLINE UT_StringRef& UT_StringRef::operator= ( UT_StringRef &&  s)
inline

Move the contents of about-to-be-destructed string s to this string.

Definition at line 359 of file UT_StringHolder.h.

bool UT_StringRef::operator== ( const UT_StringRef s) const
inline

Definition at line 366 of file UT_StringHolder.h.

bool UT_StringRef::operator== ( const char *  s) const
inline

Definition at line 382 of file UT_StringHolder.h.

bool UT_StringRef::operator== ( const UT_String s) const
inline

Definition at line 397 of file UT_StringHolder.h.

bool UT_StringRef::operator> ( const UT_StringRef k) const
inline

Definition at line 411 of file UT_StringHolder.h.

bool UT_StringRef::operator>= ( const UT_StringRef k) const
inline

Definition at line 413 of file UT_StringHolder.h.

void UT_StringRef::reference ( const char *  src)
inline

Make a light weight reference to the source. Caller must make sure src lives for the duration of this object, and any objects value copied from this!

Definition at line 692 of file UT_StringHolder.h.

void UT_StringRef::saveAscii ( std::ostream &  os) const
inline

Save string to ASCII stream. This will add double quotes and escape to the stream if necessary (empty string or contains spaces).

Definition at line 874 of file UT_StringHolder.h.

void UT_StringRef::saveBinary ( std::ostream &  os) const
inline

Save string to binary stream.

Definition at line 869 of file UT_StringHolder.h.

bool UT_StringRef::startsWith ( const char *  prefix,
bool  case_sense = true,
exint  len = -1 
) const
inline

Imported from UT_String.

Definition at line 429 of file UT_StringHolder.h.

char* UT_StringRef::stealAsMalloc ( )
SYS_FORCE_INLINE void UT_StringRef::swap ( UT_StringRef other)
inline

Definition at line 499 of file UT_StringHolder.h.

fpreal UT_StringRef::toFloat ( ) const
inline

Definition at line 460 of file UT_StringHolder.h.

int UT_StringRef::toInt ( ) const
inline

Definition at line 458 of file UT_StringHolder.h.

UT_StringRef UT_StringRef::toLower ( ) const

Convert to lower case. If the string is already lower case, the string itself is returned.

std::string UT_StringRef::toStdString ( ) const
inline

Converts the contents of this UT_String to a std::string. Since we are never null this is easy

Definition at line 495 of file UT_StringHolder.h.

bool UT_StringRef::trimBoundingSpace ( )

A version of trimSpace() that only removes leading and following spaces from a string, leaving any between words intact.

bool UT_StringRef::trimSpace ( bool  leave_single_space_between_words = false)

trimSpace() will remove all space characters (leading and following) from a string. If the string consists of multiple words, the words will be collapsed. To keep a single space between words, pass in true. The function returns true if space was trimmed.

static bool UT_StringRef::verifyStringLit ( )
static

Friends And Related Function Documentation

UT_API std::ostream& operator<< ( std::ostream &  os,
const UT_StringRef d 
)
friend

This operator saves the string to the stream via the string's saveAscii() method, protecting any whitespace (by adding quotes), backslashes or quotes in the string.

UT_API UT_OStream& operator<< ( UT_OStream os,
const UT_StringRef d 
)
friend
void swap ( UT_StringRef a,
UT_StringRef b 
)
friend

Friend specialization of std::swap() to use UT_StringRef::swap()

Definition at line 507 of file UT_StringHolder.h.

friend class UT_StringHolder
friend

Definition at line 918 of file UT_StringHolder.h.

Member Data Documentation

const void* UT_StringRef::myData

Definition at line 902 of file UT_StringHolder.h.

const char* UT_StringRef::myDataIfChars

Definition at line 903 of file UT_StringHolder.h.

Holder* UT_StringRef::myDataIfHolder

Definition at line 904 of file UT_StringHolder.h.


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