UT_String Class Reference

#include <UT_String.h>

Inheritance diagram for UT_String:

UT_DeepString

List of all members.

Public Types

enum  UT_AlwaysDeepType { ALWAYS_DEEP }

Public Member Functions

 UT_String (const char *str=0, int deepCopy=0, int len=-1)
 Construct UT_String from a C string, using shallow semantics.
 UT_String (const std::string &str)
 Construct UT_String from a std::string using ALWAYS_DEEP semantics.
 UT_String (UT_AlwaysDeepType, const char *str=0)
 Construct UT_String from a C string, using ALWAYS_DEEP semantics.
 UT_String (UT_AlwaysDeepType, const std::string &str)
 Construct UT_String from a std::string, using ALWAYS_DEEP semantics.
 UT_String (const UT_String &str)
 ~UT_String ()
void setAlwaysDeep (bool deep)
 Make a string always deep.
bool isAlwaysDeep () const
void swap (UT_String &other)
bool isHard () const
 Returns whether this string is hardened already.
char * steal (void)
void saveBinary (ostream &os) const
 Save string to binary stream.
void saveAscii (ostream &os) const
void saveAscii (UT_OStream &os) const
void save (ostream &os, bool binary) const
 Save string to stream. Saves as binary if binary is true.
void save (UT_OStream &os, bool binary) const
bool load (UT_IStream &is)
 Load string from stream. Use is.eof() to check eof status.
void clear ()
 Reset the string to the default constructor.
void append (char ch)
 Append a character.
UT_Stringoperator= (const UT_String &str)
UT_Stringoperator= (const char *str)
UT_Stringoperator= (const std::string &str)
UT_Stringoperator+= (const char *str)
UT_Stringoperator+= (const UT_String &str)
int compare (const char *str, bool case_sensitive=true) const
int compare (const UT_String &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 operator== (const char *str) const
bool operator== (const UT_String &str) const
bool operator!= (const char *str) const
bool operator!= (const UT_String &str) const
bool operator< (const char *str) const
bool operator< (const UT_String &str) const
bool operator<= (const char *str) const
bool operator<= (const UT_String &str) const
bool operator> (const char *str) const
bool operator> (const UT_String &str) const
bool operator>= (const char *str) const
bool operator>= (const UT_String &str) const
 operator const char * () const
 operator char * ()
const char * buffer () const
const char * nonNullBuffer () const
char operator() (unsigned i) const
char & operator() (unsigned i)
int toInt () const
fpreal toFloat () const
std::string toStdString () const
unsigned length (void) const
 Return length of string.
int64 getMemoryUsage () const
 Return memory usage in bytes.
char * findChar (int c) const
 Find first occurrance of character. Returns NULL upon failure.
char * lastChar (int c) const
 Find last occurance of character.
int countChar (int c) const
 Return the number of occurrences of the specified character.
int count (const char *str) const
 Count the occurrences of the string.
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) const
 Determine if string can be seen as a single floating point number.
unsigned isInteger (int skip_spaces=0) const
 Determine if string can be seen as a single integer number.
void toUpper ()
void toLower ()
const char * fileName () const
const char * fileExtension () const
 Return the extension of a file path string.
