HDK
|
#include <UT_String.h>
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, bool deep_copy, 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 | 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_String & | operator= (const UT_String &str) |
UT_String & | operator= (const char *str) |
UT_String & | operator= (const std::string &str) |
UT_String & | operator= (const UT_StringHolder &str) |
UT_String & | operator= (const UT_StringView &str) |
UT_String & | operator+= (const char *str) |
UT_String & | operator+= (const UT_String &str) |
UT_String & | operator+= (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 * () | |
operator UT_StringView () const | |
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 () const |
Return length of string. More... | |
int64 | getMemoryUsage (bool inclusive=true) const |
Return memory usage in bytes. 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 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, bool all=true) |
int | changeString (const char *from, const char *to, bool fullword) |
int | changeQuotedWord (const char *from, const char *to, int quote= '`', bool all=true) |
int | findLongestCommonSuffix (const char *with) const |
int | substr (UT_String &buf, int index, int len=0) const |
bool | isFloat (bool skip_spaces=false, bool loose=false, bool allow_underscore=false) const |
Determine if string can be seen as a single floating point number. More... | |
bool | isInteger (bool skip_spaces=false) const |
Determine if string can be seen as a single integer number. More... | |
void | toUpper () |
void | toLower () |
const char * | fileName () const |
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 leave_single_space_between_words=false) |
int | trimBoundingSpace () |
int | strip (const char *chars) |
void | protectString (bool protect_empty=false) |
void | protectPreQuotePythonStringLiteral (char delimiter='\'') |
protectPreQuotePythonStringLiteral() will modify the existing string More... | |
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 max_args, 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 max_args, bool preserve_backslashes=false) |
int | parse (char *argv[], int max_args, 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 max_args, 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 max_args, char separator) |
int | tokenizeInPlace (char *argv[], int max_args, char separator) |
int | tokenize (UT_WorkArgs &argv, char separator) |
int | tokenizeInPlace (UT_WorkArgs &argv, char separator) |
int | tokenize (char *argv[], int max_args, const char *separators=" \t\n") |
int | tokenizeInPlace (char *argv[], int max_args, 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 |
bool | match (const char *pattern, bool case_sensitive=true) const |
bool | matchFile (const char *pattern) const |
bool | matchPath (const char *pattern, bool case_sensitive=true, bool *excludes_branch=nullptr) const |
bool | multiMatch (const char *pattern, bool case_sensitive, char separator) const |
bool | multiMatch (const char *pattern, bool case_sensitive=true, const char *separators=", ", bool *explicitly_excluded=0, int *match_index=0, ut_PatternRecord *pattern_record=NULL) const |
bool | multiMatch (const UT_StringMMPattern &pattern, bool *explicitly_excluded=0, int *match_index=0, ut_PatternRecord *pattern_record=NULL) const |
bool | multiMatchRecord (const char *pattern, int maxpatterns, char *singles, int &nsingles, char **words, int &nwords, bool case_sensitive=true, const char *separators=", ") const |
bool | multiMatchRecord (const UT_StringMMPattern &pattern, int maxpatterns, char *singles, int &nsingles, char **words, int &nwords) const |
bool | multiMatchRecord (const char *pattern, UT_StringHolder &singles, UT_StringArray &words, bool case_sensitive=true, 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 UT_StringView &prefix, bool case_sensitive=true) const |
bool | endsWith (const UT_StringView &suffix, bool case_sensitive=true) 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 () const |
void | incrementNumberedName (bool preserve_padding=false) |
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 | itoaPretty (int64 val) |
void | timeDeltaToPrettyString (double time_ms) |
void | timeDeltaToPrettyStringMS (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... | |
int | expandArrays (UT_WorkArgs &tokens, UT_WorkArgs &names) |
UT_String (UT_String &&str) noexcept | |
UT_String & | operator= (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 (int c) |
const char * | findChar (int c) const |
char * | findChar (const char *str) |
const char * | findChar (const char *str) const |
char * | lastChar (int c) |
const char * | lastChar (int c) const |
char * | fileExtension () |
const char * | fileExtension () const |
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 bool | multiMatchCheck (const char *pattern) |
static bool | 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_String & | getEmptyString () |
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_OStream & | operator<< (UT_OStream &os, const UT_String &d) |
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.
Definition at line 79 of file UT_String.h.
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.
|
inline |
Construct UT_String from a C string, using shallow semantics.
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 "". |
Definition at line 97 of file UT_String.h.
|
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
instead of
Definition at line 122 of file UT_String.h.
|
explicit |
Construct UT_String from a UT_StringHolder. This always duplicates and uses ALWAYS_DEEP semantics.
|
explicit |
Construct UT_String from a UT_StringView. This always duplicates and uses ALWAYS_DEEP semantics.
|
inline |
Construct UT_String from a C string, using ALWAYS_DEEP semantics.
Definition at line 144 of file UT_String.h.
|
inline |
Construct UT_String from a std::string, using ALWAYS_DEEP semantics.
Definition at line 151 of file UT_String.h.
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 1417 of file UT_String.h.
|
inlinenoexcept |
Move operators
Definition at line 167 of file UT_String.h.
|
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.
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 | ) |
void UT_String::append | ( | char | ch | ) |
Append a character.
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
|
inline |
Definition at line 506 of file UT_String.h.
Definition at line 505 of file UT_String.h.
int UT_String::changeQuotedWord | ( | const char * | from, |
const char * | to, | ||
int | quote = '`' , |
||
bool | all = true |
||
) |
Reset the string to the default constructor.
Definition at line 309 of file UT_String.h.
bool UT_String::collapseAbsolutePath | ( | bool | file_path = false | ) |
Definition at line 379 of file UT_String.h.
Definition at line 393 of file UT_String.h.
int UT_String::compare | ( | const UT_StringRef & | str, |
bool | case_sensitive = true |
||
) | const |
|
static |
|
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 |
Count the occurrences of the string.
Return the number of occurrences of the specified character.
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 | max_args, | ||
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 |
||
) |
|
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 UT_StringView & | suffix, |
bool | case_sensitive = true |
||
) | const |
|
inline |
Definition at line 399 of file UT_String.h.
Definition at line 403 of file UT_String.h.
|
inline |
Definition at line 407 of file UT_String.h.
Definition at line 1092 of file UT_String.h.
Definition at line 1084 of file UT_String.h.
Definition at line 1088 of file UT_String.h.
int UT_String::expandArrays | ( | UT_WorkArgs & | tokens, |
UT_WorkArgs & | names | ||
) |
expandArrays will expand a series of tokens of the form prefix[pattern]suffix into the names UT_WorkArgs
tokens | is will store the parsed tokens without expansion |
names | is will store the parsed tokens with expansion This doesn't need a max argument like: int 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:
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.
Definition at line 999 of file UT_String.h.
|
inline |
Return the extension of a file path string
Definition at line 650 of file UT_String.h.
|
inline |
Return the extension of a file path string
Definition at line 665 of file UT_String.h.
|
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 629 of file UT_String.h.
|
inline |
Find first occurrance of character. Returns NULL upon failure.
Definition at line 554 of file UT_String.h.
Find first occurrance of character. Returns NULL upon failure.
Definition at line 556 of file UT_String.h.
|
inline |
Find first occurrance of any character in str
Definition at line 562 of file UT_String.h.
Find first occurrance of any character in str
Definition at line 564 of file UT_String.h.
|
static |
char* UT_String::findNonSpace | ( | ) |
const char* UT_String::findNonSpace | ( | ) | const |
bool UT_String::findString | ( | const char * | str, |
bool | fullword, | ||
bool | usewildcards | ||
) | const |
bool UT_String::forceAlphaNumeric | ( | ) |
This will format a value to represent a given size in bytes, kilobytes, megabytes, etc.
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.
|
inline |
Return memory usage in bytes.
Definition at line 546 of file UT_String.h.
void UT_String::getRelativePath | ( | const char * | src_fullpath, |
const char * | dest_fullpath, | ||
bool | file_path = false |
||
) |
|
inline |
Take shallow copy and make it deep.
Definition at line 213 of file UT_String.h.
|
inline |
Take shallow copy and make it deep.
Definition at line 222 of file UT_String.h.
Take shallow copy and make it deep.
Definition at line 232 of file UT_String.h.
|
inline |
Definition at line 898 of file UT_String.h.
|
inlinestatic |
Definition at line 903 of file UT_String.h.
bool UT_String::hasWhiteSpace | ( | ) | const |
void UT_String::incrementNumberedName | ( | bool | preserve_padding = false | ) |
Definition at line 1100 of file UT_String.h.
bool UT_String::isAbsolutePath | ( | bool | file_path = false | ) | const |
|
inline |
Definition at line 204 of file UT_String.h.
bool UT_String::isFloat | ( | bool | skip_spaces = false , |
bool | loose = false , |
||
bool | allow_underscore = false |
||
) | const |
Determine if string can be seen as a single floating point number.
|
inline |
Returns whether this string is hardened already.
Definition at line 242 of file UT_String.h.
bool UT_String::isInteger | ( | bool | skip_spaces = false | ) | 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'.
|
inline |
Definition at line 710 of file UT_String.h.
bool UT_String::isValidVariableName | ( | const char * | safechars = NULL | ) | const |
|
inline |
Find last occurance of character
Definition at line 570 of file UT_String.h.
Find last occurance of character
Definition at line 572 of file UT_String.h.
|
inline |
bool UT_String::load | ( | UT_IStream & | is | ) |
Load string from stream. Use is.eof() to check eof status.
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.
bool UT_String::match | ( | const char * | pattern, |
bool | case_sensitive = true |
||
) | const |
bool UT_String::matchFile | ( | const char * | pattern | ) | const |
|
inline |
Return whether the file extension matches. The extension passed in should include the '.' separator. For example:
Definition at line 675 of file UT_String.h.
bool UT_String::matchPath | ( | const char * | pattern, |
bool | case_sensitive = true , |
||
bool * | excludes_branch = nullptr |
||
) | 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 |
Given a path, check to see whether the program name matches the expected. For example:
The matching is always case-insensitive.
bool UT_String::multiMatch | ( | const char * | pattern, |
bool | case_sensitive, | ||
char | separator | ||
) | const |
bool UT_String::multiMatch | ( | const char * | pattern, |
bool | case_sensitive = true , |
||
const char * | separators = ", " , |
||
bool * | explicitly_excluded = 0 , |
||
int * | match_index = 0 , |
||
ut_PatternRecord * | pattern_record = NULL |
||
) | const |
bool UT_String::multiMatch | ( | const UT_StringMMPattern & | pattern, |
bool * | explicitly_excluded = 0 , |
||
int * | match_index = 0 , |
||
ut_PatternRecord * | pattern_record = NULL |
||
) | const |
|
static |
bool UT_String::multiMatchRecord | ( | const char * | pattern, |
int | maxpatterns, | ||
char * | singles, | ||
int & | nsingles, | ||
char ** | words, | ||
int & | nwords, | ||
bool | case_sensitive = true , |
||
const char * | separators = ", " |
||
) | const |
bool UT_String::multiMatchRecord | ( | const UT_StringMMPattern & | pattern, |
int | maxpatterns, | ||
char * | singles, | ||
int & | nsingles, | ||
char ** | words, | ||
int & | nwords | ||
) | const |
bool UT_String::multiMatchRecord | ( | const char * | pattern, |
UT_StringHolder & | singles, | ||
UT_StringArray & | words, | ||
bool | case_sensitive = true , |
||
const char * | separators = ", " |
||
) | const |
|
inline |
Definition at line 507 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.
|
inline |
Test whether the string is defined or not.
Definition at line 486 of file UT_String.h.
|
inline |
Definition at line 499 of file UT_String.h.
|
inline |
Definition at line 497 of file UT_String.h.
|
inline |
Definition at line 502 of file UT_String.h.
|
inline |
Definition at line 424 of file UT_String.h.
|
inline |
Definition at line 428 of file UT_String.h.
|
inline |
Definition at line 432 of file UT_String.h.
|
inline |
Definition at line 509 of file UT_String.h.
|
inline |
Definition at line 516 of file UT_String.h.
Definition at line 339 of file UT_String.h.
Definition at line 371 of file UT_String.h.
UT_String& UT_String::operator+= | ( | const UT_StringRef & | str | ) |
|
inline |
Definition at line 436 of file UT_String.h.
Definition at line 440 of file UT_String.h.
|
inline |
Definition at line 444 of file UT_String.h.
|
inline |
Definition at line 448 of file UT_String.h.
Definition at line 452 of file UT_String.h.
|
inline |
Definition at line 456 of file UT_String.h.
Move operators
Definition at line 175 of file UT_String.h.
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 | ) |
|
inline |
Definition at line 412 of file UT_String.h.
Definition at line 416 of file UT_String.h.
|
inline |
Definition at line 420 of file UT_String.h.
|
inline |
Definition at line 460 of file UT_String.h.
Definition at line 464 of file UT_String.h.
|
inline |
Definition at line 468 of file UT_String.h.
|
inline |
Definition at line 472 of file UT_String.h.
Definition at line 476 of file UT_String.h.
|
inline |
Definition at line 480 of file UT_String.h.
|
inline |
Definition at line 817 of file UT_String.h.
|
inline |
Definition at line 823 of file UT_String.h.
int UT_String::parseInPlace | ( | char * | argv[], |
int | max_args, | ||
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
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 | ( | char | ch | ) |
Prepend a string (or character)
void UT_String::protectPreQuotePythonStringLiteral | ( | char | delimiter = '\'' | ) |
protectPreQuotePythonStringLiteral() will modify the existing string
specified delimiter. Unlike protectString(), it will not wrap the string in quotes.
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 |
|
static |
|
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 | ( | ) |
Replace the file extension and return the new string.
void UT_String::save | ( | std::ostream & | os, |
bool | binary | ||
) | const |
Save string to stream. Saves as binary if binary is true.
void UT_String::save | ( | UT_OStream & | os, |
bool | binary | ||
) | 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.
|
inline |
Definition at line 299 of file UT_String.h.
|
inline |
Save string to binary stream.
Definition at line 294 of file UT_String.h.
|
inline |
Make a string always deep.
Definition at line 188 of file UT_String.h.
|
static |
std::ostream& UT_String::setFormat | ( | std::ostream & | os | ) |
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.
bool UT_String::startsWith | ( | const UT_StringView & | prefix, |
bool | case_sensitive = true |
||
) | const |
|
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.
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 | ( | char | find, |
char | replacement, | ||
bool | all = true |
||
) |
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 | ( | ) | const |
Definition at line 1436 of file UT_String.h.
void UT_String::timeDeltaToPrettyString | ( | double | time_ms | ) |
Convert the given time delta (in milliseconds) to a reader-friendly string in days, hours, minutes, and seconds.
void UT_String::timeDeltaToPrettyStringMS | ( | double | time_ms | ) |
Convert the given time delta (in milliseconds) to a reader-friendly string in milliseconds.
fpreal UT_String::toFloat | ( | ) | const |
int UT_String::toInt | ( | ) | const |
Definition at line 838 of file UT_String.h.
|
inline |
Definition at line 844 of file UT_String.h.
Definition at line 850 of file UT_String.h.
|
inline |
Definition at line 858 of file UT_String.h.
|
inline |
Definition at line 867 of file UT_String.h.
int UT_String::tokenizeInPlace | ( | UT_WorkArgs & | argv, |
char | separator | ||
) |
int UT_String::tokenizeInPlace | ( | UT_WorkArgs & | argv, |
const char * | separators = " \t\n" |
||
) |
|
inline |
Definition at line 874 of file UT_String.h.
|
inline |
Definition at line 615 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();
|
inline |
Definition at line 608 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 | leave_single_space_between_words = false | ) |
trimSpace() will remove all space characters (leading and following) from a string. If the string consists of multiple words, the words will be collapsed. The function returns 1 if space was trimmed.
bool UT_String::truncateMiddle | ( | int | max_length | ) |
|
static |
|
inline |
Definition at line 523 of file UT_String.h.
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.
|
friend |
Friend specialization of std::swap() to use UT_String::swap()
Definition at line 1285 of file UT_String.h.
|
friend |
Definition at line 1345 of file UT_String.h.