Common Analysis Framework » QFRAMEWORK » TQStringUtils

namespace TQStringUtils


 TQStringUtils:

 The TQStringUtils namespace provides a set of static utility methods related to the inspection
 and manipulation of strings.


Function Members (Methods)

public:
boolappend(TString& text, const TString& appendix, const TString& sep = ", ")
TStringchartostr(char c)
TStringcompactify(const TString& text)
intcompare(const TString& a, const TString& b)
intcompareHeads(const TString& str1, const TString& str2)
intcompareTails(const TString& str1, const TString& str2)
TStringconcat(int n,...)
TStringconcat(TString first, const TString& second)
TStringconcatNames(TCollection* c, const TString& sep = ",", const TString& quote = "")
TStringconvertHTML2LaTeX(TString text)
TStringconvertHTML2Plain(TString text, bool unicode = true)
TStringconvertLaTeX2HTML(TString text)
TStringconvertLaTeX2Plain(TString text, bool unicod = true)
TStringconvertLaTeX2ROOTTeX(TString text)
TStringconvertPlain2HTML(TString text)
TStringconvertPlain2LaTeX(TString text)
TStringconvertROOTTeX2HTML(TString text)
TStringconvertROOTTeX2LaTeX(TString text)
TStringconvertROOTTeX2Plain(TString text, bool unicode = true)
intcountLeading(const TString& text, const TString& characters, int nMax = -1)
intcountText(const TString& haystack, const TString& needle)
intcountTrailing(const TString& text, const TString& characters, int nMax = -1)
TStringcutUnit(TString& label)
intensureLeadingText(TString& text, const TString& prefix)
intensureTrailingText(TString& text, const TString& appendix)
boolequal(const TString& first, const TString& second)
TStringexpand(TString in, const TString& characters, const TString& blocks, bool embrace = false)
vector<TString>extractMatches(const TString& string, const TString& regexp)
intfind(const TString& item, const vector<TString>& vec)
intfind(const TString& haystack, const TString& needle, int pos = 0)
intfindFirstNotOf(const TString& haystack, const TString& needle, int pos = 0)
intfindFirstOf(const TString& haystack, const TString& needle, int pos = 0)
TStringfindFormat(const TString& content)
size_tfindFree(const TString& haystack, const TString& needle, const TString& parentheses, size_t startpos = 0)
size_tfindFree(const TString& haystack, const TString& needle, const TString& paropen, const TString& parclose, size_t startpos = 0)
size_tfindFreeOf(const TString& haystack, const TString& needles, const TString& paropen, const TString& parclose, size_t startpos = 0)
intfindLastNotOf(const TString& haystack, const TString& needle)
intfindLastNotOf(const TString& haystack, const TString& needle, int pos)
intfindLastOf(const TString& haystack, const TString& needle)
intfindLastOf(const TString& haystack, const TString& needle, int pos)
size_tfindParenthesisMatch(const TString& str, size_t nextpos, const TString& paropen, const TString& parclose)
size_tfindParenthesisMatch(const TString& str, size_t nextpos, char paropen, char parclose)
TStringfixedWidth(const TString& text, int width, const TString& options = "l")
TStringfixedWidth(const char* text, int width, const TString& options = "l")
TStringfixedWidth(const TString& text, int width, bool rightJustified)
TStringfixedWidth(const TString& text, int width, const char* options)
TStringfixedWidth(const char* text, int width, const char* options)
TStringfixedWidth(const char* text, int width, bool rightJustified)
TStringformat(const char* fmt,...)
TStringformatSignificantDigits(double val, int nDigits)
TStringformatValueError(double val, double err, const TString& format = "%g +/- %g")
TStringformatValueErrorPDG(double val, double err, int expval, const TString& format)
const TString&getAllBlanks()
const TString&getBlanks()
boolgetBoolFromString(const TString& boolString)
boolgetBoolFromString(const TString& boolString, bool& isBool)
const TString&getCapitalLetters()
intgetCharIndex(const TString& text, int index)
TStringgetColorDefStringLaTeX(const TString& name, int color)
TStringgetColorDefStringLaTeX(const TString& name, TColor* color)
intgetColorFromString(TString colorString)
const TString&getDefaultIDCharacters()
TStringgetDetails(const TObject* obj)
intgetEditDistance(const TString& str1, const TString& str2)
TStringgetFirstToken(TString text, const TString& sep = ",", bool trim = true, const TString& blocks = "", const TString& quotes = "")
TStringgetIndentationLines(int indent)
const TString&getLetters()
TStringgetLongestCommonSubstring(const vector<TString>& fullStrings_, const TString& seed)
const TString&getLowerLetters()
TStringgetMaxCommonHead(TList* strings)
const TString&getNumerals()
TStringgetSIsuffix(int exponent, const TString& format = "ascii")
TStringgetStatusBar(int pos, int max, const TString& def = "[> ]")
TStringgetStringFromBool(bool boolValue)
vector<TString>getTagPlaceholders(TString in)
TStringgetThousandsSeparators(int value, const TString& sep = "'")
TStringgetThousandsSeparators(Long64_t value, const TString& sep = "'")
TStringgetThousandsSeparators(TString value, const TString& sep = "'")
TStringgetUniqueName(TDirectory* dir, TString proposal = "instance")
TStringgetUnit(TString label)
intgetWidth(const TString& text)
TStringgetWithoutUnit(TString label)
charhasStringSwitch(const TString& input)
boolhasTFormulaParameters(const TString& text)
boolhasUnquotedStrings(const TString& text, const TString& quotes = "\"'")
boolhasWildcards(TString text)
TStringinsertEscapes(const TString& text, const TString& escapes = "\\\"")
intinterpret(const TString& str)
boolisASCII(TString content)
boolisBool(const TString& str)
boolisDouble(TString str)
boolisEmpty(const TString& str, bool allowBlanks = false)
boolisEscaped(const TString& text, int pos, const TString& escChar = "\\")
boolisInteger(TString str)
boolisNumber(const TString& str)
boolisValidIdentifier(const TString& identifier, const TString& characters = getDefaultIDCharacters(), int minLength = -1, int maxLength = -1)
size_tlength(const string& s)
size_tlength(const TString& s)
TStringmakeASCII(const TString& content)
TStringmakeBlue(const TString& text)
TStringmakeBoldBlue(const TString& text)
TStringmakeBoldGreen(const TString& text)
TStringmakeBoldPink(const TString& text)
TStringmakeBoldRed(const TString& text)
TStringmakeBoldWhite(const TString& text)
TStringmakeBoldYellow(const TString& text)
TStringmakeGreen(const TString& text)
TStringmakeLowercase(TString s)
TStringmakePink(const TString& text)
TStringmakeRed(const TString& text)
TStringmakeTurquoise(const TString& text)
TStringmakeUnicodeSubscript(TString s)
TStringmakeUnicodeSuperscript(TString s)
TStringmakeUppercase(TString s)
TStringmakeValidIdentifier(const TString& identifier, const TString& characters = getDefaultIDCharacters(), const TString& replacement = "")
TStringmakeYellow(const TString& text)
boolmatches(const TString& text, const TString& pattern)
boolmatchesFilter(const TString& text, TString filter, const TString& orSep = "", bool ignoreBlanks = true)
TStringmaxLength(const TString& text, int maxLength, const TString& appendix = "...")
TStringmerge(const vector<TString>& vecStr, const TString& del = " ", int start = 0, int stop = 0)
TStringminimize(TString text)
TStringpadNumber(int num, int length)
boolprintDiffOfLists(TList* l1, TList* l2, bool ignoreMatches = false)
TStringquote(const TString& str, char q = '"')
intreadBlanks(TString& in)
intreadBlanksAndNewlines(TString& in)
intreadBlanksAndNewlines(TString& in, int& nNewlines)
intreadBlock(TString& in, TString& out, const TString& blocks = "()[]{}", const TString& quotes = "", bool keepEnclosed = false, int ignoreUnexpectedClosingQuotes = -1)
boolreadCharacter(const TString& text, int& index, int& count)
TList*readDefinitionFile(const TString& filename)
TStringreadFile(const TString& filename, const TString& blacklist = "", const TString& replace = "")
vector<TString>*readFileLines(const TString& filename, size_t len = 256, bool allowComments = true)
size_treadFileLines(vector<TString>* lines, const TString& filename, size_t len = 256, bool allowComments = true)
TStringreadPrefix(TString& in, const TString& delim, const TString& defaultPrefix = "")
TStringreadSVGtoDataURI(const TString& filename)
TStringreadTextFromFile(istream* input, const char* commentLine = "//", const char* commentBlockOpen = "/*", const char* commentBlockClose = "*/")
intreadToken(TString& in, TString& out, const TString& characters, int nMax = -1)
intreadTokenAndBlock(TString& in, TString& out, const TString& characters, const TString& blocks = "()[]{}")
intreadUpTo(TString& in, TString& out, const TString& upTo, const TString& blocks = "", const TString& quotes = "", int ignoreUnexpectedClosingQuotes = -1)
intreadUpToText(TString& in, TString& out, const TString& upTo, const TString& blocks = "", const TString& quotes = "", int ignoreUnexpectedClosingQuotes = -1)
intreduceToCommonPrefix(TString& prefix, const TString& other)
intremoveAll(TString& text, const TString& chars, TString::ECaseCompare comp = TString::ECaseCompare::kExact, int max = -1)
TStringremoveDuplicateSubStrings(const TString& longString, int minLength = 16)
TStringremoveDuplicateSubStrings(const TString& longString, TString& removedSequence, int minLength = 16)
TStringremoveEscapes(const TString& text, const TString& escapes = "\\")
intremoveLeading(TString& text, TString characters, int nMax = -1)
intremoveLeadingBlanks(TString& text, int nMax = -1)
boolremoveLeadingText(TString& text, TString prefix)
intremoveTrailing(TString& text, TString characters, int nMax = -1)
intremoveTrailingBlanks(TString& text, int nMax = -1)
boolremoveTrailingText(TString& text, TString appendix)
TStringrepeat(const TString& text, int n, const TString& sep = "")
TStringrepeatSpaces(int n)
TStringrepeatTabs(int n)
TStringreplace(TString str, const TString& needle, const TString& newNeedle)
TStringreplace(TString str, const char* needle, const TString& newNeedle)
TStringreplace(TString str, const TString& needle, const char* newNeedle)
TStringreplace(TString str, const char* needle, const char* newNeedle)
TStringreplaceEnclosed(TString haystack, TString needle, TString newNeedle, const TString& symbols)
boolrequal(const TString& first, const TString& second)
intrfind(const TString& haystack, const TString& needle)
intrfind(const TString& haystack, const TString& needle, int pos)
intrfindFirstNotOf(const TString& haystack, const TString& needle, int pos = 0)
intrfindFirstOf(const TString& haystack, const TString& needle, int pos = 0)
size_trfindFree(const TString& haystack, const TString& needle, const TString& parentheses, size_t startpos = 0)
size_trfindFree(const TString& haystack, const TString& needle, const TString& paropen, const TString& parclose, size_t startpos = -1)
size_trfindFreeOf(const TString& haystack, const TString& needles, const TString& paropen, const TString& parclose, size_t startpos = -1)
size_trfindParenthesisMatch(const TString& str, size_t nextpos, const TString& paropen, const TString& parclose)
size_trfindParenthesisMatch(const TString& str, size_t nextpos, char paropen, char parclose)
TStringrtrim(const TString& text, const TString& blanks = getBlanks())
vector<TString>split(const TString& str, const TString& del = " ")
vector<TString>split(const TString& str, const TString& del, const TString& paropen, const TString& parclose)
inttestNumber(double number, TString test)
TList*tokenize(TString text, const TString& sep = ",", bool trim = true, const TString& blocks = "", const TString& quotes = "")
vector<TString>tokenizeVector(TString text, const TString& sep = ",", bool trim = true, const TString& blocks = "", const TString& quotes = "")
TStringtrim(const TString& text, const TString& blanks = getBlanks())
TStringunblock(TString str, const TString& blocks = "(){}[]")
TStringunquote(TString str, const TString& quotes = "\"'")
voidunquoteInPlace(TString& text, const TString& quotes = "\"'")
char*vaFormat(const char* fmt, va_list ap)
boolwriteTextToFile(TList* text, const TString& filename = "")