bool matchFileExtension (const char *match_extension) const
UT_String pathUpToExtension () const
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
int isstring () const
int trimSpace (bool leaveSingleSpaceBetweenWords=false)
int trimBoundingSpace ()
int strip (const char *chars)
void protectString ()
bool isQuotedString (char delimiter='\'') const
UT_String makeQuotedString (char delimiter='\'') const
UT_String makeSmartQuotedString (char default_delimiter='\'') const
void expandControlSequences ()
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)
int dosParse (char *argv[], int maxArgs)
int parse (char *argv[], int maxArgs)
int parseInPlace (char *argv[], int maxArgs)
int parse (UT_WorkArgs &argv)
int parseInPlace (UT_WorkArgs &argv)
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")
int tokenize (UT_StringArray &list, const char *separators=" \t\n")
int tokenizeInPlace (UT_StringArray &list, const char *separators=" \t\n")
void expandVariables ()
unsigned hash () const
unsigned match (const char *pattern, int caseSensitive=1) const
unsigned pathMatch (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
bool matchPattern (const UT_WorkArgs &pattern_args, bool assume_match=false) const
unsigned contains (const char *pattern, int caseSensitive=1) const
bool startsWith (const char *prefix) const
bool endsWith (const char *suffix) const
bool endsWith (const char *suffix, bool case_sensitive) const
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) const
bool patternRename (const char *match_pattern, const char *replace)
UT_Stringbase (void) const
const char * suffix (void) const
void incrementNumberedName ()
ostream & setFormat (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 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 (int i)
void utoa (int i)
void itoa_pretty (int64 val)
void timeDeltaToPrettyString (fpreal time_ms)
int sprintf (const char *fmt,...) SYS_PRINTF_CHECK_ATTRIBUTE(2
int int forceValidVariableName (const char *safechars=NULL)
bool forceAlphaNumeric ()
void getRelativePath (const char *src_fullpath, const char *dest_fullpath)
bool isAbsolutePath (bool file_path=false) const
bool collapseAbsolutePath (bool file_path=false)
bool truncateMiddle (int max_length)
void extractModifiers (UT_String &modifiers)
bool applyModifiers (const UT_String &modifiers)
bool applyNextModifier (const char *mod, bool all)
UT_String removeRange ()
void formatByteSize (exint size, int digits=2)
void harden ()
 Take shallow copy and make it deep.
void harden (const char *s, int len=-1)
 Take shallow copy and make it deep.
void hardenIfNeeded ()
 Take shallow copy and make it deep.
void hardenIfNeeded (const char *s)
 Take shallow copy and make it deep.
void adopt (char *s)
void adopt (UT_String &str)
void prepend (const char *prefix)
 Prepend a string (or character).
void prepend (char ch)
 Prepend a string (or character).
char * findChar (const char *str) const
 Find first occurrance of any character in str.
char * findChar (const UT_String &str) const
 Find first occurrance of any character in str.

Static Public Member Functions

static unsigned hash (const char *str, unsigned code=0)
static int multiMatchCheck (const char *pattern)
static int wildcardMatchCheck (const char *pattern)
static ostream & setFormat (ostream &os, const char *fmt)
static int compareNumberedString (const char *s1, const char *s2, bool case_sensitive=true)
static int qsortCmpNumberedString (const void *v1, const void *v2)
static int qsortCmpNumberedString (char *const *v1, char *const *v2)
static int compareNumberedFilename (const char *s1, const char *s2, bool case_sensitive=false)
static int qsortCmpNumberedFilename (const void *v1, const void *v2)
static int qsortCmpNumberedFilename (char *const *v1, 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, int i)
static int utoa (char *str, unsigned i)
static int findLongestCommonPathPrefix (const char *fullpath1, int len1, const char *fullpath2, int len2)
static const UT_StringgetEmptyString ()
static bool isValidModifier (const char c, bool have_subst)
static int findModifiers (const char *src)

Friends

UT_API ostream & operator<< (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:

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, DOP/DOP_GroupAndApply.C, DOP/DOP_GroupAndApply.h, field3d/f3d_io.C, field3d/GEO_Field3DTranslator.C, field3d/ROP_Field3D.C, field3d/ROP_Field3D.h, FS/FS_Background.C, FS/FS_HomeHelper.C, GEO/GEO_VoxelTranslator.C, OBJ/OBJ_WorldAlign.C, POP/POP_CircleForce.C, POP/POP_CircleForce.h, POP/POP_LocalForce.C, POP/POP_LocalForce.h, POP/POP_RadialBirth.C, POP/POP_RadialBirth.h, POP/POP_SpotLight.C, POP/POP_SpotLight.h, ROP/ROP_DopField.C, ROP/ROP_DopField.h, ROP/ROP_Dumper.C, ROP/ROP_Dumper.h, SIM/SNOW_Solver.C, SOP/MSS_BrushHairLen.C, SOP/MSS_BrushHairLen.h, SOP/MSS_CustomBrushState.C, SOP/SOP_BlindData.C, SOP/SOP_BrushHairLen.h, SOP/SOP_CopRaster.C, SOP/SOP_CopRaster.h, SOP/SOP_DetailAttrib.C, SOP/SOP_DetailAttrib.h, SOP/SOP_Flatten.C, 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_Star.h, SOP/SOP_TimeCompare.C, SOP/SOP_TimeCompare.h, standalone/geo2voxel.C, standalone/i3ddsmgen.C, VOP/VOP_CustomContext.C, VOP/VOP_CustomContext.h, VOP/VOP_Switch.C, VOP/VOP_Switch.h, VRAY/VRAY_DemoFile.h, and VRAY/VRAY_DemoSprite.C.

Definition at line 77 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 83 of file UT_String.h.


Constructor & Destructor Documentation

UT_String::UT_String ( const char *  str = 0,
int  deepCopy = 0,
int  len = -1 
)

Construct UT_String from a C string, using shallow semantics.

Parameters:
str The initial string.
deepCopy If true, a copy of str will be used.
len Number 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 "".

UT_String::UT_String ( const std::string str  )  [inline, explicit]

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

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 108 of file UT_String.h.

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 114 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 121 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.

UT_String::~UT_String (  ) 


Member Function Documentation

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 226 of file UT_String.h.

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 216 of file UT_String.h.

void UT_String::append ( char  ch  ) 

Append a character.

bool UT_String::applyModifiers ( const UT_String modifiers  ) 

loops through a modifier string created by extractModifiers

Parameters:
[in] modifiers The modifiers to apply to this string; must start with a colon
Returns:
whether any modification was performed

bool UT_String::applyNextModifier ( const char *  mod,
bool  all 
)

implements a few csh-style modifiers.

Parameters:
mod pointer to a string starting with the modifier to apply. so, to apply a global substitute modifier :gs/l/r/ mod should be: s/l/r
all True if all possible modifications should be (recursively) performed. Otherwise, at most one modification is applied.
Returns:
whether any modification was performed

UT_String* UT_String::base ( void   )  const

const char* UT_String::buffer (  )  const [inline]

Examples:
VOP/VOP_Switch.C, and VRAY/VRAY_DemoSprite.C.

Definition at line 388 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.

Definition at line 248 of file UT_String.h.

bool UT_String::collapseAbsolutePath ( bool  file_path = false  ) 

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

Definition at line 316 of file UT_String.h.

int UT_String::compare ( const char *  str,
bool  case_sensitive = true 
) const [inline]

Definition at line 302 of file UT_String.h.

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 
) [static]

static int UT_String::compareVersionString ( const char *  s1,
const char *  s2 
) [static]

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

unsigned UT_String::contains ( const char *  pattern,
int  caseSensitive = 1 
) const

int UT_String::count ( const char *  str  )  const

Count the occurrences of the string.

int UT_String::countChar ( int  c  )  const

Return the number of occurrences of the specified character.

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::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::dosParse ( char *  argv[],
int  maxArgs 
)

int UT_String::dosParse ( UT_WorkArgs argv  ) 

bool UT_String::endsWith ( const char *  suffix,
bool  case_sensitive 
) const

bool UT_String::endsWith ( const char *  suffix  )  const

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

Definition at line 325 of file UT_String.h.

bool UT_String::equal ( const char *  str,
bool  case_sensitive = true 
) const [inline]

Definition at line 321 of file UT_String.h.

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

Definition at line 896 of file UT_String.h.

int UT_String::eraseHead ( int  len  )  [inline]

Definition at line 888 of file UT_String.h.

int UT_String::eraseTail ( int  len  )  [inline]

Definition at line 892 of file UT_String.h.

int UT_String::expandArrays ( char *  names[],
int  max 
)

void UT_String::expandControlSequences (  ) 

void UT_String::expandVariables (  ) 

void UT_String::extractModifiers ( UT_String modifiers  ) 

Finds the first colon and extracts the modifier string. this string is truncated at the first colon.

Parameters:
[out] modifiers Filled with the modifier string, which is everything after the first colon.

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  )  const [inline]

Definition at line 815 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 513 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 493 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 435 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 433 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 428 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  ) 

