TQStringUtils: The TQStringUtils namespace provides a set of static utility methods related to the inspection and manipulation of strings.
bool | append(TString& text, const TString& appendix, const TString& sep = ", ") |
TString | chartostr(char c) |
TString | compactify(const TString& text) |
int | compare(const TString& a, const TString& b) |
int | compareHeads(const TString& str1, const TString& str2) |
int | compareTails(const TString& str1, const TString& str2) |
TString | concat(int n,...) |
TString | concat(TString first, const TString& second) |
TString | concatNames(TCollection* c, const TString& sep = ",", const TString& quote = "") |
TString | convertHTML2LaTeX(TString text) |
TString | convertHTML2Plain(TString text, bool unicode = true) |
TString | convertLaTeX2HTML(TString text) |
TString | convertLaTeX2Plain(TString text, bool unicod = true) |
TString | convertLaTeX2ROOTTeX(TString text) |
TString | convertPlain2HTML(TString text) |
TString | convertPlain2LaTeX(TString text) |
TString | convertROOTTeX2HTML(TString text) |
TString | convertROOTTeX2LaTeX(TString text) |
TString | convertROOTTeX2Plain(TString text, bool unicode = true) |
int | countLeading(const TString& text, const TString& characters, int nMax = -1) |
int | countText(const TString& haystack, const TString& needle) |
int | countTrailing(const TString& text, const TString& characters, int nMax = -1) |
TString | cutUnit(TString& label) |
int | ensureLeadingText(TString& text, const TString& prefix) |
int | ensureTrailingText(TString& text, const TString& appendix) |
bool | equal(const TString& first, const TString& second) |
TString | expand(TString in, const TString& characters, const TString& blocks, bool embrace = false) |
vector<TString> | extractMatches(const TString& string, const TString& regexp) |
int | find(const TString& item, const vector<TString>& vec) |
int | find(const TString& haystack, const TString& needle, int pos = 0) |
int | findFirstNotOf(const TString& haystack, const TString& needle, int pos = 0) |
int | findFirstOf(const TString& haystack, const TString& needle, int pos = 0) |
TString | findFormat(const TString& content) |
size_t | findFree(const TString& haystack, const TString& needle, const TString& parentheses, size_t startpos = 0) |
size_t | findFree(const TString& haystack, const TString& needle, const TString& paropen, const TString& parclose, size_t startpos = 0) |
size_t | findFreeOf(const TString& haystack, const TString& needles, const TString& paropen, const TString& parclose, size_t startpos = 0) |
int | findLastNotOf(const TString& haystack, const TString& needle) |
int | findLastNotOf(const TString& haystack, const TString& needle, int pos) |
int | findLastOf(const TString& haystack, const TString& needle) |
int | findLastOf(const TString& haystack, const TString& needle, int pos) |
size_t | findParenthesisMatch(const TString& str, size_t nextpos, const TString& paropen, const TString& parclose) |
size_t | findParenthesisMatch(const TString& str, size_t nextpos, char paropen, char parclose) |
TString | fixedWidth(const TString& text, int width, const TString& options = "l") |
TString | fixedWidth(const char* text, int width, const TString& options = "l") |
TString | fixedWidth(const TString& text, int width, bool rightJustified) |
TString | fixedWidth(const TString& text, int width, const char* options) |
TString | fixedWidth(const char* text, int width, const char* options) |
TString | fixedWidth(const char* text, int width, bool rightJustified) |
TString | format(const char* fmt,...) |
TString | formatSignificantDigits(double val, int nDigits) |
TString | formatValueError(double val, double err, const TString& format = "%g +/- %g") |
TString | formatValueErrorPDG(double val, double err, int expval, const TString& format) |
const TString& | getAllBlanks() |
const TString& | getBlanks() |
bool | getBoolFromString(const TString& boolString) |
bool | getBoolFromString(const TString& boolString, bool& isBool) |
const TString& | getCapitalLetters() |
int | getCharIndex(const TString& text, int index) |
TString | getColorDefStringLaTeX(const TString& name, int color) |
TString | getColorDefStringLaTeX(const TString& name, TColor* color) |
int | getColorFromString(TString colorString) |
const TString& | getDefaultIDCharacters() |
TString | getDetails(const TObject* obj) |
int | getEditDistance(const TString& str1, const TString& str2) |
TString | getFirstToken(TString text, const TString& sep = ",", bool trim = true, const TString& blocks = "", const TString& quotes = "") |
TString | getIndentationLines(int indent) |
const TString& | getLetters() |
TString | getLongestCommonSubstring(const vector<TString>& fullStrings_, const TString& seed) |
const TString& | getLowerLetters() |
TString | getMaxCommonHead(TList* strings) |
const TString& | getNumerals() |
TString | getSIsuffix(int exponent, const TString& format = "ascii") |
TString | getStatusBar(int pos, int max, const TString& def = "[> ]") |
TString | getStringFromBool(bool boolValue) |
vector<TString> | getTagPlaceholders(TString in) |
TString | getThousandsSeparators(int value, const TString& sep = "'") |
TString | getThousandsSeparators(Long64_t value, const TString& sep = "'") |
TString | getThousandsSeparators(TString value, const TString& sep = "'") |
TString | getUniqueName(TDirectory* dir, TString proposal = "instance") |
TString | getUnit(TString label) |
int | getWidth(const TString& text) |
TString | getWithoutUnit(TString label) |
char | hasStringSwitch(const TString& input) |
bool | hasTFormulaParameters(const TString& text) |
bool | hasUnquotedStrings(const TString& text, const TString& quotes = "\"'") |
bool | hasWildcards(TString text) |
TString | insertEscapes(const TString& text, const TString& escapes = "\\\"") |
int | interpret(const TString& str) |
bool | isASCII(TString content) |
bool | isBool(const TString& str) |
bool | isDouble(TString str) |
bool | isEmpty(const TString& str, bool allowBlanks = false) |
bool | isEscaped(const TString& text, int pos, const TString& escChar = "\\") |
bool | isInteger(TString str) |
bool | isNumber(const TString& str) |
bool | isValidIdentifier(const TString& identifier, const TString& characters = getDefaultIDCharacters(), int minLength = -1, int maxLength = -1) |
size_t | length(const string& s) |
size_t | length(const TString& s) |
TString | makeASCII(const TString& content) |
TString | makeBlue(const TString& text) |
TString | makeBoldBlue(const TString& text) |
TString | makeBoldGreen(const TString& text) |
TString | makeBoldPink(const TString& text) |
TString | makeBoldRed(const TString& text) |
TString | makeBoldWhite(const TString& text) |
TString | makeBoldYellow(const TString& text) |
TString | makeGreen(const TString& text) |
TString | makeLowercase(TString s) |
TString | makePink(const TString& text) |
TString | makeRed(const TString& text) |
TString | makeTurquoise(const TString& text) |
TString | makeUnicodeSubscript(TString s) |
TString | makeUnicodeSuperscript(TString s) |
TString | makeUppercase(TString s) |
TString | makeValidIdentifier(const TString& identifier, const TString& characters = getDefaultIDCharacters(), const TString& replacement = "") |
TString | makeYellow(const TString& text) |
bool | matches(const TString& text, const TString& pattern) |
bool | matchesFilter(const TString& text, TString filter, const TString& orSep = "", bool ignoreBlanks = true) |
TString | maxLength(const TString& text, int maxLength, const TString& appendix = "...") |
TString | merge(const vector<TString>& vecStr, const TString& del = " ", int start = 0, int stop = 0) |
TString | minimize(TString text) |
TString | padNumber(int num, int length) |
bool | printDiffOfLists(TList* l1, TList* l2, bool ignoreMatches = false) |
TString | quote(const TString& str, char q = '"') |
int | readBlanks(TString& in) |
int | readBlanksAndNewlines(TString& in) |
int | readBlanksAndNewlines(TString& in, int& nNewlines) |
int | readBlock(TString& in, TString& out, const TString& blocks = "()[]{}", const TString& quotes = "", bool keepEnclosed = false, int ignoreUnexpectedClosingQuotes = -1) |
bool | readCharacter(const TString& text, int& index, int& count) |
TList* | readDefinitionFile(const TString& filename) |
TString | readFile(const TString& filename, const TString& blacklist = "", const TString& replace = "") |
vector<TString>* | readFileLines(const TString& filename, size_t len = 256, bool allowComments = true) |
size_t | readFileLines(vector<TString>* lines, const TString& filename, size_t len = 256, bool allowComments = true) |
TString | readPrefix(TString& in, const TString& delim, const TString& defaultPrefix = "") |
TString | readSVGtoDataURI(const TString& filename) |
TString | readTextFromFile(istream* input, const char* commentLine = "//", const char* commentBlockOpen = "/*", const char* commentBlockClose = "*/") |
int | readToken(TString& in, TString& out, const TString& characters, int nMax = -1) |
int | readTokenAndBlock(TString& in, TString& out, const TString& characters, const TString& blocks = "()[]{}") |
int | readUpTo(TString& in, TString& out, const TString& upTo, const TString& blocks = "", const TString& quotes = "", int ignoreUnexpectedClosingQuotes = -1) |
int | readUpToText(TString& in, TString& out, const TString& upTo, const TString& blocks = "", const TString& quotes = "", int ignoreUnexpectedClosingQuotes = -1) |
int | reduceToCommonPrefix(TString& prefix, const TString& other) |
int | removeAll(TString& text, const TString& chars, TString::ECaseCompare comp = TString::ECaseCompare::kExact, int max = -1) |
TString | removeDuplicateSubStrings(const TString& longString, int minLength = 16) |
TString | removeDuplicateSubStrings(const TString& longString, TString& removedSequence, int minLength = 16) |
TString | removeEscapes(const TString& text, const TString& escapes = "\\") |
int | removeLeading(TString& text, TString characters, int nMax = -1) |
int | removeLeadingBlanks(TString& text, int nMax = -1) |
bool | removeLeadingText(TString& text, TString prefix) |
int | removeTrailing(TString& text, TString characters, int nMax = -1) |
int | removeTrailingBlanks(TString& text, int nMax = -1) |
bool | removeTrailingText(TString& text, TString appendix) |
TString | repeat(const TString& text, int n, const TString& sep = "") |
TString | repeatSpaces(int n) |
TString | repeatTabs(int n) |
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) |
TString | replaceEnclosed(TString haystack, TString needle, TString newNeedle, const TString& symbols) |
bool | requal(const TString& first, const TString& second) |
int | rfind(const TString& haystack, const TString& needle) |
int | rfind(const TString& haystack, const TString& needle, int pos) |
int | rfindFirstNotOf(const TString& haystack, const TString& needle, int pos = 0) |
int | rfindFirstOf(const TString& haystack, const TString& needle, int pos = 0) |
size_t | rfindFree(const TString& haystack, const TString& needle, const TString& parentheses, size_t startpos = 0) |
size_t | rfindFree(const TString& haystack, const TString& needle, const TString& paropen, const TString& parclose, size_t startpos = -1) |
size_t | rfindFreeOf(const TString& haystack, const TString& needles, const TString& paropen, const TString& parclose, size_t startpos = -1) |
size_t | rfindParenthesisMatch(const TString& str, size_t nextpos, const TString& paropen, const TString& parclose) |
size_t | rfindParenthesisMatch(const TString& str, size_t nextpos, char paropen, char parclose) |
TString | rtrim(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) |
int | testNumber(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 = "") |
TString | trim(const TString& text, const TString& blanks = getBlanks()) |
TString | unblock(TString str, const TString& blocks = "(){}[]") |
TString | unquote(TString str, const TString& quotes = "\"'") |
void | unquoteInPlace(TString& text, const TString& quotes = "\"'") |
char* | vaFormat(const char* fmt, va_list ap) |
bool | writeTextToFile(TList* text, const TString& filename = "") |
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.
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: "]")
retrieve the SI suffix corresponding to the given exponent special formats include latex, html and unicode
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()).
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
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
converts ROOT color identifiers (kRed, kGreen, ...) and rgb hex codes (#xxxxxx) to the corresponding integer color identifier
converts any type of textual boolean expression into a bool values like yes, no, ok, fail, true, false, etc. will be accepted
converts a boolean value to its corresponding string (true or false)
Return true if input string <str> represents either a double or an integer value. This method is equivalent to "isInteger(str) || isDouble(str)".
returns the number of edits required to convert str1 to str2
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!
convenience wrapper in case the removed sequence is not of interest
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)
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
match with logical OR? loop over individual filter
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
Returns true if the input string <text> contains wildcards "?" or "*" and false otherwise.
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
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.
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.
Returns the longest common sequence of all strings (names of objects obtained using GetName()) present in input list <strings>.
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.
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>.
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.
reduce the first of two strings to the their common prefix return the length of this prefix
concatenate the names of a vector of TObject-derived objects to a single string using the given separator
FIXME: parameter 'trim' is unused. This might lead to wrong expectations of users! read and return first token in <text>
Appends input string <appendix> to string <text> adding the separator string <sep> in case <text> is not an empty string before the operation.
Returns <text> without trailing blanks.
Returns <text> without leading and trailing blanks.
Returns the concatenation of <n> times <text> separated by <sep>.
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
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
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
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
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
scan the text and count characters excluding control sequences
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
expand or shrink the given string to a given width, returning the result returns right aligned text if rightJustified is true, otherwise left aligned
expand or shrink the given string to a given width, returning the result returns right aligned text if rightJustified is true, otherwise left aligned
compile result including thousands separators
creates indentation lines ("||||-") for tree-style console printing
format a number to a string with the given number of significant digits
implementing the PDG rounding guidelines http://pdg.lbl.gov/2010/reviews/rpp2010-rev-rpp-intro.pdf
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.
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.
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.
Removes one occurence of string sequence <prefix> from head of string <text> if present and returns true in this case and false otherwise.
Removes one occurence of string sequence <appendix> from tail of string <text> if present and returns true in this case and false otherwise.
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.
ensure that a string ends with a given character sequence
ensure that a string starts with a given character sequence
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().
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().
Count and return the number of characters listed in <characters> at head of string <text>.
Count and return the number of characters listed in <characters> at tail of string <text>.
count the occurences of needle in haystack
removes leading blanks from a string, counting removed newlines
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.
read a token consisting of the given characters and a subsequent block the number of characters read from string <in>
read a parenthesis enclosed block from a string stop if no valid block or quote definition was given
read a string up to occurence of some other string
read a string up to occurence of the first of a set of characters stop if no valid block or quote definition was given
read a string up to the occurence of some delimiter
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.
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
Read a text file, line by line, and return the contents as a std::vector
Read a text file, line by line, and push the contents into a std::vector
read a histogram definition file, returning a TList of TObjStrings with histogram definitions
remove enclosing quotes from a string, returning the result
remove enclosing quotes from a string, returning the result
remove enclosing parenthesis from a string, returning the result
returns true if the string contains unquoted string literals, false otherwise
read a data from the given stream, purging c-style comments
finds the nearest mathing closing parenthesis in a string from a given position assuming that the opening parenthesis is at the given position
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)
finds the nearest mathing closing parenthesis in a string from a given position assuming that the opening parenthesis is at the given position
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)
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
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.
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.
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
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
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
find the index of an item in a list, return -1 if not found
finds the next occurrence of needle in haystack, starting at given position if needle is found returns position of the first character of needle
finds the next occurrence of needle in haystack, starting backwards at given position
finds the next occurrence of any needle in haystack, starting at given position
finds the next occurrence of needle in haystack, starting backwards at given position
see TQStringUtils::findLastOf(const TString& haystack, const TString& needle, int pos)
finds the next occurrence of anything else than needle in haystack, starting at given position
finds the next occurrence of anything else than needle in haystack, starting backwards at given position
see TQStringUtils::findLastNotOf(const TString& haystack, const TString& needle, int pos)
split a string at all occurrences of the delimiter and return a vector of results
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 !
The opposite method of split. Takes a vector of strings and combines it to a single string.
convert plain text to LaTeX code TODO: implement this function (currently, this is a DUMMY function)
convert plain text to HTML code TODO: implement this function (currently, this is a DUMMY function)
convert LaTeX symbols to plain text (ASCII or unicode)
convert HTML code to plain text (ASCII or unicode) TODO: implement this function (currently, this is a DUMMY function)
convert HTML code to LaTeX TODO: implement this function (currently, this is a DUMMY function)
convert ROOTTeX to plain text (ASCII or unicode) TODO: implement this function (currently, this is a DUMMY function)
convert ROOTTeX to HTML code TODO: implement this function (currently, this is a DUMMY function)
replace all characters in the given string by their unicode superscript variants if possible
replace all characters in the given string by their unicode superscript variants if possible
retrieve a color definition string for LaTeX
of the form "\definecolor{<name>}{rgb}{<r>,<g>,<b>}"
for some predefined color enum