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