KaliVeda
Toolkit for HIC analysis
|
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 73 of file KVString.h.
#include <KVString.h>
Public Member Functions | |
KVString () | |
KVString (const Char_t *s) | |
KVString (const KVString &s) | |
KVString (const TString &s) | |
KVString (Double_t value, Double_t error) | |
virtual | ~KVString () |
void | Begin (TString delim) const |
void | Capitalize () |
Change first character of string from lower to upper case. | |
Bool_t | End () const |
KVString & | FindCommonCharacters (const TCollection *, const char bug=' *') |
KVString & | FindCommonTitleCharacters (const TCollection *, const char bug=' *') |
Int_t | GetNValues (TString delim) const |
virtual Bool_t | Match (TString pattern) |
KVString | Next (Bool_t strip_whitespace=kFALSE) const |
KVString & | operator= (const char *s) |
KVString & | operator= (const KVString &s) |
KVString & | operator= (const TString &s) |
void | RandomLetterSequence (Int_t length) |
void | RBegin (TString delim) const |
void | RemoveAllExtraWhiteSpace () |
KVString | RNext (Bool_t strip_whitespace=kFALSE) const |
virtual Int_t | Sscanf (const Char_t *fmt,...) |
KVString | StripAllExtraWhiteSpace () const |
virtual KVString & | Substitute (const Char_t c1, const Char_t c2) |
Replace every occurence of 'c1' with 'c2'. | |
std::vector< KVString > | Vectorize (TString delim, Bool_t strip_whitespace=kFALSE) |
Public Member Functions inherited from TString | |
TString () | |
TString (char c) | |
TString (char c, Ssiz_t s) | |
TString (const char *s) | |
TString (const char *s, Ssiz_t n) | |
TString (const std::string &s) | |
TString (const std::string_view &sub) | |
TString (const TString &s) | |
TString (const TSubString &sub) | |
TString (Ssiz_t ic) | |
TString (TString &&s) noexcept | |
virtual | ~TString () |
TString & | Append (char c, Ssiz_t rep=1) |
TString & | Append (const char *cs) |
TString & | Append (const char *cs, Ssiz_t n) |
TString & | Append (const TString &s) |
TString & | Append (const TString &s, Ssiz_t n) |
Double_t | Atof () const |
Int_t | Atoi () const |
Long64_t | Atoll () const |
Bool_t | BeginsWith (const char *s, ECaseCompare cmp=kExact) const |
Bool_t | BeginsWith (const TString &pat, ECaseCompare cmp=kExact) const |
Ssiz_t | Capacity () const |
Ssiz_t | Capacity (Ssiz_t n) |
TString & | Chop () |
void | Clear () |
int | CompareTo (const char *cs, ECaseCompare cmp=kExact) const |
int | CompareTo (const TString &st, ECaseCompare cmp=kExact) const |
Bool_t | Contains (const char *pat, ECaseCompare cmp=kExact) const |
Bool_t | Contains (const TRegexp &pat) const |
Bool_t | Contains (const TString &pat, ECaseCompare cmp=kExact) const |
Bool_t | Contains (TPRegexp &pat) const |
TString | Copy () const |
Int_t | CountChar (Int_t c) const |
const char * | Data () const |
Bool_t | EndsWith (const char *pat, ECaseCompare cmp=kExact) const |
Bool_t | EqualTo (const char *cs, ECaseCompare cmp=kExact) const |
Bool_t | EqualTo (const TString &st, ECaseCompare cmp=kExact) const |
virtual void | FillBuffer (char *&buffer) const |
Ssiz_t | First (char c) const |
Ssiz_t | First (const char *cs) const |
void | Form (const char *fmt,...) |
Bool_t | Gets (FILE *fp, Bool_t chop=kTRUE) |
UInt_t | Hash (ECaseCompare cmp=kExact) const |
Ssiz_t | Index (const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const |
Ssiz_t | Index (const char *pat, Ssiz_t patlen, Ssiz_t i, ECaseCompare cmp) const |
Ssiz_t | Index (const TRegexp &pat, Ssiz_t *ext, Ssiz_t i=0) const |
Ssiz_t | Index (const TRegexp &pat, Ssiz_t i=0) const |
Ssiz_t | Index (const TString &s, Ssiz_t i=0, ECaseCompare cmp=kExact) const |
Ssiz_t | Index (const TString &s, Ssiz_t patlen, Ssiz_t i, ECaseCompare cmp) const |
Ssiz_t | Index (TPRegexp &pat, Ssiz_t *ext, Ssiz_t i=0) const |
Ssiz_t | Index (TPRegexp &pat, Ssiz_t i=0) const |
TString & | Insert (Ssiz_t pos, const char *s) |
TString & | Insert (Ssiz_t pos, const char *s, Ssiz_t extent) |
TString & | Insert (Ssiz_t pos, const TString &s) |
TString & | Insert (Ssiz_t pos, const TString &s, Ssiz_t extent) |
virtual TClass * | IsA () const |
Bool_t | IsAlnum () const |
Bool_t | IsAlpha () const |
Bool_t | IsAscii () const |
Bool_t | IsBin () const |
Bool_t | IsDec () const |
Bool_t | IsDigit () const |
Bool_t | IsFloat () const |
Bool_t | IsHex () const |
Bool_t | IsInBaseN (Int_t base) const |
Bool_t | IsNull () const |
Bool_t | IsOct () const |
Bool_t | IsWhitespace () const |
Ssiz_t | Last (char c) const |
Ssiz_t | Length () const |
Bool_t | MaybeRegexp () const |
Bool_t | MaybeWildcard () const |
TString | MD5 () const |
operator const char * () const | |
operator ROOT::Internal::TStringView () const | |
TSubString | operator() (const TRegexp &re) const |
TSubString | operator() (const TRegexp &re, Ssiz_t start) const |
char & | operator() (Ssiz_t i) |
char | operator() (Ssiz_t i) const |
TSubString | operator() (Ssiz_t start, Ssiz_t len) const |
TSubString | operator() (TPRegexp &re) const |
TSubString | operator() (TPRegexp &re, Ssiz_t start) const |
TString & | operator+= (char c) |
TString & | operator+= (const char *s) |
TString & | operator+= (const TString &s) |
std::enable_if< ROOT::TypeTraits::IsFloatNumeral< T >::value, TString >::type & | operator+= (T f) |
std::enable_if< ROOT::TypeTraits::IsSignedNumeral< T >::value, TString >::type & | operator+= (T i) |
std::enable_if< ROOT::TypeTraits::IsUnsignedNumeral< T >::value, TString >::type & | operator+= (T u) |
TString & | operator= (char s) |
TString & | operator= (const char *s) |
TString & | operator= (const std::string &s) |
TString & | operator= (const std::string_view &s) |
TString & | operator= (const TString &s) |
TString & | operator= (const TSubString &s) |
TString & | operator= (TString &&s) noexcept |
char & | operator[] (Ssiz_t i) |
char | operator[] (Ssiz_t i) const |
TString & | Prepend (char c, Ssiz_t rep=1) |
TString & | Prepend (const char *cs) |
TString & | Prepend (const char *cs, Ssiz_t n) |
TString & | Prepend (const TString &s) |
TString & | Prepend (const TString &s, Ssiz_t n) |
void | Puts (FILE *fp) |
virtual void | ReadBuffer (char *&buffer) |
std::istream & | ReadFile (std::istream &str) |
std::istream & | ReadLine (std::istream &str, Bool_t skipWhite=kTRUE) |
std::istream & | ReadString (std::istream &str) |
std::istream & | ReadToDelim (std::istream &str, char delim='\n') |
std::istream & | ReadToken (std::istream &str) |
TString & | Remove (EStripType s, char c) |
TString & | Remove (Ssiz_t pos) |
TString & | Remove (Ssiz_t pos, Ssiz_t n) |
TString & | Replace (Ssiz_t pos, Ssiz_t n, const char *s) |
TString & | Replace (Ssiz_t pos, Ssiz_t n, const char *s, Ssiz_t ns) |
TString & | Replace (Ssiz_t pos, Ssiz_t n, const TString &s) |
TString & | Replace (Ssiz_t pos, Ssiz_t n1, const TString &s, Ssiz_t n2) |
TString & | ReplaceAll (const char *s1, const char *s2) |
TString & | ReplaceAll (const char *s1, const TString &s2) |
TString & | ReplaceAll (const char *s1, Ssiz_t ls1, const char *s2, Ssiz_t ls2) |
TString & | ReplaceAll (const TString &s1, const char *s2) |
TString & | ReplaceAll (const TString &s1, const TString &s2) |
TString & | ReplaceSpecialCppChars () |
void | Resize (Ssiz_t n) |
virtual Int_t | Sizeof () const |
virtual void | Streamer (TBuffer &) |
void | StreamerNVirtual (TBuffer &ClassDef_StreamerNVirtual_b) |
TSubString | Strip (EStripType s=kTrailing, char c=' ') const |
TSubString | SubString (const char *pat, Ssiz_t start=0, ECaseCompare cmp=kExact) const |
TString & | Swap (TString &other) |
TObjArray * | Tokenize (const TString &delim) const |
Bool_t | Tokenize (TString &tok, Ssiz_t &from, const char *delim=" ") const |
void | ToLower () |
void | ToUpper () |
std::string_view | View () const |
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 TClass * | Class () |
static const char * | Class_Name () |
static constexpr Version_t | Class_Version () |
static const char * | DeclFileName () |
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) |
Private Attributes | |
Bool_t | fEndList |
used by Next() & End() to iterate over list | |
Int_t | fIterIndex |
used by Next() to iterate over list | |
std::unique_ptr< TObjArray > | kObjArr |
used by Next() to iterate over list | |
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 constexpr 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) |
Protected Attributes inherited from TString | |
Rep_t | fRep |
kAlignment | |
|
inline |
Definition at line 83 of file KVString.h.
|
inline |
Definition at line 86 of file KVString.h.
|
inline |
Definition at line 89 of file KVString.h.
|
inline |
Definition at line 92 of file KVString.h.
Definition at line 1466 of file KVString.cpp.
|
inlinevirtual |
Definition at line 97 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.
Bool_t KVString::End | ( | ) | const |
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 183 of file KVString.h.
Definition at line 169 of file KVString.h.
Definition at line 177 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.
|
mutableprivate |
used by Next() & End() to iterate over list
Definition at line 79 of file KVString.h.
|
mutableprivate |
used by Next() to iterate over list
Definition at line 78 of file KVString.h.
|
mutableprivate |
used by Next() to iterate over list
Definition at line 77 of file KVString.h.