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