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