Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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 <string_view>
29#include "ROOT/TypeTraits.hxx"
30#include "snprintf.h"
31
32#include <iosfwd>
33#include <cstdarg>
34#include <cstdio>
35#include <cstring>
36#include <string>
37#if (__cplusplus >= 202002L)
38# include <compare>
39#endif
40
41class TRegexp;
42class TPRegexp;
43class TString;
44class TSubString;
45class TObjArray;
46class TVirtualMutex;
47class TBuffer;
48class TClass;
49class TBufferFile;
50
51TString operator+(const TString &s1, const TString &s2);
52TString operator+(const TString &s, const char *cs);
53TString operator+(const char *cs, const TString &s);
54TString operator+(const TString &s, char c);
55TString operator+(char c, const TString &s);
56Bool_t operator==(const TString &s1, const TString &s2);
57Bool_t operator==(const TString &s1, const char *s2);
59Bool_t operator==(const TSubString &s1, const TString &s2);
60Bool_t operator==(const TSubString &s1, const char *s2);
61/*
62template<class T>
63struct is_signed_numeral : std::integral_constant<bool,
64 std::is_integral<T>::value && std::is_signed<T>::value
65> {};
66
67template<class T>
68struct is_unsigned_numeral : std::integral_constant<bool,
69 std::is_integral<T>::value && !std::is_signed<T>::value
70> {};
71
72template<class T>
73using is_float_numeral = std::is_floating_point<T>;
74*/
75
76//////////////////////////////////////////////////////////////////////////
77// //
78// TSubString //
79// //
80// The TSubString class allows selected elements to be addressed. //
81// There are no public constructors. //
82// //
83//////////////////////////////////////////////////////////////////////////
85
86friend class TStringLong;
87friend class TString;
88
89friend Bool_t operator==(const TSubString &s1, const TSubString &s2);
90friend Bool_t operator==(const TSubString &s1, const TString &s2);
91friend Bool_t operator==(const TSubString &s1, const char *s2);
92
93private:
94 TString &fStr; // Referenced string
95 Ssiz_t fBegin; // Index of starting character
96 Ssiz_t fExtent; // Length of TSubString
97
98 // NB: the only constructor is private
99 TSubString(const TString &s, Ssiz_t start, Ssiz_t len);
100
101protected:
102 void SubStringError(Ssiz_t, Ssiz_t, Ssiz_t) const;
103 void AssertElement(Ssiz_t i) const; // Verifies i is valid index
104
105public:
107 : fStr(s.fStr), fBegin(s.fBegin), fExtent(s.fExtent) { }
108
109 TSubString &operator=(const char *s); // Assignment from a char*
110 TSubString &operator=(const TString &s); // Assignment from a TString
111 TSubString &operator=(const TSubString &s); // Assignment from a TSubString
112 char &operator()(Ssiz_t i); // Index with optional bounds checking
113 char &operator[](Ssiz_t i); // Index with bounds checking
114 char operator()(Ssiz_t i) const; // Index with optional bounds checking
115 char operator[](Ssiz_t i) const; // Index with bounds checking
116
117 operator std::string_view() const { return std::string_view(Data(),fExtent); }
118 operator std::string() const { return std::string(Data(),fExtent); }
119
120 const char *Data() const;
121 Ssiz_t Length() const { return fExtent; }
122 Ssiz_t Start() const { return fBegin; }
123 TString& String() { return fStr; }
124 void ToLower(); // Convert self to lower-case
125 void ToUpper(); // Convert self to upper-case
126
127 // For detecting null substrings
128 Bool_t IsNull() const { return fBegin == kNPOS; }
129 int operator!() const { return fBegin == kNPOS; }
130};
131
132
133//////////////////////////////////////////////////////////////////////////
134// //
135// TString //
136// //
137//////////////////////////////////////////////////////////////////////////
138class TString {
139
140friend class TStringLong;
141friend class TSubString;
142friend class TBufferFile;
143
144friend TString operator+(const TString &s1, const TString &s2);
145friend TString operator+(const TString &s, const char *cs);
146friend TString operator+(const char *cs, const TString &s);
147friend TString operator+(const TString &s, char c);
148friend TString operator+(char c, const TString &s);
149
150template<class T>
151friend typename std::enable_if<ROOT::TypeTraits::IsSignedNumeral<T>::value,TString>::type
152operator+(TString s, T i);
153template<class T>
154friend typename std::enable_if<ROOT::TypeTraits::IsUnsignedNumeral<T>::value,TString>::type
155operator+(TString s, T u);
156template<class T>
157friend typename std::enable_if<ROOT::TypeTraits::IsFloatNumeral<T>::value,TString>::type
158operator+(TString s, T f);
159template<class T>
160friend typename std::enable_if<ROOT::TypeTraits::IsSignedNumeral<T>::value,TString>::type
161operator+(T i, const TString &s);
162template<class T>
163friend typename std::enable_if<ROOT::TypeTraits::IsUnsignedNumeral<T>::value,TString>::type
164operator+(T u, const TString &s);
165template<class T>
166friend typename std::enable_if<ROOT::TypeTraits::IsFloatNumeral<T>::value,TString>::type
167operator+(T f, const TString &s);
168
169friend Bool_t operator==(const TString &s1, const TString &s2);
170friend Bool_t operator==(const TString &s1, const char *s2);
171#if __cplusplus >= 202002L
172friend std::strong_ordering operator<=>(const TString &s1, const TString &s2) {
173 const int cmp = s1.CompareTo(s2);
174 if (cmp == 0) return std::strong_ordering::equal;
175 if (cmp < 0) return std::strong_ordering::less;
176 return std::strong_ordering::greater;
177}
178#endif
179
180private:
181#ifdef R__BYTESWAP
182 enum { kShortMask = 0x01, kLongMask = 0x1 };
183#else
184 enum { kShortMask = 0x80, kLongMask = 0x80000000 };
185#endif
186
188 {
189 Ssiz_t fCap; // Max string length (including null)
190 Ssiz_t fSize; // String length (excluding null)
191 char *fData; // Long string data
192 };
193
194 enum { kMinCap = (sizeof(LongStr_t) - 1)/sizeof(char) > 2 ?
195 (sizeof(LongStr_t) - 1)/sizeof(char) : 2 };
196
198 {
199 unsigned char fSize; // String length (excluding null)
200 char fData[kMinCap]; // Short string data
201 };
202
204
205 enum { kNwords = sizeof(UStr_t) / sizeof(Ssiz_t)};
206
207 struct RawStr_t
208 {
210 };
211
212 struct Rep_t
213 {
214 union
215 {
219 };
220 };
221
222protected:
223 Rep_t fRep; //! String data
224
225 // Special concatenation constructor
226 TString(const char *a1, Ssiz_t n1, const char *a2, Ssiz_t n2);
227 void AssertElement(Ssiz_t nc) const; // Index in range
228 Ssiz_t Clobber(Ssiz_t nc); // Remove old contents
229 void InitChar(char c); // Initialize from char
230
231 enum { kAlignment = 16 };
232 static Ssiz_t Align(Ssiz_t s) { return (s + (kAlignment-1)) & ~(kAlignment-1); }
233 // `s` is expected to be <= MaxSize() = (kMaxInt-1) ; `s + 1` includes the terminating nullchar
235 {
236 if (s < kMinCap)
237 return kMinCap;
238 else if (s > MaxSize() - (kAlignment - 1))
239 return s;
240 else
241 return Align(s + 1) - 1;
242 }
244
245private:
247#ifdef R__BYTESWAP
248 void SetShortSize(Ssiz_t s) { fRep.fShort.fSize = (unsigned char)(s << 1); }
249 Ssiz_t GetShortSize() const { return fRep.fShort.fSize >> 1; }
250#else
251 void SetShortSize(Ssiz_t s) { fRep.fShort.fSize = (unsigned char)s; }
252 Ssiz_t GetShortSize() const { return fRep.fShort.fSize; }
253#endif
255 Ssiz_t GetLongSize() const { return fRep.fLong.fSize; }
259 void SetLongPointer(char *p) { fRep.fLong.fData = p; }
260 char *GetLongPointer() { return fRep.fLong.fData; }
261 const char *GetLongPointer() const { return fRep.fLong.fData; }
262 char *GetShortPointer() { return fRep.fShort.fData; }
263 const char *GetShortPointer() const { return fRep.fShort.fData; }
264 char *GetPointer() { return IsLong() ? GetLongPointer() : GetShortPointer(); }
265 const char *GetPointer() const { return IsLong() ? GetLongPointer() : GetShortPointer(); }
266#ifdef R__BYTESWAP
267 static constexpr Ssiz_t MaxSize() { return kMaxInt - 1; }
268#else
269 static constexpr Ssiz_t MaxSize() { return (kMaxInt >> 1) - 1; }
270#endif
271 void UnLink() const { if (IsLong()) delete [] fRep.fLong.fData; }
272 void Zero() {
274 for (UInt_t i = 0; i < kNwords; ++i)
275 a[i] = 0;
276 }
277 char *Init(Ssiz_t capacity, Ssiz_t nchar);
278 void Clone(Ssiz_t nc); // Make self a distinct copy w. capacity nc
279 void FormImp(const char *fmt, va_list ap);
280 UInt_t HashCase() const;
281 UInt_t HashFoldCase() const;
282
283public:
284 enum EStripType { kLeading = 0x1, kTrailing = 0x2, kBoth = 0x3 };
286 static constexpr Ssiz_t kNPOS = ::kNPOS;
288
289 TString(); // Null string
290 explicit TString(Ssiz_t ic); // Suggested capacity
291 TString(const TString &s); // Copy constructor
292 TString(TString &&s) noexcept; // Move constructor
293 TString(const char *s); // Copy to embedded null
294 TString(const char *s, Ssiz_t n); // Copy past any embedded nulls
295 TString(const std::string &s);
296 TString(char c);
297 TString(char c, Ssiz_t s);
298 explicit TString(const std::string_view &sub);
299 TString(const TSubString &sub);
300
301 virtual ~TString();
302
303 // ROOT I/O interface
304 virtual void FillBuffer(char *&buffer) const;
305 virtual void ReadBuffer(char *&buffer);
306 virtual Int_t Sizeof() const;
307
308 static TString *ReadString(TBuffer &b, const TClass *clReq);
309 static void WriteString(TBuffer &b, const TString *a);
310
311 friend TBuffer &operator<<(TBuffer &b, const TString *obj);
312
313 // C I/O interface
315 void Puts(FILE *fp);
316
317 // Type conversion
318 operator const char*() const { return GetPointer(); }
319#if !defined(_MSC_VER) && (!defined(__clang_major__) || __clang_major__ > 5)
320 // Clang 5.0 support for explicit conversion is still inadequate even in c++17 mode.
321 // (It leads to extraneous ambiguous overload errors)
322 inline explicit operator std::string() const { return std::string(GetPointer(),Length()); }
323#endif
324 inline operator std::string_view() const { return std::string_view(GetPointer(),Length()); }
325
326 // Assignment
327 TString &operator=(char s); // Replace string
328 TString &operator=(const char *s);
329 TString &operator=(const TString &s);
330 TString &operator=(TString &&s) noexcept;
331 TString &operator=(const std::string &s);
332 TString &operator=(const std::string_view &s);
333 TString &operator=(const TSubString &s);
334 TString &operator+=(const char *s); // Append string
335 TString &operator+=(const TString &s);
336 TString &operator+=(char c);
337
338 template<class T>
339 typename std::enable_if<ROOT::TypeTraits::IsSignedNumeral<T>::value,TString>::type
340 &operator+=(T i);
341 template<class T>
342 typename std::enable_if<ROOT::TypeTraits::IsUnsignedNumeral<T>::value,TString>::type
344 template<class T>
345 typename std::enable_if<ROOT::TypeTraits::IsFloatNumeral<T>::value,TString>::type
347
348 // Indexing operators
349 char &operator[](Ssiz_t i); // Indexing with bounds checking
350 char &operator()(Ssiz_t i); // Indexing with optional bounds checking
351 char operator[](Ssiz_t i) const;
352 char operator()(Ssiz_t i) const;
353 TSubString operator()(Ssiz_t start, Ssiz_t len) const; // Sub-string operator
354 TSubString operator()(const TRegexp &re) const; // Match the RE
355 TSubString operator()(const TRegexp &re, Ssiz_t start) const;
356 TSubString operator()(TPRegexp &re) const; // Match the Perl compatible Regular Expression
357 TSubString operator()(TPRegexp &re, Ssiz_t start) const;
358 TSubString SubString(const char *pat, Ssiz_t start = 0,
359 ECaseCompare cmp = kExact) const;
360
361 // Non-static member functions
362 TString &Append(const char *cs);
363 TString &Append(const char *cs, Ssiz_t n);
364 TString &Append(const TString &s);
365 TString &Append(const TString &s, Ssiz_t n);
366 TString &Append(char c, Ssiz_t rep = 1); // Append c rep times
367 Int_t Atoi() const;
368 Long64_t Atoll() const;
369 Double_t Atof() const;
370 Bool_t BeginsWith(const char *s, ECaseCompare cmp = kExact) const;
371 Bool_t BeginsWith(const TString &pat, ECaseCompare cmp = kExact) const;
372 Ssiz_t Capacity() const { return (IsLong() ? GetLongCap() : kMinCap) - 1; }
374 TString &Chop();
375 void Clear();
376 int CompareTo(const char *cs, ECaseCompare cmp = kExact) const;
377 int CompareTo(const TString &st, ECaseCompare cmp = kExact) const;
378 Bool_t Contains(const char *pat, ECaseCompare cmp = kExact) const;
379 Bool_t Contains(const TString &pat, ECaseCompare cmp = kExact) const;
380 Bool_t Contains(const TRegexp &pat) const;
381 Bool_t Contains(TPRegexp &pat) const;
382 Int_t CountChar(Int_t c) const;
383 TString Copy() const;
384 const char *Data() const { return GetPointer(); }
385 Bool_t EndsWith(const char *pat, ECaseCompare cmp = kExact) const;
386 Bool_t EqualTo(const char *cs, ECaseCompare cmp = kExact) const;
387 Bool_t EqualTo(const TString &st, ECaseCompare cmp = kExact) const;
388 Ssiz_t First(char c) const;
389 Ssiz_t First(const char *cs) const;
390 void Form(const char *fmt, ...)
391#if defined(__GNUC__)
392 __attribute__((format(printf, 2, 3))) /* 1 is the this pointer */
393#endif
394 ;
395 UInt_t Hash(ECaseCompare cmp = kExact) const;
396 Ssiz_t Index(const char *pat, Ssiz_t i = 0,
397 ECaseCompare cmp = kExact) const;
398 Ssiz_t Index(const TString &s, Ssiz_t i = 0,
399 ECaseCompare cmp = kExact) const;
400 Ssiz_t Index(const char *pat, Ssiz_t patlen, Ssiz_t i,
401 ECaseCompare cmp) const;
402 Ssiz_t Index(const TString &s, Ssiz_t patlen, Ssiz_t i,
403 ECaseCompare cmp) const;
404 Ssiz_t Index(const TRegexp &pat, Ssiz_t i = 0) const;
405 Ssiz_t Index(const TRegexp &pat, Ssiz_t *ext, Ssiz_t i = 0) const;
406 Ssiz_t Index(TPRegexp &pat, Ssiz_t i = 0) const;
407 Ssiz_t Index(TPRegexp &pat, Ssiz_t *ext, Ssiz_t i = 0) const;
408 TString &Insert(Ssiz_t pos, const char *s);
409 TString &Insert(Ssiz_t pos, const char *s, Ssiz_t extent);
410 TString &Insert(Ssiz_t pos, const TString &s);
411 TString &Insert(Ssiz_t pos, const TString &s, Ssiz_t extent);
412 Bool_t IsAscii() const;
413 Bool_t IsAlpha() const;
414 Bool_t IsAlnum() const;
415 Bool_t IsDigit() const;
416 Bool_t IsFloat() const;
417 Bool_t IsHex() const;
418 Bool_t IsBin() const;
419 Bool_t IsOct() const;
420 Bool_t IsDec() const;
421 Bool_t IsInBaseN(Int_t base) const;
422 Bool_t IsNull() const { return Length() == 0; }
423 Bool_t IsWhitespace() const { return (Length() == CountChar(' ')); }
424 Ssiz_t Last(char c) const;
425 Ssiz_t Length() const { return IsLong() ? GetLongSize() : GetShortSize(); }
426 Bool_t MaybeRegexp() const;
427 Bool_t MaybeWildcard() const;
428 TString MD5() const;
429 TString &Prepend(const char *cs); // Prepend a character string
430 TString &Prepend(const char *cs, Ssiz_t n);
431 TString &Prepend(const TString &s);
432 TString &Prepend(const TString &s, Ssiz_t n);
433 TString &Prepend(char c, Ssiz_t rep = 1); // Prepend c rep times
434 std::istream &ReadFile(std::istream &str); // Read to EOF or null character
435 std::istream &ReadLine(std::istream &str,
436 Bool_t skipWhite = kTRUE); // Read to EOF or newline
437 std::istream &ReadString(std::istream &str); // Read to EOF or null character
438 std::istream &ReadToDelim(std::istream &str, char delim = '\n'); // Read to EOF or delimitor
439 std::istream &ReadToken(std::istream &str); // Read separated by white space
440 TString &Remove(Ssiz_t pos); // Remove pos to end of string
441 TString &Remove(Ssiz_t pos, Ssiz_t n); // Remove n chars starting at pos
442 TString &Remove(EStripType s, char c); // Like Strip() but changing string directly
443 TString &Replace(Ssiz_t pos, Ssiz_t n, const char *s);
444 TString &Replace(Ssiz_t pos, Ssiz_t n, const char *s, Ssiz_t ns);
445 TString &Replace(Ssiz_t pos, Ssiz_t n, const TString &s);
446 TString &Replace(Ssiz_t pos, Ssiz_t n1, const TString &s, Ssiz_t n2);
447 TString &ReplaceAll(const TString &s1, const TString &s2); // Find&Replace all s1 with s2 if any
448 TString &ReplaceAll(const TString &s1, const char *s2); // Find&Replace all s1 with s2 if any
449 TString &ReplaceAll(const char *s1, const TString &s2); // Find&Replace all s1 with s2 if any
450 TString &ReplaceAll(const char *s1, const char *s2); // Find&Replace all s1 with s2 if any
451 TString &ReplaceAll(const char *s1, Ssiz_t ls1, const char *s2, Ssiz_t ls2); // Find&Replace all s1 with s2 if any
453 void Resize(Ssiz_t n); // Truncate or add blanks as necessary
454 TSubString Strip(EStripType s = kTrailing, char c = ' ') const;
455 TString &Swap(TString &other); // Swap the contents of this and other without reallocation
456 void ToLower(); // Change self to lower-case
457 void ToUpper(); // Change self to upper-case
458 TObjArray *Tokenize(const TString &delim) const;
459 Bool_t Tokenize(TString &tok, Ssiz_t &from, const char *delim = " ") const;
460 std::string_view View() const { return std::string_view(GetPointer(),Length()); }
461
462 // Static member functions
463 static UInt_t Hash(const void *txt, Int_t ntxt); // Calculates hash index from any char string.
464 static Ssiz_t InitialCapacity(Ssiz_t ic = 15); // Initial allocation capacity
465 static Ssiz_t MaxWaste(Ssiz_t mw = 15); // Max empty space before reclaim
466 static Ssiz_t ResizeIncrement(Ssiz_t ri = 16); // Resizing increment
467 static Ssiz_t GetInitialCapacity();
468 static Ssiz_t GetResizeIncrement();
469 static Ssiz_t GetMaxWaste();
470 static TString Itoa ( Int_t value, Int_t base); // Converts int to string with respect to the base specified (2-36)
471 static TString UItoa ( UInt_t value, Int_t base);
472 static TString LLtoa ( Long64_t value, Int_t base);
473 static TString ULLtoa (ULong64_t value, Int_t base);
474 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)
475 static TString Format(const char *fmt, ...)
476#if defined(__GNUC__)
477 __attribute__((format(printf, 1, 2)))
478#endif
479 ;
480
481 ClassDef(TString,2) //Basic string class
482};
483
484// Related global functions
485std::istream &operator>>(std::istream &str, TString &s);
486std::ostream &operator<<(std::ostream &str, const TString &s);
487#if defined(R__TEMPLATE_OVERLOAD_BUG)
488template <>
489#endif
491TBuffer &operator<<(TBuffer &buf, const TString * sp);
492
493// Conversion operator (per se).
494inline std::string& operator+=(std::string &left, const TString &right)
495{
496 return left.append(right.Data());
497}
498
499TString ToLower(const TString &s); // Return lower-case version of argument
500TString ToUpper(const TString &s); // Return upper-case version of argument
501
502inline UInt_t Hash(const TString &s) { return s.Hash(); }
503inline UInt_t Hash(const TString *s) { return s->Hash(); }
504 UInt_t Hash(const char *s);
505
506extern char *Form(const char *fmt, ...) // format in circular buffer
507#if defined(__GNUC__)
509#endif
510;
511extern void Printf(const char *fmt, ...) // format and print
512#if defined(__GNUC__)
514#endif
515;
516extern char *Strip(const char *str, char c = ' '); // strip c off str, free with delete []
517extern char *StrDup(const char *str); // duplicate str, free with delete []
518extern char *Compress(const char *str); // remove blanks from string, free with delele []
519extern int EscChar(const char *src, char *dst, int dstlen, char *specchars,
520 char escchar); // copy from src to dst escaping specchars by escchar
521extern int UnEscChar(const char *src, char *dst, int dstlen, char *specchars,
522 char escchar); // copy from src to dst removing escchar from specchars
523
524#ifdef NEED_STRCASECMP
525extern int strcasecmp(const char *str1, const char *str2);
526extern int strncasecmp(const char *str1, const char *str2, Ssiz_t n);
527#endif
528
529//////////////////////////////////////////////////////////////////////////
530// //
531// Inlines //
532// //
533//////////////////////////////////////////////////////////////////////////
534
535template<class T>
536inline typename std::enable_if<ROOT::TypeTraits::IsSignedNumeral<T>::value,TString>::type
538{ return s += i; }
539
540template<class T>
541inline typename std::enable_if<ROOT::TypeTraits::IsUnsignedNumeral<T>::value,TString>::type
543{ return s += u; }
544
545template<class T>
546inline typename std::enable_if<ROOT::TypeTraits::IsFloatNumeral<T>::value,TString>::type
548{ return s += f; }
549
550template<class T>
551inline typename std::enable_if<ROOT::TypeTraits::IsSignedNumeral<T>::value,TString>::type
552operator+(T i, const TString &s)
553{
554 char buffer[32];
555 // coverity[secure_coding] Buffer is large enough (2^64 = 20 digits).
556 snprintf(buffer, sizeof(buffer), "%lld", static_cast<Long64_t>(i));
557 return TString(buffer, strlen(buffer), s.Data(), s.Length());
558}
559
560template<class T>
561inline typename std::enable_if<ROOT::TypeTraits::IsUnsignedNumeral<T>::value,TString>::type
562operator+(T u, const TString &s)
563{
564 char buffer[32];
565 // coverity[secure_coding] Buffer is large enough (2^64 = 20 digits).
566 snprintf(buffer, sizeof(buffer), "%llu", static_cast<ULong64_t>(u));
567 return TString(buffer, strlen(buffer), s.Data(), s.Length());
568}
569
570template<class T>
571inline typename std::enable_if<ROOT::TypeTraits::IsFloatNumeral<T>::value,TString>::type
572operator+(T f, const TString &s)
573{
574 char buffer[32];
575 // coverity[secure_coding] Buffer is large enough: width specified in format
576 snprintf(buffer, sizeof(buffer), "%.17Lg", static_cast<LongDouble_t>(f));
577 return TString(buffer, strlen(buffer), s.Data(), s.Length());
578}
579
580inline TString &TString::Append(const char *cs)
581{ return Replace(Length(), 0, cs, cs ? (Ssiz_t)strlen(cs) : 0); }
582
583inline TString &TString::Append(const char *cs, Ssiz_t n)
584{ return Replace(Length(), 0, cs, n); }
585
587{ return Replace(Length(), 0, s.Data(), s.Length()); }
588
590{ return Replace(Length(), 0, s.Data(), std::min(n, s.Length())); }
591
592inline TString &TString::operator+=(const char *cs)
593{ return Append(cs, cs ? (Ssiz_t)strlen(cs) : 0); }
594
596{ return Append(s.Data(), s.Length()); }
597
599{ return Append(c); }
600
601template<class T>
602inline typename std::enable_if<ROOT::TypeTraits::IsSignedNumeral<T>::value,TString>::type
604{
605 char buffer[32];
606 // coverity[secure_coding] Buffer is large enough (2^64 = 20 digits).
607 snprintf(buffer, sizeof(buffer), "%lld", static_cast<Long64_t>(i));
608 return operator+=(buffer);
609}
610
611template<class T>
612inline typename std::enable_if<ROOT::TypeTraits::IsUnsignedNumeral<T>::value,TString>::type
614{
615 char buffer[32];
616 // coverity[secure_coding] Buffer is large enough (2^64 = 20 digits).
617 snprintf(buffer, sizeof(buffer), "%llu", static_cast<ULong64_t>(u));
618 return operator+=(buffer);
619}
620
621template<class T>
622inline typename std::enable_if<ROOT::TypeTraits::IsFloatNumeral<T>::value,TString>::type
624{
625 char buffer[32];
626 // coverity[secure_coding] Buffer is large enough: width specified in format
627 snprintf(buffer, sizeof(buffer), "%.17Lg", static_cast<LongDouble_t>(f));
628 return operator+=(buffer);
629}
630
631inline Bool_t TString::BeginsWith(const char *s, ECaseCompare cmp) const
632{ return Index(s, s ? (Ssiz_t)strlen(s) : (Ssiz_t)0, (Ssiz_t)0, cmp) == 0; }
633
635{ return Index(pat.Data(), pat.Length(), (Ssiz_t)0, cmp) == 0; }
636
638{ return Index(pat.Data(), pat.Length(), (Ssiz_t)0, cmp) != kNPOS; }
639
640inline Bool_t TString::Contains(const char *s, ECaseCompare cmp) const
641{ return Index(s, s ? (Ssiz_t)strlen(s) : 0, (Ssiz_t)0, cmp) != kNPOS; }
642
643////////////////////////////////////////////////////////////////////////////////
644/// \brief Returns whether the string matches the input TRegexp.
645/// \warning Matching regular expressions of type ".?" is not supported. Use
646/// std::regex instead.
648{ return Index(pat, (Ssiz_t)0) != kNPOS; }
649
651{ return Index(pat, (Ssiz_t)0) != kNPOS; }
652
653inline Bool_t TString::EqualTo(const char *cs, ECaseCompare cmp) const
654{ return (CompareTo(cs, cmp) == 0) ? kTRUE : kFALSE; }
655
657{ return (CompareTo(st, cmp) == 0) ? kTRUE : kFALSE; }
658
659inline Ssiz_t TString::Index(const char *s, Ssiz_t i, ECaseCompare cmp) const
660{ return Index(s, s ? (Ssiz_t)strlen(s) : 0, i, cmp); }
661
662inline Ssiz_t TString::Index(const TString &s, Ssiz_t i, ECaseCompare cmp) const
663{ return Index(s.Data(), s.Length(), i, cmp); }
664
666 ECaseCompare cmp) const
667{ return Index(pat.Data(), patlen, i, cmp); }
668
669inline TString &TString::Insert(Ssiz_t pos, const char *cs)
670{ return Replace(pos, 0, cs, cs ? (Ssiz_t)strlen(cs) : 0); }
671
672inline TString &TString::Insert(Ssiz_t pos, const char *cs, Ssiz_t n)
673{ return Replace(pos, 0, cs, n); }
674
675inline TString &TString::Insert(Ssiz_t pos, const TString &s)
676{ return Replace(pos, 0, s.Data(), s.Length()); }
677
679{ return Replace(pos, 0, s.Data(), std::min(n, s.Length())); }
680
681inline TString &TString::Prepend(const char *cs)
682{ return Replace(0, 0, cs, cs ? (Ssiz_t)strlen(cs) : 0); }
683
684inline TString &TString::Prepend(const char *cs, Ssiz_t n)
685{ return Replace(0, 0, cs, n); }
686
688{ return Replace(0, 0, s.Data(), s.Length()); }
689
691{ return Replace(0, 0, s.Data(), std::min(n, s.Length())); }
692
694{ return Replace(pos, std::max(0, Length()-pos), nullptr, 0); }
695
697{ return Replace(pos, n, nullptr, 0); }
698
700{ return Remove(std::max(0, Length()-1)); }
701
702inline TString &TString::Replace(Ssiz_t pos, Ssiz_t n, const char *cs)
703{ return Replace(pos, n, cs, cs ? (Ssiz_t)strlen(cs) : 0); }
704
706{ return Replace(pos, n, s.Data(), s.Length()); }
707
709 Ssiz_t n2)
710{ return Replace(pos, n1, s.Data(), std::min(s.Length(), n2)); }
711
713{ return ReplaceAll(s1.Data(), s1.Length(), s2.Data(), s2.Length()) ; }
714
715inline TString &TString::ReplaceAll(const TString &s1, const char *s2)
716{ return ReplaceAll(s1.Data(), s1.Length(), s2, s2 ? (Ssiz_t)strlen(s2) : 0); }
717
718inline TString &TString::ReplaceAll(const char *s1, const TString &s2)
719{ return ReplaceAll(s1, s1 ? (Ssiz_t)strlen(s1) : 0, s2.Data(), s2.Length()); }
720
721inline TString &TString::ReplaceAll(const char *s1,const char *s2)
722{ return ReplaceAll(s1, s1 ? (Ssiz_t)strlen(s1) : 0, s2, s2 ? (Ssiz_t)strlen(s2) : 0); }
723
725 // Swap the contents of other and this without reallocation.
726 Rep_t tmp = other.fRep;
727 other.fRep = fRep;
728 fRep = tmp;
729 return *this;
730}
731
733{ return GetPointer()[i]; }
734
735inline char TString::operator()(Ssiz_t i) const
736{ return GetPointer()[i]; }
737
739{ AssertElement(i); return GetPointer()[i]; }
740
741inline char TString::operator[](Ssiz_t i) const
742{ AssertElement(i); return GetPointer()[i]; }
743
744inline const char *TSubString::Data() const
745{
746 // Return a pointer to the beginning of the substring. Note that the
747 // terminating null is in the same place as for the original
748 // TString, so this method is not appropriate for converting the
749 // TSubString to a string. To do that, construct a TString from the
750 // TSubString. For example:
751 //
752 // root [0] TString s("hello world")
753 // root [1] TSubString sub=s(0, 5)
754 // root [2] sub.Data()
755 // (const char* 0x857c8b8)"hello world"
756 // root [3] TString substr(sub)
757 // root [4] substr
758 // (class TString)"hello"
759
760 return fStr.Data() + fBegin;
761}
762
763// Access to elements of sub-string with bounds checking
764inline char TSubString::operator[](Ssiz_t i) const
765{ AssertElement(i); return fStr.GetPointer()[fBegin+i]; }
766
767inline char TSubString::operator()(Ssiz_t i) const
768{ return fStr.GetPointer()[fBegin+i]; }
769
771{ fStr = s.fStr; fBegin = s.fBegin; fExtent = s.fExtent; return *this; }
772
773
774// String Logical operators
775inline Bool_t operator==(const TString &s1, const TString &s2)
776{
777 return ((s1.Length() == s2.Length()) &&
778 !memcmp(s1.Data(), s2.Data(), s1.Length()));
779}
780
781inline Bool_t operator!=(const TString &s1, const TString &s2)
782{ return !(s1 == s2); }
783
784inline Bool_t operator<(const TString &s1, const TString &s2)
785{ return s1.CompareTo(s2) < 0; }
786
787inline Bool_t operator>(const TString &s1, const TString &s2)
788{ return s1.CompareTo(s2) > 0; }
789
790inline Bool_t operator<=(const TString &s1, const TString &s2)
791{ return s1.CompareTo(s2) <= 0; }
792
793inline Bool_t operator>=(const TString &s1, const TString &s2)
794{ return s1.CompareTo(s2) >= 0; }
795
796// Bool_t operator==(const TString &s1, const char *s2);
797inline Bool_t operator!=(const TString &s1, const char *s2)
798{ return !(s1 == s2); }
799
800inline Bool_t operator<(const TString &s1, const char *s2)
801{ return s1.CompareTo(s2) < 0; }
802
803inline Bool_t operator>(const TString &s1, const char *s2)
804{ return s1.CompareTo(s2) > 0; }
805
806inline Bool_t operator<=(const TString &s1, const char *s2)
807{ return s1.CompareTo(s2) <= 0; }
808
809inline Bool_t operator>=(const TString &s1, const char *s2)
810{ return s1.CompareTo(s2) >= 0; }
811
812inline Bool_t operator==(const char *s1, const TString &s2)
813{ return (s2 == s1); }
814
815inline Bool_t operator!=(const char *s1, const TString &s2)
816{ return !(s2 == s1); }
817
818inline Bool_t operator<(const char *s1, const TString &s2)
819{ return s2.CompareTo(s1) > 0; }
820
821inline Bool_t operator>(const char *s1, const TString &s2)
822{ return s2.CompareTo(s1) < 0; }
823
824inline Bool_t operator<=(const char *s1, const TString &s2)
825{ return s2.CompareTo(s1) >= 0; }
826
827inline Bool_t operator>=(const char *s1, const TString &s2)
828{ return s2.CompareTo(s1) <= 0; }
829
830// SubString Logical operators
831// Bool_t operator==(const TSubString &s1, const TSubString &s2);
832// Bool_t operator==(const TSubString &s1, const char *s2);
833// Bool_t operator==(const TSubString &s1, const TString &s2);
834inline Bool_t operator==(const TString &s1, const TSubString &s2)
835{ return (s2 == s1); }
836
837inline Bool_t operator==(const char *s1, const TSubString &s2)
838{ return (s2 == s1); }
839
840inline Bool_t operator!=(const TSubString &s1, const char *s2)
841{ return !(s1 == s2); }
842
843inline Bool_t operator!=(const TSubString &s1, const TString &s2)
844{ return !(s1 == s2); }
845
847{ return !(s1 == s2); }
848
849inline Bool_t operator!=(const TString &s1, const TSubString &s2)
850{ return !(s2 == s1); }
851
852inline Bool_t operator!=(const char *s1, const TSubString &s2)
853{ return !(s2 == s1); }
854
855namespace llvm {
856 class raw_ostream;
857}
858
859namespace cling {
860 std::string printValue(const TString* val);
861 std::string printValue(const TSubString* val);
862 std::string printValue(const std::string_view* val);
863}
864
865#endif
#define b(i)
Definition RSha256.hxx:100
#define f(i)
Definition RSha256.hxx:104
#define c(i)
Definition RSha256.hxx:101
#define a(i)
Definition RSha256.hxx:99
#define s1(x)
Definition RSha256.hxx:91
bool Bool_t
Boolean (0=false, 1=true) (bool)
Definition RtypesCore.h:77
int Int_t
Signed integer 4 bytes (int)
Definition RtypesCore.h:59
constexpr Int_t kMaxInt
Definition RtypesCore.h:119
int Ssiz_t
String size (currently int)
Definition RtypesCore.h:81
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int)
Definition RtypesCore.h:60
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
long double LongDouble_t
Long Double (not portable)
Definition RtypesCore.h:75
constexpr Ssiz_t kNPOS
The equivalent of std::string::npos for the ROOT class TString.
Definition RtypesCore.h:131
long long Long64_t
Portable signed long integer 8 bytes.
Definition RtypesCore.h:83
unsigned long long ULong64_t
Portable unsigned long integer 8 bytes.
Definition RtypesCore.h:84
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
#define ClassDef(name, id)
Definition Rtypes.h:344
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t UChar_t len
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t format
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t nchar
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t src
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
TString ToUpper(const TString &s)
Return an upper-case version of str.
Definition TString.cxx:1518
Bool_t operator!=(const TString &s1, const TString &s2)
Definition TString.h:781
TString ToLower(const TString &s)
Return a lower-case version of str.
Definition TString.cxx:1504
std::ostream & operator<<(std::ostream &str, const TString &s)
Write string to stream.
Definition Stringio.cxx:177
Bool_t operator>(const TString &s1, const TString &s2)
Definition TString.h:787
Bool_t operator>=(const TString &s1, const TString &s2)
Definition TString.h:793
char * Compress(const char *str)
Remove all blanks from the string str.
Definition TString.cxx:2579
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
Definition TString.cxx:2496
UInt_t Hash(const TString &s)
Definition TString.h:502
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:2624
Bool_t operator<(const TString &s1, const TString &s2)
Definition TString.h:784
TString operator+(const TString &s1, const TString &s2)
Use the special concatenation constructor.
Definition TString.cxx:1548
char * Strip(const char *str, char c=' ')
Strip leading and trailing c (blanks by default) from a string.
Definition TString.cxx:2528
Bool_t operator<=(const TString &s1, const TString &s2)
Definition TString.h:790
void Printf(const char *fmt,...)
Formats a string in a circular formatting buffer and prints the string.
Definition TString.cxx:2510
Bool_t operator==(const TString &s1, const TString &s2)
Definition TString.h:775
char * StrDup(const char *str)
Duplicate the string str.
Definition TString.cxx:2564
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:2600
std::istream & operator>>(std::istream &str, TString &s)
Read string from stream.
Definition Stringio.cxx:169
std::string & operator+=(std::string &left, const TString &right)
Definition TString.h:494
#define snprintf
Definition civetweb.c:1579
The concrete implementation of TBuffer for writing/reading to/from a ROOT file or socket.
Definition TBufferFile.h:47
Buffer base class used for serializing objects.
Definition TBuffer.h:43
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition TClass.h:84
An array of TObjects.
Definition TObjArray.h:31
Regular expression class.
Definition TRegexp.h:31
ATTENTION: this class is obsolete.
Definition TStringLong.h:30
Basic string class.
Definition TString.h:138
TString Copy() const
Copy a string.
Definition TString.cxx:537
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:2126
@ kLongMask
Definition TString.h:184
@ kShortMask
Definition TString.h:184
Ssiz_t Length() const
Definition TString.h:425
const char * GetPointer() const
Definition TString.h:265
char & operator[](Ssiz_t i)
Definition TString.h:738
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:2151
Rep_t fRep
Definition TString.h:223
std::enable_if< ROOT::TypeTraits::IsFloatNumeral< T >::value, TString >::type & operator+=(T f)
void SetShortSize(Ssiz_t s)
Definition TString.h:251
char & operator()(Ssiz_t i)
Definition TString.h:732
Bool_t IsDec() const
Returns true if all characters in string are decimal digits (0-9).
Definition TString.cxx:1947
Bool_t IsLong() const
Definition TString.h:246
void ToLower()
Change string to lower-case.
Definition TString.cxx:1190
int CompareTo(const char *cs, ECaseCompare cmp=kExact) const
Compare a string to char *cs2.
Definition TString.cxx:465
TString & Insert(Ssiz_t pos, const char *s)
Definition TString.h:669
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:1619
Int_t Atoi() const
Return integer value of string.
Definition TString.cxx:1995
static Ssiz_t Align(Ssiz_t s)
Definition TString.h:232
@ kNwords
Definition TString.h:205
void SetLongSize(Ssiz_t s)
Definition TString.h:254
Bool_t Gets(FILE *fp, Bool_t chop=kTRUE)
Read one line from the stream, including the \n, or until EOF.
Definition Stringio.cxx:204
std::istream & ReadToDelim(std::istream &str, char delim='\n')
Read up to an EOF, or a delimiting character, whichever comes first.
Definition Stringio.cxx:95
static constexpr Ssiz_t kNPOS
Definition TString.h:286
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
Return true if string ends with the specified string.
Definition TString.cxx:2251
TSubString Strip(EStripType s=kTrailing, char c=' ') const
Return a substring of self stripped at beginning and/or end.
Definition TString.cxx:1171
TString()
TString default ctor.
Definition TString.cxx:95
Bool_t IsHex() const
Returns true if all characters in string are hexadecimal digits (0-9,a-f,A-F).
Definition TString.cxx:1899
Double_t Atof() const
Return floating-point value contained in string.
Definition TString.cxx:2061
TString & ReplaceSpecialCppChars()
Find special characters which are typically used in printf() calls and replace them by appropriate es...
Definition TString.cxx:1122
Bool_t IsFloat() const
Returns kTRUE if string contains a floating point or integer number.
Definition TString.cxx:1865
void Clear()
Clear string without changing its capacity.
Definition TString.cxx:1242
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:1664
TString & Replace(Ssiz_t pos, Ssiz_t n, const char *s)
Definition TString.h:702
Ssiz_t First(char c) const
Find first occurrence of a character c.
Definition TString.cxx:546
const char * Data() const
Definition TString.h:384
static TString * ReadString(TBuffer &b, const TClass *clReq)
Read TString object from buffer.
Definition TString.cxx:1369
Bool_t EqualTo(const char *cs, ECaseCompare cmp=kExact) const
Definition TString.h:653
Bool_t IsDigit() const
Returns true if all characters in string are digits (0-9) or white spaces, i.e.
Definition TString.cxx:1837
TString & Chop()
Definition TString.h:699
Bool_t MaybeRegexp() const
Returns true if string contains one of the regexp characters "^$.[]*+?".
Definition TString.cxx:960
static Ssiz_t ResizeIncrement(Ssiz_t ri=16)
Set default resize increment for all TStrings. Default is 16.
Definition TString.cxx:1609
UInt_t HashCase() const
Return a case-sensitive hash value (endian independent).
Definition TString.cxx:641
Bool_t IsOct() const
Returns true if all characters in string are octal digits (0-7).
Definition TString.cxx:1931
virtual ~TString()
Delete a TString.
Definition TString.cxx:259
Ssiz_t Capacity() const
Definition TString.h:372
static Ssiz_t GetMaxWaste()
Definition TString.cxx:1591
TString & ReplaceAll(const TString &s1, const TString &s2)
Definition TString.h:712
static Ssiz_t AdjustCapacity(Ssiz_t oldCap, Ssiz_t newCap)
Calculate a nice capacity greater than or equal to newCap.
Definition TString.cxx:1228
TString MD5() const
Return the MD5 digest for this string, in a string representation.
Definition TString.cxx:948
void Resize(Ssiz_t n)
Resize the string. Truncate or add blanks as necessary.
Definition TString.cxx:1160
@ kLeading
Definition TString.h:284
@ kTrailing
Definition TString.h:284
@ kBoth
Definition TString.h:284
ECaseCompare
Definition TString.h:285
@ kIgnoreCase
Definition TString.h:285
@ kExact
Definition TString.h:285
Bool_t IsAlpha() const
Returns true if all characters in string are alphabetic.
Definition TString.cxx:1805
UInt_t HashFoldCase() const
Return a case-insensitive hash value (endian independent).
Definition TString.cxx:670
Ssiz_t Last(char c) const
Find last occurrence of a character c.
Definition TString.cxx:939
void ToUpper()
Change string to upper case.
Definition TString.cxx:1203
Bool_t IsAscii() const
Returns true if all characters in string are ascii.
Definition TString.cxx:1792
TObjArray * Tokenize(const TString &delim) const
This function is used to isolate sequential tokens in a TString.
Definition TString.cxx:2271
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
Definition TString.h:631
static Ssiz_t GetResizeIncrement()
Definition TString.cxx:1583
void Puts(FILE *fp)
Write string to the stream.
Definition Stringio.cxx:229
void SetLongCap(Ssiz_t s)
Definition TString.h:257
friend TString operator+(const TString &s1, const TString &s2)
Use the special concatenation constructor.
Definition TString.cxx:1548
std::string_view View() const
Definition TString.h:460
@ kAlignment
Definition TString.h:231
TString & Prepend(const char *cs)
Definition TString.h:681
TString & Swap(TString &other)
Definition TString.h:724
Bool_t IsBin() const
Returns true if all characters in string are binary digits (0,1).
Definition TString.cxx:1915
void UnLink() const
Definition TString.h:271
Bool_t IsNull() const
Definition TString.h:422
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:2201
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:2178
Int_t CountChar(Int_t c) const
Return number of times character c occurs in the string.
Definition TString.cxx:523
friend Bool_t operator==(const TString &s1, const TString &s2)
Definition TString.h:775
static constexpr Ssiz_t MaxSize()
Definition TString.h:269
UInt_t Hash(ECaseCompare cmp=kExact) const
Return hash value.
Definition TString.cxx:685
static void WriteString(TBuffer &b, const TString *a)
Write TString object to buffer.
Definition TString.cxx:1435
virtual void FillBuffer(char *&buffer) const
Copy string into I/O buffer.
Definition TString.cxx:1317
TString & operator=(char s)
Assign character c to TString.
Definition TString.cxx:309
std::istream & ReadFile(std::istream &str)
Replace string with the contents of strm, stopping at an EOF.
Definition Stringio.cxx:29
TString & Remove(Ssiz_t pos)
Definition TString.h:693
static Ssiz_t InitialCapacity(Ssiz_t ic=15)
Set default initial capacity for all TStrings. Default is 15.
Definition TString.cxx:1600
char * GetShortPointer()
Definition TString.h:262
TString & Append(const char *cs)
Definition TString.h:580
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:1964
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:269
Bool_t MaybeWildcard() const
Returns true if string contains one of the wildcard characters "[]*?".
Definition TString.cxx:972
void InitChar(char c)
Initialize a string with a single character.
Definition TString.cxx:156
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:2385
char * GetLongPointer()
Definition TString.h:260
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:2099
virtual Int_t Sizeof() const
Returns size string will occupy on I/O buffer.
Definition TString.cxx:1408
Ssiz_t Clobber(Ssiz_t nc)
Clear string and make sure it has a capacity of nc.
Definition TString.cxx:1253
TString & operator+=(const char *s)
Definition TString.h:592
Ssiz_t GetShortSize() const
Definition TString.h:252
Bool_t IsWhitespace() const
Definition TString.h:423
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:1286
void SetSize(Ssiz_t s)
Definition TString.h:256
const char * GetLongPointer() const
Definition TString.h:261
std::enable_if< ROOT::TypeTraits::IsUnsignedNumeral< T >::value, TString >::type & operator+=(T u)
const char * GetShortPointer() const
Definition TString.h:263
void Zero()
Definition TString.h:272
Ssiz_t GetLongCap() const
Definition TString.h:258
void SetLongPointer(char *p)
Definition TString.h:259
std::istream & ReadToken(std::istream &str)
Read a token, delimited by whitespace, from the input stream.
Definition Stringio.cxx:133
Ssiz_t GetLongSize() const
Definition TString.h:255
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
Definition TString.cxx:2363
friend TBuffer & operator<<(TBuffer &b, const TString *obj)
Write TString or derived to TBuffer.
Definition TString.cxx:1477
static Ssiz_t GetInitialCapacity()
Definition TString.cxx:1575
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition TString.h:640
void AssertElement(Ssiz_t nc) const
Check to make sure a string index is in range.
Definition TString.cxx:1216
virtual void ReadBuffer(char *&buffer)
Read string from I/O buffer.
Definition TString.cxx:1338
Bool_t IsAlnum() const
Returns true if all characters in string are alphanumeric.
Definition TString.cxx:1820
void FormImp(const char *fmt, va_list ap)
Formats a string using a printf style format descriptor.
Definition TString.cxx:2317
char * GetPointer()
Definition TString.h:264
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
Definition TString.h:659
static Ssiz_t Recommend(Ssiz_t s)
Definition TString.h:234
std::istream & ReadLine(std::istream &str, Bool_t skipWhite=kTRUE)
Read a line from stream upto newline skipping any whitespace.
Definition Stringio.cxx:71
Long64_t Atoll() const
Return long long value of string.
Definition TString.cxx:2021
A zero length substring is legal.
Definition TString.h:84
TString & String()
Definition TString.h:123
TSubString(const TString &s, Ssiz_t start, Ssiz_t len)
Private constructor.
Definition TString.cxx:1638
TSubString & operator=(const char *s)
Assign char* to sub-string.
Definition TString.cxx:1703
Bool_t IsNull() const
Definition TString.h:128
void ToUpper()
Convert sub-string to upper-case.
Definition TString.cxx:1761
TString & fStr
Definition TString.h:94
Ssiz_t Start() const
Definition TString.h:122
int operator!() const
Definition TString.h:129
void SubStringError(Ssiz_t, Ssiz_t, Ssiz_t) const
Output error message.
Definition TString.cxx:1773
Ssiz_t fBegin
Definition TString.h:95
char & operator[](Ssiz_t i)
Return character at pos i from sub-string. Check validity of i.
Definition TString.cxx:1675
Ssiz_t fExtent
Definition TString.h:96
friend Bool_t operator==(const TSubString &s1, const TSubString &s2)
Compare two sub-strings.
Definition TString.cxx:1738
void AssertElement(Ssiz_t i) const
Check to make sure a sub-string index is in range.
Definition TString.cxx:1782
void ToLower()
Convert sub-string to lower-case.
Definition TString.cxx:1749
TSubString(const TSubString &s)
Definition TString.h:106
const char * Data() const
Definition TString.h:744
char & operator()(Ssiz_t i)
Return character at pos i from sub-string. No check on i.
Definition TString.cxx:1684
Ssiz_t Length() const
Definition TString.h:121
This class implements a mutex interface.
const Int_t n
Definition legend1.C:16
Ssiz_t fWords[kNwords]
Definition TString.h:209
RawStr_t fRaw
Definition TString.h:218
ShortStr_t fShort
Definition TString.h:217
LongStr_t fLong
Definition TString.h:216
unsigned char fSize
Definition TString.h:199
char fData[kMinCap]
Definition TString.h:200
LongStr_t fL
Definition TString.h:203
ShortStr_t fS
Definition TString.h:203