115 operator std::string_view()
const {
return std::string_view(
Data(),
fExtent); }
116 operator std::string()
const {
return std::string(
Data(),
fExtent); }
118 const char *
Data()
const;
149friend typename std::enable_if<ROOT::TypeTraits::IsSignedNumeral<T>::value,
TString>
::type
152friend typename std::enable_if<ROOT::TypeTraits::IsUnsignedNumeral<T>::value,
TString>
::type
155friend typename std::enable_if<ROOT::TypeTraits::IsFloatNumeral<T>::value,
TString>
::type
158friend typename std::enable_if<ROOT::TypeTraits::IsSignedNumeral<T>::value,
TString>
::type
161friend typename std::enable_if<ROOT::TypeTraits::IsUnsignedNumeral<T>::value,
TString>
::type
164friend typename std::enable_if<ROOT::TypeTraits::IsFloatNumeral<T>::value,
TString>
::type
184 enum { kMinCap = (
sizeof(
LongStr_t) - 1)/
sizeof(char) > 2 ?
185 (
sizeof(
LongStr_t) - 1)/
sizeof(
char) : 2 };
262 void FormImp(
const char *fmt, va_list ap);
280 explicit TString(
const std::string_view &sub);
301#if (__cplusplus >= 201700L) && (!defined(__clang_major__) || __clang_major__ > 5)
304 explicit operator std::string()
const {
return std::string(
GetPointer(),
Length()); }
306 operator std::string_view()
const {
return std::string_view(
GetPointer(),
Length()); }
324 typename std::enable_if<ROOT::TypeTraits::IsSignedNumeral<T>::value,
TString>
::type
327 typename std::enable_if<ROOT::TypeTraits::IsUnsignedNumeral<T>::value,
TString>
::type
330 typename std::enable_if<ROOT::TypeTraits::IsFloatNumeral<T>::value,
TString>
::type
374 Ssiz_t First(
const char *cs)
const;
375 void Form(
const char *fmt, ...)
376#if defined(__GNUC__) && !defined(__CINT__)
377 __attribute__((format(printf, 2, 3)))
419 std::istream &
ReadFile(std::istream &str);
420 std::istream &
ReadLine(std::istream &str,
423 std::istream &
ReadToDelim(std::istream &str,
char delim =
'\n');
424 std::istream &
ReadToken(std::istream &str);
460#if defined(__GNUC__) && !defined(__CINT__)
461 __attribute__((format(printf, 1, 2)))
471#if defined(R__TEMPLATE_OVERLOAD_BUG)
480 return left.append(right.
Data());
490extern char *
Form(
const char *fmt, ...)
491#if defined(__GNUC__) && !defined(__CINT__)
492__attribute__((format(printf, 1, 2)))
496#if defined(__GNUC__) && !defined(__CINT__)
497__attribute__((format(printf, 1, 2)))
500extern char *
Strip(
const char *str,
char c =
' ');
501extern char *
StrDup(
const char *str);
502extern char *
Compress(
const char *str);
503extern int EscChar(
const char *src,
char *dst,
int dstlen,
char *specchars,
505extern int UnEscChar(
const char *src,
char *dst,
int dstlen,
char *specchars,
508#ifdef NEED_STRCASECMP
509extern int strcasecmp(
const char *str1,
const char *str2);
510extern int strncasecmp(
const char *str1,
const char *str2,
Ssiz_t n);
520inline typename std::enable_if<ROOT::TypeTraits::IsSignedNumeral<T>::value,
TString>
::type
525inline typename std::enable_if<ROOT::TypeTraits::IsUnsignedNumeral<T>::value,
TString>
::type
530inline typename std::enable_if<ROOT::TypeTraits::IsFloatNumeral<T>::value,
TString>
::type
535inline typename std::enable_if<ROOT::TypeTraits::IsSignedNumeral<T>::value,
TString>
::type
545inline typename std::enable_if<ROOT::TypeTraits::IsUnsignedNumeral<T>::value,
TString>
::type
555inline typename std::enable_if<ROOT::TypeTraits::IsFloatNumeral<T>::value,
TString>
::type
577{
return Append(cs, cs ? strlen(cs) : 0); }
586inline typename std::enable_if<ROOT::TypeTraits::IsSignedNumeral<T>::value,
TString>
::type
596inline typename std::enable_if<ROOT::TypeTraits::IsUnsignedNumeral<T>::value,
TString>
::type
606inline typename std::enable_if<ROOT::TypeTraits::IsFloatNumeral<T>::value,
TString>
::type
640{
return Index(s, s ? strlen(s) : 0, i, cmp); }
647{
return Index(pat.
Data(), patlen, i, cmp); }
650{
return Replace(pos, 0, cs, cs ? strlen(cs) : 0); }
662{
return Replace(0, 0, cs, cs ? strlen(cs) : 0); }
683{
return Replace(pos,
n, cs, cs ? strlen(cs) : 0); }
696{
return ReplaceAll(
s1.Data(),
s1.Length(), s2, s2 ? strlen(s2) : 0); }
759 return ((
s1.Length() == s2.
Length()) &&
760 !memcmp(
s1.Data(), s2.
Data(),
s1.Length()));
764{
return !(
s1 == s2); }
767{
return s1.CompareTo(s2) < 0; }
770{
return s1.CompareTo(s2) > 0; }
773{
return s1.CompareTo(s2) <= 0; }
776{
return s1.CompareTo(s2) >= 0; }
780{
return !(
s1 == s2); }
783{
return s1.CompareTo(s2) < 0; }
786{
return s1.CompareTo(s2) > 0; }
789{
return s1.CompareTo(s2) <= 0; }
792{
return s1.CompareTo(s2) >= 0; }
795{
return (s2 ==
s1); }
798{
return !(s2 ==
s1); }
817{
return (s2 ==
s1); }
820{
return (s2 ==
s1); }
823{
return !(
s1 == s2); }
826{
return !(
s1 == s2); }
829{
return !(
s1 == s2); }
832{
return !(s2 ==
s1); }
835{
return !(s2 ==
s1); }
841 return std::string_view(
s1) == s2;
846 return s1 == std::string_view(s2);
855 std::string printValue(
const TString* val);
856 std::string printValue(
const TSubString* val);
857 std::string printValue(
const std::string_view* val);
unsigned long long ULong64_t
#define ClassDef(name, id)
TBuffer & operator<<(TBuffer &buf, const Tmpl *obj)
TString ToUpper(const TString &s)
Return an upper-case version of str.
Bool_t operator!=(const TString &s1, const TString &s2)
TString ToLower(const TString &s)
Return a lower-case version of str.
Bool_t operator>(const TString &s1, const TString &s2)
Bool_t operator>=(const TString &s1, const TString &s2)
char * Compress(const char *str)
Remove all blanks from the string str.
char * Form(const char *fmt,...)
UInt_t Hash(const TString &s)
int UnEscChar(const char *src, char *dst, int dstlen, char *specchars, char escchar)
Un-escape specchars in src from escchar and copy to dst.
Bool_t operator<(const TString &s1, const TString &s2)
TString operator+(const TString &s1, const TString &s2)
Use the special concatenation constructor.
char * Strip(const char *str, char c=' ')
Strip leading and trailing c (blanks by default) from a string.
Bool_t operator<=(const TString &s1, const TString &s2)
void Printf(const char *fmt,...)
Bool_t operator==(const TString &s1, const TString &s2)
char * StrDup(const char *str)
Duplicate the string str.
int EscChar(const char *src, char *dst, int dstlen, char *specchars, char escchar)
Escape specchars in src with escchar and copy to dst.
std::istream & operator>>(std::istream &str, TString &s)
Read string from stream.
std::string & operator+=(std::string &left, const TString &right)
The concrete implementation of TBuffer for writing/reading to/from a ROOT file or socket.
Buffer base class used for serializing objects.
TClass instances represent classes, structs and namespaces in the ROOT type system.
Regular expression class.
ATTENTION: this class is obsolete.
TString Copy() const
Copy a string.
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...
const char * GetPointer() const
char & operator[](Ssiz_t i)
static TString LLtoa(Long64_t value, Int_t base)
Converts a Long64_t to a TString with respect to the base specified (2-36).
std::enable_if< ROOT::TypeTraits::IsFloatNumeral< T >::value, TString >::type & operator+=(T f)
void SetShortSize(Ssiz_t s)
char & operator()(Ssiz_t i)
Bool_t IsDec() const
Returns true if all characters in string are decimal digits (0-9).
void ToLower()
Change string to lower-case.
int CompareTo(const char *cs, ECaseCompare cmp=kExact) const
Compare a string to char *cs2.
TString & Insert(Ssiz_t pos, const char *s)
static Ssiz_t MaxWaste(Ssiz_t mw=15)
Set maximum space that may be wasted in a string before doing a resize.
Int_t Atoi() const
Return integer value of string.
static Ssiz_t Align(Ssiz_t s)
void SetLongSize(Ssiz_t s)
Bool_t Gets(FILE *fp, Bool_t chop=kTRUE)
Read one line from the stream, including the , or until EOF.
std::istream & ReadToDelim(std::istream &str, char delim='\n')
Read up to an EOF, or a delimiting character, whichever comes first.
static const Ssiz_t kNPOS
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
Return true if string ends with the specified string.
TSubString Strip(EStripType s=kTrailing, char c=' ') const
Return a substring of self stripped at beginning and/or end.
TString()
TString default ctor.
Bool_t IsHex() const
Returns true if all characters in string are hexadecimal digits (0-9,a-f,A-F).
Double_t Atof() const
Return floating-point value contained in string.
Bool_t IsFloat() const
Returns kTRUE if string contains a floating point or integer number.
void Clear()
Clear string without changing its capacity.
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.
TString & Replace(Ssiz_t pos, Ssiz_t n, const char *s)
const char * Data() const
static TString * ReadString(TBuffer &b, const TClass *clReq)
Read TString object from buffer.
Bool_t EqualTo(const char *cs, ECaseCompare cmp=kExact) const
Bool_t IsDigit() const
Returns true if all characters in string are digits (0-9) or white spaces, i.e.
Bool_t MaybeRegexp() const
Returns true if string contains one of the regexp characters "^$.[]*+?".
static Ssiz_t ResizeIncrement(Ssiz_t ri=16)
Set default resize increment for all TStrings. Default is 16.
UInt_t HashCase() const
Return a case-sensitive hash value (endian independent).
Bool_t IsOct() const
Returns true if all characters in string are octal digits (0-7).
virtual ~TString()
Delete a TString.
static Ssiz_t GetMaxWaste()
TString & ReplaceAll(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.
TString MD5() const
Return the MD5 digest for this string, in a string representation.
void Resize(Ssiz_t n)
Resize the string. Truncate or add blanks as necessary.
Bool_t IsAlpha() const
Returns true if all characters in string are alphabetic.
UInt_t HashFoldCase() const
Return a case-insensitive hash value (endian independent).
Ssiz_t Last(char c) const
Find last occurrence of a character c.
void ToUpper()
Change string to upper case.
Bool_t IsAscii() const
Returns true if all characters in string are ascii.
TObjArray * Tokenize(const TString &delim) const
This function is used to isolate sequential tokens in a TString.
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
static Ssiz_t GetResizeIncrement()
void Puts(FILE *fp)
Write string to the stream.
void SetLongCap(Ssiz_t s)
friend TString operator+(const TString &s1, const TString &s2)
Use the special concatenation constructor.
std::string_view View() const
TString & Prepend(const char *cs)
TString & Swap(TString &other)
Bool_t IsBin() const
Returns true if all characters in string are binary digits (0,1).
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.
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...
Int_t CountChar(Int_t c) const
Return number of times character c occurs in the string.
friend Bool_t operator==(const TString &s1, const TString &s2)
UInt_t Hash(ECaseCompare cmp=kExact) const
Return hash value.
static void WriteString(TBuffer &b, const TString *a)
Write TString object to buffer.
virtual void FillBuffer(char *&buffer) const
Copy string into I/O buffer.
TString & operator=(char s)
Assign character c to TString.
std::istream & ReadFile(std::istream &str)
Replace string with the contents of strm, stopping at an EOF.
TString & Remove(Ssiz_t pos)
static Ssiz_t InitialCapacity(Ssiz_t ic=15)
Set default initial capacity for all TStrings. Default is 15.
TString & Append(const char *cs)
Bool_t IsInBaseN(Int_t base) const
Returns true if all characters in string are expressed in the base specified (range=2-36),...
char * Init(Ssiz_t capacity, Ssiz_t nchar)
Private member function returning an empty string representation of size capacity and containing ncha...
Bool_t MaybeWildcard() const
Returns true if string contains one of the wildcard characters "[]*?".
void InitChar(char c)
Initialize a string with a single character.
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
static TString Itoa(Int_t value, Int_t base)
Converts an Int_t to a TString with respect to the base specified (2-36).
virtual Int_t Sizeof() const
Returns size string will occupy on I/O buffer.
TString & operator+=(const char *s)
Ssiz_t GetShortSize() const
Bool_t IsWhitespace() const
void Clone(Ssiz_t nc)
Make self a distinct copy with capacity of at least tot, where tot cannot be smaller than the current...
const char * GetLongPointer() const
std::enable_if< ROOT::TypeTraits::IsUnsignedNumeral< T >::value, TString >::type & operator+=(T u)
const char * GetShortPointer() const
Ssiz_t GetLongCap() const
void SetLongPointer(char *p)
std::istream & ReadToken(std::istream &str)
Read a token, delimited by whitespace, from the input stream.
Ssiz_t GetLongSize() const
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
friend TBuffer & operator<<(TBuffer &b, const TString *obj)
Write TString or derived to TBuffer.
static Ssiz_t GetInitialCapacity()
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
void AssertElement(Ssiz_t nc) const
Check to make sure a string index is in range.
virtual void ReadBuffer(char *&buffer)
Read string from I/O buffer.
Bool_t IsAlnum() const
Returns true if all characters in string are alphanumeric.
void FormImp(const char *fmt, va_list ap)
Formats a string using a printf style format descriptor.
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
void Clobber(Ssiz_t nc)
Clear string and make sure it has a capacity of nc.
static Ssiz_t Recommend(Ssiz_t s)
std::istream & ReadLine(std::istream &str, Bool_t skipWhite=kTRUE)
Read a line from stream upto newline skipping any whitespace.
Long64_t Atoll() const
Return long long value of string.
A zero length substring is legal.
TSubString & operator=(const char *s)
Assign char* to sub-string.
void ToUpper()
Convert sub-string to upper-case.
void SubStringError(Ssiz_t, Ssiz_t, Ssiz_t) const
Output error message.
char & operator[](Ssiz_t i)
Return character at pos i from sub-string. Check validity of i.
friend Bool_t operator==(const TSubString &s1, const TSubString &s2)
Compare two sub-strings.
void AssertElement(Ssiz_t i) const
Check to make sure a sub-string index is in range.
void ToLower()
Convert sub-string to lower-case.
TSubString(const TSubString &s)
const char * Data() const
char & operator()(Ssiz_t i)
Return character at pos i from sub-string. No check on i.
This class implements a mutex interface.
Short_t Max(Short_t a, Short_t b)
Short_t Min(Short_t a, Short_t b)