KaliVeda
1.13/01
Heavy-Ion Analysis Toolkit
|
Extension of ROOT TString class which allows backwards compatibility with ROOT v3.10/02 onwards.
Tokenize() and IsDigit() methods are added here if they don't exist in the version of ROOT being used.
IsFloat() method is added: returns true if string is a floating-point number, i.e. if it has any of following formats (only first one returns kTRUE with TString::IsDigit()):
Also Atoi() and Atof() are extended to include the following possibilities:
Begin(), Next() and End() can be used to loop over items in a string separated by the delimiter character given as argument to Begin().
Example:
This will give the following output:
or, if Next() is called with argument strip_whitespace=kTRUE,
Definition at line 72 of file KVString.h.
Static Public Member Functions | |
static KVString | BaseConvert (const KVString &s_in, Int_t base_in, Int_t base_out) |
static KVString | Itoa (Int_t value, Int_t base) |
static KVString | LLtoa (Long64_t value, Int_t base) |
static KVString | UItoa (UInt_t value, Int_t base) |
static KVString | ULLtoa (ULong64_t value, Int_t base) |
Static Public Member Functions inherited from TString | |
static TString | BaseConvert (const TString &s_in, Int_t base_in, Int_t base_out) |
static TString | Format (const char *fmt,...) |
static Ssiz_t | GetInitialCapacity () |
static Ssiz_t | GetMaxWaste () |
static Ssiz_t | GetResizeIncrement () |
static UInt_t | Hash (const void *txt, Int_t ntxt) |
static Ssiz_t | InitialCapacity (Ssiz_t ic=15) |
static TString | Itoa (Int_t value, Int_t base) |
static TString | LLtoa (Long64_t value, Int_t base) |
static Ssiz_t | MaxWaste (Ssiz_t mw=15) |
static TString * | ReadString (TBuffer &b, const TClass *clReq) |
static Ssiz_t | ResizeIncrement (Ssiz_t ri=16) |
static TString | UItoa (UInt_t value, Int_t base) |
static TString | ULLtoa (ULong64_t value, Int_t base) |
static void | WriteString (TBuffer &b, const TString *a) |
Protected Attributes | |
Bool_t | fEndList |
used by Next() & End() to iterate over list More... | |
Int_t | fIterIndex |
used by Next() to iterate over list More... | |
std::unique_ptr< TObjArray > | kObjArr |
used by Next() to iterate over list More... | |
Protected Attributes inherited from TString | |
Rep_t | fRep |
kAlignment | |
Additional Inherited Members | |
Public Types inherited from TString | |
enum | ECaseCompare |
enum | EStripType |
Public Attributes inherited from TString | |
kBoth | |
kExact | |
kIgnoreCase | |
kLeading | |
kTrailing | |
Static Public Attributes inherited from TString | |
static const Ssiz_t | kNPOS |
Protected Member Functions inherited from TString | |
TString (const char *a1, Ssiz_t n1, const char *a2, Ssiz_t n2) | |
void | AssertElement (Ssiz_t nc) const |
void | Clobber (Ssiz_t nc) |
void | InitChar (char c) |
Static Protected Member Functions inherited from TString | |
static Ssiz_t | AdjustCapacity (Ssiz_t oldCap, Ssiz_t newCap) |
static Ssiz_t | Align (Ssiz_t s) |
static Ssiz_t | Recommend (Ssiz_t s) |
#include <KVString.h>
|
inline |
Definition at line 82 of file KVString.h.
|
inline |
Definition at line 85 of file KVString.h.
|
inline |
Definition at line 88 of file KVString.h.
|
inline |
Definition at line 91 of file KVString.h.
Definition at line 1466 of file KVString.cpp.
|
inlinevirtual |
Definition at line 96 of file KVString.h.
Converts string from base base_in to base base_out. Supported bases are 2-36. At most 64 bit data can be converted.
Definition at line 1192 of file KVString.cpp.
Begin(), Next() and End() can be used to loop over items in a string separated by the delimiter character given as argument to Begin().
Example:
This will give the following output:
Definition at line 565 of file KVString.cpp.
void KVString::Capitalize | ( | ) |
Change first character of string from lower to upper case.
Definition at line 1454 of file KVString.cpp.
Begin(), Next() and End() can be used to loop over items in a string separated by the delimiter character given as argument to Begin().
Example:
This will give the following output:
Definition at line 634 of file KVString.cpp.
KVString & KVString::FindCommonCharacters | ( | const TCollection * | list, |
const char | bug = '*' |
||
) |
list is a collection of objects with names this method generates a string containing all characters which appear in every name in the list, the others are replaced by the 'bug' character.
example: list contains a set of TNamed with names: run_0001.root run_0002.root ... run_0099.root
then toto.FindCommonCharacters(list) will produce toto="run_00*.root"
Definition at line 1307 of file KVString.cpp.
KVString & KVString::FindCommonTitleCharacters | ( | const TCollection * | list, |
const char | bug = '*' |
||
) |
list is a collection of objects with titles this method generates a string containing all characters which appear in every title in the list, the others are replaced by the 'bug' character.
example: list contains a set of TNamed with titles: run_0001.root run_0002.root ... run_0099.root
then toto.FindCommonCharacters(list) will produce toto="run_00*.root"
Definition at line 1377 of file KVString.cpp.
Count the number of substrings in this string separated by the given character(s) e.g. given a string "one | two | three", GetNValues("|") returns 3 Note that if the 'delim' character is not contained in the string, GetNValues() will return 1 (not 0) - see Begin().
Definition at line 886 of file KVString.cpp.
Converts an Int_t to a KVString with respect to the base specified (2-36). Thus it is an enhanced version of sprintf (adapted from versions 0.4 of http://www.jb.man.ac.uk/~slowe/cpp/itoa.html). Usage: the following statement produce the same output, namely "1111" std::cout << KVString::Itoa(15,2) ; std::cout << KVString::Itoa(0xF,2) ; /// 0x prefix to handle hex std::cout << KVString::Itoa(017,2) ; /// 0 prefix to handle oct In case of error returns the "!" string.
Definition at line 1038 of file KVString.cpp.
Converts a Long64_t to a KVString with respect to the base specified (2-36). Thus it is an enhanced version of sprintf (adapted from versions 0.4 of http://www.jb.man.ac.uk/~slowe/cpp/itoa.html). In case of error returns the "!" string.
Definition at line 1118 of file KVString.cpp.
Check if pattern fit the considered string As in ls shell command the * symbol represents the non discriminant part of the pattern if no * is present in the pattern, the result correspond to TString::Contains method Example KVString st(file_R45.dat); st.Match("*") -> kTRUE st.Match("file") ->kTRUE st.Match("*file*R*") ->kTRUE etc ....
Definition at line 494 of file KVString.cpp.
Begin(), Next() and End() can be used to loop over items in a string separated by the delimiter character given as argument to Begin().
[in] | strip_whitespace | if kTRUE (default is kFALSE), any leading or trailing whitespace is removed from each item |
Example:
This will give the following output:
whereas if Next() is used (i.e. strip_whitespace=kFALSE), this gives:
Definition at line 695 of file KVString.cpp.
|
inline |
Definition at line 182 of file KVString.h.
Definition at line 168 of file KVString.h.
Definition at line 176 of file KVString.h.
Generate a random sequence of upper- and lower-case letters of given length
Definition at line 1436 of file KVString.cpp.
RBegin(), RNext() and End() can be used to loop BACKWARDS over items in a string separated by the delimiter character given as argument to RBegin().
Example: KVString str("First | Second | Third"); str.RBegin("|"); while( !str.End() ){ cout << str.RNext().Data() << endl; }
This will give the following output:
Third Second First
WARNING: If the delimiter character is not contained in the string, calling RNext() will return the entire contents of the string, after which End() will return kTRUE. This allows to parse strings containing variable numbers of parameters separated by a delimiter which is only used with 2 or more parameters, i.e.:
"par1|par2|par3" -> "par3" "par2" "par1" "par1" -> "par1"
Definition at line 768 of file KVString.cpp.
void KVString::RemoveAllExtraWhiteSpace | ( | ) |
Remove any superfluous whitespace (or tabs or newlines) from this string (modifies string) i.e. transform " Mary Had\tA Little \n Laaaaaaaaaaaaaaaaaamb" into "Mary Had A Little Lamb"
Definition at line 1253 of file KVString.cpp.
RBegin(), RNext() and End() can be used to loop BACKWARDS over items in a string separated by the delimiter character given as argument to RBegin(). If strip_whitespace=kTRUE (default is kFALSE), any leading or trailing whitespace is removed from each item.
Example: KVString str("First | Second | Third"); str.RBegin("|"); while( !str.End() ){ cout << str.RNext(kTRUE).Data() << endl; }
This will give the following output:
Third Second First
whereas if RNext() is used (i.e. strip_whitespace=kFALSE), this gives:
Third Second First
Definition at line 841 of file KVString.cpp.
A more strict implementation than the standard 'sscanf' We require that any characters in the format string which are not format descriptors ("%d" etc.) be identical to the characters in this KVString
i.e. for a string "file6.root", sscanf("file6.root", "file%d.root", &some_integer) returns 1 but so does sscanf("file6.root", "file%danything_you_want_here_i_dont_care", &some_integer).
Use this method when you ONLY want "file%d.root" to match "file6.root"
Returns number of fields read from string
HANDLED FORMAT DESCRIPTORS
d - simple integer descriptor %3d - simple integer descriptor with length - only integers of correct length accepted (leading characters may be white space, i.e. ' 4' for 4 written with '%3d') %03d - simple integer descriptor with length + zero padding - only integers of correct length accepted (leading characters may be zeroes, i.e. '004' for 4 written with '%03d') %* - just garbage, no argument required, it is not read. we ignore the rest of the string and the rest of the format. this is not counted as a field to be read. i.e. Sscanf("%*") gives 0 for any string, not because it doesn't match, but because there is nothing to read.
Definition at line 320 of file KVString.cpp.
KVString KVString::StripAllExtraWhiteSpace | ( | ) | const |
Remove any superfluous whitespace (or tabs or newlines) from string (does not modify string) i.e. transform " Mary Had\tA Little \n Laaaaaaaaaaaaaaaaaamb" into "Mary Had A Little Lamb"
Definition at line 1275 of file KVString.cpp.
Replace every occurence of 'c1' with 'c2'.
Definition at line 275 of file KVString.cpp.
Converts a UInt_t (twice the range of an Int_t) to a KVString with respect to the base specified (2-36). Thus it is an enhanced version of sprintf (adapted from versions 0.4 of http://www.jb.man.ac.uk/~slowe/cpp/itoa.html). In case of error returns the "!" string.
Definition at line 1081 of file KVString.cpp.
Converts a ULong64_t (twice the range of an Long64_t) to a KVString with respect to the base specified (2-36). Thus it is an enhanced version of sprintf (adapted from versions 0.4 of http://www.jb.man.ac.uk/~slowe/cpp/itoa.html). In case of error returns the "!" string.
Definition at line 1157 of file KVString.cpp.
Split string into components according to delimiter 'delim' See Begin()/Next()/End()
Definition at line 909 of file KVString.cpp.
|
mutableprotected |
used by Next() & End() to iterate over list
Definition at line 78 of file KVString.h.
|
mutableprotected |
used by Next() to iterate over list
Definition at line 77 of file KVString.h.
|
mutableprotected |
used by Next() to iterate over list
Definition at line 76 of file KVString.h.