static int UT_String::findModifiers ( const char *  src  )  [static]

will find all valid characters including modifiers and their preceding text

Returns:
: number of modifier chars found, ie, for ":ras/foo/bar", 12

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.

static const UT_String& UT_String::getEmptyString (  )  [static]

int64 UT_String::getMemoryUsage ( void   )  const [inline]

Return memory usage in bytes.

Definition at line 420 of file UT_String.h.

void UT_String::getRelativePath ( const char *  src_fullpath,
const char *  dest_fullpath 
)

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::harden (  ) 

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

Take shallow copy and make it deep.

Definition at line 173 of file UT_String.h.

void UT_String::hardenIfNeeded (  )  [inline]

Take shallow copy and make it deep.

Definition at line 163 of file UT_String.h.

static unsigned UT_String::hash ( const char *  str,
unsigned  code = 0 
) [inline, static]

Definition at line 706 of file UT_String.h.

unsigned UT_String::hash (  )  const [inline]

Definition at line 701 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 904 of file UT_String.h.

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

bool UT_String::isAlwaysDeep (  )  const [inline]

Definition at line 152 of file UT_String.h.

unsigned UT_String::isFloat ( int  skip_spaces = 0,
int  loose = 0 
) 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 183 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'.

int UT_String::isstring (  )  const [inline]

