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

#include <UT_String.h>

+ Inheritance diagram for UT_String:

Public Types

enum  UT_AlwaysDeepType { ALWAYS_DEEP }
 

Public Member Functions

SYS_FORCE_INLINE UT_String (const char *str=0)
 Construct UT_String from a C string, using shallow semantics. More...
 
 UT_String (const char *str, int deepCopy, int len=-1)
 
 UT_String (const std::string &str)
 Construct UT_String from a std::string, always doing a deep copy. The result will only be a UT_AlwaysDeep if the appropriate version is used, however! More...
 
 UT_String (const UT_StringHolder &str)
 Construct UT_String from a UT_StringHolder. This always duplicates and uses ALWAYS_DEEP semantics. More...
 
 UT_String (const UT_StringView &sv)
 Construct UT_String from a UT_StringView. This always duplicates and uses ALWAYS_DEEP semantics. More...
 
 UT_String (UT_AlwaysDeepType, const char *str=0)
 Construct UT_String from a C string, using ALWAYS_DEEP semantics. More...
 
 UT_String (UT_AlwaysDeepType, const std::string &str)
 Construct UT_String from a std::string, using ALWAYS_DEEP semantics. More...
 
 UT_String (const UT_String &str)
 
 ~UT_String ()
 
void setAlwaysDeep (bool deep)
 Make a string always deep. More...
 
bool isAlwaysDeep () const
 
void swap (UT_String &other)
 
bool isHard () const
 Returns whether this string is hardened already. More...
 
char * steal (void)
 
void saveBinary (std::ostream &os) const
 Save string to binary stream. More...
 
void saveAscii (std::ostream &os) const
 
void saveAscii (UT_OStream &os) const
 
void save (std::ostream &os, bool binary) const
 Save string to stream. Saves as binary if binary is true. More...
 
void save (UT_OStream &os, bool binary) const
 
bool load (UT_IStream &is)
 Load string from stream. Use is.eof() to check eof status. More...
 
void clear ()
 Reset the string to the default constructor. More...
 
void append (char ch)
 Append a character. More...
 
void append (const char *str, exint len=-1)
 Append a string or a section of a string. More...
 
void removeLast ()
 Remove the last character. More...
 
void truncate (exint len)
 Truncate the string at the Nth character. More...
 
UT_Stringoperator= (const UT_String &str)
 
UT_Stringoperator= (const char *str)
 
UT_Stringoperator= (const std::string &str)
 
UT_Stringoperator= (const UT_StringHolder &str)
 
UT_Stringoperator= (const UT_StringView &str)
 
UT_Stringoperator+= (const char *str)
 
UT_Stringoperator+= (const UT_String &str)
 
UT_Stringoperator+= (const UT_StringRef &str)
 
int compare (const char *str, bool case_sensitive=true) const
 
int compare (const UT_String &str, bool case_sensitive=true) const
 
int compare (const UT_StringRef &str, bool case_sensitive=true) const
 
bool equal (const char *str, bool case_sensitive=true) const
 
bool equal (const UT_String &str, bool case_sensitive=true) const
 
bool equal (const UT_StringRef &str, bool case_sensitive=true) const
 
bool operator== (const char *str) const
 
bool operator== (const UT_String &str) const
 
bool operator== (const UT_StringRef &str) const
 
bool operator!= (const char *str) const
 
bool operator!= (const UT_String &str) const
 
bool operator!= (const UT_StringRef &str) const
 
bool operator< (const char *str) const
 
bool operator< (const UT_String &str) const
 
bool operator< (const UT_StringRef &str) const
 
bool operator<= (const char *str) const
 
bool operator<= (const UT_String &str) const
 
bool operator<= (const UT_StringRef &str) const
 
bool operator> (const char *str) const
 
bool operator> (const UT_String &str) const
 
bool operator> (const UT_StringRef &str) const
 
bool operator>= (const char *str) const
 
bool operator>= (const UT_String &str) const
 
bool operator>= (const UT_StringRef &str) const
 
SYS_SAFE_BOOL operator bool () const
 Test whether the string is defined or not. More...
 
int distance (const char *str, bool case_sensitive=true, bool allow_subst=true) const
 
 operator const char * () const
 
 operator char * ()
 
const char * c_str () const
 
const char * buffer () const
 
const char * nonNullBuffer () const
 
char operator() (unsigned i) const
 
char & operator() (unsigned i)
 
void write (unsigned i, char c)
 
int toInt () const
 
fpreal toFloat () const
 
std::string toStdString () const
 
unsigned length (void) const
 Return length of string. More...
 
int64 getMemoryUsage (bool inclusive=true) const
 Return memory usage in bytes. More...
 
char * findChar (int c) const
 Find first occurrance of character. Returns NULL upon failure. More...
 
char * lastChar (int c) const
 Find last occurance of character. More...
 
int countChar (int c) const
 Return the number of occurrences of the specified character. More...
 
int count (const char *str, bool case_sensitive=true) const
 Count the occurrences of the string. More...
 
char * findNonSpace () const
 
const char * findWord (const char *word) const
 
bool findString (const char *str, bool fullword, bool usewildcards) const
 
int changeWord (const char *from, const char *to, int all=1)
 
int changeString (const char *from, const char *to, bool fullword)
 
int changeQuotedWord (const char *from, const char *to, int quote= '`', int all=1)
 
int findLongestCommonSuffix (const char *with)
 
int substr (UT_String &buf, int index, int len=0) const
 
unsigned isFloat (int skip_spaces=0, int loose=0, bool allow_underscore=false) 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...
 
void toUpper ()
 
void toLower ()
 
const char * fileName () const
 
const char * fileExtension () const
 Return the extension of a file path string. More...
 
bool matchFileExtension (const char *match_extension) const
 
UT_String pathUpToExtension () const
 
