Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TString.h
Go to the documentation of this file.
1// @(#)root/base:$Id$
2// Author: Fons Rademakers 04/08/95
3
4/*************************************************************************
5 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12#ifndef ROOT_TString
13#define ROOT_TString
14
15
16//////////////////////////////////////////////////////////////////////////
17// //
18// TString //
19// //
20// Basic string class. //
21// //
22// Cannot be stored in a TCollection... use TObjString instead. //
23// //
24//////////////////////////////////////////////////////////////////////////
25
26#include "Rtypes.h"
27
28#include "TMathBase.h"
29#include "ROOT/RStringView.hxx"
30#include "ROOT/TypeTraits.hxx"
31#include "snprintf.h"
32
33#include <iosfwd>
34#include <cstdarg>
35#include <cstdio>
36#include <cstring>
37#include <string>
38
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:
105 : fStr(s.fStr), fBegin(s.fBegin), fExtent(s.fExtent) { }
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>
149friend typename std::enable_if<ROOT::TypeTraits::IsSignedNumeral<T>::value,TString>::type
150operator+(TString s, T i);
151template<class T>
152friend typename std::enable_if<ROOT::TypeTraits::IsUnsignedNumeral<T>::value,TString>::type
153operator+(TString s, T u);
154template<class T>
155friend typename std::enable_if<ROOT::TypeTraits::IsFloatNumeral<T>::value,TString>::type
156operator+(TString s, T f);
157template<class T>
158friend typename std::enable_if<ROOT::TypeTraits::IsSignedNumeral<T>::value,TString>::type
159operator+(T i, const TString &s);
160template<class T>
161friend typename std::enable_if<ROOT::TypeTraits::IsUnsignedNumeral<T>::value,TString>::type
162operator+(T u, const TString &s);
163template<class T>
164friend typename std::enable_if<ROOT::TypeTraits::IsFloatNumeral<T>::value,TString>::type
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(__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);
317 TString &operator=(const std::string_view &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>
324 typename std::enable_if<ROOT::TypeTraits::IsSignedNumeral<T>::value,TString>::type
325 &operator+=(T i);
326 template<class T>
327 typename std::enable_if<ROOT::TypeTraits::IsUnsignedNumeral<T>::value,TString>::type
329 template<class T>
330 typename std::enable_if<ROOT::TypeTraits::IsFloatNumeral<T>::value,TString>::type
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
437 void Resize(Ssiz_t n); // Truncate or add blanks as necessary
438 TSubString Strip(EStripType s = kTrailing, char c = ' ') const;
439 TString &Swap(TString &other); // Swap the contents of this and other without reallocation
440 void ToLower(); // Change self to lower-case
441 void ToUpper(); // Change self to upper-case
442 TObjArray *Tokenize(const TString &delim) const;
443 Bool_t Tokenize(TString &tok, Ssiz_t &from, const char *delim = " ") const;
444 std::string_view View() const { return std::string_view(GetPointer(),Length()); }
445
446 // Static member functions
447 static UInt_t Hash(const void *txt, Int_t ntxt); // Calculates hash index from any char string.
448 static Ssiz_t InitialCapacity(Ssiz_t ic = 15); // Initial allocation capacity
449 static Ssiz_t MaxWaste(Ssiz_t mw = 15); // Max empty space before reclaim
450 static Ssiz_t ResizeIncrement(Ssiz_t ri = 16); // Resizing increment
451 static Ssiz_t GetInitialCapacity();
452 static Ssiz_t GetResizeIncrement();
453 static Ssiz_t GetMaxWaste();
454 static TString Itoa ( Int_t value, Int_t base); // Converts int to string with respect to the base specified (2-36)
455 static TString UItoa ( UInt_t value, Int_t base);
456 static TString LLtoa ( Long64_t value, Int_t base);
457 static TString ULLtoa (ULong64_t value, Int_t base);
458 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)
459 static TString Format(const char *fmt, ...)
460#if defined(__GNUC__) && !defined(__CINT__)
461 __attribute__((format(printf, 1, 2)))
462#endif
463 ;
464
465 ClassDef(TString,2) //Basic string class
466};
467
468// Related global functions
469std::istream &operator>>(std::istream &str, TString &s);
470std::ostream &operator<<(std::ostream &str, const TString &s);
471#if defined(R__TEMPLATE_OVERLOAD_BUG)
472template <>
473#endif
474TBuffer &operator>>(TBuffer &buf, TString *&sp);
475TBuffer &operator<<(TBuffer &buf, const TString * sp);
476
477// Conversion operator (per se).
478inline std::string& operator+=(std::string &left, const TString &right)
479{
480 return left.append(right.Data());
481}
482
483TString ToLower(const TString &s); // Return lower-case version of argument
484TString ToUpper(const TString &s); // Return upper-case version of argument
485
486inline UInt_t Hash(const TString &s) { return s.Hash(); }
487inline UInt_t Hash(const TString *s) { return s->Hash(); }
488 UInt_t Hash(const char *s);
489
490extern char *Form(const char *fmt, ...) // format in circular buffer
491#if defined(__GNUC__) && !defined(__CINT__)
492__attribute__((format(printf, 1, 2)))
493#endif
494;
495extern void Printf(const char *fmt, ...) // format and print
496#if defined(__GNUC__) && !defined(__CINT__)
497__attribute__((format(printf, 1, 2)))
498#endif
499;
500extern char *Strip(const char *str, char c = ' '); // strip c off str, free with delete []
501extern char *StrDup(const char *str); // duplicate str, free with delete []
502extern char *Compress(const char *str); // remove blanks from string, free with delele []
503extern int EscChar(const char *src, char *dst, int dstlen, char *specchars,
504 char escchar); // copy from src to dst escaping specchars by escchar
505extern int UnEscChar(const char *src, char *dst, int dstlen, char *specchars,
506 char escchar); // copy from src to dst removing escchar from specchars
507
508#ifdef NEED_STRCASECMP
509extern int strcasecmp(const char *str1, const char *str2);
510extern int strncasecmp(const char *str1, const char *str2, Ssiz_t n);
511#endif
512
513//////////////////////////////////////////////////////////////////////////
514// //
515// Inlines //
516// //
517//////////////////////////////////////////////////////////////////////////
518
519template<class T>
520inline typename std::enable_if<ROOT::TypeTraits::IsSignedNumeral<T>::value,TString>::type
522{ return s += i; }
523
524template<class T>
525inline typename std::enable_if<ROOT::TypeTraits::IsUnsignedNumeral<T>::value,TString>::type
527{ return s += u; }
528
529template<class T>
530inline typename std::enable_if<ROOT::TypeTraits::IsFloatNumeral<T>::value,TString>::type
532{ return s += f; }
533
534template<class T>
535inline typename std::enable_if<ROOT::TypeTraits::IsSignedNumeral<T>::value,TString>::type
536operator+(T i, const TString &s)
537{
538 char buffer[32];
539 // coverity[secure_coding] Buffer is large enough (2^64 = 20 digits).
540 snprintf(buffer, sizeof(buffer), "%lld", static_cast<Long64_t>(i));
541 return TString(buffer, strlen(buffer), s.Data(), s.Length());
542}
543
544template<class T>
545inline typename std::enable_if<ROOT::TypeTraits::IsUnsignedNumeral<T>::value,TString>::type
546operator+(T u, const TString &s)
547{
548 char buffer[32];
549 // coverity[secure_coding] Buffer is large enough (2^64 = 20 digits).
550 snprintf(buffer, sizeof(buffer), "%llu", static_cast<ULong64_t>(u));
551 return TString(buffer, strlen(buffer), s.Data(), s.Length());
552}
553
554template<class T>
555inline typename std::enable_if<ROOT::TypeTraits::IsFloatNumeral<T>::value,TString>::type
556operator+(T f, const TString &s)
557{
558 char buffer[32];
559 // coverity[secure_coding] Buffer is large enough: width specified in format
560 snprintf(buffer, sizeof(buffer), "%.17Lg", static_cast<LongDouble_t>(f));
561 return TString(buffer, strlen(buffer), s.Data(), s.Length());
562}
563
564inline TString &TString::Append(const char *cs)
565{ return Replace(Length(), 0, cs, cs ? strlen(cs) : 0); }
566
567inline TString &TString::Append(const char *cs, Ssiz_t n)
568{ return Replace(Length(), 0, cs, n); }
569
571{ return Replace(Length(), 0, s.Data(), s.Length()); }
572
574{ return Replace(Length(), 0, s.Data(), TMath::Min(n, s.Length())); }
575
576inline TString &TString::operator+=(const char *cs)
577{ return Append(cs, cs ? strlen(cs) : 0); }
578
580{ return Append(s.Data(), s.Length()); }
581
583{ return Append(c); }
584
585template<class T>
586inline typename std::enable_if<ROOT::TypeTraits::IsSignedNumeral<T>::value,TString>::type
588{
589 char buffer[32];
590 // coverity[secure_coding] Buffer is large enough (2^64 = 20 digits).
591 snprintf(buffer, sizeof(buffer), "%lld", static_cast<Long64_t>(i));
592 return operator+=(buffer);
593}
594
595template<class T>
596inline typename std::enable_if<ROOT::TypeTraits::IsUnsignedNumeral<T>::value,TString>::type
598{
599 char buffer[32];
600 // coverity[secure_coding] Buffer is large enough (2^64 = 20 digits).
601 snprintf(buffer, sizeof(buffer), "%llu", static_cast<ULong64_t>(u));
602 return operator+=(buffer);
603}
604
605template<class T>
606inline typename std::enable_if<ROOT::TypeTraits::IsFloatNumeral<T>::value,TString>::type
608{
609 char buffer[32];
610 // coverity[secure_coding] Buffer is large enough: width specified in format
611 snprintf(buffer, sizeof(buffer), "%.17Lg", static_cast<LongDouble_t>(f));
612 return operator+=(buffer);
613}
614
615inline Bool_t TString::BeginsWith(const char *s, ECaseCompare cmp) const
616{ return Index(s, s ? strlen(s) : (Ssiz_t)0, (Ssiz_t)0, cmp) == 0; }
617
618inline Bool_t TString::BeginsWith(const TString &pat, ECaseCompare cmp) const
619{ return Index(pat.Data(), pat.Length(), (Ssiz_t)0, cmp) == 0; }
620
621inline Bool_t TString::Contains(const TString &pat, ECaseCompare cmp) const
622{ return Index(pat.Data(), pat.Length(), (Ssiz_t)0, cmp) != kNPOS; }
623
624inline Bool_t TString::Contains(const char *s, ECaseCompare cmp) const
625{ return Index(s, s ? strlen(s) : 0, (Ssiz_t)0, cmp) != kNPOS; }
626
627inline Bool_t TString::Contains(const TRegexp &pat) const
628{ return Index(pat, (Ssiz_t)0) != kNPOS; }
629
631{ return Index(pat, (Ssiz_t)0) != kNPOS; }
632
633inline Bool_t TString::EqualTo(const char *cs, ECaseCompare cmp) const
634{ return (CompareTo(cs, cmp) == 0) ? kTRUE : kFALSE; }
635
636inline Bool_t TString::EqualTo(const TString &st, ECaseCompare cmp) const
637{ return (CompareTo(st, cmp) == 0) ? kTRUE : kFALSE; }
638
639inline Ssiz_t TString::Index(const char *s, Ssiz_t i, ECaseCompare cmp) const
640{ return Index(s, s ? strlen(s) : 0, i, cmp); }
641
642inline Ssiz_t TString::Index(const TString &s, Ssiz_t i, ECaseCompare cmp) const
643{ return Index(s.Data(), s.Length(), i, cmp); }
644
645inline Ssiz_t TString::Index(const TString &pat, Ssiz_t patlen, Ssiz_t i,
646 ECaseCompare cmp) const
647{ return Index(pat.Data(), patlen, i, cmp); }
648
649inline TString &TString::Insert(Ssiz_t pos, const char *cs)
650{ return Replace(pos, 0, cs, cs ? strlen(cs) : 0); }
651
652inline TString &TString::Insert(Ssiz_t pos, const char *cs, Ssiz_t n)
653{ return Replace(pos, 0, cs, n); }
654
655inline TString &TString::Insert(Ssiz_t pos, const TString &s)
656{ return Replace(pos, 0, s.Data(), s.Length()); }
657
659{ return Replace(pos, 0, s.Data(), TMath::Min(n, s.Length())); }
660
661inline TString &TString::Prepend(const char *cs)
662{ return Replace(0, 0, cs, cs ? strlen(cs) : 0); }
663
664inline TString &TString::Prepend(const char *cs, Ssiz_t n)
665{ return Replace(0, 0, cs, n); }
666
668{ return Replace(0, 0, s.Data(), s.Length()); }
669
671{ return Replace(0, 0, s.Data(), TMath::Min(n, s.Length())); }
672
674{ return Replace(pos, TMath::Max(0, Length()-pos), 0, 0); }
675
677{ return Replace(pos, n, 0, 0); }
678
680{ return Remove(TMath::Max(0, Length()-1)); }
681
682inline TString &TString::Replace(Ssiz_t pos, Ssiz_t n, const char *cs)
683{ return Replace(pos, n, cs, cs ? strlen(cs) : 0); }
684
686{ return Replace(pos, n, s.Data(), s.Length()); }
687
688inline TString &TString::Replace(Ssiz_t pos, Ssiz_t n1, const TString &s,
689 Ssiz_t n2)
690{ return Replace(pos, n1, s.Data(), TMath::Min(s.Length(), n2)); }
691
692inline TString &TString::ReplaceAll(const TString &s1, const TString &s2)
693{ return ReplaceAll(s1.Data(), s1.Length(), s2.Data(), s2.Length()) ; }
694
695inline TString &TString::ReplaceAll(const TString &s1, const char *s2)
696{ return ReplaceAll(s1.Data(), s1.Length(), s2, s2 ? strlen(s2) : 0); }
697
698inline TString &TString::ReplaceAll(const char *s1, const TString &s2)
699{ return ReplaceAll(s1, s1 ? strlen(s1) : 0, s2.Data(), s2.Length()); }
700
701inline TString &TString::ReplaceAll(const char *s1,const char *s2)
702{ return ReplaceAll(s1, s1 ? strlen(s1) : 0, s2, s2 ? strlen(s2) : 0); }
703
705 // Swap the contents of other and this without reallocation.
706#ifndef __CINT__
707 Rep_t tmp = other.fRep;
708 other.fRep = fRep;
709 fRep = tmp;
710#endif
711 return *this;
712}
713
715{ return GetPointer()[i]; }
716
717inline char TString::operator()(Ssiz_t i) const
718{ return GetPointer()[i]; }
719
721{ AssertElement(i); return GetPointer()[i]; }
722
723inline char TString::operator[](Ssiz_t i) const
724{ AssertElement(i); return GetPointer()[i]; }
725
726inline const char *TSubString::Data() const
727{
728 // Return a pointer to the beginning of the substring. Note that the
729 // terminating null is in the same place as for the original
730 // TString, so this method is not appropriate for converting the
731 // TSubString to a string. To do that, construct a TString from the
732 // TSubString. For example:
733 //
734 // root [0] TString s("hello world")
735 // root [1] TSubString sub=s(0, 5)
736 // root [2] sub.Data()
737 // (const char* 0x857c8b8)"hello world"
738 // root [3] TString substr(sub)
739 // root [4] substr
740 // (class TString)"hello"
741
742 return fStr.Data() + fBegin;
743}
744
745// Access to elements of sub-string with bounds checking
746inline char TSubString::operator[](Ssiz_t i) const
747{ AssertElement(i); return fStr.GetPointer()[fBegin+i]; }
748
749inline char TSubString::operator()(Ssiz_t i) const
750{ return fStr.GetPointer()[fBegin+i]; }
751
753{ fStr = s.fStr; fBegin = s.fBegin; fExtent = s.fExtent; return *this; }
754
755
756// String Logical operators
757inline Bool_t operator==(const TString &s1, const TString &s2)
758{
759 return ((s1.Length() == s2.Length()) &&
760 !memcmp(s1.Data(), s2.Data(), s1.Length()));
761}
762
763inline Bool_t operator!=(const TString &s1, const TString &s2)
764{ return !(s1 == s2); }
765
766inline Bool_t operator<(const TString &s1, const TString &s2)
767{ return s1.CompareTo(s2) < 0; }
768
769inline Bool_t operator>(const TString &s1, const TString &s2)
770{ return s1.CompareTo(s2) > 0; }
771
772inline Bool_t operator<=(const TString &s1, const TString &s2)
773{ return s1.CompareTo(s2) <= 0; }
774
775inline Bool_t operator>=(const TString &s1, const TString &s2)
776{ return s1.CompareTo(s2) >= 0; }
777
778// Bool_t operator==(const TString &s1, const char *s2);
779inline Bool_t operator!=(const TString &s1, const char *s2)
780{ return !(s1 == s2); }
781
782inline Bool_t operator<(const TString &s1, const char *s2)
783{ return s1.CompareTo(s2) < 0; }
784
785inline Bool_t operator>(const TString &s1, const char *s2)
786{ return s1.CompareTo(s2) > 0; }
787
788inline Bool_t operator<=(const TString &s1, const char *s2)
789{ return s1.CompareTo(s2) <= 0; }
790
791inline Bool_t operator>=(const TString &s1, const char *s2)
792{ return s1.CompareTo(s2) >= 0; }
793
794inline Bool_t operator==(const char *s1, const TString &s2)
795{ return (s2 == s1); }
796
797inline Bool_t operator!=(const char *s1, const TString &s2)
798{ return !(s2 == s1); }
799
800inline Bool_t operator<(const char *s1, const TString &s2)
801{ return s2.CompareTo(s1) > 0; }
802
803inline Bool_t operator>(const char *s1, const TString &s2)
804{ return s2.CompareTo(s1) < 0; }
805
806inline Bool_t operator<=(const char *s1, const TString &s2)
807{ return s2.CompareTo(s1) >= 0; }
808
809inline Bool_t operator>=(const char *s1, const TString &s2)
810{ return s2.CompareTo(s1) <= 0; }
811
812// SubString Logical operators
813// Bool_t operator==(const TSubString &s1, const TSubString &s2);
814// Bool_t operator==(const TSubString &s1, const char *s2);
815// Bool_t operator==(const TSubString &s1, const TString &s2);
816inline Bool_t operator==(const TString &s1, const TSubString &s2)
817{ return (s2 == s1); }
818
819inline Bool_t operator==(const char *s1, const TSubString &s2)
820{ return (s2 == s1); }
821
822inline Bool_t operator!=(const TSubString &s1, const char *s2)
823{ return !(s1 == s2); }
824
825inline Bool_t operator!=(const TSubString &s1, const TString &s2)
826{ return !(s1 == s2); }
827
828inline Bool_t operator!=(const TSubString &s1, const TSubString &s2)
829{ return !(s1 == s2); }
830
831inline Bool_t operator!=(const TString &s1, const TSubString &s2)
832{ return !(s2 == s1); }
833
834inline Bool_t operator!=(const char *s1, const TSubString &s2)
835{ return !(s2 == s1); }
836
837#ifndef WIN32
838// To avoid ambiguities.
839inline Bool_t operator==(const char *s1, const std::string_view &s2)
840{
841 return std::string_view(s1) == s2;
842}
843
844inline Bool_t operator==(const std::string_view &s1, const char *s2)
845{
846 return s1 == std::string_view(s2);
847}
848#endif
849
850namespace llvm {
851 class raw_ostream;
852}
853
854namespace cling {
855 std::string printValue(const TString* val);
856 std::string printValue(const TSubString* val);
857 std::string printValue(const std::string_view* val);
858}
859
860#endif
#define b(i)
Definition RSha256.hxx:100
#define f(i)
Definition RSha256.hxx:104
#define c(i)
Definition RSha256.hxx:101
#define a(i)
Definition RSha256.hxx:99
#define s1(x)
Definition RSha256.hxx:91
const Ssiz_t kNPOS
Definition RtypesCore.h:115
int Int_t
Definition RtypesCore.h:45
const Int_t kMaxInt
Definition RtypesCore.h:103
int Ssiz_t
Definition RtypesCore.h:67
unsigned int UInt_t
Definition RtypesCore.h:46
const Bool_t kFALSE
Definition RtypesCore.h:92
bool Bool_t
Definition RtypesCore.h:63
double Double_t
Definition RtypesCore.h:59
long double LongDouble_t
Definition RtypesCore.h:61
long long Long64_t
Definition RtypesCore.h:73
unsigned long long ULong64_t
Definition RtypesCore.h:74
const Bool_t kTRUE
Definition RtypesCore.h:91
#define ClassDef(name, id)
Definition Rtypes.h:325
TBuffer & operator<<(TBuffer &buf, const Tmpl *obj)
Definition TBuffer.h:399
int type
Definition TGX11.cxx:121
TString ToUpper(const TString &s)
Return an upper-case version of str.
Definition TString.cxx:1464
Bool_t operator!=(const TString &s1, const TString &s2)
Definition TString.h:763
TString ToLower(const TString &s)
Return a lower-case version of str.
Definition TString.cxx:1450
Bool_t operator>(const TString &s1, const TString &s2)
Definition TString.h:769
Bool_t operator>=(const TString &s1, const TString &s2)
Definition TString.h:775
char * Compress(const char *str)
Remove all blanks from the string str.
Definition TString.cxx:2524
char * Form(const char *fmt,...)
UInt_t Hash(const TString &s)
Definition TString.h:486
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:2569
Bool_t operator<(const TString &s1, const TString &s2)
Definition TString.h:766
TString operator+(const TString &s1, const TString &s2)
Use the special concatenation constructor.
Definition TString.cxx:1494
char * Strip(const char *str, char c=' ')
Strip leading and trailing c (blanks by default) from a string.
Definition TString.cxx:2474
Bool_t operator<=(const TString &s1, const TString &s2)
Definition TString.h:772
void Printf(const char *fmt,...)
Bool_t operator==(const TString &s1, const TString &s2)
Definition TString.h:757
char * StrDup(const char *str)
Duplicate the string str.
Definition TString.cxx:2510
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:2545
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:478
#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:80
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:136
TString Copy() const
Copy a string.
Definition TString.cxx:510
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:2072
@ 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:720
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:2097
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:714
Bool_t IsDec() const
Returns true if all characters in string are decimal digits (0-9).
Definition TString.cxx:1893
Bool_t IsLong() const
Definition TString.h:229
void ToLower()
Change string to lower-case.
Definition TString.cxx:1145
int CompareTo(const char *cs, ECaseCompare cmp=kExact) const
Compare a string to char *cs2.
Definition TString.cxx:438
TString & Insert(Ssiz_t pos, const char *s)
Definition TString.h:649
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:1565
Int_t Atoi() const
Return integer value of string.
Definition TString.cxx:1941
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 , 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:2197
TSubString Strip(EStripType s=kTrailing, char c=' ') const
Return a substring of self stripped at beginning and/or end.
Definition TString.cxx:1126
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:1845
Double_t Atof() const
Return floating-point value contained in string.
Definition TString.cxx:2007
Bool_t IsFloat() const
Returns kTRUE if string contains a floating point or integer number.
Definition TString.cxx:1811
void Clear()
Clear string without changing its capacity.
Definition TString.cxx:1196
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:1610
TString & Replace(Ssiz_t pos, Ssiz_t n, const char *s)
Definition TString.h:682
const char * Data() const
Definition TString.h:369
static TString * ReadString(TBuffer &b, const TClass *clReq)
Read TString object from buffer.
Definition TString.cxx:1315
Bool_t EqualTo(const char *cs, ECaseCompare cmp=kExact) const
Definition TString.h:633
Bool_t IsDigit() const
Returns true if all characters in string are digits (0-9) or white spaces, i.e.
Definition TString.cxx:1783
TString & Chop()
Definition TString.h:679
Bool_t MaybeRegexp() const
Returns true if string contains one of the regexp characters "^$.[]*+?".
Definition TString.cxx:933
static Ssiz_t ResizeIncrement(Ssiz_t ri=16)
Set default resize increment for all TStrings. Default is 16.
Definition TString.cxx:1555
UInt_t HashCase() const
Return a case-sensitive hash value (endian independent).
Definition TString.cxx:614
Bool_t IsOct() const
Returns true if all characters in string are octal digits (0-7).
Definition TString.cxx:1877
virtual ~TString()
Delete a TString.
Definition TString.cxx:238
Ssiz_t Capacity() const
Definition TString.h:357
static Ssiz_t GetMaxWaste()
Definition TString.cxx:1537
TString & ReplaceAll(const TString &s1, const TString &s2)
Definition TString.h:692
static Ssiz_t AdjustCapacity(Ssiz_t oldCap, Ssiz_t newCap)
Calculate a nice capacity greater than or equal to newCap.
Definition TString.cxx:1181
TString MD5() const
Return the MD5 digest for this string, in a string representation.
Definition TString.cxx:921
void Resize(Ssiz_t n)
Resize the string. Truncate or add blanks as necessary.
Definition TString.cxx:1115
@ 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:1751
UInt_t HashFoldCase() const
Return a case-insensitive hash value (endian independent).
Definition TString.cxx:643
Ssiz_t Last(char c) const
Find last occurrence of a character c.
Definition TString.cxx:912
void ToUpper()
Change string to upper case.
Definition TString.cxx:1158
Bool_t IsAscii() const
Returns true if all characters in string are ascii.
Definition TString.cxx:1738
TObjArray * Tokenize(const TString &delim) const
This function is used to isolate sequential tokens in a TString.
Definition TString.cxx:2217
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
Definition TString.h:615
static Ssiz_t GetResizeIncrement()
Definition TString.cxx:1529
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:1494
std::string_view View() const
Definition TString.h:444
@ kAlignment
Definition TString.h:223
TString & Prepend(const char *cs)
Definition TString.h:661
TString & Swap(TString &other)
Definition TString.h:704
Bool_t IsBin() const
Returns true if all characters in string are binary digits (0,1).
Definition TString.cxx:1861
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:2147
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:2124
Int_t CountChar(Int_t c) const
Return number of times character c occurs in the string.
Definition TString.cxx:496
friend Bool_t operator==(const TString &s1, const TString &s2)
Definition TString.h:757
UInt_t Hash(ECaseCompare cmp=kExact) const
Return hash value.
Definition TString.cxx:658
static void WriteString(TBuffer &b, const TString *a)
Write TString object to buffer.
Definition TString.cxx:1381
virtual void FillBuffer(char *&buffer) const
Copy string into I/O buffer.
Definition TString.cxx:1263
TString & operator=(char s)
Assign character c to TString.
Definition TString.cxx:283
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:673
static Ssiz_t InitialCapacity(Ssiz_t ic=15)
Set default initial capacity for all TStrings. Default is 15.
Definition TString.cxx:1546
char * GetShortPointer()
Definition TString.h:245
TString & Append(const char *cs)
Definition TString.h:564
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:1910
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:247
Bool_t MaybeWildcard() const
Returns true if string contains one of the wildcard characters "[]*?".
Definition TString.cxx:945
void InitChar(char c)
Initialize a string with a single character.
Definition TString.cxx:140
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:2331
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:2045
virtual Int_t Sizeof() const
Returns size string will occupy on I/O buffer.
Definition TString.cxx:1354
TString & operator+=(const char *s)
Definition TString.h:576
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:1232
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:2309
friend TBuffer & operator<<(TBuffer &b, const TString *obj)
Write TString or derived to TBuffer.
Definition TString.cxx:1423
static Ssiz_t GetInitialCapacity()
Definition TString.cxx:1521
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition TString.h:624
void AssertElement(Ssiz_t nc) const
Check to make sure a string index is in range.
Definition TString.cxx:1171
virtual void ReadBuffer(char *&buffer)
Read string from I/O buffer.
Definition TString.cxx:1284
Bool_t IsAlnum() const
Returns true if all characters in string are alphanumeric.
Definition TString.cxx:1766
void FormImp(const char *fmt, va_list ap)
Formats a string using a printf style format descriptor.
Definition TString.cxx:2263
char * GetPointer()
Definition TString.h:247
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
Definition TString.h:639
void Clobber(Ssiz_t nc)
Clear string and make sure it has a capacity of nc.
Definition TString.cxx:1204
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:1967
A zero length substring is legal.
Definition TString.h:82
TString & String()
Definition TString.h:121
TSubString & operator=(const char *s)
Assign char* to sub-string.
Definition TString.cxx:1649
Bool_t IsNull() const
Definition TString.h:126
void ToUpper()
Convert sub-string to upper-case.
Definition TString.cxx:1707
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:1719
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:1621
Ssiz_t fExtent
Definition TString.h:94
friend Bool_t operator==(const TSubString &s1, const TSubString &s2)
Compare two sub-strings.
Definition TString.cxx:1684
void AssertElement(Ssiz_t i) const
Check to make sure a sub-string index is in range.
Definition TString.cxx:1728
void ToLower()
Convert sub-string to lower-case.
Definition TString.cxx:1695
TSubString(const TSubString &s)
Definition TString.h:104
const char * Data() const
Definition TString.h:726
char & operator()(Ssiz_t i)
Return character at pos i from sub-string. No check on i.
Definition TString.cxx:1630
Ssiz_t Length() const
Definition TString.h:119
This class implements a mutex interface.
#define Swap(a, b)
Definition geom.c:201
const Int_t n
Definition legend1.C:16
Short_t Max(Short_t a, Short_t b)
Definition TMathBase.h:212
Short_t Min(Short_t a, Short_t b)
Definition TMathBase.h:180
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
LongStr_t fL
Definition TString.h:193
ShortStr_t fS
Definition TString.h:193