static bool UT_String::isValidModifier ( const char  c,
bool  have_subst 
) [static]

void UT_String::itoa ( int  i  ) 

static int UT_String::itoa ( char *  str,
int  i 
) [static]

void UT_String::itoa_pretty ( int64  val  ) 

char* UT_String::lastChar ( int  c  )  const [inline]

Find last occurance of character.

Definition at line 440 of file UT_String.h.

unsigned UT_String::length ( void   )  const [inline]

Return length of string.

Examples:
VOP/VOP_CustomContext.C.

Definition at line 416 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 = '\''  )  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 string that's returned is UT_String::ALWAYS_DEEP.

UT_String UT_String::makeSmartQuotedString ( char  default_delimiter = '\''  )  const

makeSmartQuotedString() will use either ' or " as the delimiter to avoid escaped quotes, using the default delimiter if it doesn't matter. The string that's returned is UT_String::ALWAYS_DEEP.

unsigned UT_String::match ( const char *  pattern,
int  caseSensitive = 1 
) 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 532 of file UT_String.h.

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 UT_StringMMPattern pattern,
bool *  explicitlyExcluded = 0,
int *  matchIndex = 0,
ut_PatternRecord *  pattern_record = NULL 
) 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 char *  pattern,
int  caseSensitive,
char  separator 
) const

static int UT_String::multiMatchCheck ( const char *  pattern  )  [static]

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,
int  maxpatterns,
char *  singles,
int &  nsingles,
char **  words,
int &  nwords,
int  case_sensitive = 1,
const char *  separators = ", " 
) const

const char* UT_String::nonNullBuffer (  )  const [inline]

Definition at line 390 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.

UT_String::operator char * (  )  [inline]

Definition at line 385 of file UT_String.h.

UT_String::operator const char * (  )  const [inline]

Definition at line 383 of file UT_String.h.

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

Reimplemented in UT_DeepString.

Definition at line 342 of file UT_String.h.

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

Reimplemented in UT_DeepString.

Definition at line 338 of file UT_String.h.

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

Definition at line 398 of file UT_String.h.

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

Definition at line 392 of file UT_String.h.

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

Definition at line 295 of file UT_String.h.

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

Definition at line 263 of file UT_String.h.

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

Reimplemented in UT_DeepString.

Definition at line 350 of file UT_String.h.

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

Reimplemented in UT_DeepString.

Definition at line 346 of file UT_String.h.

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

Reimplemented in UT_DeepString.

Definition at line 358 of file UT_String.h.

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

Reimplemented in UT_DeepString.

Definition at line 354 of file UT_String.h.

UT_String& UT_String::operator= ( const std::string str  ) 

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

Reimplemented in UT_DeepString.

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

Reimplemented in UT_DeepString.

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

Reimplemented in UT_DeepString.

Definition at line 334 of file UT_String.h.

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

Reimplemented in UT_DeepString.

Definition at line 330 of file UT_String.h.

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

Reimplemented in UT_DeepString.

Definition at line 366 of file UT_String.h.

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

Reimplemented in UT_DeepString.

Definition at line 362 of file UT_String.h.

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

Reimplemented in UT_DeepString.

