All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
stringUtils.h File Reference

Definitions of basic string utilities in tf. More...

+ Include dependency graph for stringUtils.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  TfDictionaryLessThan
 Provides dictionary ordering binary predicate function on strings. More...
 
struct  TfStreamFloat
 A type which offers streaming for floats in a canonical format that can safely roundtrip with the minimal number of digits. More...
 
struct  TfStreamDouble
 A type which offers streaming for doubles in a canonical format that can safely roundtrip with the minimal number of digits. More...
 

Functions

TF_API std::string TfStringPrintf (const char *fmt,...)
 Returns a string formed by a printf()-like specification. More...
 
TF_API std::string TfVStringPrintf (const std::string &fmt, va_list ap)
 Returns a string formed by a printf()-like specification. More...
 
TF_API std::string TfVStringPrintf (const char *fmt, va_list ap)
 Bloat-avoidance version of TfVStringPrintf() More...
 
std::string TfSafeString (const char *ptr)
 Safely create a std::string from a (possibly NULL) char*. More...
 
std::string TfIntToString (int i)
 Returns the given integer as a string. More...
 
TF_API double TfStringToDouble (const std::string &txt)
 Converts text string to double. More...
 
TF_API double TfStringToDouble (const char *text)
 
TF_API long TfStringToLong (const std::string &txt, bool *outOfRange=NULL)
 Convert a sequence of digits in txt to a long int value. More...
 
TF_API long TfStringToLong (const char *txt, bool *outOfRange=NULL)
 
TF_API unsigned long TfStringToULong (const std::string &txt, bool *outOfRange=NULL)
 Convert a sequence of digits in txt to an unsigned long value. More...
 
TF_API unsigned long TfStringToULong (const char *txt, bool *outOfRange=NULL)
 
TF_API int64_t TfStringToInt64 (const std::string &txt, bool *outOfRange=NULL)
 Convert a sequence of digits in txt to an int64_t value. More...
 
TF_API int64_t TfStringToInt64 (const char *txt, bool *outOfRange=NULL)
 
TF_API uint64_t TfStringToUInt64 (const std::string &txt, bool *outOfRange=NULL)
 Convert a sequence of digits in txt to a uint64_t value. More...
 
TF_API uint64_t TfStringToUInt64 (const char *txt, bool *outOfRange=NULL)
 
bool TfStringStartsWith (const std::string &s, const char *prefix)
 Returns true if s starts with prefix. More...
 
bool TfStringStartsWith (const std::string &s, const std::string &prefix)
 
TF_API bool TfStringStartsWith (const std::string &s, const TfToken &prefix)
 
bool TfStringEndsWith (const std::string &s, const char *suffix)
 Returns true if s ends with suffix. More...
 
bool TfStringEndsWith (const std::string &s, const std::string &suffix)
 
TF_API bool TfStringEndsWith (const std::string &s, const TfToken &suffix)
 
TF_API bool TfStringContains (const std::string &s, const char *substring)
 Returns true if s contains substring. More...
 
bool TfStringContains (const std::string &s, const std::string &substring)
 
TF_API bool TfStringContains (const std::string &s, const TfToken &substring)
 
TF_API std::string TfStringToLower (const std::string &source)
 Makes all characters in source lowercase, and returns the result. More...
 
TF_API std::string TfStringToUpper (const std::string &source)
 Makes all characters in source uppercase, and returns the result. More...
 
TF_API std::string TfStringCapitalize (const std::string &source)
 Returns a copy of the source string with only its first character capitalized. More...
 
TF_API std::string TfStringTrimLeft (const std::string &s, const char *trimChars=" \n\t\r")
 Trims characters (by default, whitespace) from the left. More...
 
TF_API std::string TfStringTrimRight (const std::string &s, const char *trimChars=" \n\t\r")
 Trims characters (by default, whitespace) from the right. More...
 
TF_API std::string TfStringTrim (const std::string &s, const char *trimChars=" \n\t\r")
 Trims characters (by default, whitespace) from the beginning and end of string. More...
 
TF_API std::string TfStringGetCommonPrefix (std::string a, std::string b)
 Returns the common prefix of the input strings, if any. More...
 
TF_API std::string TfStringGetSuffix (const std::string &name, char delimiter= '.')
 Returns the suffix of a string. More...
 
TF_API std::string TfStringGetBeforeSuffix (const std::string &name, char delimiter= '.')
 Returns everything up to the suffix of a string. More...
 
