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