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