UT_String replaceExtension (const UT_String &new_ext) const
 Replace the file extension and return the new string. More...
 
void splitPath (UT_String &dir_name, UT_String &file_name) const
 
int parseNumberedFilename (UT_String &prefix, UT_String &frame, UT_String &suff, bool negative=true, bool fractional=false) const
 
bool isstring () const
 
int trimSpace (bool leaveSingleSpaceBetweenWords=false)
 
int trimBoundingSpace ()
 
int strip (const char *chars)
 
void protectString (bool protect_empty=false)
 
bool isQuotedString (char delimiter='\'') const
 
UT_String makeQuotedString (char delimiter='\'', bool escape_nonprinting=false) const
 
UT_String makeSmartQuotedString (char default_delimiter='\'', bool escape_nonprinting=false) const
 
void expandControlSequences (bool expand_extended=false)
 
bool hasWhiteSpace () const
 
void removeTrailingSpace ()
 
void removeTrailingChars (char chr)
 
void removeTrailingDigits ()
 
int cshParse (char *argv[], int maxArgs, void(*vlookup)(const char *, UT_String &)=UTvarLookup, void(*elookup)(const char *, UT_String &)=UTexprLookup, int *error=0, UT_StringCshIO *io=0)
 
int cshParse (UT_WorkArgs &argv, void(*vlookup)(const char *, UT_String &)=UTvarLookup, void(*elookup)(const char *, UT_String &)=UTexprLookup, int *error=0, UT_StringCshIO *io=0)
 
int dosParse (UT_WorkArgs &argv, bool preserve_backslashes=false)
 
int dosParse (char *argv[], int maxArgs, bool preserve_backslashes=false)
 
int parse (char *argv[], int maxArgs, const char *quotes="\"'", bool keep_quotes=false)
 
int parse (UT_WorkArgs &argv, int start_arg=0, const char *quotes="\"'", bool keep_quotes=false)
 
int parseInPlace (char *argv[], int maxArgs, const char *quotes="\"'", bool keep_quotes=false)
 
int parseInPlace (UT_WorkArgs &argv, int start_arg=0, const char *quotes="\"'", bool keep_quotes=false)
 
int tokenize (char *argv[], int maxArgs, char separator)
 
int tokenizeInPlace (char *argv[], int maxArgs, char separator)
 
int tokenize (UT_WorkArgs &argv, char separator)
 
int tokenizeInPlace (UT_WorkArgs &argv, char separator)
 
int tokenize (char *argv[], int maxArgs, const char *separators=" \t\n")
 
int tokenizeInPlace (char *argv[], int maxArgs, const char *separators=" \t\n")
 
int tokenize (UT_WorkArgs &argv, const char *separators=" \t\n")
 
int tokenizeInPlace (UT_WorkArgs &argv, const char *separators=" \t\n")
 
template<typename T >
int tokenize (T &list, const char *separators=" \t\n")
 
template<typename T >
int tokenizeInPlace (T &list, const char *separators=" \t\n")
 
void expandVariables ()
 
SYS_FORCE_INLINE uint32 hash () const
 
unsigned match (const char *pattern, int caseSensitive=1) const
 
unsigned matchFile (const char *pattern) const
 
