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

#include <UT_StringHolder.h>

+ Inheritance diagram for UT_StringHolder:

Public Types

enum  UT_StringReferenceType { REFERENCE }
 
- Public Types inherited from UT_StringRef
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_StringHolder ()
 
SYS_FORCE_INLINE UT_StringHolder (const char *str)
 Will make a copy of the provided string. More...
 
SYS_FORCE_INLINE UT_StringHolder (UT_StringReferenceType, const char *str)
 Will make a shallow reference. More...
 
SYS_FORCE_INLINE UT_StringHolder (const char *data, exint length)
 Will make a copy of the provided string. More...
 
SYS_FORCE_INLINE UT_StringHolder (const std::string &str)
 Will make a copy of the provided string. More...
 
SYS_FORCE_INLINE UT_StringHolder (UT_StringReferenceType, const std::string &str)
 This will make a shallow reference to the contents of the string. More...
 
 UT_StringHolder (const UT_WorkBuffer &str)
 Will make a copy of the provided string. More...
 
SYS_FORCE_INLINE UT_StringHolder (UT_StringReferenceType, const UT_WorkBuffer &str)
 This will make a shallow reference to the contents of the string. More...
 
SYS_FORCE_INLINE UT_StringHolder (const UT_String &str)
 Will make a copy of the provided string. More...
 
SYS_FORCE_INLINE UT_StringHolder (UT_StringReferenceType, const UT_String &str)
 This will make a shallow reference to the contents of the string. More...
 
SYS_FORCE_INLINE UT_StringHolder (const UT_StringView &sv)
 Will make a copy of the provided string. More...
 
SYS_FORCE_INLINE UT_StringHolder (UT_StringReferenceType, const UT_StringRef &ref)
 Makes a shallow reference to the contents of the UT_StringRef. More...
 
 UT_StringHolder (const UT_StringRef &ref)
 
SYS_FORCE_INLINE UT_StringHolder (const UT_StringHolder &str)
 Makes a copy of the provided string. More...
 
SYS_FORCE_INLINE UT_StringHolder (UT_StringHolder &&a) SYS_NOEXCEPT
 Move constructor. Steals the working data from the original. More...
 
SYS_FORCE_INLINE UT_StringHolderoperator= (const UT_StringHolder &s)
 Makes a bit-wise copy of the string and adjust the reference count. More...
 
SYS_FORCE_INLINE UT_StringHolderoperator= (UT_StringHolder &&s)
 
template<typename... Args>
size_t format (const char *fmt, const Args &...args)
 Format a string using the same formatting codes as UTformat. More...
 
template<typename... Args>
size_t sprintf (const char *fmt, const Args &...args)
 Format a string using the same formatting codes as UTprintf. More...
 
- Public Member Functions inherited from UT_StringRef
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 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 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 lastChar (char c, int occurance_number=1) 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 ()
 
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 ()
 

Static Public Attributes

static const UT_StringHolder theEmptyString
 

Protected Types

enum  UT_StringLiteralType { LITERAL }
 A marker enum to use this constructor. More...
 

Protected Member Functions

SYS_FORCE_INLINE UT_StringHolder (UT_StringLiteralType, const char *str, size_t length)
 

Friends

UT_StringHolder UT::Literal::operator""_sh (const char *s, std::size_t const length)
 
UT_StringHolder operator""_UTsh (const char *s, std::size_t const length)
 

Additional Inherited Members

- Static Public Member Functions inherited from UT_StringRef
static SYS_FORCE_INLINE unsigned hash_string (const char *str, exint len)
 

Detailed Description

A holder for a string, which stores the length and caches the hash value. The lifetime of the string is >= the lifetime of the UT_StringHolder.

Examples:
OPUI/OPUI_HighlightBadge.C, OPUI/OPUI_MemUsageTextBadge.C, packedshareddata/GU_PackedSharedData.C, packedshareddata/GU_PackedSharedData.h, RAY/RAY_DemoFile.h, RAY/RAY_DemoSprite.C, SOP/SOP_BouncyAgent.C, and SOP/SOP_GroupRename.C.

Definition at line 731 of file UT_StringHolder.h.

Member Enumeration Documentation

A marker enum to use this constructor.

Enumerator
LITERAL 

Definition at line 957 of file UT_StringHolder.h.

UT_StringHolder can be constructed with UT_StringHolder::REFERENCE to create a shallow reference to the const char *.

Enumerator
REFERENCE 

Definition at line 736 of file UT_StringHolder.h.

Constructor & Destructor Documentation

SYS_FORCE_INLINE UT_StringHolder::UT_StringHolder ( )
inline

Definition at line 739 of file UT_StringHolder.h.

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

Will make a copy of the provided string.

