Logo ROOT  
Reference Guide
TString.h
Go to the documentation of this file.
1 // @(#)root/base:$Id$
2 // Author: Fons Rademakers 04/08/95
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_TString
13 #define ROOT_TString
14 
15 
16 //////////////////////////////////////////////////////////////////////////
17 // //
18 // TString //
19 // //
20 // Basic string class. //
21 // //
22 // Cannot be stored in a TCollection... use TObjString instead. //
23 // //
24 //////////////////////////////////////////////////////////////////////////
25 
26 #include "Rtypes.h"
27 
28 #include "TMathBase.h"
29 #include "ROOT/RStringView.hxx"
30 #include "ROOT/TypeTraits.hxx"
31 #include "snprintf.h"
32 
33 #include <iosfwd>
34 #include <cstdarg>
35 #include <cstdio>
36 #include <cstring>
37 #include <string>
38 
39 class TRegexp;
40 class TPRegexp;
41 class TString;
42 class TSubString;
43 class TObjArray;
44 class TVirtualMutex;
45 class TBuffer;
46 class TClass;
47 class TBufferFile;
48 
49 TString operator+(const TString &s1, const TString &s2);
50 TString operator+(const TString &s, const char *cs);
51 TString operator+(const char *cs, const TString &s);
52 TString operator+(const TString &s, char c);
53 TString operator+(char c, const TString &s);
54 Bool_t operator==(const TString &s1, const TString &s2);
55 Bool_t operator==(const TString &s1, const char *s2);
56 Bool_t operator==(const TSubString &s1, const TSubString &s2);
57 Bool_t operator==(const TSubString &s1, const TString &s2);
58 Bool_t operator==(const TSubString &s1, const char *s2);
59 /*
60 template<class T>
61 struct is_signed_numeral : std::integral_constant<bool,
62  std::is_integral<T>::value && std::is_signed<T>::value
63 > {};
64 
65 template<class T>
66 struct is_unsigned_numeral : std::integral_constant<bool,
67  std::is_integral<T>::value && !std::is_signed<T>::value
68 > {};
69 
70 template<class T>
71 using is_float_numeral = std::is_floating_point<T>;
72 */
73 
74 //////////////////////////////////////////////////////////////////////////
75 // //
76 // TSubString //
77 // //
78 // The TSubString class allows selected elements to be addressed. //
79 // There are no public constructors. //
80 // //
81 //////////////////////////////////////////////////////////////////////////
82 class TSubString {
83 
84 friend class TStringLong;
85 friend class TString;
86 
87 friend Bool_t operator==(const TSubString &s1, const TSubString &s2);
88 friend Bool_t operator==(const TSubString &s1, const TString &s2);
89 friend Bool_t operator==(const TSubString &s1, const char *s2);
90 
91 private:
92  TString &fStr; // Referenced string
93  Ssiz_t fBegin; // Index of starting character
94  Ssiz_t fExtent; // Length of TSubString
95 
96  // NB: the only constructor is private
97  TSubString(const TString &s, Ssiz_t start, Ssiz_t len);
98 
99 protected:
100  void SubStringError(Ssiz_t, Ssiz_t, Ssiz_t) const;
101  void AssertElement(Ssiz_t i) const; // Verifies i is valid index
102 
103 public:
105  : fStr(s.fStr), fBegin(s.fBegin), fExtent(s.fExtent) { }
106 
107  TSubString &operator=(const char *s); // Assignment from a char*
108  TSubString &operator=(const TString &s); // Assignment from a TString
109  TSubString &operator=(const TSubString &s); // Assignment from a TSubString
110  char &operator()(Ssiz_t i); // Index with optional bounds checking
111  char &operator[](Ssiz_t i); // Index with bounds checking
112  char operator()(Ssiz_t i) const; // Index with optional bounds checking
113  char operator[](Ssiz_t i) const; // Index with bounds checking
114 
115  operator std::string_view() const { return std::string_view(Data(),fExtent); }
116  operator std::string() const { return std::string(Data(),fExtent); }
117 
118  const char *Data() const;
119  Ssiz_t Length() const { return fExtent; }
120  Ssiz_t Start() const { return fBegin; }
121  TString& String() { return fStr; }
122  void ToLower(); // Convert self to lower-case
123  void ToUpper(); // Convert self to upper-case
124 
125  // For detecting null substrings
126  Bool_t IsNull() const { return fBegin == kNPOS; }
127  int operator!() const { return fBegin == kNPOS; }
128 };
129 
130 
131 //////////////////////////////////////////////////////////////////////////
132 // //
133 // TString //
134 // //
135 //////////////////////////////////////////////////////////////////////////
136 class TString {
137 
138 friend class TStringLong;
139 friend class TSubString;
140 friend class TBufferFile;
141 
142 friend TString operator+(const TString &s1, const TString &s2);
143 friend TString operator+(const TString &s, const char *cs);
144 friend TString operator+(const char *cs, const TString &s);
145 friend TString operator+(const TString &s, char c);
146 friend TString operator+(char c, const TString &s);
147 
148 template<class T>
149 friend typename std::enable_if<ROOT::TypeTraits::IsSignedNumeral<T>::value,TString>::type
150 operator+(TString s, T i);
151 template<class T>
152 friend typename std::enable_if<ROOT::TypeTraits::IsUnsignedNumeral<T>::value,TString>::type
153 operator+(TString s, T u);
154 template<class T>
155 friend typename std::enable_if<ROOT::TypeTraits::IsFloatNumeral<T>::value,TString>::type
156 operator+(TString s, T f);
157 template<class T>
158 friend typename std::enable_if<ROOT::TypeTraits::IsSignedNumeral<T>::value,TString>::type
159 operator+(T i, const TString &s);
160 template<class T>
161 friend typename std::enable_if<ROOT::TypeTraits::IsUnsignedNumeral<T>::value,TString>::type
162 operator+(T u, const TString &s);
163 template<class T>
164 friend typename std::enable_if<ROOT::TypeTraits::IsFloatNumeral<T>::value,TString>::type
165 operator+(T f, const TString &s);
166 
167 friend Bool_t operator==(const TString &s1, const TString &s2);
168 friend Bool_t operator==(const TString &s1, const char *s2);
169 
170 private:
171 #ifdef R__BYTESWAP
172  enum { kShortMask = 0x01, kLongMask = 0x1 };
173 #else
174  enum { kShortMask = 0x80, kLongMask = 0x80000000 };
175 #endif
176 
177  struct LongStr_t
178  {
179  Ssiz_t fCap; // Max string length (including null)
180  Ssiz_t fSize; // String length (excluding null)
181  char *fData; // Long string data
182  };
183 
184  enum { kMinCap = (sizeof(LongStr_t) - 1)/sizeof(char) > 2 ?
185  (sizeof(LongStr_t) - 1)/sizeof(char) : 2 };
186 
187  struct ShortStr_t
188  {
189  unsigned char fSize; // String length (excluding null)
190  char fData[kMinCap]; // Short string data
191  };
192 
194 
195  enum { kNwords = sizeof(UStr_t) / sizeof(Ssiz_t)};
196 
197  struct RawStr_t
198  {
200  };
201 
202  struct Rep_t
203  {
204  union
205  {
209  };
210  };
211 
212 protected:
213 #ifndef __CINT__
214  Rep_t fRep; //! String data
215 #endif
216 
217  // Special concatenation constructor
218  TString(const char *a1, Ssiz_t n1, const char *a2, Ssiz_t n2);
219  void AssertElement(Ssiz_t nc) const; // Index in range
220  void Clobber(Ssiz_t nc); // Remove old contents
221  void InitChar(char c); // Initialize from char
222 
223  enum { kAlignment = 16 };
224  static Ssiz_t Align(Ssiz_t s) { return (s + (kAlignment-1)) & ~(kAlignment-1); }
225  static Ssiz_t Recommend(Ssiz_t s) { return (s < kMinCap ? kMinCap : Align(s+1)) - 1; }
226  static Ssiz_t AdjustCapacity(Ssiz_t oldCap, Ssiz_t newCap);
227 
228 private:
229  Bool_t IsLong() const { return Bool_t(fRep.fShort.fSize & kShortMask); }
230 #ifdef R__BYTESWAP
231  void SetShortSize(Ssiz_t s) { fRep.fShort.fSize = (unsigned char)(s << 1); }
232  Ssiz_t GetShortSize() const { return fRep.fShort.fSize >> 1; }
233 #else
234  void SetShortSize(Ssiz_t s) { fRep.fShort.fSize = (unsigned char)s; }
235  Ssiz_t GetShortSize() const { return fRep.fShort.fSize; }
236 #endif
238  Ssiz_t GetLongSize() const { return fRep.fLong.fSize; }
241  Ssiz_t GetLongCap() const { return fRep.fLong.fCap & ~kLongMask; }
242  void SetLongPointer(char *p) { fRep.fLong.fData = p; }
243  char *GetLongPointer() { return fRep.fLong.fData; }
244  const char *GetLongPointer() const { return fRep.fLong.fData; }
245  char *GetShortPointer() { return fRep.fShort.fData; }
246  const char *GetShortPointer() const { return fRep.fShort.fData; }
247  char *GetPointer() { return IsLong() ? GetLongPointer() : GetShortPointer(); }
248  const char *GetPointer() const { return IsLong() ? GetLongPointer() : GetShortPointer(); }
249 #ifdef R__BYTESWAP
250  static Ssiz_t MaxSize() { return kMaxInt - 1; }
251 #else
252  static Ssiz_t MaxSize() { return (kMaxInt >> 1) - 1; }
253 #endif
254  void UnLink() const { if (IsLong()) delete [] fRep.fLong.fData; }
255  void Zero() {
256  Ssiz_t (&a)[kNwords] = fRep.fRaw.fWords;
257  for (UInt_t i = 0; i < kNwords; ++i)
258  a[i] = 0;
259  }
260  char *Init(Ssiz_t capacity, Ssiz_t nchar);
261  void Clone(Ssiz_t nc); // Make self a distinct copy w. capacity nc
262  void FormImp(const char *fmt, va_list ap);
263  UInt_t HashCase() const;
264  UInt_t HashFoldCase() const;
265 
266 public:
267  enum EStripType { kLeading = 0x1, kTrailing = 0x2, kBoth = 0x3 };
269  static const Ssiz_t kNPOS = ::kNPOS;
270 
271  TString(); // Null string
272  explicit TString(Ssiz_t ic); // Suggested capacity
273  TString(const TString &s); // Copy constructor
274  TString(TString &&s) noexcept; // Move constructor
275  TString(const char *s); // Copy to embedded null
276  TString(const char *s, Ssiz_t n); // Copy past any embedded nulls
277  TString(const std::string &s);
278  TString(char c);
279  TString(char c, Ssiz_t s);
280  explicit TString(const std::string_view &sub);
281  TString(const TSubString &sub);
282 
283  virtual ~TString();
284 
285  // ROOT I/O interface
286  virtual void FillBuffer(char *&buffer) const;
287  virtual void ReadBuffer(char *&buffer);
288  virtual Int_t Sizeof() const;
289 
290  static TString *ReadString(TBuffer &b, const TClass *clReq);
291  static void WriteString(TBuffer &b, const TString *a);
292 
293  friend TBuffer &operator<<(TBuffer &b, const TString *obj);
294 
295  // C I/O interface
296  Bool_t Gets(FILE *fp, Bool_t chop=kTRUE);
297  void Puts(FILE *fp);
298 
299  // Type conversion
300  operator const char*() const { return GetPointer(); }
301 #if (__cplusplus >= 201700L) && (!defined(__clang_major__) || __clang_major__ > 5)
302  // Clang 5.0 support for explicit conversion is still inadequate even in c++17 mode.
303  // (It leads to extraneous ambiguous overload errors)
304  explicit operator std::string() const { return std::string(GetPointer(),Length()); }
305  explicit operator ROOT::Internal::TStringView() const { return ROOT::Internal::TStringView(GetPointer(),Length()); }
306  operator std::string_view() const { return std::string_view(GetPointer(),Length()); }
307 #else
309 #endif
310 
311  // Assignment
312  TString &operator=(char s); // Replace string
313  TString &operator=(const char *s);
314  TString &operator=(const TString &s);
315  TString &operator=(TString &&s) noexcept;
316  TString &operator=(const std::string &s);
318  TString &operator=(const TSubString &s);
319  TString &operator+=(const char *s); // Append string
320  TString &operator+=(const TString &s);
321  TString &operator+=(char c);
322 
323  template<class T>
324  typename std::enable_if<ROOT::TypeTraits::IsSignedNumeral<T>::value,TString>::type
325  &operator+=(T i);
326  template<class T>
327  typename std::enable_if<ROOT::TypeTraits::IsUnsignedNumeral<T>::value,TString>::type
329  template<class T>
330  typename std::enable_if<ROOT::TypeTraits::IsFloatNumeral<T>::value,TString>::type
332 
333  // Indexing operators
334  char &operator[](Ssiz_t i); // Indexing with bounds checking
335  char &operator()(Ssiz_t i); // Indexing with optional bounds checking
336  char operator[](Ssiz_t i) const;
337  char operator()(Ssiz_t i) const;
338  TSubString operator()(Ssiz_t start, Ssiz_t len) const; // Sub-string operator
339  TSubString operator()(const TRegexp &re) const; // Match the RE
340  TSubString operator()(const TRegexp &re, Ssiz_t start) const;
341  TSubString operator()(TPRegexp &re) const; // Match the Perl compatible Regular Expression
342  TSubString operator()(TPRegexp &re, Ssiz_t start) const;
343  TSubString SubString(const char *pat, Ssiz_t start = 0,
344  ECaseCompare cmp = kExact) const;
345 
346  // Non-static member functions
347  TString &Append(const char *cs);
348  TString &Append(const char *cs, Ssiz_t n);
349  TString &Append(const TString &s);
350  TString &Append(const TString &s, Ssiz_t n);
351  TString &Append(char c, Ssiz_t rep = 1); // Append c rep times
352  Int_t Atoi() const;
353  Long64_t Atoll() const;
354  Double_t Atof() const;
355  Bool_t BeginsWith(const char *s, ECaseCompare cmp = kExact) const;
356  Bool_t BeginsWith(const TString &pat, ECaseCompare cmp = kExact) const;
357  Ssiz_t Capacity() const { return (IsLong() ? GetLongCap() : kMinCap) - 1; }
359  TString &Chop();
360  void Clear();
361  int CompareTo(const char *cs, ECaseCompare cmp = kExact) const;
362  int CompareTo(const TString &st, ECaseCompare cmp = kExact) const;
363  Bool_t Contains(const char *pat, ECaseCompare cmp = kExact) const;
364  Bool_t Contains(const TString &pat, ECaseCompare cmp = kExact) const;
365  Bool_t Contains(const TRegexp &pat) const;
366  Bool_t Contains(TPRegexp &pat) const;
367  Int_t CountChar(Int_t c) const;
368  TString Copy() const;
369  const char *Data() const { return GetPointer(); }
370  Bool_t EndsWith(const char *pat, ECaseCompare cmp = kExact) const;
371  Bool_t EqualTo(const char *cs, ECaseCompare cmp = kExact) const;
372  Bool_t EqualTo(const TString &st, ECaseCompare cmp = kExact) const;
373  Ssiz_t First(char c) const;
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))) /* 1 is the this pointer */
378 #endif
379  ;
380  UInt_t Hash(ECaseCompare cmp = kExact) const;
381  Ssiz_t Index(const char *pat, Ssiz_t i = 0,
382  ECaseCompare cmp = kExact) const;
383  Ssiz_t Index(const TString &s, Ssiz_t i = 0,
384  ECaseCompare cmp = kExact) const;
385  Ssiz_t Index(const char *pat, Ssiz_t patlen, Ssiz_t i,
386  ECaseCompare cmp) const;
387  Ssiz_t Index(const TString &s, Ssiz_t patlen, Ssiz_t i,
388  ECaseCompare cmp) const;
389  Ssiz_t Index(const TRegexp &pat, Ssiz_t i = 0) const;
390  Ssiz_t Index(const TRegexp &pat, Ssiz_t *ext, Ssiz_t i = 0) const;
391  Ssiz_t Index(TPRegexp &pat, Ssiz_t i = 0) const;
392  Ssiz_t Index(TPRegexp &pat, Ssiz_t *ext, Ssiz_t i = 0) const;
393  TString &Insert(Ssiz_t pos, const char *s);
394  TString &Insert(Ssiz_t pos, const char *s, Ssiz_t extent);
395  TString &Insert(Ssiz_t pos, const TString &s);
396  TString &Insert(Ssiz_t pos, const TString &s, Ssiz_t extent);
397  Bool_t IsAscii() const;
398  Bool_t IsAlpha() const;
399  Bool_t IsAlnum() const;
400  Bool_t IsDigit() const;
401  Bool_t IsFloat() const;
402  Bool_t IsHex() const;
403  Bool_t IsBin() const;
404  Bool_t IsOct() const;
405  Bool_t IsDec() const;
406  Bool_t IsInBaseN(Int_t base) const;
407  Bool_t IsNull() const { return Length() == 0; }
408  Bool_t IsWhitespace() const { return (Length() == CountChar(' ')); }
409  Ssiz_t Last(char c) const;
410  Ssiz_t Length() const { return IsLong() ? GetLongSize() : GetShortSize(); }
411  Bool_t MaybeRegexp() const;
412  Bool_t MaybeWildcard() const;
413  TString MD5() const;
414  TString &Prepend(const char *cs); // Prepend a character string
415  TString &Prepend(const char *cs, Ssiz_t n);
416  TString &Prepend(const TString &s);
417  TString &Prepend(const TString &s, Ssiz_t n);
418  TString &Prepend(char c, Ssiz_t rep = 1); // Prepend c rep times
419  std::istream &ReadFile(std::istream &str); // Read to EOF or null character
420  std::istream &ReadLine(std::istream &str,
421  Bool_t skipWhite = kTRUE); // Read to EOF or newline
422  std::istream &ReadString(std::istream &str); // Read to EOF or null character
423  std::istream &ReadToDelim(std::istream &str, char delim = '\n'); // Read to EOF or delimitor
424  std::istream &ReadToken(std::istream &str); // Read separated by white space
425  TString &Remove(Ssiz_t pos); // Remove pos to end of string
426  TString &Remove(Ssiz_t pos, Ssiz_t n); // Remove n chars starting at pos
427  TString &Remove(EStripType s, char c); // Like Strip() but changing string directly
428  TString &Replace(Ssiz_t pos, Ssiz_t n, const char *s);
429  TString &Replace(Ssiz_t pos, Ssiz_t n, const char *s, Ssiz_t ns);
430  TString &Replace(Ssiz_t pos, Ssiz_t n, const TString &s);
431  TString &Replace(Ssiz_t pos, Ssiz_t n1, const TString &s, Ssiz_t n2);
432  TString &ReplaceAll(const TString &s1, const TString &s2); // Find&Replace all s1 with s2 if any
433  TString &ReplaceAll(const TString &s1, const char *s2); // Find&Replace all s1 with s2 if any
434  TString &ReplaceAll(const char *s1, const TString &s2); // Find&Replace all s1 with s2 if any
435  TString &ReplaceAll(const char *s1, const char *s2); // Find&Replace all s1 with s2 if any
436  TString &ReplaceAll(const char *s1, Ssiz_t ls1, const char *s2, Ssiz_t ls2); // Find&Replace all s1 with s2 if any
437  void Resize(Ssiz_t n); // Truncate or add blanks as necessary
438  TSubString Strip(EStripType s = kTrailing, char c = ' ') const;
439  TString &Swap(TString &other); // Swap the contents of this and other without reallocation
440  void ToLower(); // Change self to lower-case
441  void ToUpper(); // Change self to upper-case
442  TObjArray *Tokenize(const TString &delim) const;
443  Bool_t Tokenize(TString &tok, Ssiz_t &from, const char *delim = " ") const;
445 
446  // Static member functions
447  static UInt_t Hash(const void *txt, Int_t ntxt); // Calculates hash index from any char string.
448  static Ssiz_t InitialCapacity(Ssiz_t ic = 15); // Initial allocation capacity
449  static Ssiz_t MaxWaste(Ssiz_t mw = 15); // Max empty space before reclaim
450  static Ssiz_t ResizeIncrement(Ssiz_t ri = 16); // Resizing increment
451  static Ssiz_t GetInitialCapacity();
452  static Ssiz_t GetResizeIncrement();
453  static Ssiz_t GetMaxWaste();
454  static TString Itoa ( Int_t value, Int_t base); // Converts int to string with respect to the base specified (2-36)
455  static TString UItoa ( UInt_t value, Int_t base);
456  static TString LLtoa ( Long64_t value, Int_t base);
457  static TString ULLtoa (ULong64_t value, Int_t base);
458  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 (supported bases 2-36)
459  static TString Format(const char *fmt, ...)
460 #if defined(__GNUC__) && !defined(__CINT__)
461  __attribute__((format(printf, 1, 2)))
462 #endif
463  ;
464 
465  ClassDef(TString,2) //Basic string class
466 };
467 
468 // Related global functions
469 std::istream &operator>>(std::istream &str, TString &s);
470 std::ostream &operator<<(std::ostream &str, const TString &s);
471 #if defined(R__TEMPLATE_OVERLOAD_BUG)
472 template <>
473 #endif
474 TBuffer &operator>>(TBuffer &buf, TString *&sp);
475 TBuffer &operator<<(TBuffer &buf, const TString * sp);
476 
477 // Conversion operator (per se).
478 inline std::string& operator+=(std::string &left, const TString &right)
479 {
480  return left.append(right.Data());
481 }
482 
483 TString ToLower(const TString &s); // Return lower-case version of argument
484 TString ToUpper(const TString &s); // Return upper-case version of argument
485 
486 inline UInt_t Hash(const TString &s) { return s.Hash(); }
487 inline UInt_t Hash(const TString *s) { return s->Hash(); }
488  UInt_t Hash(const char *s);
489 
490 extern char *Form(const char *fmt, ...) // format in circular buffer
491 #if defined(__GNUC__) && !defined(__CINT__)
492 __attribute__((format(printf, 1, 2)))
493 #endif
494 ;
495 extern void Printf(const char *fmt, ...) // format and print
496 #if defined(__GNUC__) && !defined(__CINT__)
497 __attribute__((format(printf, 1, 2)))
498 #endif
499 ;
500 extern char *Strip(const char *str, char c = ' '); // strip c off str, free with delete []
501 extern char *StrDup(const char *str); // duplicate str, free with delete []
502 extern char *Compress(const char *str); // remove blanks from string, free with delele []
503 extern int EscChar(const char *src, char *dst, int dstlen, char *specchars,
504  char escchar); // copy from src to dst escaping specchars by escchar
505 extern int UnEscChar(const char *src, char *dst, int dstlen, char *specchars,
506  char escchar); // copy from src to dst removing escchar from specchars
507 
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);
511 #endif
512 
513 //////////////////////////////////////////////////////////////////////////
514 // //
515 // Inlines //
516 // //
517 //////////////////////////////////////////////////////////////////////////
518 
519 template<class T>
520 inline typename std::enable_if<ROOT::TypeTraits::IsSignedNumeral<T>::value,TString>::type
522 { return s += i; }
523 
524 template<class T>
525 inline typename std::enable_if<ROOT::TypeTraits::IsUnsignedNumeral<T>::value,TString>::type
527 { return s += u; }
528 
529 template<class T>
530 inline typename std::enable_if<ROOT::TypeTraits::IsFloatNumeral<T>::value,TString>::type
532 { return s += f; }
533 
534 template<class T>
535 inline typename std::enable_if<ROOT::TypeTraits::IsSignedNumeral<T>::value,TString>::type
536 operator+(T i, const TString &s)
537 {
538  char buffer[32];
539  // coverity[secure_coding] Buffer is large enough (2^64 = 20 digits).
540  snprintf(buffer, sizeof(buffer), "%lld", static_cast<Long64_t>(i));
541  return TString(buffer, strlen(buffer), s.Data(), s.Length());
542 }
543 
544 template<class T>
545 inline typename std::enable_if<ROOT::TypeTraits::IsUnsignedNumeral<T>::value,TString>::type
546 operator+(T u, const TString &s)
547 {
548  char buffer[32];
549  // coverity[secure_coding] Buffer is large enough (2^64 = 20 digits).
550  snprintf(buffer, sizeof(buffer), "%llu", static_cast<ULong64_t>(u));
551  return TString(buffer, strlen(buffer), s.Data(), s.Length());
552 }
553 
554 template<class T>
555 inline typename std::enable_if<ROOT::TypeTraits::IsFloatNumeral<T>::value,TString>::type
557 {
558  char buffer[32];
559  // coverity[secure_coding] Buffer is large enough: width specified in format
560  snprintf(buffer, sizeof(buffer), "%.17Lg", static_cast<LongDouble_t>(f));
561  return TString(buffer, strlen(buffer), s.Data(), s.Length());
562 }
563 
564 inline TString &TString::Append(const char *cs)
565 { return Replace(Length(), 0, cs, cs ? strlen(cs) : 0); }
566 
567 inline TString &TString::Append(const char *cs, Ssiz_t n)
568 { return Replace(Length(), 0, cs, n); }
569 
571 { return Replace(Length(), 0, s.Data(), s.Length()); }
572 
574 { return Replace(Length(), 0, s.Data(), TMath::Min(n, s.Length())); }
575 
576 inline TString &TString::operator+=(const char *cs)
577 { return Append(cs, cs ? strlen(cs) : 0); }
578 
580 { return Append(s.Data(), s.Length()); }
581 
583 { return Append(c); }
584 
585 template<class T>
586 inline typename std::enable_if<ROOT::TypeTraits::IsSignedNumeral<T>::value,TString>::type
588 {
589  char buffer[32];
590  // coverity[secure_coding] Buffer is large enough (2^64 = 20 digits).
591  snprintf(buffer, sizeof(buffer), "%lld", static_cast<Long64_t>(i));
592  return operator+=(buffer);
593 }
594 
595 template<class T>
596 inline typename std::enable_if<ROOT::TypeTraits::IsUnsignedNumeral<T>::value,TString>::type
598 {
599  char buffer[32];
600  // coverity[secure_coding] Buffer is large enough (2^64 = 20 digits).
601  snprintf(buffer, sizeof(buffer), "%llu", static_cast<ULong64_t>(u));
602  return operator+=(buffer);
603 }
604 
605 template<class T>
606 inline typename std::enable_if<ROOT::TypeTraits::IsFloatNumeral<T>::value,TString>::type
608 {
609  char buffer[32];
610  // coverity[secure_coding] Buffer is large enough: width specified in format
611  snprintf(buffer, sizeof(buffer), "%.17Lg", static_cast<LongDouble_t>(f));
612  return operator+=(buffer);
613 }
614 
615 inline Bool_t TString::BeginsWith(const char *s, ECaseCompare cmp) const
616 { return Index(s, s ? strlen(s) : (Ssiz_t)0, (Ssiz_t)0, cmp) == 0; }
617 
618 inline Bool_t TString::BeginsWith(const TString &pat, ECaseCompare cmp) const
619 { return Index(pat.Data(), pat.Length(), (Ssiz_t)0, cmp) == 0; }
620 
621 inline Bool_t TString::Contains(const TString &pat, ECaseCompare cmp) const
622 { return Index(pat.Data(), pat.Length(), (Ssiz_t)0, cmp) != kNPOS; }
623 
624 inline Bool_t TString::Contains(const char *s, ECaseCompare cmp) const
625 { return Index(s, s ? strlen(s) : 0, (Ssiz_t)0, cmp) != kNPOS; }
626 
627 inline Bool_t TString::Contains(const TRegexp &pat) const
628 { return Index(pat, (Ssiz_t)0) != kNPOS; }
629 
631 { return Index(pat, (Ssiz_t)0) != kNPOS; }
632 
633 inline Bool_t TString::EqualTo(const char *cs, ECaseCompare cmp) const
634 { return (CompareTo(cs, cmp) == 0) ? kTRUE : kFALSE; }
635 
636 inline Bool_t TString::EqualTo(const TString &st, ECaseCompare cmp) const
637 { return (CompareTo(st, cmp) == 0) ? kTRUE : kFALSE; }
638 
639 inline Ssiz_t TString::Index(const char *s, Ssiz_t i, ECaseCompare cmp) const
640 { return Index(s, s ? strlen(s) : 0, i, cmp); }
641 
642 inline Ssiz_t TString::Index(const TString &s, Ssiz_t i, ECaseCompare cmp) const
643 { return Index(s.Data(), s.Length(), i, cmp); }
644 
645 inline Ssiz_t TString::Index(const TString &pat, Ssiz_t patlen, Ssiz_t i,
646  ECaseCompare cmp) const
647 { return Index(pat.Data(), patlen, i, cmp); }
648 
649 inline TString &TString::Insert(Ssiz_t pos, const char *cs)
650 { return Replace(pos, 0, cs, cs ? strlen(cs) : 0); }
651 
652 inline TString &TString::Insert(Ssiz_t pos, const char *cs, Ssiz_t n)
653 { return Replace(pos, 0, cs, n); }
654 
655 inline TString &TString::Insert(Ssiz_t pos, const TString &s)
656 { return Replace(pos, 0, s.Data(), s.Length()); }
657 
659 { return Replace(pos, 0, s.Data(), TMath::Min(n, s.Length())); }
660 
661 inline TString &TString::Prepend(const char *cs)
662 { return Replace(0, 0, cs, cs ? strlen(cs) : 0); }
663 
664 inline TString &TString::Prepend(const char *cs, Ssiz_t n)
665 { return Replace(0, 0, cs, n); }
666 
668 { return Replace(0, 0, s.Data(), s.Length()); }
669 
671 { return Replace(0, 0, s.Data(), TMath::Min(n, s.Length())); }
672 
674 { return Replace(pos, TMath::Max(0, Length()-pos), 0, 0); }
675 
677 { return Replace(pos, n, 0, 0); }
678 
680 { return Remove(TMath::Max(0, Length()-1)); }
681 
682 inline TString &TString::Replace(Ssiz_t pos, Ssiz_t n, const char *cs)
683 { return Replace(pos, n, cs, cs ? strlen(cs) : 0); }
684 
686 { return Replace(pos, n, s.Data(), s.Length()); }
687 
688 inline TString &TString::Replace(Ssiz_t pos, Ssiz_t n1, const TString &s,
689  Ssiz_t n2)
690 { return Replace(pos, n1, s.Data(), TMath::Min(s.Length(), n2)); }
691 
692 inline TString &TString::ReplaceAll(const TString &s1, const TString &s2)
693 { return ReplaceAll(s1.Data(), s1.Length(), s2.Data(), s2.Length()) ; }
694 
695 inline TString &TString::ReplaceAll(const TString &s1, const char *s2)
696 { return ReplaceAll(s1.Data(), s1.Length(), s2, s2 ? strlen(s2) : 0); }
697 
698 inline TString &TString::ReplaceAll(const char *s1, const TString &s2)
699 { return ReplaceAll(s1, s1 ? strlen(s1) : 0, s2.Data(), s2.Length()); }
700 
701 inline TString &TString::ReplaceAll(const char *s1,const char *s2)
702 { return ReplaceAll(s1, s1 ? strlen(s1) : 0, s2, s2 ? strlen(s2) : 0); }
703 
704 inline TString &TString::Swap(TString &other) {
705  // Swap the contents of other and this without reallocation.
706 #ifndef __CINT__
707  Rep_t tmp = other.fRep;
708  other.fRep = fRep;
709  fRep = tmp;
710 #endif
711  return *this;
712 }
713 
715 { return GetPointer()[i]; }
716 
717 inline char TString::operator()(Ssiz_t i) const
718 { return GetPointer()[i]; }
719 
721 { AssertElement(i); return GetPointer()[i]; }
722 
723 inline char TString::operator[](Ssiz_t i) const
724 { AssertElement(i); return GetPointer()[i]; }
725 
726 inline const char *TSubString::Data() const
727 {
728  // Return a pointer to the beginning of the substring. Note that the
729  // terminating null is in the same place as for the original
730  // TString, so this method is not appropriate for converting the
731  // TSubString to a string. To do that, construct a TString from the
732  // TSubString. For example:
733  //
734  // root [0] TString s("hello world")
735  // root [1] TSubString sub=s(0, 5)
736  // root [2] sub.Data()
737  // (const char* 0x857c8b8)"hello world"
738  // root [3] TString substr(sub)
739  // root [4] substr
740  // (class TString)"hello"
741 
742  return fStr.Data() + fBegin;
743 }
744 
745 // Access to elements of sub-string with bounds checking
746 inline char TSubString::operator[](Ssiz_t i) const
747 { AssertElement(i); return fStr.GetPointer()[fBegin+i]; }
748 
749 inline char TSubString::operator()(Ssiz_t i) const
750 { return fStr.GetPointer()[fBegin+i]; }
751 
753 { fStr = s.fStr; fBegin = s.fBegin; fExtent = s.fExtent; return *this; }
754 
755 
756 // String Logical operators
757 inline Bool_t operator==(const TString &s1, const TString &s2)
758 {
759  return ((s1.Length() == s2.Length()) &&
760  !memcmp(s1.Data(), s2.Data(), s1.Length()));
761 }
762 
763 inline Bool_t operator!=(const TString &s1, const TString &s2)
764 { return !(s1 == s2); }
765 
766 inline Bool_t operator<(const TString &s1, const TString &s2)
767 { return s1.CompareTo(s2) < 0; }
768 
769 inline Bool_t operator>(const TString &s1, const TString &s2)
770 { return s1.CompareTo(s2) > 0; }
771 
772 inline Bool_t operator<=(const TString &s1, const TString &s2)
773 { return s1.CompareTo(s2) <= 0; }
774 
775 inline Bool_t operator>=(const TString &s1, const TString &s2)
776 { return s1.CompareTo(s2) >= 0; }
777 
778 // Bool_t operator==(const TString &s1, const char *s2);
779 inline Bool_t operator!=(const TString &s1, const char *s2)
780 { return !(s1 == s2); }
781 
782 inline Bool_t operator<(const TString &s1, const char *s2)
783 { return s1.CompareTo(s2) < 0; }
784 
785 inline Bool_t operator>(const TString &s1, const char *s2)
786 { return s1.CompareTo(s2) > 0; }
787 
788 inline Bool_t operator<=(const TString &s1, const char *s2)
789 { return s1.CompareTo(s2) <= 0; }
790 
791 inline Bool_t operator>=(const TString &s1, const char *s2)
792 { return s1.CompareTo(s2) >= 0; }
793 
794 inline Bool_t operator==(const char *s1, const TString &s2)
795 { return (s2 == s1); }
796 
797 inline Bool_t operator!=(const char *s1, const TString &s2)
798 { return !(s2 == s1); }
799 
800 inline Bool_t operator<(const char *s1, const TString &s2)
801 { return s2.CompareTo(s1) > 0; }
802 
803 inline Bool_t operator>(const char *s1, const TString &s2)
804 { return s2.CompareTo(s1) < 0; }
805 
806 inline Bool_t operator<=(const char *s1, const TString &s2)
807 { return s2.CompareTo(s1) >= 0; }
808 
809 inline Bool_t operator>=(const char *s1, const TString &s2)
810 { return s2.CompareTo(s1) <= 0; }
811 
812 // SubString Logical operators
813 // Bool_t operator==(const TSubString &s1, const TSubString &s2);
814 // Bool_t operator==(const TSubString &s1, const char *s2);
815 // Bool_t operator==(const TSubString &s1, const TString &s2);
816 inline Bool_t operator==(const TString &s1, const TSubString &s2)
817 { return (s2 == s1); }
818 
819 inline Bool_t operator==(const char *s1, const TSubString &s2)
820 { return (s2 == s1); }
821 
822 inline Bool_t operator!=(const TSubString &s1, const char *s2)
823 { return !(s1 == s2); }
824 
825 inline Bool_t operator!=(const TSubString &s1, const TString &s2)
826 { return !(s1 == s2); }
827 
828 inline Bool_t operator!=(const TSubString &s1, const TSubString &s2)
829 { return !(s1 == s2); }
830 
831 inline Bool_t operator!=(const TString &s1, const TSubString &s2)
832 { return !(s2 == s1); }
833 
834 inline Bool_t operator!=(const char *s1, const TSubString &s2)
835 { return !(s2 == s1); }
836 
837 #ifndef WIN32
838 // To avoid ambiguities.
839 inline Bool_t operator==(const char *s1, const std::string_view &s2)
840 {
841  return std::string_view(s1) == s2;
842 }
843 
844 inline Bool_t operator==(const std::string_view &s1, const char *s2)
845 {
846  return s1 == std::string_view(s2);
847 }
848 #endif
849 
850 namespace llvm {
851  class raw_ostream;
852 }
853 
854 namespace cling {
855  std::string printValue(const TString* val);
856  std::string printValue(const TSubString* val);
857  std::string printValue(const std::string_view* val);
858 }
859 
860 #endif
c
#define c(i)
Definition: RSha256.hxx:101
TString::IsDec
Bool_t IsDec() const
Returns true if all characters in string are decimal digits (0-9).
Definition: TString.cxx:1873
TStringLong
ATTENTION: this class is obsolete.
Definition: TStringLong.h:30
n
const Int_t n
Definition: legend1.C:16
llvm
Definition: TString.h:850
TString::ReadBuffer
virtual void ReadBuffer(char *&buffer)
Read string from I/O buffer.
Definition: TString.cxx:1264
TString::ReadToDelim
std::istream & ReadToDelim(std::istream &str, char delim='\n')
Read up to an EOF, or a delimiting character, whichever comes first.
Definition: Stringio.cxx:89
TString::IsLong
Bool_t IsLong() const
Definition: TString.h:229
TString::RawStr_t
Definition: TString.h:198
TString::RawStr_t::fWords
Ssiz_t fWords[kNwords]
Definition: TString.h:199
TString::LongStr_t::fSize
Ssiz_t fSize
Definition: TString.h:180
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:91
TString::operator+=
std::enable_if< ROOT::TypeTraits::IsFloatNumeral< T >::value, TString >::type & operator+=(T f)
TString::Zero
void Zero()
Definition: TString.h:255
snprintf
#define snprintf
Definition: civetweb.c:1540
TObjArray
An array of TObjects.
Definition: TObjArray.h:37
TString::operator==
friend Bool_t operator==(const TString &s1, const TString &s2)
Definition: TString.h:757
f
#define f(i)
Definition: RSha256.hxx:104
TString::GetPointer
char * GetPointer()
Definition: TString.h:247
Hash
UInt_t Hash(const TString &s)
Definition: TString.h:486
TMath::Max
Short_t Max(Short_t a, Short_t b)
Definition: TMathBase.h:212
TString::Atoi
Int_t Atoi() const
Return integer value of string.
Definition: TString.cxx:1921
TString::Strip
TSubString Strip(EStripType s=kTrailing, char c=' ') const
Return a substring of self stripped at beginning and/or end.
Definition: TString.cxx:1106
kNPOS
const Ssiz_t kNPOS
Definition: RtypesCore.h:115
TString::fRep
Rep_t fRep
Definition: TString.h:214
TString::Prepend
TString & Prepend(const char *cs)
Definition: TString.h:661
TSubString::Data
const char * Data() const
Definition: TString.h:726
TString::Atoll
Long64_t Atoll() const
Return long long value of string.
Definition: TString.cxx:1947
TString::UnLink
void UnLink() const
Definition: TString.h:254
TString::HashFoldCase
UInt_t HashFoldCase() const
Return a case-insensitive hash value (endian independent).
Definition: TString.cxx:623
TString::Data
const char * Data() const
Definition: TString.h:369
TString::View
std::string_view View() const
Definition: TString.h:444
TString::MaybeWildcard
Bool_t MaybeWildcard() const
Returns true if string contains one of the wildcard characters "[]*?".
Definition: TString.cxx:925
TString::Rep_t::fRaw
RawStr_t fRaw
Definition: TString.h:208
Form
char * Form(const char *fmt,...)
TString::FormImp
void FormImp(const char *fmt, va_list ap)
Formats a string using a printf style format descriptor.
Definition: TString.cxx:2243
TString::kNPOS
static const Ssiz_t kNPOS
Definition: TString.h:269
TSubString::operator=
TSubString & operator=(const char *s)
Assign char* to sub-string.
Definition: TString.cxx:1629
TString::Replace
TString & Replace(Ssiz_t pos, Ssiz_t n, const char *s)
Definition: TString.h:682
TString::Clobber
void Clobber(Ssiz_t nc)
Clear string and make sure it has a capacity of nc.
Definition: TString.cxx:1184
operator<=
Bool_t operator<=(const TString &s1, const TString &s2)
Definition: TString.h:772
Long64_t
long long Long64_t
Definition: RtypesCore.h:73
operator<<
std::ostream & operator<<(std::ostream &str, const TString &s)
Write string to stream.
Definition: Stringio.cxx:171
TString::IsBin
Bool_t IsBin() const
Returns true if all characters in string are binary digits (0,1).
Definition: TString.cxx:1841
TString::GetLongPointer
const char * GetLongPointer() const
Definition: TString.h:244
TString::kIgnoreCase
@ kIgnoreCase
Definition: TString.h:268
string_view
basic_string_view< char > string_view
Definition: libcpp_string_view.h:785
TString::Atof
Double_t Atof() const
Return floating-point value contained in string.
Definition: TString.cxx:1987
TString::Clone
void Clone(Ssiz_t nc)
Make self a distinct copy with capacity of at least tot, where tot cannot be smaller than the current...
Definition: TString.cxx:1212
TGeant4Unit::s
static constexpr double s
Definition: TGeant4SystemOfUnits.h:162
Int_t
int Int_t
Definition: RtypesCore.h:45
TSubString::Start
Ssiz_t Start() const
Definition: TString.h:120
TVirtualMutex
This class implements a mutex interface.
Definition: TVirtualMutex.h:32
TString::Hash
UInt_t Hash(ECaseCompare cmp=kExact) const
Return hash value.
Definition: TString.cxx:638
TString::Contains
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition: TString.h:624
TString::EndsWith
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
Return true if string ends with the specified string.
Definition: TString.cxx:2177
TString::ULLtoa
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...
Definition: TString.cxx:2104
TString::ReadFile
std::istream & ReadFile(std::istream &str)
Replace string with the contents of strm, stopping at an EOF.
Definition: Stringio.cxx:28
TString::Length
Ssiz_t Length() const
Definition: TString.h:410
TString::kExact
@ kExact
Definition: TString.h:268
TString::UStr_t::fL
LongStr_t fL
Definition: TString.h:193
TString::Copy
TString Copy() const
Copy a string.
Definition: TString.cxx:490
TString::GetShortPointer
const char * GetShortPointer() const
Definition: TString.h:246
TSubString::operator()
char & operator()(Ssiz_t i)
Return character at pos i from sub-string. No check on i.
Definition: TString.cxx:1610
TBuffer
Buffer base class used for serializing objects.
Definition: TBuffer.h:43
TString::~TString
virtual ~TString()
Delete a TString.
Definition: TString.cxx:230
TString::UItoa
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...
Definition: TString.cxx:2052
TString::IsFloat
Bool_t IsFloat() const
Returns kTRUE if string contains a floating point or integer number.
Definition: TString.cxx:1791
TString::Format
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Definition: TString.cxx:2311
TString::Init
char * Init(Ssiz_t capacity, Ssiz_t nchar)
Private member function returning an empty string representation of size capacity and containing ncha...
Definition: TString.cxx:239
TString
Basic string class.
Definition: TString.h:136
Bool_t
bool Bool_t
Definition: RtypesCore.h:63
operator==
Bool_t operator==(const TString &s1, const TString &s2)
Definition: TString.h:757
TString::IsOct
Bool_t IsOct() const
Returns true if all characters in string are octal digits (0-7).
Definition: TString.cxx:1857
TString::Clear
void Clear()
Clear string without changing its capacity.
Definition: TString.cxx:1176
b
#define b(i)
Definition: RSha256.hxx:100
TString::GetInitialCapacity
static Ssiz_t GetInitialCapacity()
Definition: TString.cxx:1501
TSubString::ToUpper
void ToUpper()
Convert sub-string to upper-case.
Definition: TString.cxx:1687
bool
TString::operator<<
friend TBuffer & operator<<(TBuffer &b, const TString *obj)
Write TString or derived to TBuffer.
Definition: TString.cxx:1403
TString::Itoa
static TString Itoa(Int_t value, Int_t base)
Converts an Int_t to a TString with respect to the base specified (2-36).
Definition: TString.cxx:2025
operator+
TString operator+(const TString &s1, const TString &s2)
Use the special concatenation constructor.
Definition: TString.cxx:1474
TString::ReplaceAll
TString & ReplaceAll(const TString &s1, const TString &s2)
Definition: TString.h:692
TString::AssertElement
void AssertElement(Ssiz_t nc) const
Check to make sure a string index is in range.
Definition: TString.cxx:1151
TString::CountChar
Int_t CountChar(Int_t c) const
Return number of times character c occurs in the string.
Definition: TString.cxx:476
TString::operator+=
TString & operator+=(const char *s)
Definition: TString.h:576
ROOT::Internal::TStringView
Definition: RStringView.hxx:77
TSubString::fBegin
Ssiz_t fBegin
Definition: TString.h:93
TString::operator+
friend TString operator+(const TString &s1, const TString &s2)
Use the special concatenation constructor.
Definition: TString.cxx:1474
TString::kBoth
@ kBoth
Definition: TString.h:267
TString::Last
Ssiz_t Last(char c) const
Find last occurrence of a character c.
Definition: TString.cxx:892
TString::GetShortSize
Ssiz_t GetShortSize() const
Definition: TString.h:235
TString::SetLongSize
void SetLongSize(Ssiz_t s)
Definition: TString.h:237
TString::operator[]
char & operator[](Ssiz_t i)
Definition: TString.h:720
TSubString::ToLower
void ToLower()
Convert sub-string to lower-case.
Definition: TString.cxx:1675
TString::ToUpper
void ToUpper()
Change string to upper case.
Definition: TString.cxx:1138
TString::ReadString
static TString * ReadString(TBuffer &b, const TClass *clReq)
Read TString object from buffer.
Definition: TString.cxx:1295
TString::Gets
Bool_t Gets(FILE *fp, Bool_t chop=kTRUE)
Read one line from the stream, including the , or until EOF.
Definition: Stringio.cxx:198
TSubString::IsNull
Bool_t IsNull() const
Definition: TString.h:126
TString::Form
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
Definition: TString.cxx:2289
TString::UStr_t::fS
ShortStr_t fS
Definition: TString.h:193
TString::ECaseCompare
ECaseCompare
Definition: TString.h:268
TString::Recommend
static Ssiz_t Recommend(Ssiz_t s)
Definition: TString.h:225
TString::Tokenize
TObjArray * Tokenize(const TString &delim) const
This function is used to isolate sequential tokens in a TString.
Definition: TString.cxx:2197
TString::GetLongPointer
char * GetLongPointer()
Definition: TString.h:243
TSubString
A zero length substring is legal.
Definition: TString.h:82
TString::ResizeIncrement
static Ssiz_t ResizeIncrement(Ssiz_t ri=16)
Set default resize increment for all TStrings. Default is 16.
Definition: TString.cxx:1535
TString::Resize
void Resize(Ssiz_t n)
Resize the string. Truncate or add blanks as necessary.
Definition: TString.cxx:1095
EscChar
int EscChar(const char *src, char *dst, int dstlen, char *specchars, char escchar)
Escape specchars in src with escchar and copy to dst.
Definition: TString.cxx:2525
TSubString::operator==
friend Bool_t operator==(const TSubString &s1, const TSubString &s2)
Compare two sub-strings.
Definition: TString.cxx:1664
TSubString::Length
Ssiz_t Length() const
Definition: TString.h:119
TString::Chop
TString & Chop()
Definition: TString.h:679
TSubString::operator[]
char & operator[](Ssiz_t i)
Return character at pos i from sub-string. Check validity of i.
Definition: TString.cxx:1601
TString::HashCase
UInt_t HashCase() const
Return a case-sensitive hash value (endian independent).
Definition: TString.cxx:594
TString::kTrailing
@ kTrailing
Definition: TString.h:267
operator+=
std::string & operator+=(std::string &left, const TString &right)
Definition: TString.h:478
TString::MaxSize
static Ssiz_t MaxSize()
Definition: TString.h:252
a
auto * a
Definition: textangle.C:12
TString::Remove
TString & Remove(Ssiz_t pos)
Definition: TString.h:673
RStringView.hxx
TString::GetPointer
const char * GetPointer() const
Definition: TString.h:248
TString::LongStr_t::fData
char * fData
Definition: TString.h:181
kFALSE
const Bool_t kFALSE
Definition: RtypesCore.h:92
TString::Append
TString & Append(const char *cs)
Definition: TString.h:564
TString::kLongMask
@ kLongMask
Definition: TString.h:174
operator>=
Bool_t operator>=(const TString &s1, const TString &s2)
Definition: TString.h:775
s1
#define s1(x)
Definition: RSha256.hxx:91
TString::UStr_t
Definition: TString.h:193
TString::TString
TString()
TString default ctor.
Definition: TString.cxx:87
TString::First
Ssiz_t First(char c) const
Find first occurrence of a character c.
Definition: TString.cxx:499
TGeant4Unit::ns
static constexpr double ns
Definition: TGeant4SystemOfUnits.h:161
TypeTraits.hxx
StrDup
char * StrDup(const char *str)
Duplicate the string str.
Definition: TString.cxx:2490
TString::WriteString
static void WriteString(TBuffer &b, const TString *a)
Write TString object to buffer.
Definition: TString.cxx:1361
operator<
Bool_t operator<(const TString &s1, const TString &s2)
Definition: TString.h:766
TString::Insert
TString & Insert(Ssiz_t pos, const char *s)
Definition: TString.h:649
TSubString::String
TString & String()
Definition: TString.h:121
UInt_t
unsigned int UInt_t
Definition: RtypesCore.h:46
TString::BeginsWith
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
Definition: TString.h:615
TString::IsAlnum
Bool_t IsAlnum() const
Returns true if all characters in string are alphanumeric.
Definition: TString.cxx:1746
TString::SetShortSize
void SetShortSize(Ssiz_t s)
Definition: TString.h:234
TSubString::TSubString
TSubString(const TSubString &s)
Definition: TString.h:104
operator>>
std::istream & operator>>(std::istream &str, TString &s)
Read string from stream.
Definition: Stringio.cxx:163
TString::SetSize
void SetSize(Ssiz_t s)
Definition: TString.h:239
TString::MD5
TString MD5() const
Return the MD5 digest for this string, in a string representation.
Definition: TString.cxx:901
TString::IsDigit
Bool_t IsDigit() const
Returns true if all characters in string are digits (0-9) or white spaces, i.e.
Definition: TString.cxx:1763
TString::GetShortPointer
char * GetShortPointer()
Definition: TString.h:245
TMath::Min
Short_t Min(Short_t a, Short_t b)
Definition: TMathBase.h:180
TString::Rep_t::fLong
LongStr_t fLong
Definition: TString.h:206
unsigned int
TRegexp
Regular expression class.
Definition: TRegexp.h:31
TPRegexp
Definition: TPRegexp.h:36
TString::Index
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
Definition: TString.h:639
TString::GetLongSize
Ssiz_t GetLongSize() const
Definition: TString.h:238
Printf
void Printf(const char *fmt,...)
TString::GetLongCap
Ssiz_t GetLongCap() const
Definition: TString.h:241
Ssiz_t
int Ssiz_t
Definition: RtypesCore.h:67
TString::Sizeof
virtual Int_t Sizeof() const
Returns size string will occupy on I/O buffer.
Definition: TString.cxx:1334
TString::kAlignment
@ kAlignment
Definition: TString.h:223
ULong64_t
unsigned long long ULong64_t
Definition: RtypesCore.h:74
TString::operator=
TString & operator=(char s)
Assign character c to TString.
Definition: TString.cxx:267
TString::CompareTo
int CompareTo(const char *cs, ECaseCompare cmp=kExact) const
Compare a string to char *cs2.
Definition: TString.cxx:418
TString::IsNull
Bool_t IsNull() const
Definition: TString.h:407
TString::LongStr_t
Definition: TString.h:178
LongDouble_t
long double LongDouble_t
Definition: RtypesCore.h:61
Double_t
double Double_t
Definition: RtypesCore.h:59
TString::ShortStr_t::fData
char fData[kMinCap]
Definition: TString.h:190
TString::EStripType
EStripType
Definition: TString.h:267
TString::LLtoa
static TString LLtoa(Long64_t value, Int_t base)
Converts a Long64_t to a TString with respect to the base specified (2-36).
Definition: TString.cxx:2077
TString::SetLongCap
void SetLongCap(Ssiz_t s)
Definition: TString.h:240
ToLower
TString ToLower(const TString &s)
Return a lower-case version of str.
Definition: TString.cxx:1430
TString::kNwords
@ kNwords
Definition: TString.h:195
UnEscChar
int UnEscChar(const char *src, char *dst, int dstlen, char *specchars, char escchar)
Un-escape specchars in src from escchar and copy to dst.
Definition: TString.cxx:2549
TString::ReadToken
std::istream & ReadToken(std::istream &str)
Read a token, delimited by whitespace, from the input stream.
Definition: Stringio.cxx:127
TString::MaxWaste
static Ssiz_t MaxWaste(Ssiz_t mw=15)
Set maximum space that may be wasted in a string before doing a resize.
Definition: TString.cxx:1545
TString::GetResizeIncrement
static Ssiz_t GetResizeIncrement()
Definition: TString.cxx:1509
TString::kShortMask
@ kShortMask
Definition: TString.h:174
TClass
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition: TClass.h:80
TString::SetLongPointer
void SetLongPointer(char *p)
Definition: TString.h:242
TString::IsAlpha
Bool_t IsAlpha() const
Returns true if all characters in string are alphabetic.
Definition: TString.cxx:1731
TString::IsWhitespace
Bool_t IsWhitespace() const
Definition: TString.h:408
TString::SubString
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.
Definition: TString.cxx:1590
TString::ShortStr_t
Definition: TString.h:188
TString::BaseConvert
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.
Definition: TString.cxx:2127
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
ToUpper
TString ToUpper(const TString &s)
Return an upper-case version of str.
Definition: TString.cxx:1444
TString::Capacity
Ssiz_t Capacity() const
Definition: TString.h:357
TString::Rep_t::fShort
ShortStr_t fShort
Definition: TString.h:207
TString::ReadLine
std::istream & ReadLine(std::istream &str, Bool_t skipWhite=kTRUE)
Read a line from stream upto newline skipping any whitespace.
Definition: Stringio.cxx:65
ROOT::Math::Chebyshev::T
double T(double x)
Definition: ChebyshevPol.h:34
TString::InitChar
void InitChar(char c)
Initialize a string with a single character.
Definition: TString.cxx:139
TString::Swap
TString & Swap(TString &other)
Definition: TString.h:704
TSubString::SubStringError
void SubStringError(Ssiz_t, Ssiz_t, Ssiz_t) const
Output error message.
Definition: TString.cxx:1699
kMaxInt
const Int_t kMaxInt
Definition: RtypesCore.h:103
Compress
char * Compress(const char *str)
Remove all blanks from the string str.
Definition: TString.cxx:2504
TMathBase.h
TString::kLeading
@ kLeading
Definition: TString.h:267
TString::EqualTo
Bool_t EqualTo(const char *cs, ECaseCompare cmp=kExact) const
Definition: TString.h:633
TString::Puts
void Puts(FILE *fp)
Write string to the stream.
Definition: Stringio.cxx:223
TString::Rep_t
Definition: TString.h:203
TString::GetMaxWaste
static Ssiz_t GetMaxWaste()
Definition: TString.cxx:1517
TSubString::fStr
TString & fStr
Definition: TString.h:92
TString::IsHex
Bool_t IsHex() const
Returns true if all characters in string are hexadecimal digits (0-9,a-f,A-F).
Definition: TString.cxx:1825
type
int type
Definition: TGX11.cxx:121
TString::InitialCapacity
static Ssiz_t InitialCapacity(Ssiz_t ic=15)
Set default initial capacity for all TStrings. Default is 15.
Definition: TString.cxx:1526
TString::operator+=
std::enable_if< ROOT::TypeTraits::IsUnsignedNumeral< T >::value, TString >::type & operator+=(T u)
TString::AdjustCapacity
static Ssiz_t AdjustCapacity(Ssiz_t oldCap, Ssiz_t newCap)
Calculate a nice capacity greater than or equal to newCap.
Definition: TString.cxx:1161
TString::ToLower
void ToLower()
Change string to lower-case.
Definition: TString.cxx:1125
TSubString::AssertElement
void AssertElement(Ssiz_t i) const
Check to make sure a sub-string index is in range.
Definition: TString.cxx:1708
TString::MaybeRegexp
Bool_t MaybeRegexp() const
Returns true if string contains one of the regexp characters "^$.[]*+?".
Definition: TString.cxx:913
TSubString::operator!
int operator!() const
Definition: TString.h:127
TString::IsAscii
Bool_t IsAscii() const
Returns true if all characters in string are ascii.
Definition: TString.cxx:1718
Rtypes.h
TString::FillBuffer
virtual void FillBuffer(char *&buffer) const
Copy string into I/O buffer.
Definition: TString.cxx:1243
TSubString::fExtent
Ssiz_t fExtent
Definition: TString.h:94
TBufferFile
The concrete implementation of TBuffer for writing/reading to/from a ROOT file or socket.
Definition: TBufferFile.h:47
Strip
char * Strip(const char *str, char c=' ')
Strip leading and trailing c (blanks by default) from a string.
Definition: TString.cxx:2454
operator!=
Bool_t operator!=(const TString &s1, const TString &s2)
Definition: TString.h:763
TString::LongStr_t::fCap
Ssiz_t fCap
Definition: TString.h:179
TSubString::TSubString
TSubString(const TString &s, Ssiz_t start, Ssiz_t len)
Private constructor.
Definition: TString.cxx:1564
operator>
Bool_t operator>(const TString &s1, const TString &s2)
Definition: TString.h:769
TString::Align
static Ssiz_t Align(Ssiz_t s)
Definition: TString.h:224
int
TString::operator()
char & operator()(Ssiz_t i)
Definition: TString.h:714
TString::ShortStr_t::fSize
unsigned char fSize
Definition: TString.h:189
TString::IsInBaseN
Bool_t IsInBaseN(Int_t base) const
Returns true if all characters in string are expressed in the base specified (range=2-36),...
Definition: TString.cxx:1890