Data Members

Class Charts

Function documentation

std::vector<TString> getTagPlaceholders(TString in)
 get the list of all the placeholders $(xyz)
TString getUniqueName(TDirectory* dir, TString proposal = "instance")
 Returns a string that does not exist as object name in TDirectory instance
 <dir>. The string is constructed from input string <proposal> and if an object
 with the same name is present in <dir> an increasing integer is appended
 ("_iN") until the name is unique.
TString getDetails(const TObject* obj)
 return details on some TObject as a TString
TString getStatusBar(int pos, int max, const TString& def = "[> ]")
 produce a "status bar" from some pos/max integer fraction
 def is expected to have length 4 (default is "[> ]")
 def[0] is a starting character (default: "[")
 def[1] is a "done" character (default: ">")
 def[2] is a "pending" character (default: " ")
 def[3] is a terminating character (default: "]")
bool isValidIdentifier(const TString& identifier, const TString& characters = getDefaultIDCharacters(), int minLength = -1, int maxLength = -1)
 check if the given string is a valid identifier, that is,
 - contains only the allowed characters
 - having a minimum length of minLength
 - having a maximum length of maxLength
TString getSIsuffix(int exponent, const TString& format = "ascii")
 retrieve the SI suffix corresponding to the given exponent
 special formats include latex, html and unicode