Definition at line 374 of file UT_String.h.

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

Reimplemented in UT_DeepString.

Definition at line 370 of file UT_String.h.

int UT_String::parse ( UT_WorkArgs argv  )  [inline]

Definition at line 654 of file UT_String.h.

int UT_String::parse ( char *  argv[],
int  maxArgs 
) [inline]

Examples:
SOP/SOP_PrimVOP.C.

Definition at line 646 of file UT_String.h.

int UT_String::parseInPlace ( UT_WorkArgs argv  ) 

int UT_String::parseInPlace ( char *  argv[],
int  maxArgs 
)

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.

unsigned UT_String::pathMatch ( const char *  pattern,
int  caseSensitive = 1 
) const

NOTE: the regular UT_String::match algorithm is faster! Use it if you do not need the extra functionality of boost::regex's perl regex checker

pathMatch adds functionality to the regular match. It uses boost::regex to implement perl's regex syntax. In addition, the '' character is allowed. '' is equivalent to [^/]* in perl.

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::prepend ( char  ch  ) 

Prepend a string (or character).

void UT_String::prepend ( const char *  prefix  ) 

Prepend a string (or character).

void UT_String::protectString (  ) 

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.

static int UT_String::qsortCmpNumberedFilename ( char *const *  v1,
char *const *  v2 
) [static]

static int UT_String::qsortCmpNumberedFilename ( const void *  v1,
const void *  v2 
) [static]

static int UT_String::qsortCmpNumberedString ( char *const *  v1,
char *const *  v2 
) [static]

static int UT_String::qsortCmpNumberedString ( const void *  v1,
const void *  v2 
) [static]

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 
)

int UT_String::replacePrefix ( const char *  oldpref,
const char *  newpref 
)

int UT_String::replaceSuffix ( const char *  oldsuffix,
const char *  newsuffix 
)

void UT_String::save ( UT_OStream os,
bool  binary 
) const

void UT_String::save ( ostream &  os,
bool  binary 
) const

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

Examples:
SOP/SOP_BlindData.C.

void UT_String::saveAscii ( UT_OStream os  )  const [inline]

Definition at line 238 of file UT_String.h.

void UT_String::saveAscii ( 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 237 of file UT_String.h.

void UT_String::saveBinary ( ostream &  os  )  const [inline]

Save string to binary stream.

Definition at line 233 of file UT_String.h.

void UT_String::setAlwaysDeep ( bool  deep  )  [inline]

Make a string always deep.

Definition at line 136 of file UT_String.h.

ostream& UT_String::setFormat ( ostream &  os  ) 

static ostream& UT_String::setFormat ( ostream &  os,
const char *  fmt 
) [static]

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  )  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 194 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::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  ) 

void UT_String::timeDeltaToPrettyString ( fpreal  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 ( UT_StringArray list,
const char *  separators = " \t\n" 
) [inline]

Definition at line 688 of file UT_String.h.

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

Definition at line 681 of file UT_String.h.

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

Definition at line 673 of file UT_String.h.

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

Definition at line 667 of file UT_String.h.

int UT_String::tokenize ( char *  argv[],
int  maxArgs,
char  separator 
) [inline]

Examples:
standalone/i3ddsmgen.C.

Definition at line 661 of file UT_String.h.

int UT_String::tokenizeInPlace ( UT_StringArray list,
const char *  separators = " \t\n" 
)

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

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

int UT_String::tokenizeInPlace ( UT_WorkArgs argv,
char  separator 
)

int UT_String::tokenizeInPlace ( char *  argv[],
int  maxArgs,
char  separator 
)

void UT_String::toLower (  )  [inline]

Definition at line 479 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 472 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.

bool UT_String::truncateMiddle ( int  max_length  ) 

void UT_String::utoa ( int  i  ) 

static int UT_String::utoa ( char *  str,
unsigned  i 
) [static]

static int UT_String::wildcardMatchCheck ( const char *  pattern  )  [static]


Friends And Related Function Documentation

UT_API UT_OStream& operator<< ( UT_OStream os,
const UT_String d 
) [friend]

UT_API ostream& operator<< ( 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.


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

Generated on Thu Jan 31 00:33:38 2013 for HDK by  doxygen 1.5.9