35 #ifndef ROOT_TMathBase
44 namespace std { using ::string; }
119 const char *
Data()
const;
173 enum { kMinCap = (
sizeof(
LongStr_t) - 1)/
sizeof(char) > 2 ?
174 (
sizeof(
LongStr_t) - 1)/
sizeof(
char) : 2 };
251 void FormImp(
const char *fmt, va_list ap);
269 TString(
const std::string_view &sub);
355 void Form(
const char *fmt, ...)
356 #if defined(__GNUC__) && !defined(__CINT__)
399 std::istream &
ReadFile(std::istream &str);
400 std::istream &
ReadLine(std::istream &str,
403 std::istream &
ReadToDelim(std::istream &str,
char delim =
'\n');
404 std::istream &
ReadToken(std::istream &str);
439 #if defined(__GNUC__) && !defined(__CINT__)
450 #if defined(R__TEMPLATE_OVERLOAD_BUG)
463 extern char *
Form(
const char *fmt, ...)
464 #if defined(__GNUC__) && !defined(__CINT__)
468 extern void Printf(
const char *fmt, ...)
469 #if defined(__GNUC__) && !defined(__CINT__)
473 extern char *
Strip(
const char *str,
char c =
' ');
474 extern char *
StrDup(
const char *str);
475 extern char *
Compress(
const char *str);
476 extern int EscChar(
const char *src,
char *dst,
int dstlen,
char *specchars,
478 extern int UnEscChar(
const char *src,
char *dst,
int dstlen,
char *specchars,
481 #ifdef NEED_STRCASECMP
482 extern int strcasecmp(
const char *str1,
const char *str2);
483 extern int strncasecmp(
const char *str1,
const char *str2,
Ssiz_t n);
505 {
return Append(cs, cs ? strlen(cs) : 0); }
514 {
char s[32]; sprintf(s,
"%ld", i);
return operator+=(s); }
517 {
char s[32]; sprintf(s,
"%lu", i);
return operator+=(s); }
535 sprintf(s,
"%.17g", f);
546 sprintf(s,
"%lld", l);
554 sprintf(s,
"%llu", ul);
583 {
return Index(s, s ? strlen(s) : 0, i, cmp); }
590 {
return Index(pat.
Data(), patlen, i, cmp); }
593 {
return Replace(pos, 0, cs, cs ? strlen(cs) : 0); }
596 {
return Replace(pos, 0, cs, n); }
605 {
return Replace(0, 0, cs, cs ? strlen(cs) : 0); }
608 {
return Replace(0, 0, cs, n); }
620 {
return Replace(pos, n, 0, 0); }
626 {
return Replace(pos, n, cs, cs ? strlen(cs) : 0); }
645 {
return ReplaceAll(s1, s1 ? strlen(s1) : 0, s2, s2 ? strlen(s2) : 0); }
707 {
return !(s1 ==
s2); }
723 {
return !(s1 ==
s2); }
738 {
return (s2 == s1); }
741 {
return !(s2 ==
s1); }
760 {
return (s2 == s1); }
763 {
return (s2 == s1); }
766 {
return !(s1 ==
s2); }
769 {
return !(s1 ==
s2); }
772 {
return !(s1 ==
s2); }
775 {
return !(s2 ==
s1); }
778 {
return !(s2 ==
s1); }
787 std::string
printValue(
const std::string_view &val);
A zero length substring is legal.
static Ssiz_t GetMaxWaste()
TString MD5() const
Return the MD5 digest for this string, in a string representation.
Ssiz_t Last(char c) const
Find last occurrence of a character c.
std::istream & ReadFile(std::istream &str)
Replace string with the contents of strm, stopping at an EOF.
void ToLower()
Convert sub-string to lower-case.
virtual void FillBuffer(char *&buffer) const
Copy string into I/O buffer.
TSubString & operator=(const char *s)
Assign char* to sub-string.
static TString Itoa(Int_t value, Int_t base)
Converts an Int_t to a TString with respect to the base specified (2-36).
The concrete implementation of TBuffer for writing/reading to/from a ROOT file or socket...
friend TString operator+(const TString &s1, const TString &s2)
Use the special concatenation constructor.
UInt_t Hash(const TString &s)
static Ssiz_t MaxWaste(Ssiz_t mw=15)
Set maximum space that may be wasted in a string before doing a resize.
char * Compress(const char *str)
Remove all blanks from the string str.
Bool_t MaybeRegexp() const
Returns true if string contains one of the regexp characters "^$.[]*+?".
void ToUpper()
Convert sub-string to upper-case.
Bool_t IsOct() const
Returns true if all characters in string are octal digits (0-7).
std::ostream & operator<<(std::ostream &str, const TString &s)
Write string to stream.
friend Bool_t operator==(const TSubString &s1, const TSubString &s2)
Compare two sub-strings.
ATTENTION: this class is obsolete.
TString & ReplaceAll(const TString &s1, const TString &s2)
void SubStringError(Ssiz_t, Ssiz_t, Ssiz_t) const
Output error message.
Bool_t IsInBaseN(Int_t base) const
Returns true if all characters in string are expressed in the base specified (range=2-36), i.e.
std::istream & ReadLine(std::istream &str, Bool_t skipWhite=kTRUE)
Read a line from stream upto newline skipping any whitespace.
Double_t Atof() const
Return floating-point value contained in string.
char & operator[](Ssiz_t i)
Bool_t IsAlnum() const
Returns true if all characters in string are alphanumeric.
void Clone(Ssiz_t nc)
Make self a distinct copy with capacity of at least tot, where tot cannot be smaller than the current...
static TString UItoa(UInt_t value, Int_t base)
Converts a UInt_t (twice the range of an Int_t) to a TString with respect to the base specified (2-36...
void ToUpper()
Change string to upper case.
int UnEscChar(const char *src, char *dst, int dstlen, char *specchars, char escchar)
Un-escape specchars in src from escchar and copy to dst.
Buffer base class used for serializing objects.
Regular expression class.
This class implements a mutex interface.
Short_t Min(Short_t a, Short_t b)
void ToLower()
Change string to lower-case.
TString & operator=(char s)
Assign character c to TString.
static Ssiz_t ResizeIncrement(Ssiz_t ri=16)
Set default resize increment for all TStrings. Default is 16.
TString & operator+=(const char *s)
std::istream & ReadToken(std::istream &str)
Read a token, delimited by whitespace, from the input stream.
std::istream & operator>>(std::istream &str, TString &s)
Read string from stream.
TString & Prepend(const char *cs)
static std::string format(double x, double y, int digits, int width)
static void WriteString(TBuffer &b, const TString *a)
Write TString object to buffer.
TSubString(const TSubString &s)
TString Copy() const
Copy a string.
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
TString & Insert(Ssiz_t pos, const char *s)
char * Init(Ssiz_t capacity, Ssiz_t nchar)
Private member function returning an empty string representation of size capacity and containing ncha...
Bool_t operator>=(const TString &s1, const TString &s2)
TString & Replace(Ssiz_t pos, Ssiz_t n, const char *s)
const char * Data() const
const char * GetShortPointer() const
Bool_t IsBin() const
Returns true if all characters in string are binary digits (0,1).
#define ClassDef(name, id)
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString...
virtual void ReadBuffer(char *&buffer)
Read string from I/O buffer.
Ssiz_t GetShortSize() const
static TString * ReadString(TBuffer &b, const TClass *clReq)
Read TString object from buffer.
void Clear()
Clear string without changing its capacity.
TString & Append(const char *cs)
static Ssiz_t Recommend(Ssiz_t s)
static Ssiz_t GetInitialCapacity()
Int_t Atoi() const
Return integer value of string.
TString operator+(const TString &s1, const TString &s2)
Use the special concatenation constructor.
void AssertElement(Ssiz_t nc) const
Check to make sure a string index is in range.
basic_string_view< char > string_view
Bool_t operator!=(const TString &s1, const TString &s2)
char & operator()(Ssiz_t i)
std::string printValue(const TDatime &val)
Print a TDatime at the prompt.
Bool_t operator<=(const TString &s1, const TString &s2)
void AssertElement(Ssiz_t i) const
Check to make sure a sub-string index is in range.
char & operator[](Ssiz_t i)
Return character at pos i from sub-string. Check validity of i.
Bool_t IsDec() const
Returns true if all characters in string are decimal digits (0-9).
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
Return true if string ends with the specified string.
Ssiz_t GetLongSize() const
TSubString SubString(const char *pat, Ssiz_t start=0, ECaseCompare cmp=kExact) const
Returns a substring matching "pattern", or the null substring if there is no such match...
Bool_t EqualTo(const char *cs, ECaseCompare cmp=kExact) const
char & operator()(Ssiz_t i)
Return character at pos i from sub-string. No check on i.
Bool_t Gets(FILE *fp, Bool_t chop=kTRUE)
Read one line from the stream, including the , or until EOF.
char * Strip(const char *str, char c= ' ')
Strip leading and trailing c (blanks by default) from a string.
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
char * Form(const char *fmt,...)
void SetLongCap(Ssiz_t s)
Bool_t IsWhitespace() const
TSubString Strip(EStripType s=kTrailing, char c= ' ') const
Return a substring of self stripped at beginning and/or end.
The ROOT global object gROOT contains a list of all defined classes.
UInt_t HashFoldCase() const
Return a case-insensitive hash value (endian independent).
void SetLongPointer(char *p)
Int_t CountChar(Int_t c) const
Return number of times character c occurs in the string.
static Ssiz_t GetResizeIncrement()
std::istream & ReadToDelim(std::istream &str, char delim= '\n')
Read up to an EOF, or a delimiting character, whichever comes first.
TObjArray * Tokenize(const TString &delim) const
This function is used to isolate sequential tokens in a TString.
static Ssiz_t InitialCapacity(Ssiz_t ic=15)
Set default initial capacity for all TStrings. Default is 15.
void FormImp(const char *fmt, va_list ap)
Formats a string using a printf style format descriptor.
TString ToLower(const TString &s)
Return a lower-case version of str.
char * StrDup(const char *str)
Duplicate the string str.
static const Ssiz_t kNPOS
void Clobber(Ssiz_t nc)
Clear string and make sure it has a capacity of nc.
TString & Remove(Ssiz_t pos)
friend TBuffer & operator<<(TBuffer &b, const TString *obj)
Write TString or derived to TBuffer.
TString & Swap(TString &other)
void SetLongSize(Ssiz_t s)
void Printf(const char *fmt,...)
Long64_t Atoll() const
Return long long value of string.
unsigned long long ULong64_t
void Puts(FILE *fp)
Write string to the stream.
ClassImp(TMCParticle) void TMCParticle printf(": p=(%7.3f,%7.3f,%9.3f) ;", fPx, fPy, fPz)
static TString BaseConvert(const TString &s_in, Int_t base_in, Int_t base_out)
Converts string from base base_in to base base_out.
Bool_t IsFloat() const
Returns kTRUE if string contains a floating point or integer number.
Bool_t MaybeWildcard() const
Returns true if string contains one of the wildcard characters "[]*?".
static TString ULLtoa(ULong64_t value, Int_t base)
Converts a ULong64_t (twice the range of an Long64_t) to a TString with respect to the base specified...
UInt_t HashCase() const
Return a case-sensitive hash value (endian independent).
void SetShortSize(Ssiz_t s)
int EscChar(const char *src, char *dst, int dstlen, char *specchars, char escchar)
Escape specchars in src with escchar and copy to dst.
Bool_t IsDigit() const
Returns true if all characters in string are digits (0-9) or white spaces, i.e.
Bool_t operator>(const TString &s1, const TString &s2)
Bool_t operator==(const TString &s1, const TString &s2)
const char * GetPointer() const
static Ssiz_t Align(Ssiz_t s)
TSubString(const TString &s, Ssiz_t start, Ssiz_t len)
Private constructor.
Short_t Max(Short_t a, Short_t b)
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
virtual Int_t Sizeof() const
Returns size string will occupy on I/O buffer.
TString ToUpper(const TString &s)
Return an upper-case version of str.
static TString LLtoa(Long64_t value, Int_t base)
Converts a Long64_t to a TString with respect to the base specified (2-36).
TString()
TString default ctor.
const char * Data() const
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
Bool_t IsAlpha() const
Returns true if all characters in string are alphabetic.
Bool_t operator<(const TString &s1, const TString &s2)
Bool_t IsHex() const
Returns true if all characters in string are hexadecimal digits (0-9,a-f,A-F).
friend Bool_t operator==(const TString &s1, const TString &s2)
static Ssiz_t AdjustCapacity(Ssiz_t oldCap, Ssiz_t newCap)
Calculate a nice capacity greater than or equal to newCap.
Ssiz_t GetLongCap() const
Ssiz_t First(char c) const
Find first occurrence of a character c.
int CompareTo(const char *cs, ECaseCompare cmp=kExact) const
Compare a string to char *cs2.
Bool_t IsAscii() const
Returns true if all characters in string are ascii.
void InitChar(char c)
Initialize a string with a single character.
void Resize(Ssiz_t n)
Resize the string. Truncate or add blanks as necessary.
const char * GetLongPointer() const
virtual ~TString()
Delete a TString.
UInt_t Hash(ECaseCompare cmp=kExact) const
Return hash value.