bool isEmpty(const TString& str, bool allowBlanks = false)
 Returns true if the input string <str> is empty and false otherwise. If
 <allowBlanks> is true the input string is considered empty even if it still
 contains blanks (listed in TQStringUtils::getBlanks()).
bool equal(const TString& first, const TString& second)
 returns true if the input strings are equal
bool requal(const TString& first, const TString& second)
 returns true if the input strings are equal.
 This version starts the comparison from the end which can be faster for long
 strings that are in any case expected to be largely identical at the beginning.
TString makeValidIdentifier(const TString& identifier, const TString& characters = getDefaultIDCharacters(), const TString& replacement = "")
 converts the given string into a valid identifier
 all characters not contained in the set of allowed characters
 are replaced by the given string
the string to return
bool getBoolFromString(const TString& boolString, bool& isBool)
 converts any type of textual boolean expression into a bool
 values like yes, no, ok, fail, true, false, etc. will be accepted
 result will be returned, success is indicated by value written to second argument
int interpret(const TString& str)
 pass some string through the root interpreter
int getColorFromString(TString colorString)
 converts ROOT color identifiers (kRed, kGreen, ...)
 and rgb hex codes (#xxxxxx)
 to the corresponding integer color identifier
bool getBoolFromString(const TString& boolString)
 converts any type of textual boolean expression into a bool
 values like yes, no, ok, fail, true, false, etc. will be accepted
TString getStringFromBool(bool boolValue)
 converts a boolean value to its corresponding string (true or false)
bool isDouble(TString str)
 Returns true if the input string <str> represents a double value or false
 otherwise. Please note: for pure integer values this method returns false, e.g.
 isDouble("4") will evaluate to false while isDouble("4.") and isDouble("4E0")
 will evaluate to true.
bool isInteger(TString str)
 Returns true if the input string <str> represents an integer value or false
 otherwise. Please note: for integer values given in "double notation" false is
 returned, e.g. isInteger("4.") and isInteger("4E0") will evaluate to false.
bool isNumber(const TString& str)
 Return true if input string <str> represents either a double or an integer
 value. This method is equivalent to "isInteger(str) || isDouble(str)".
bool isBool(const TString& str)
 returns true if the given string is a valid boolean expression
int getEditDistance(const TString& str1, const TString& str2)
 returns the number of edits required to convert str1 to str2
TString getLongestCommonSubstring(const vector<TString>& fullStrings_, const TString& seed)
 returns the longest string containing the seed which is a substring of all strings provided.
 Please note that if seed appears multiple times in a string, only the first occurance is considered!
TString removeDuplicateSubStrings(const TString& longString, int minLength = 16)
 convenience wrapper in case the removed sequence is not of interest
TString removeDuplicateSubStrings(const TString& longString, TString& removedSequence, int minLength = 16)
 checks for substrings of 'longString' which are at least 'minLength'
 characters long and (disjointly) occur multiple times in 'longString',
 removing all but the first occurence. The identified substring is
 additionally stored in the 'removedSequence' parameter.
 In case of ambiguities, i.e., a shorter but more frequently occuring substring
 versus a longer but less frequently occuring substring, the more frequent
 one is treated (given it is at least 'minLength' characters long)
int testNumber(double number, TString test)
 Tests number <number> with simple condition <test> and returns 1 if the
 condition is fulfilled and 0 otherwise. The syntax of <test> is expected
 to be "<operator> <number>". Supported operators are "==", "!=", ">=", ">",
 "<=", and "<". -1 is returned in case the condition could not be parsed.
 Examples:

 - testNumber(5, "== 5.") returns 1
 - testNumber(4, "> 5.") returns 0
 - testNumber(5, ">> 1") returns -1
bool matchesFilter(const TString& text, TString filter, const TString& orSep = "", bool ignoreBlanks = true)
 match with logical OR?
loop over individual filter
bool matches(const TString& text, const TString& pattern)
 Performs a string match between the input string <text> and the string pattern
 <pattern> and returns true in case of a match and false otherwise. The string
 pattern may use wildcards "?" (matching exactly one character) and "*"
 (matching any string sequence).

 Examples:

 - matches("hello", "h?llo") returns true
 - matches("hallo", "h?llo") returns true
 - matches("hello", "h*") returns true
 - matches("hello", "h*a") returns false
bool hasWildcards(TString text)
 Returns true if the input string <text> contains wildcards "?" or "*" and
 false otherwise.
int compare(const TString& a, const TString& b)
 Compares the two input strings <a> and <b> and returns 0 in case both strings
 are identical. In case string <a> (<b>) is longer or "greater" than string <b>
 (<a>) 1 (-1) is returned. A string is considered greater than another string
 if the character code at the left most position with non-matching characters
 is larger.

 Examples:
 - compare("a", "a") returns 0
 - compare("a", "b") returns -1
 - compare("ab", "a") returns 1
 - compare("a", "A") returns 1
int compareHeads(const TString& str1, const TString& str2)
 Compares the heads of the two input strings <str1> and <str2> and returns the
 length of the longest common string sequence both strings begin with.
int compareTails(const TString& str1, const TString& str2)
 Compares the tails of the two input strings <str1> and <str2> and returns the
 length of the longest common string sequence both strings end with.
TString getMaxCommonHead(TList* strings)
 Returns the longest common sequence of all strings (names of objects obtained
 using GetName()) present in input list <strings>.
bool isEscaped(const TString& text, int pos, const TString& escChar = "\\")
 Counts the number of occurences of <escChar> in front of <pos> in <text>.
 Returns true if the value is odd and false if it is even.
TString removeEscapes(const TString& text, const TString& escapes = "\\")
 Returns a string similar to the input string <text> but removing escape
 characters. The list of characters to escape is given by the input string
 <escapes>.
TString insertEscapes(const TString& text, const TString& escapes = "\\\"")
 Returns a string similar to the input string <text> but inserting escape
 characters where necessary. The list of characters to escape is given by the
 input string <escapes> where the first character is used as the escape
 character to be inserted in the text.
int reduceToCommonPrefix(TString& prefix, const TString& other)
 reduce the first of two strings to the their common prefix
 return the length of this prefix
TString concat(TString first, const TString& second)
 concatenate two strings
size_t length(const TString& s)
size_t length(const string& s)
TString concatNames(TCollection* c, const TString& sep = ",", const TString& quote = "")
 concatenate the names of a vector of TObject-derived objects to a single string using the given separator
TString getFirstToken(TString text, const TString& sep = ",", bool trim = true, const TString& blocks = "", const TString& quotes = "")
FIXME: parameter 'trim' is unused. This might lead to wrong expectations of users!
 read and return first token in <text>
TList * tokenize(TString text, const TString& sep = ",", bool trim = true, const TString& blocks = "", const TString& quotes = "")
 tokenize a string, return the result as a TList
 the list to return
std::vector<TString> tokenizeVector(TString text, const TString& sep = ",", bool trim = true, const TString& blocks = "", const TString& quotes = "")
bool append(TString& text, const TString& appendix, const TString& sep = ", ")
 Appends input string <appendix> to string <text> adding the separator string
 <sep> in case <text> is not an empty string before the operation.
TString rtrim(const TString& text, const TString& blanks = getBlanks())
 Returns <text> without trailing blanks.
TString trim(const TString& text, const TString& blanks = getBlanks())
 Returns <text> without leading and trailing blanks.
TString repeat(const TString& text, int n, const TString& sep = "")
 Returns the concatenation of <n> times <text> separated by <sep>.
TString repeatSpaces(int n)
 Returns a string with <n> spaces.
TString repeatTabs(int n)
 Returns a string with <n> tabs.
int getWidth(const TString& text)
 retrieve the with of some string in characters
 NOTE: this width is not identical to the the string length,
 since some (unicode) characters and control sequences
 require different amounts of characters in string length and on screen
 NOTE: this function is still under developement
 and will not work for all symbols
int getCharIndex(const TString& text, int index)
 return the index of a given character in a string
 this takes into account control sequences and unicode characters
 please see TQStringUtils::getWidth for details
TString fixedWidth(const TString& text, int width, const char* options)
 expand or shrink the given string to a given width, returning the result
 alignment may be specified as "r", "c" or "l" as the last argument
TString fixedWidth(const char* text, int width, const char* options)
 expand or shrink the given string to a given width, returning the result
 alignment may be specified as "r", "c" or "l" as the last argument
TString fixedWidth(const char* text, int width, const TString& options = "l")
 expand or shrink the given string to a given width, returning the result
 alignment may be specified as "r", "c" or "l" as the last argument
bool readCharacter(const TString& text, int& index, int& count)
scan the text and count characters excluding control sequences
TString fixedWidth(const TString& text, int width, const TString& options = "l")
 expand or shrink the given string to a given width, returning the result
 alignment may be specified as "r", "c" or "l" as the last argument
TString fixedWidth(const TString& text, int width, bool rightJustified)
 expand or shrink the given string to a given width, returning the result
 returns right aligned text if rightJustified is true, otherwise left aligned
TString fixedWidth(const char* text, int width, bool rightJustified)
 expand or shrink the given string to a given width, returning the result
 returns right aligned text if rightJustified is true, otherwise left aligned
TString maxLength(const TString& text, int maxLength, const TString& appendix = "...")
 trim a string to a maximum length, including the appendix if shortened
TString getThousandsSeparators(int value, const TString& sep = "'")
convert integer to string
TString getThousandsSeparators(TString value, const TString& sep = "'")
compile result including thousands separators
TString getThousandsSeparators(Long64_t value, const TString& sep = "'")
convert long to string
TString getIndentationLines(int indent)
 creates indentation lines ("||||-") for tree-style console printing
TString formatSignificantDigits(double val, int nDigits)
 format a number to a string with the given number of significant digits
TString formatValueErrorPDG(double val, double err, int expval, const TString& format)
 implementing the PDG rounding guidelines
   http://pdg.lbl.gov/2010/reviews/rpp2010-rev-rpp-intro.pdf
TString formatValueError(double val, double err, const TString& format = "%g +/- %g")
 format a number and uncertainty to a string in the given format
bool printDiffOfLists(TList* l1, TList* l2, bool ignoreMatches = false)
 Performs a 'diff' of the two input lists (instances of TList) <l1> and <l2>
 based on the result of the Compare(...) methods on contained objects, prints
 the result on std::cout, and returns true if both lists fully match or false
 otherwise. The print-out is a list of all elements present in either of the two
 lists with matching elements (elements with the same name and present in both
 lists) being printed side-by-side. If <ignoreMatches> == true (default is false)
 only elements present in one list are shown.
int removeLeading(TString& text, TString characters, int nMax = -1)
 Removes from the head of string <text> all characters listed in <characters>
 (but not more than <nMax>) and returns the number of characters that have been
 removed.
int removeTrailing(TString& text, TString characters, int nMax = -1)
 Removes from the tail of string <text> all characters listed in <characters>
 (but not more than <nMax>) and returns the number of characters that have been
 removed.
bool removeLeadingText(TString& text, TString prefix)
 Removes one occurence of string sequence <prefix> from head of string <text>
 if present and returns true in this case and false otherwise.
bool removeTrailingText(TString& text, TString appendix)
 Removes one occurence of string sequence <appendix> from tail of string <text>
 if present and returns true in this case and false otherwise.
int removeAll(TString& text, const TString& chars, TString::ECaseCompare comp = TString::ECaseCompare::kExact, int max = -1)
 Removes up to 'max' occurences of characters contained in chars from text
 starting at the beginning of text. 'max' is ignored if it is negative.
int ensureTrailingText(TString& text, const TString& appendix)
 ensure that a string ends with a given character sequence
int ensureLeadingText(TString& text, const TString& prefix)
 ensure that a string starts with a given character sequence
int removeLeadingBlanks(TString& text, int nMax = -1)
 Removes leading blanks from head of string <text> (but not more than <nMax>)
 and returns the number of blanks that have been removed. Characters are
 recognized as blanks if listed in TQStringUtils::getBlanks().
int removeTrailingBlanks(TString& text, int nMax = -1)
 Removes trailing blanks from tail of string <text> (but not more than <nMax>)
 and returns the number of blanks that have been removed. Characters are
 recognized as blanks if listed in TQStringUtils::getBlanks().
int countLeading(const TString& text, const TString& characters, int nMax = -1)
 Count and return the number of characters listed in <characters> at head of
 string <text>.
int countTrailing(const TString& text, const TString& characters, int nMax = -1)
 Count and return the number of characters listed in <characters> at tail of
 string <text>.
int countText(const TString& haystack, const TString& needle)
 count the occurences of needle in haystack
TString cutUnit(TString& label)
 remove the unit "[...]" from some label
 returns the unit
TString getUnit(TString label)
 retrieve the unit "[...]" from some label
TString getWithoutUnit(TString label)
 remove the unit "[...]" from some label
 returns the result
int readBlanks(TString& in)
 removes leading blanks from a string
int readBlanksAndNewlines(TString& in)
 removes leading blanks and newlines from a string
int readBlanksAndNewlines(TString& in, int& nNewlines)
 removes leading blanks from a string, counting removed newlines
int readToken(TString& in, TString& out, const TString& characters, int nMax = -1)
 Counts the number of leading characters at head of string <in> listed in
 <characters>, moves the corresponding sequence from head of string <in> to
 tail of string <out>, and returns the number of characters that have been
 moved. If <nMax> is non-negative at most <nMax> characters are moved.
int readTokenAndBlock(TString& in, TString& out, const TString& characters, const TString& blocks = "()[]{}")
 read a token consisting of the given characters and a subsequent block
 the number of characters read from string <in>
int readBlock(TString& in, TString& out, const TString& blocks = "()[]{}", const TString& quotes = "", bool keepEnclosed = false, int ignoreUnexpectedClosingQuotes = -1)
 read a parenthesis enclosed block from a string
stop if no valid block or quote definition was given
int readUpToText(TString& in, TString& out, const TString& upTo, const TString& blocks = "", const TString& quotes = "", int ignoreUnexpectedClosingQuotes = -1)
 read a string up to occurence of some other string
int readUpTo(TString& in, TString& out, const TString& upTo, const TString& blocks = "", const TString& quotes = "", int ignoreUnexpectedClosingQuotes = -1)
 read a string up to occurence of the first of a set of characters
stop if no valid block or quote definition was given
TString expand(TString in, const TString& characters, const TString& blocks, bool embrace = false)
TString replace(TString str, const TString& needle, const TString& newNeedle)
TString replace(TString str, const char* needle, const TString& newNeedle)
TString replace(TString str, const TString& needle, const char* newNeedle)
TString replace(TString str, const char* needle, const char* newNeedle)
std::vector<TString> extractMatches(const TString& string, const TString& regexp)
TString readPrefix(TString& in, const TString& delim, const TString& defaultPrefix = "")
 read a string up to the occurence of some delimiter
bool writeTextToFile(TList* text, const TString& filename = "")
 Writes the lines of strings in list <text> (names of objects obtained using
 GetName()) to external file <filename> or to std::cout in case <filename> is
 an empty string and return true in case of success and false otherwise.
TString readFile(const TString& filename, const TString& blacklist = "", const TString& replace = "")
 Read a text file to a single string, ignoring all blacklisted characters
 if replacements are given, characters with odd indices are replaced by their successor
TString readSVGtoDataURI(const TString& filename)
 read an SVG file, returning a data URI string
std::vector<TString>* readFileLines(const TString& filename, size_t len = 256, bool allowComments = true)
 Read a text file, line by line, and return the contents as a std::vector
size_t readFileLines(vector<TString>* lines, const TString& filename, size_t len = 256, bool allowComments = true)
 Read a text file, line by line, and push the contents into a std::vector
TList* readDefinitionFile(const TString& filename)
 read a histogram definition file, returning a TList of TObjStrings with histogram definitions
TString unquote(TString str, const TString& quotes = "\"'")
 remove enclosing quotes from a string, returning the result
TString quote(const TString& str, char q = '"')
 enclose a string in quotes, returning the result
void unquoteInPlace(TString& text, const TString& quotes = "\"'")
 remove enclosing quotes from a string, returning the result
TString unblock(TString str, const TString& blocks = "(){}[]")
 remove enclosing parenthesis from a string, returning the result
TString minimize(TString text)
 compactify a string, removing all spaces
TString compactify(const TString& text)
 compactify a string, removing all double whitespaces
bool hasUnquotedStrings(const TString& text, const TString& quotes = "\"'")
 returns true if the string contains unquoted string literals, false otherwise
bool hasTFormulaParameters(const TString& text)
char hasStringSwitch(const TString& input)
TString readTextFromFile(istream* input, const char* commentLine = "//", const char* commentBlockOpen = "/*", const char* commentBlockClose = "*/")
 read a data from the given stream, purging c-style comments
size_t findParenthesisMatch(const TString& str, size_t nextpos, const TString& paropen, const TString& parclose)
 finds the nearest mathing closing parenthesis in a string from a given position assuming that the opening parenthesis is at the given position
size_t rfindParenthesisMatch(const TString& str, size_t nextpos, const TString& paropen, const TString& parclose)
 finds the nearest mathing (opening) parenthesis in a string from a given position assuming that the closing parenthesis is at the given position (backwards search)
size_t findParenthesisMatch(const TString& str, size_t nextpos, char paropen, char parclose)
 finds the nearest mathing closing parenthesis in a string from a given position assuming that the opening parenthesis is at the given position
size_t rfindParenthesisMatch(const TString& str, size_t nextpos, char paropen, char parclose)
 finds the nearest mathing (opening) parenthesis in a string from a given position assuming that the closing parenthesis is at the given position (backwards search)
size_t findFree(const TString& haystack, const TString& needle, const TString& paropen, const TString& parclose, size_t startpos = 0)
 finds the next "free" occurrence of needle in haystack. Note that this version checks for an exact match of the entire string paropen and parclose
size_t findFree(const TString& haystack, const TString& needle, const TString& parentheses, size_t startpos = 0)
 finds the next "free" occurrence of needle in haystack. This version assumes parentheses to be provides as "()[]{}", i.e. opening followed by closing parenthesis. Needle must be matched exactly.
size_t rfindFree(const TString& haystack, const TString& needle, const TString& parentheses, size_t startpos = 0)
 reverse-finds the next "free" occurrence of needle in haystack. This version assumes parentheses to be provides as "()[]{}", i.e. opening followed by closing parenthesis. Needle must be matched exactly.
size_t rfindFree(const TString& haystack, const TString& needle, const TString& paropen, const TString& parclose, size_t startpos = -1)
 reverse-finds the next "free" occurrence of needle in haystack. Note that this version checks for an exact match of the entire string paropen and parclose
size_t findFreeOf(const TString& haystack, const TString& needles, const TString& paropen, const TString& parclose, size_t startpos = 0)
 finds the next "free" occurrence of any needle in haystack. Note that this version checks for an exact match of the entire string paropen and parclose
size_t rfindFreeOf(const TString& haystack, const TString& needles, const TString& paropen, const TString& parclose, size_t startpos = -1)
 reverse-finds the next "free" occurrence of any needle in haystack. Note that this version checks for an exact match of the entire string paropen and parclose
int find(const TString& item, const vector<TString>& vec)
 find the index of an item in a list, return -1 if not found
int find(const TString& haystack, const TString& needle, int pos = 0)
 finds the next occurrence of needle in haystack, starting at given position
 if needle is found returns position of the first character of needle
int rfind(const TString& haystack, const TString& needle, int pos)
 finds the next occurrence of needle in haystack, starting backwards at given position
int findFirstOf(const TString& haystack, const TString& needle, int pos = 0)
 finds the next occurrence of any needle in haystack, starting at given position
int findLastOf(const TString& haystack, const TString& needle, int pos)
 finds the next occurrence of needle in haystack, starting backwards at given position
int rfindFirstOf(const TString& haystack, const TString& needle, int pos = 0)
 see TQStringUtils::findLastOf(const TString& haystack, const TString& needle, int pos)
int findFirstNotOf(const TString& haystack, const TString& needle, int pos = 0)
 finds the next occurrence of anything else than needle in haystack, starting at given position
int findLastNotOf(const TString& haystack, const TString& needle, int pos)
 finds the next occurrence of anything else than needle in haystack, starting backwards at given position
int rfindFirstNotOf(const TString& haystack, const TString& needle, int pos = 0)
 see TQStringUtils::findLastNotOf(const TString& haystack, const TString& needle, int pos)
std::vector<TString> split(const TString& str, const TString& del = " ")
 split a string at all occurrences of the delimiter and return a vector of results
std::vector<TString> split(const TString& str, const TString& del, const TString& paropen, const TString& parclose)
 split a string into little chunks
 This version of the stringsplit function accepts one delimiter
 and respects parenthesis (e.g. does not split in a way that will break parenthesis matches)
 Note that this method treats paropen and parclose at a potentially multi-character opening
 closing substring. To split using a variety of several different pairs of parentheses use
 TQStringUtils::tokenizeVector !
TString merge(const vector<TString>& vecStr, const TString& del = " ", int start = 0, int stop = 0)
 The opposite method of split. Takes a vector of strings and combines it
 to a single string.
TString findFormat(const TString& content)
 make an elaborate guess of the formatting of some string
 may return one of html,latex,roottex,unicode,ascii
bool isASCII(TString content)
 convert a string to plain ascii
TString makeASCII(const TString& content)
 convert a string to plain ascii
TString convertPlain2LaTeX(TString text)
 convert plain text to LaTeX code
 TODO: implement this function (currently, this is a DUMMY function)
TString convertPlain2HTML(TString text)
 convert plain text to HTML code
 TODO: implement this function (currently, this is a DUMMY function)
TString convertLaTeX2Plain(TString text, bool unicod = true)
 convert LaTeX symbols to plain text (ASCII or unicode)
TString convertLaTeX2HTML(TString text)
 converts LaTeX formattet text to HTML code
TString convertHTML2Plain(TString text, bool unicode = true)
 convert HTML code to plain text (ASCII or unicode)
 TODO: implement this function (currently, this is a DUMMY function)
TString convertHTML2LaTeX(TString text)
 convert HTML code to LaTeX
 TODO: implement this function (currently, this is a DUMMY function)
TString convertROOTTeX2Plain(TString text, bool unicode = true)
 convert ROOTTeX to plain text (ASCII or unicode)
 TODO: implement this function (currently, this is a DUMMY function)
TString convertLaTeX2ROOTTeX(TString text)
 convert ROOTTeX to plain text (ASCII or unicode)
TString convertROOTTeX2LaTeX(TString text)
 convert ROOTTeX to (real) LaTeX
TString convertROOTTeX2HTML(TString text)
 convert ROOTTeX to HTML code
 TODO: implement this function (currently, this is a DUMMY function)
TString makeUppercase(TString s)
 convert a string to uppercase
TString makeLowercase(TString s)
 convert a string to lowercase
TString makeUnicodeSuperscript(TString s)
 replace all characters in the given string by their unicode superscript variants if possible
TString makeUnicodeSubscript(TString s)
 replace all characters in the given string by their unicode superscript variants if possible
TString format(const char *va_(fmt), ...)
 format a string - analog to TString::Format
TString concat(TString first, const TString& second)
 concatenate arguments
char* vaFormat(const char* fmt, va_list ap)
 format a string - variadic variant of TString::Format
 analog to (private) function TString::FormatImp
TString replaceEnclosed(TString haystack, TString needle, TString newNeedle, const TString& symbols)
 replace all occurences of needle in haystack, as long as they are
 enclosed in characters from the symbols
TString getColorDefStringLaTeX(const TString& name, int color)
 retrieve a color definition string for LaTeX
 of the form "\definecolor{<name>}{rgb}{<r>,<g>,<b>}"
 for some predefined color enum
TString getColorDefStringLaTeX(const TString& name, TColor* color)
 retrieve a color definition string for LaTeX
 of the form "\definecolor{<name>}{rgb}{<r>,<g>,<b>}"
 for some ROOT TColor
TString padNumber(int num, int length)
 pad an integer with leading zeros
const TString& getLowerLetters()
const TString& getCapitalLetters()
const TString& getLetters()
const TString& getNumerals()
const TString& getDefaultIDCharacters()
const TString& getBlanks()
const TString& getAllBlanks()
TString makeBoldWhite(const TString& text)
TString makeBoldPink(const TString& text)
TString makeBoldBlue(const TString& text)
TString makeBoldYellow(const TString& text)
TString makeBoldGreen(const TString& text)
TString makeBoldRed(const TString& text)
TString makePink(const TString& text)
TString makeTurquoise(const TString& text)
TString makeBlue(const TString& text)
TString makeYellow(const TString& text)
TString makeGreen(const TString& text)
TString makeRed(const TString& text)
TString chartostr(char c)
{ TString s(""); s+=c; return s;}
int rfind(const TString& haystack, const TString& needle, int pos)
int findLastOf(const TString& haystack, const TString& needle, int pos)
int findLastNotOf(const TString& haystack, const TString& needle, int pos)