Definition at line 746 of file UT_StringHolder.h.

SYS_FORCE_INLINE UT_StringHolder::UT_StringHolder ( UT_StringReferenceType  ,
const char *  str 
)
inline

Will make a shallow reference.

Definition at line 764 of file UT_StringHolder.h.

SYS_FORCE_INLINE UT_StringHolder::UT_StringHolder ( const char *  data,
exint  length 
)
inline

Will make a copy of the provided string.

Definition at line 771 of file UT_StringHolder.h.

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

Will make a copy of the provided string.

Definition at line 790 of file UT_StringHolder.h.

SYS_FORCE_INLINE UT_StringHolder::UT_StringHolder ( UT_StringReferenceType  ,
const std::string str 
)
inline

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

Definition at line 808 of file UT_StringHolder.h.

UT_StringHolder::UT_StringHolder ( const UT_WorkBuffer str)

Will make a copy of the provided string.

SYS_FORCE_INLINE UT_StringHolder::UT_StringHolder ( UT_StringReferenceType  ,
const UT_WorkBuffer str 
)
inline

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

Definition at line 818 of file UT_StringHolder.h.

SYS_FORCE_INLINE UT_StringHolder::UT_StringHolder ( const UT_String str)
inline

Will make a copy of the provided string.

Definition at line 825 of file UT_StringHolder.h.

SYS_FORCE_INLINE UT_StringHolder::UT_StringHolder ( UT_StringReferenceType  ,
const UT_String str 
)
inline

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

Definition at line 832 of file UT_StringHolder.h.

SYS_FORCE_INLINE UT_StringHolder::UT_StringHolder ( const UT_StringView sv)
inline

Will make a copy of the provided string.

Definition at line 839 of file UT_StringHolder.h.

SYS_FORCE_INLINE UT_StringHolder::UT_StringHolder ( UT_StringReferenceType  ,
const UT_StringRef ref 
)
inline

Makes a shallow reference to the contents of the UT_StringRef.

Definition at line 855 of file UT_StringHolder.h.

UT_StringHolder::UT_StringHolder ( const UT_StringRef ref)

Makes a deep copy of the provided UT_StringRef. This constructor is not marked explicit since we often want this conversion (e.g. when inserting a UT_StringRef into a UT_StringMap, as with the const char* constructor).

SYS_FORCE_INLINE UT_StringHolder::UT_StringHolder ( const UT_StringHolder str)
inline

Makes a copy of the provided string.

Definition at line 868 of file UT_StringHolder.h.

SYS_FORCE_INLINE UT_StringHolder::UT_StringHolder ( UT_StringHolder &&  a)
inline

Move constructor. Steals the working data from the original.

Definition at line 875 of file UT_StringHolder.h.

SYS_FORCE_INLINE UT_StringHolder::UT_StringHolder ( UT_StringLiteralType  ,
const char *  str,
size_t  length 
)
inlineprotected

Only accepts string literals. Since there's no way to guarantee that a const char * argument is a string literal, we do this through the use of user-defined literal and only provide this constructor to our user-defined literal operator.

Definition at line 963 of file UT_StringHolder.h.

Member Function Documentation

template<typename... Args>
size_t UT_StringHolder::format ( const char *  fmt,
const Args &...  args 
)
inline

Format a string using the same formatting codes as UTformat.

Definition at line 906 of file UT_StringHolder.h.

SYS_FORCE_INLINE UT_StringHolder& UT_StringHolder::operator= ( const UT_StringHolder s)
inline

Makes a bit-wise copy of the string and adjust the reference count.

Definition at line 882 of file UT_StringHolder.h.

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

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

Definition at line 891 of file UT_StringHolder.h.

template<typename... Args>
size_t UT_StringHolder::sprintf ( const char *  fmt,
const Args &...  args 
)
inline

Format a string using the same formatting codes as UTprintf.

Definition at line 929 of file UT_StringHolder.h.

Friends And Related Function Documentation

UT_StringHolder operator""_UTsh ( const char *  s,
std::size_t const  length 
)
friend

A user-defined literal in the global namespace. Uglier, but allows the use of UT_StringHolder UDLs in headers.

Definition at line 1012 of file UT_StringHolder.h.

UT_StringHolder UT::Literal::operator""_sh ( const char *  s,
std::size_t const  length 
)
friend

Member Data Documentation

const UT_StringHolder UT_StringHolder::theEmptyString
static

In some functions it's nice to be able to return a const-reference to a UT_StringHolder. However, in error cases, you likely want to return an empty string. This would mean that you'd have to return a real UT_StringHolder (not a const reference). This static lets you return a reference to an empty string.

Definition at line 902 of file UT_StringHolder.h.


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