TF_API std::string TfGetBaseName (const std::string &fileName)
 Returns the base name of a file (final component of the path). More...
 
TF_API std::string TfGetPathName (const std::string &fileName)
 Returns the path component of a file (complement of TfGetBaseName()). More...
 
TF_API std::string TfStringReplace (const std::string &source, const std::string &from, const std::string &to)
 Replaces all occurrences of string from with to in source. More...
 
template<class ForwardIterator >
std::string TfStringJoin (ForwardIterator begin, ForwardIterator end, const char *separator=" ")
 Concatenates the strings (begin, end), with default separator. More...
 
TF_API std::string TfStringJoin (const std::vector< std::string > &strings, const char *separator=" ")
 Concatenates strings, with default separator. More...
 
TF_API std::string TfStringJoin (const std::set< std::string > &strings, const char *separator=" ")
 Concatenates strings, with default separator. More...
 
TF_API std::vector< std::string > TfStringSplit (std::string const &src, std::string const &separator)
 Breaks the given string apart, returning a vector of strings. More...
 
TF_API std::vector< std::string > TfStringTokenize (const std::string &source, const char *delimiters=" \t\n")
 Breaks the given string apart, returning a vector of strings. More...
 
TF_API std::set< std::string > TfStringTokenizeToSet (const std::string &source, const char *delimiters=" \t\n")
 Breaks the given string apart, returning a set of strings. More...
 
TF_API std::vector< std::string > TfQuotedStringTokenize (const std::string &source, const char *delimiters=" \t\n", std::string *errors=NULL)
 Breaks the given quoted string apart, returning a vector of strings. More...
 
TF_API std::vector< std::string > TfMatchedStringTokenize (const std::string &source, char openDelimiter, char closeDelimiter, char escapeCharacter= '\0', std::string *errors=NULL)
 Breaks the given string apart by matching delimiters. More...
 
std::vector< std::string > TfMatchedStringTokenize (const std::string &source, char openDelimiter, char closeDelimiter, std::string *errors)
 This overloaded version of TfMatchedStringTokenize does not take an escapeCharacter parameter but does take. More...
 
template<typename T >
std::enable_if<!std::is_enum
< T >::value, std::string >
::type 
TfStringify (const T &v)
 Convert an arbitrary type into a string. More...
 
template<typename T >
std::enable_if< std::is_enum
< T >::value, std::string >
::type 
TfStringify (const T &v)
 
TF_API std::string TfStringify (bool v)
 
TF_API std::string TfStringify (std::string const &)
 
TF_API std::string TfStringify (float)
 
TF_API std::string TfStringify (double)
 
TF_API bool TfDoubleToString (double d, char *buffer, int len, bool emitTrailingZero)
 Writes the string representation of d to buffer of length len. More...
 
TF_API std::ostream & operator<< (std::ostream &o, TfStreamFloat t)
 
TF_API std::ostream & operator<< (std::ostream &o, TfStreamDouble t)
 
template<typename T >
TfUnstringify (const std::string &instring, bool *status=NULL)
 Convert a string to an arbitrary type. More...
 
template<>
TF_API bool TfUnstringify (const std::string &instring, bool *status)
 Convert a string to an arbitrary type. More...
 
template<>
TF_API std::string TfUnstringify (const std::string &instring, bool *status)
 Convert a string to an arbitrary type. More...
 
TF_API std::string TfStringGlobToRegex (const std::string &s)
 Returns a string with glob characters converted to their regular expression equivalents. More...
 
TF_API std::string TfEscapeString (const std::string &in)
 Process escape sequences in ANSI C string constants. More...
 
TF_API void TfEscapeStringReplaceChar (const char **in, char **out)
 
TF_API std::string TfStringCatPaths (const std::string &prefix, const std::string &suffix)
 Concatenate two strings containing '/' and '..' tokens like a file path or scope name. More...
 
bool TfIsValidIdentifier (std::string const &identifier)
 Test whether identifier is valid. More...
 
TF_API std::string TfMakeValidIdentifier (const std::string &in)
 Produce a valid identifier (see TfIsValidIdentifier) from in by replacing invalid characters with '_'. More...
 
TF_API std::string TfGetXmlEscapedString (const std::string &in)
 Escapes characters in in so that they are valid XML. More...
 

Detailed Description

Definitions of basic string utilities in tf.

Definition in file stringUtils.h.

Function Documentation

std::enable_if<std::is_enum<T>::value, std::string>::type TfStringify ( const T &  v)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 537 of file stringUtils.h.