unsigned matchPath (const char *pattern, int caseSensitive=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
 
unsigned multiMatchRecord (const char *pattern, int maxpatterns, char *singles, int &nsingles, char **words, int &nwords, int case_sensitive=1, const char *separators=", ") const
 
unsigned multiMatchRecord (const UT_StringMMPattern &pattern, int maxpatterns, char *singles, int &nsingles, char **words, int &nwords) const
 
unsigned multiMatchRecord (const char *pattern, UT_StringHolder &singles, UT_StringArray &words, int case_sensitive=1, const char *separators=", ") const
 
bool matchPattern (const UT_WorkArgs &pattern_args, bool assume_match=false) const
 
bool contains (const char *pattern, bool case_sensitive=true) const
 
bool startsWith (const char *prefix, bool case_sensitive=true, exint len=-1) const
 
bool endsWith (const char *suffix, bool case_sensitive=true, exint len=-1) const
 
void pluralize ()
 
int traversePattern (int max, void *data, int(*func)(int num, int sec, void *data), unsigned int(*secfunc)(int num, void *data)=0, int offset=0) const
 
const char * fcontain (const char *pattern, bool case_sensitive=true) const
 
bool patternRename (const char *match_pattern, const char *replace)
 
const char * base (UT_String &buf) const
 
const char * suffix (void) const
 
void incrementNumberedName ()
 
std::ostream & setFormat (std::ostream &os)
 
int replacePrefix (const char *oldpref, const char *newpref)
 
int replaceSuffix (const char *oldsuffix, const char *newsuffix)
 
int expandArrays (char *names[], int max)
 
int format (int cols)
 
int substitute (const char *find, const char *replacement, bool all=true)
 
int substitute (char find, char replacement, bool all=true)
 
int replace (int pos, int len, const char *str)
 
int eraseHead (int len)
 
int eraseTail (int len)
 
int erase (int pos=0, int len=-1)
 
int insert (int pos, const char *str)
 
void extractProgramName (const char *path, bool strip_extension=true, bool normalize_path=true)
 
void normalizePath ()
 
void itoa (int64 i)
 
void utoa (uint64 i)
 
void itoa_pretty (int64 val)
 
void timeDeltaToPrettyString (double time_ms)
 
int sprintf (const char *fmt,...) SYS_PRINTF_CHECK_ATTRIBUTE(2
 
int int forceValidVariableName (const char *safechars=NULL)
 
bool isValidVariableName (const char *safechars=NULL) const
 
bool forceAlphaNumeric ()
 
void getRelativePath (const char *src_fullpath, const char *dest_fullpath, bool file_path=false)
 
bool isAbsolutePath (bool file_path=false) const
 
bool collapseAbsolutePath (bool file_path=false)
 
bool truncateMiddle (int max_length)
 
bool applyCshModifiers (const char *modifiers)
 
UT_String removeRange ()
 
void formatByteSize (exint size, int digits=2)
 
int getCodePointCount () const
 
void getAsCodePoints (UT_Int32Array &cp_list) const
 Returns a list of Unicode code points from this string. More...
 
 UT_String (UT_String &&str) SYS_NOEXCEPT
 
UT_Stringoperator= (UT_String &&str)
 
void harden ()
 Take shallow copy and make it deep. More...
 
void harden (const char *s, int len=-1)
 Take shallow copy and make it deep. More...
 
void hardenIfNeeded ()
 Take shallow copy and make it deep. More...
 
void hardenIfNeeded (const char *s)
 Take shallow copy and make it deep. More...
 
void adopt (char *s)
 
void adopt (UT_String &str)
 
void adopt (UT_StringHolder &holder)
 
void prepend (const char *prefix)
 Prepend a string (or character) More...
 
void prepend (char ch)
 Prepend a string (or character) More...
 
char * findChar (const char *str) const
 Find first occurrance of any character in str. More...
 
char * findChar (const UT_String &str) const
 Find first occurrance of any character in str. More...
 

Static Public Member Functions

static int dosParse (char *buffer, UT_WorkArgs &args, bool preserve_backslashes)
 
static SYS_FORCE_INLINE uint32 hash (const char *str, uint32 code=0)
 
static int multiMatchCheck (const char *pattern)
 
static int wildcardMatchCheck (const char *pattern)
 
static std::ostream & setFormat (std::ostream &os, const char *fmt)
 
static int compareNumberedString (const char *s1, const char *s2, bool case_sensitive=true, bool allow_negatives=false)
 
static int qsortCmpNumberedString (const char *const *v1, const char *const *v2)
 
static int compareNumberedFilename (const char *s1, const char *s2, bool case_sensitive=false)
 
static int qsortCmpNumberedFilename (const char *const *v1, const char *const *v2)
 
static int compareVersionString (const char *s1, const char *s2)
 
static bool matchProgramName (const char *path, const char *expected, bool normalize_path=false)
 
static int itoa (char *str, int64 i)
 
static int utoa (char *str, uint64 i)
 
static int findLongestCommonPathPrefix (const char *fullpath1, int len1, const char *fullpath2, int len2)
 
static const UT_StringgetEmptyString ()
 
static int countCshModifiers (const char *src)
 

Friends

class UT_API UT_StringRef
 
void swap (UT_String &a, UT_String &b)
 
UT_API std::ostream & operator<< (std::ostream &os, const UT_String &d)
 
UT_API UT_OStreamoperator<< (UT_OStream &os, const UT_String &d)
 

Detailed Description

UT_String is a string class that support two different types of assignment semantics:

  • Shallow (default): Just reference the given string and NOT take ownership.
  • Deep: Make a copy of the given string, taking ownership in the process (aka it making it "hard").

If UT_String::harden() is called, or any other UT_String method that requires modifying the string, it will make a copy of its reference pointer (and take ownership) first.

Examples:
CHOP/CHOP_Spring.h, CHOP/CHOP_Stair.C, CHOP/CHOP_Stair.h, DM/DM_InfoHook.C, DM/DM_ObjectPathHook.C, DOP/DOP_GroupAndApply.C, DOP/DOP_GroupAndApply.h, expr/globalvar.C, field3d/f3d_io.C, field3d/GEO_Field3DTranslator.C, field3d/ROP_Field3D.C, field3d/ROP_Field3D.h, FS/FS_Background.C, FS/FS_HomeHelper.C, FS/FS_HomeHelper.h, GEO/GEO_VoxelTranslator.C, LOP/LOP_Sphere.C, LOP/LOP_Sphere.h, OBJ/OBJ_WorldAlign.C, OPUI/OPUI_MemUsageTextBadge.C, packedshareddata/GU_PackedSharedData.C, RAY/RAY_DemoSprite.C, ROP/ROP_Dumper.C, ROP/ROP_Dumper.h, SHOP/SHOP_Multi.C, SHOP/SHOP_Multi.h, SHOP/SHOP_POVMaterial.C, SHOP/SHOP_POVMaterial.h, SIM/SNOW_Solver.C, SOP/MSS_BrushHairLen.C, SOP/MSS_BrushHairLen.h, SOP/MSS_CustomBrushState.C, SOP/SOP_ArrayAttrib.C, SOP/SOP_ArrayAttrib.h, SOP/SOP_BlindData.C, SOP/SOP_BlindData.h, SOP/SOP_BouncyAgent.C, SOP/SOP_BouncyAgent.h, SOP/SOP_BrushHairLen.h, SOP/SOP_CopRaster.C, SOP/SOP_CopRaster.h, SOP/SOP_CustomBrush.C, SOP/SOP_CustomBrush.h, SOP/SOP_DetailAttrib.C, SOP/SOP_DetailAttrib.h, SOP/SOP_Flatten.h, SOP/SOP_GroupRename.C, SOP/SOP_GroupRename.h, SOP/SOP_HDKObject.C, SOP/SOP_HDKObject.h, SOP/SOP_PointWave.h, SOP/SOP_PrimVOP.C, SOP/SOP_PrimVOP.h, SOP/SOP_TimeCompare.C, SOP/SOP_TimeCompare.h, standalone/geo2voxel.C, standalone/i3ddsmgen.C, standalone/tiledevice.C, standalone/traverse.C, VOP/VOP_CustomContext.C, VOP/VOP_CustomContext.h, VOP/VOP_Switch.C, and VOP/VOP_Switch.h.

Definition at line 79 of file UT_String.h.

Member Enumeration Documentation

UT_String can be constructed with UT_String::ALWAYS_DEEP to create an object that will always perform deep copies when assigned to.

Enumerator
ALWAYS_DEEP 

Definition at line 85 of file UT_String.h.

Constructor & Destructor Documentation

SYS_FORCE_INLINE UT_String::UT_String ( const char *  str = 0)
inline

Construct UT_String from a C string, using shallow semantics.

Parameters
strThe initial string.
deepCopyIf true, a copy of str will be used.
lenNumber of characters to use from str. Use -1 to use the entire string. If len is non-negative, then deepCopy will be implicitly set to true. If str is NULL and len is non-negative, then it will be initialized with "".

Definition at line 97 of file UT_String.h.

UT_String::UT_String ( const char *  str,
int  deepCopy,
int  len = -1 
)
UT_String::UT_String ( const std::string str)
inlineexplicit

Construct UT_String from a std::string, always doing a deep copy. The result will only be a UT_AlwaysDeep if the appropriate version is used, however!

NOTE: You cannot do: UT_String foo; std::string bar = "hello world"; foo = UT_String(bar.substr(2, 5));

It provides an shortcut for constructing a UT_String from a function that returns a std::string by value. For example, it lets you write

UT_String str(func());

instead of

UT_String str(func().c_str(), /*harden=*/true);

Definition at line 122 of file UT_String.h.

UT_String::UT_String ( const UT_StringHolder str)
explicit

Construct UT_String from a UT_StringHolder. This always duplicates and uses ALWAYS_DEEP semantics.

UT_String::UT_String ( const UT_StringView sv)
explicit

Construct UT_String from a UT_StringView. This always duplicates and uses ALWAYS_DEEP semantics.

UT_String::UT_String ( UT_AlwaysDeepType  ,
const char *  str = 0 
)
inline

Construct UT_String from a C string, using ALWAYS_DEEP semantics.

Definition at line 144 of file UT_String.h.

UT_String::UT_String ( UT_AlwaysDeepType  ,
const std::string str 
)
inline

Construct UT_String from a std::string, using ALWAYS_DEEP semantics.

Definition at line 151 of file UT_String.h.

UT_String::UT_String ( const UT_String str)

Copy constructor

If the string we're copying from is ALWAYS_DEEP, then this object will also become ALWAYS_DEEP. This way, you can pass/return a string by value.

SYS_FORCE_INLINE UT_String::~UT_String ( )

Definition at line 1321 of file UT_String.h.

UT_String::UT_String ( UT_String &&  str)
inline

Move operators

Definition at line 167 of file UT_String.h.

Member Function Documentation

void UT_String::adopt ( char *  s)
inline

Take ownership of given string

adopt() is the opposite of steal(). Basically, you're giving the UT_String ownership of the string.

Definition at line 275 of file UT_String.h.

void UT_String::adopt ( UT_String str)
inline

Take ownership of given string

adopt() is the opposite of steal(). Basically, you're giving the UT_String ownership of the string.

Definition at line 285 of file UT_String.h.

void UT_String::adopt ( UT_StringHolder holder)

Take ownership of given string

adopt() is the opposite of steal(). Basically, you're giving the UT_String ownership of the string.

void UT_String::append ( char  ch)

Append a character.

void UT_String::append ( const char *  str,
exint  len = -1 
)

Append a string or a section of a string.

bool UT_String::applyCshModifiers ( const char *  modifiers)

Applies a "csh" style modifier string to this string. For example, a modifier string of ":e" would replace the string with the file extension of the string.

Returns true if any modifications were performed

const char* UT_String::base ( UT_String buf) const
const char* UT_String::buffer ( ) const
inline
const char* UT_String::c_str ( void  ) const
inline
Examples:
standalone/traverse.C.

Definition at line 502 of file UT_String.h.

int UT_String::changeQuotedWord ( const char *  from,
const char *  to,
int  quote = '`',
int  all = 1 
)
int UT_String::changeString ( const char *  from,
const char *  to,
bool  fullword 
)
int UT_String::changeWord ( const char *  from,
const char *  to,
int  all = 1 
)
void UT_String::clear ( void  )
inline

Reset the string to the default constructor.

Examples:
FS/FS_HomeHelper.C.

Definition at line 309 of file UT_String.h.

bool UT_String::collapseAbsolutePath ( bool  file_path = false)
int UT_String::compare ( const char *  str,
bool  case_sensitive = true 
) const
inline

Definition at line 379 of file UT_String.h.

int UT_String::compare ( const UT_String str,
bool  case_sensitive = true 
) const
inline

Definition at line 393 of file UT_String.h.

int UT_String::compare ( const UT_StringRef str,
bool  case_sensitive = true 
) const
static int UT_String::compareNumberedFilename ( const char *  s1,
const char *  s2,
bool  case_sensitive = false 
)
static
static int UT_String::compareNumberedString ( const char *  s1,
const char *  s2,
bool  case_sensitive = true,
bool  allow_negatives = false 
)
static
static int UT_String::compareVersionString ( const char *  s1,
const char *  s2 
)
static

Compare two version strings which have numbered components separated by dots. eg. "X.Y.Z". Assumes the components go from most to least significant in left to right order.

bool UT_String::contains ( const char *  pattern,
bool  case_sensitive = true 
) const
int UT_String::count ( const char *  str,
bool  case_sensitive = true 
) const

Count the occurrences of the string.

int UT_String::countChar ( int  c) const

Return the number of occurrences of the specified character.

static int UT_String::countCshModifiers ( const char *  src)
static

Count the number of valid characters in the : modifier for variable expansion. For example, the string ":r" will return 2, the string ":r:t" will return 4, the string ":z" will return 0. These use the csh expansion modifiers.

If the string doesn't start with a ':', the method will return 0.

int UT_String::cshParse ( char *  argv[],
int  maxArgs,
void(*)(const char *, UT_String &)  vlookup = UTvarLookup,
void(*)(const char *, UT_String &)  elookup = UTexprLookup,
int error = 0,
UT_StringCshIO io = 0 
)
int UT_String::cshParse ( UT_WorkArgs argv,
void(*)(const char *, UT_String &)  vlookup = UTvarLookup,
void(*)(const char *, UT_String &)  elookup = UTexprLookup,
int error = 0,
UT_StringCshIO io = 0 
)
int UT_String::distance ( const char *  str,
bool  case_sensitive = true,
bool  allow_subst = true 
) const

Return the edit distance between two strings. See http://en.wikipedia.org/wiki/Levenshtein_distance for details. allow_subst controls whether a substitution of a character with another is a single operation, rather than two operations of insert and delete.

int UT_String::dosParse ( UT_WorkArgs argv,
bool  preserve_backslashes = false 
)
int UT_String::dosParse ( char *  argv[],
int  maxArgs,
bool  preserve_backslashes = false 
)
static int UT_String::dosParse ( char *  buffer,
UT_WorkArgs args,
bool  preserve_backslashes 
)
static

Perform dos parsing modifying the buffer passed in. The args will be stored as raw pointers into the given buffer

bool UT_String::endsWith ( const char *  suffix,
bool  case_sensitive = true,
exint  len = -1 
) const
bool UT_String::equal ( const char *  str,
bool  case_sensitive = true 
) const
inline

Definition at line 399 of file UT_String.h.

bool UT_String::equal ( const UT_String str,
bool  case_sensitive = true 
) const
inline

Definition at line 403 of file UT_String.h.

bool UT_String::equal ( const UT_StringRef str,
bool  case_sensitive = true 
) const
inline

Definition at line 407 of file UT_String.h.

int UT_String::erase ( int  pos = 0,
int  len = -1 
)
inline

Definition at line 1062 of file UT_String.h.

int UT_String::eraseHead ( int  len)
inline

Definition at line 1054 of file UT_String.h.

int UT_String::eraseTail ( int  len)
inline

Definition at line 1058 of file UT_String.h.

int UT_String::expandArrays ( char *  names[],
int  max 
)
void UT_String::expandControlSequences ( bool  expand_extended = false)

Expands standard control sequences ('\n', '\r', '\t', '\0') to their corresponding ASCII values (10, 13, 9, 0, respectively). If the expand_extended flag is enabled, an extended expansion is enabled which adds hexadecimal, decimal and Unicode control sequence expansion. Any values resulting from that expansion, which are outside the standard ASCII range, will be encoded as UTF8-encoded control points.

void UT_String::expandVariables ( )
void UT_String::extractProgramName ( const char *  path,
bool  strip_extension = true,
bool  normalize_path = true 
)

Given a path, set the value of the string to the program name. For example:

str.extractProgramName(argv[0]);
str.extractProgramName("c:/Path/program.exe");
str.extractProgramName("/usr/bin/program");

This will extract the last path component. Program names may also have their extensions stripped. For example ".exe" on Windows and "-bin" to strip the Houdini wrappers on other platforms.

Note
The path should be normalized to have forward slashes as the path separator.
const char* UT_String::fcontain ( const char *  pattern,
bool  case_sensitive = true 
) const
inline

Definition at line 973 of file UT_String.h.

const char* UT_String::fileExtension ( ) const
inline

Return the extension of a file path string.

Examples:
field3d/f3d_io.C, and standalone/geo2voxel.C.

Definition at line 635 of file UT_String.h.

const char* UT_String::fileName ( ) const
inline

Return last component of forward slash separated path string

If there is a slash in the string, fileName() returns the string starting after the slash. Otherwise, it returns the contents of this string. Note that it returns a pointer into this string.

Definition at line 615 of file UT_String.h.

char* UT_String::findChar ( int  c) const
inline

Find first occurrance of character. Returns NULL upon failure.

Definition at line 550 of file UT_String.h.

char* UT_String::findChar ( const char *  str) const
inline

Find first occurrance of any character in str.

Definition at line 555 of file UT_String.h.

char* UT_String::findChar ( const UT_String str) const
inline

Find first occurrance of any character in str.

Definition at line 557 of file UT_String.h.

static int UT_String::findLongestCommonPathPrefix ( const char *  fullpath1,
int  len1,
const char *  fullpath2,
int  len2 
)
static
int UT_String::findLongestCommonSuffix ( const char *  with)
char* UT_String::findNonSpace ( ) const
bool UT_String::findString ( const char *  str,
bool  fullword,
bool  usewildcards 
) const
const char* UT_String::findWord ( const char *  word) const
bool UT_String::forceAlphaNumeric ( )
int int UT_String::forceValidVariableName ( const char *  safechars = NULL)
int UT_String::format ( int  cols)
void UT_String::formatByteSize ( exint  size,
int  digits = 2 
)

This will format a value to represent a given size in bytes, kilobytes, megabytes, etc.

Examples:
OPUI/OPUI_MemUsageTextBadge.C.
void UT_String::getAsCodePoints ( UT_Int32Array cp_list) const

Returns a list of Unicode code points from this string.

int UT_String::getCodePointCount ( ) const

Returns the number of Unicode codepoints in the string, assuming it's encoded as UTF-8.

static const UT_String& UT_String::getEmptyString ( )
static
int64 UT_String::getMemoryUsage ( bool  inclusive = true) const
inline

Return memory usage in bytes.

Definition at line 543 of file UT_String.h.

void UT_String::getRelativePath ( const char *  src_fullpath,
const char *  dest_fullpath,
bool  file_path = false 
)
Examples:
SOP/SOP_CopRaster.C.
void UT_String::harden ( const char *  s,
int  len = -1 
)

Take shallow copy and make it deep.

void UT_String::hardenIfNeeded ( )
inline

Take shallow copy and make it deep.

Definition at line 222 of file UT_String.h.

void UT_String::hardenIfNeeded ( const char *  s)
inline

Take shallow copy and make it deep.

Definition at line 232 of file UT_String.h.

SYS_FORCE_INLINE uint32 UT_String::hash ( ) const
inline

Definition at line 871 of file UT_String.h.

static SYS_FORCE_INLINE uint32 UT_String::hash ( const char *  str,
uint32  code = 0 
)
inlinestatic

Definition at line 876 of file UT_String.h.

bool UT_String::hasWhiteSpace ( ) const
void UT_String::incrementNumberedName ( )
int UT_String::insert ( int  pos,
const char *  str 
)
inline

Definition at line 1070 of file UT_String.h.

bool UT_String::isAbsolutePath ( bool  file_path = false) const
bool UT_String::isAlwaysDeep ( ) const
inline

Definition at line 204 of file UT_String.h.

unsigned UT_String::isFloat ( int  skip_spaces = 0,
int  loose = 0,
bool  allow_underscore = false 
) const

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

bool UT_String::isHard ( ) const
inline

Returns whether this string is hardened already.

Definition at line 242 of file UT_String.h.

unsigned UT_String::isInteger ( int  skip_spaces = 0) const

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

bool UT_String::isQuotedString ( char  delimiter = '\'') const

returns true if the string begins and ends with a (non-escaped) quote 'delimiter'.

bool UT_String::isValidVariableName ( const char *  safechars = NULL) const
static int UT_String::itoa ( char *  str,
int64  i 
)
static
void UT_String::itoa ( int64  i)
void UT_String::itoa_pretty ( int64  val)
char* UT_String::lastChar ( int  c) const
inline

Find last occurance of character.

Definition at line 562 of file UT_String.h.

unsigned UT_String::length ( void  ) const
inline

Return length of string.

Examples:
FS/FS_HomeHelper.C.

Definition at line 539 of file UT_String.h.

bool UT_String::load ( UT_IStream is)

Load string from stream. Use is.eof() to check eof status.

Examples:
SOP/SOP_BlindData.C.
UT_String UT_String::makeQuotedString ( char  delimiter = '\'',
bool  escape_nonprinting = false 
) const

makeQuotedString() is similar to protectString() except it returns a new string instead of changing this string, it does wrap the string in quotes, and it lets you use either ' or " as the delimiter. The quoted string can also be optionally be made to escape non-printing characters. The string that's returned is UT_String::ALWAYS_DEEP.

UT_String UT_String::makeSmartQuotedString ( char  default_delimiter = '\'',
bool  escape_nonprinting = false 
) const

makeSmartQuotedString() will use either ' or " as the delimiter to avoid escaped quotes, using the default delimiter if it doesn't matter. The quoted string can also be optionally be made to escape non-printing characters. The string that's returned is UT_String::ALWAYS_DEEP.

unsigned UT_String::match ( const char *  pattern,
int  caseSensitive = 1 
) const
unsigned UT_String::matchFile ( const char *  pattern) const
bool UT_String::matchFileExtension ( const char *  match_extension) const
inline

Return whether the file extension matches. The extension passed in should include the '.' separator. For example:

Definition at line 654 of file UT_String.h.

unsigned UT_String::matchPath ( const char *  pattern,
int  caseSensitive = 1 
) const
bool UT_String::matchPattern ( const UT_WorkArgs pattern_args,
bool  assume_match = false 
) const

matchPattern(UT_WorkArgs &) assumes that the arguments contain the components of a pattern to be matched against. The method returns true if the pattern matches, false if it doesn't. This matching process handles ^ expansion properly (and efficiently). If the string doesn't match any components of the pattern, then the assumed value is returned.

static bool UT_String::matchProgramName ( const char *  path,
const char *  expected,
bool  normalize_path = false 
)
static

Given a path, check to see whether the program name matches the expected. For example:

if (UT_String::matchProgramname(argv[0], "houdini"))
if (UT_String::matchProgramname("c:/Path/houdini.exe", "houdini"))
if (UT_String::matchProgramname("/usr/bin/houdini", "houdini"))

The matching is always case-insensitive.

Note
The path should be normalized to have forward slashes as the path separator.
unsigned UT_String::multiMatch ( const char *  pattern,
int  caseSensitive,
char  separator 
) const
unsigned UT_String::multiMatch ( const char *  pattern,
int  caseSensitive = 1,
const char *  separators = ", ",
bool *  explicitlyExcluded = 0,
int matchIndex = 0,
ut_PatternRecord *  pattern_record = NULL 
) const
unsigned UT_String::multiMatch ( const UT_StringMMPattern pattern,
bool *  explicitlyExcluded = 0,
int matchIndex = 0,
ut_PatternRecord *  pattern_record = NULL 
) const
static int UT_String::multiMatchCheck ( const char *  pattern)
static
unsigned UT_String::multiMatchRecord ( const char *  pattern,
int  maxpatterns,
char *  singles,
int nsingles,
char **  words,
int nwords,
int  case_sensitive = 1,
const char *  separators = ", " 
) const
unsigned UT_String::multiMatchRecord ( const UT_StringMMPattern pattern,
int  maxpatterns,
char *  singles,
int nsingles,
char **  words,
int nwords 
) const
unsigned UT_String::multiMatchRecord ( const char *  pattern,
UT_StringHolder singles,
UT_StringArray words,
int  case_sensitive = 1,
const char *  separators = ", " 
) const
const char* UT_String::nonNullBuffer ( ) const
inline

Definition at line 504 of file UT_String.h.

void UT_String::normalizePath ( )

Convert a path to a "normalized" path. That is, all back-slashes will be converted to forward slashes. On some operating systems, this will leave the string unchanged.

SYS_SAFE_BOOL UT_String::operator bool ( ) const
inline

Test whether the string is defined or not.

Definition at line 486 of file UT_String.h.

UT_String::operator char * ( )
inline

Definition at line 499 of file UT_String.h.

UT_String::operator const char * ( ) const
inline

Definition at line 497 of file UT_String.h.

bool UT_String::operator!= ( const char *  str) const
inline

Definition at line 424 of file UT_String.h.

bool UT_String::operator!= ( const UT_String str) const
inline

Definition at line 428 of file UT_String.h.

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

Definition at line 432 of file UT_String.h.

char UT_String::operator() ( unsigned  i) const
inline

Definition at line 506 of file UT_String.h.

char& UT_String::operator() ( unsigned  i)
inline

Definition at line 513 of file UT_String.h.

UT_String& UT_String::operator+= ( const char *  str)
inline

Definition at line 339 of file UT_String.h.

UT_String& UT_String::operator+= ( const UT_String str)
inline

Definition at line 371 of file UT_String.h.

UT_String& UT_String::operator+= ( const UT_StringRef str)
bool UT_String::operator< ( const char *  str) const
inline

Definition at line 436 of file UT_String.h.

bool UT_String::operator< ( const UT_String str) const
inline

Definition at line 440 of file UT_String.h.

bool UT_String::operator< ( const UT_StringRef str) const
inline

Definition at line 444 of file UT_String.h.

bool UT_String::operator<= ( const char *  str) const
inline

Definition at line 448 of file UT_String.h.

bool UT_String::operator<= ( const UT_String str) const
inline

Definition at line 452 of file UT_String.h.

bool UT_String::operator<= ( const UT_StringRef str) const
inline

Definition at line 456 of file UT_String.h.

UT_String& UT_String::operator= ( UT_String &&  str)
inline

Move operators

Definition at line 175 of file UT_String.h.

UT_String& UT_String::operator= ( const UT_String str)
UT_String& UT_String::operator= ( const char *  str)
UT_String& UT_String::operator= ( const std::string str)
UT_String& UT_String::operator= ( const UT_StringHolder str)
UT_String& UT_String::operator= ( const UT_StringView str)
bool UT_String::operator== ( const char *  str) const
inline

Definition at line 412 of file UT_String.h.

bool UT_String::operator== ( const UT_String str) const
inline

Definition at line 416 of file UT_String.h.

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

Definition at line 420 of file UT_String.h.

bool UT_String::operator> ( const char *  str) const
inline

Definition at line 460 of file UT_String.h.

bool UT_String::operator> ( const UT_String str) const
inline

Definition at line 464 of file UT_String.h.

bool UT_String::operator> ( const UT_StringRef str) const
inline

Definition at line 468 of file UT_String.h.

bool UT_String::operator>= ( const char *  str) const
inline

Definition at line 472 of file UT_String.h.

bool UT_String::operator>= ( const UT_String str) const
inline

Definition at line 476 of file UT_String.h.

bool UT_String::operator>= ( const UT_StringRef str) const
inline

Definition at line 480 of file UT_String.h.

int UT_String::parse ( char *  argv[],
int  maxArgs,
const char *  quotes = "\"'",
bool  keep_quotes = false 
)
inline
Examples:
SOP/SOP_PrimVOP.C.

Definition at line 790 of file UT_String.h.

int UT_String::parse ( UT_WorkArgs argv,
int  start_arg = 0,
const char *  quotes = "\"'",
bool  keep_quotes = false 
)
inline

Definition at line 796 of file UT_String.h.

int UT_String::parseInPlace ( char *  argv[],
int  maxArgs,
const char *  quotes = "\"'",
bool  keep_quotes = false 
)
int UT_String::parseInPlace ( UT_WorkArgs argv,
int  start_arg = 0,
const char *  quotes = "\"'",
bool  keep_quotes = false 
)
int UT_String::parseNumberedFilename ( UT_String prefix,
UT_String frame,
UT_String suff,
bool  negative = true,
bool  fractional = false 
) const

Decompose a filename into various parts

parseNumberedFileName will breakup a filename into its various parts: file = prefix$Fsuffix (note: suffix is not the same as file extension.) 0 is returned if there is no frame number. 'negative' allows -[frame] to be interpreted as a negative number. 'fractional' allows [frame].[number] to be interpreted as a fractional frame.

UT_String UT_String::pathUpToExtension ( ) const

Return path terminated just before the extension. If the filename starts with '.' and no path is provided, returns NULL

Examples:
field3d/f3d_io.C.
bool UT_String::patternRename ( const char *  match_pattern,
const char *  replace 
)
void UT_String::pluralize ( )

Pluralize an English noun ending (i.e. box->boxes or tube->tubes). The ending must be lower case to be processed properly.

void UT_String::prepend ( const char *  prefix)

Prepend a string (or character)

void UT_String::prepend ( char  ch)

Prepend a string (or character)

void UT_String::protectString ( bool  protect_empty = false)

protectString() will modify the existing string to escape double quotes and backslashes. It will only wrap the string in double quotes if it has spaces in it. If 'protect_empty' is true, the string will become '""', otherwise it will stay empty.

static int UT_String::qsortCmpNumberedFilename ( const char *const v1,
const char *const v2 
)
static
static int UT_String::qsortCmpNumberedString ( const char *const v1,
const char *const v2 
)
static
void UT_String::removeLast ( )
inline

Remove the last character.

Definition at line 325 of file UT_String.h.

UT_String UT_String::removeRange ( )

This will remove the range from a string of the form foo$Fbar.ext (#-#) and return the first number from the range. If there is only 1 range number, it will be returned. If there is no range, 0 is returned. The returned string is hardened.

void UT_String::removeTrailingChars ( char  chr)
void UT_String::removeTrailingDigits ( )
void UT_String::removeTrailingSpace ( )
int UT_String::replace ( int  pos,
int  len,
const char *  str 
)
UT_String UT_String::replaceExtension ( const UT_String new_ext) const

Replace the file extension and return the new string.

int UT_String::replacePrefix ( const char *  oldpref,
const char *  newpref 
)
int UT_String::replaceSuffix ( const char *  oldsuffix,
const char *  newsuffix 
)
void UT_String::save ( std::ostream &  os,
bool  binary 
) const

Save string to stream. Saves as binary if binary is true.

Examples:
SOP/SOP_BlindData.C.
void UT_String::save ( UT_OStream os,
bool  binary 
) const
void UT_String::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 298 of file UT_String.h.

void UT_String::saveAscii ( UT_OStream os) const
inline

Definition at line 299 of file UT_String.h.

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

Save string to binary stream.

Definition at line 294 of file UT_String.h.

void UT_String::setAlwaysDeep ( bool  deep)
inline

Make a string always deep.

Definition at line 188 of file UT_String.h.

static std::ostream& UT_String::setFormat ( std::ostream &  os,
const char *  fmt 
)
static
std::ostream& UT_String::setFormat ( std::ostream &  os)
void UT_String::splitPath ( UT_String dir_name,
UT_String file_name 
) const

Split a path into dir_name and file_name, where file_name is everything after the final slash (i.e. the same as fileName()). Either part may be empty. Note that if the string starts with / and only contains that one slash, the dir_name will be / and not blank. dir_name and file_name will either be set to hardened strings or an empty string.

int UT_String::sprintf ( const char *  fmt,
  ... 
)
bool UT_String::startsWith ( const char *  prefix,
bool  case_sensitive = true,
exint  len = -1 
) const
char* UT_String::steal ( void  )
inline

Give up ownership of string

Take a hard reference and make it shallow. This method makes sure it gives back something you can delete, because this UT_String is taking its hands off the data. Use it with care since it may lead to memory leaks if, for example, you harden it again later.

In the case of ALWAYS_DEEP strings, this is disallowed so it will just return a copy of the data.

Definition at line 253 of file UT_String.h.

int UT_String::strip ( const char *  chars)

strips out all characters found in 'chars'. The string length will be reduced by the number of characters removed. The number of characters removed is returned.

int UT_String::substitute ( const char *  find,
const char *  replacement,
bool  all = true 
)
int UT_String::substitute ( char  find,
char  replacement,
bool  all = true 
)
int UT_String::substr ( UT_String buf,
int  index,
int  len = 0 
) const

Perform deep copy of the substring starting from index for len characters into the specified UT_String. If len is too long, then a substring starting from index to the end of the string is copied. Returns the length of the copied substring.

const char* UT_String::suffix ( void  ) const
void UT_String::swap ( UT_String other)
inline

Definition at line 1340 of file UT_String.h.

void UT_String::timeDeltaToPrettyString ( double  time_ms)

Convert the given time delta (in milliseconds) to a reader-friendly string.

fpreal UT_String::toFloat ( ) const
int UT_String::toInt ( ) const
int UT_String::tokenize ( char *  argv[],
int  maxArgs,
char  separator 
)
inline
Examples:
FS/FS_HomeHelper.C, and standalone/i3ddsmgen.C.

Definition at line 811 of file UT_String.h.

int UT_String::tokenize ( UT_WorkArgs argv,
char  separator 
)
inline

Definition at line 817 of file UT_String.h.

int UT_String::tokenize ( char *  argv[],
int  maxArgs,
const char *  separators = " \t\n" 
)
inline

Definition at line 823 of file UT_String.h.

int UT_String::tokenize ( UT_WorkArgs argv,
const char *  separators = " \t\n" 
)
inline

Definition at line 831 of file UT_String.h.

template<typename T >
int UT_String::tokenize ( T list,
const char *  separators = " \t\n" 
)
inline

Definition at line 840 of file UT_String.h.

int UT_String::tokenizeInPlace ( char *  argv[],
int  maxArgs,
char  separator 
)
int UT_String::tokenizeInPlace ( UT_WorkArgs argv,
char  separator 
)
int UT_String::tokenizeInPlace ( char *  argv[],
int  maxArgs,
const char *  separators = " \t\n" 
)
int UT_String::tokenizeInPlace ( UT_WorkArgs argv,
const char *  separators = " \t\n" 
)
template<typename T >
int UT_String::tokenizeInPlace ( T list,
const char *  separators = " \t\n" 
)
inline

Definition at line 847 of file UT_String.h.

void UT_String::toLower ( )
inline

Definition at line 601 of file UT_String.h.

std::string UT_String::toStdString ( ) const

Converts the contents of this UT_String to a std::string. Note that std::string can't be constructed with a null pointer, so you can't just write std::string s = ut_string.buffer();

void UT_String::toUpper ( )
inline

Definition at line 594 of file UT_String.h.

int UT_String::traversePattern ( int  max,
void data,
int(*)(int num, int sec, void *data func,
unsigned int(*)(int num, void *data secfunc = 0,
int  offset = 0 
) const
int UT_String::trimBoundingSpace ( )

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

int UT_String::trimSpace ( bool  leaveSingleSpaceBetweenWords = 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. The function returns 1 if space was trimmed.

void UT_String::truncate ( exint  len)

Truncate the string at the Nth character.

bool UT_String::truncateMiddle ( int  max_length)
static int UT_String::utoa ( char *  str,
uint64  i 
)
static
void UT_String::utoa ( uint64  i)
static int UT_String::wildcardMatchCheck ( const char *  pattern)
static
void UT_String::write ( unsigned  i,
char  c 
)
inline

Definition at line 520 of file UT_String.h.

Friends And Related Function Documentation

UT_API std::ostream& operator<< ( std::ostream &  os,
const UT_String 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_String d 
)
friend
void swap ( UT_String a,
UT_String b 
)
friend

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

Definition at line 1251 of file UT_String.h.

friend class UT_API UT_StringRef
friend

Definition at line 1300 of file UT_String.h.


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