28 #include "RStringView.h" 36 namespace std { using ::string; }
98 : fStr(s.fStr), fBegin(s.fBegin), fExtent(s.fExtent) { }
108 operator std::string_view()
const {
return std::string_view(
Data(),fExtent); }
109 operator std::string()
const {
return std::string(
Data(),fExtent); }
111 const char *
Data()
const;
153 enum { kShortMask = 0x01, kLongMask = 0x1 };
155 enum { kShortMask = 0x80, kLongMask = 0x80000000 };
165 enum { kMinCap = (
sizeof(
LongStr_t) - 1)/
sizeof(char) > 2 ?
166 (
sizeof(
LongStr_t) - 1)/
sizeof(
char) : 2 };
200 void AssertElement(
Ssiz_t nc)
const;
202 void InitChar(
char c);
204 enum { kAlignment = 16 };
228 char *
GetPointer() {
return IsLong() ? GetLongPointer() : GetShortPointer(); }
229 const char *
GetPointer()
const {
return IsLong() ? GetLongPointer() : GetShortPointer(); }
238 for (
UInt_t i = 0; i < kNwords; ++i)
243 void FormImp(
const char *fmt, va_list ap);
245 UInt_t HashFoldCase()
const;
248 enum EStripType { kLeading = 0x1, kTrailing = 0x2, kBoth = 0x3 };
261 TString(
const std::string_view &sub);
267 virtual void FillBuffer(
char *&buffer)
const;
269 virtual Int_t Sizeof()
const;
281 operator const char*()
const {
return GetPointer(); }
282 operator std::string_view()
const {
return std::string_view(GetPointer(),Length()); }
283 #if __cplusplus >= 201700L 284 explicit operator std::string()
const {
return std::string(GetPointer(),Length()); }
309 char &operator[](
Ssiz_t i);
311 char operator[](
Ssiz_t i)
const;
322 TString &Append(
const char *cs);
336 int CompareTo(
const char *cs,
ECaseCompare cmp = kExact)
const;
344 const char *
Data()
const {
return GetPointer(); }
348 Ssiz_t First(
char c)
const;
349 Ssiz_t First(
const char *cs)
const;
350 void Form(
const char *fmt, ...)
351 #if defined(__GNUC__) && !defined(__CINT__) 352 __attribute__((
format(printf, 2, 3)))
384 Ssiz_t Last(
char c)
const;
385 Ssiz_t Length()
const {
return IsLong() ? GetLongSize() : GetShortSize(); }
386 Bool_t MaybeRegexp()
const;
387 Bool_t MaybeWildcard()
const;
389 TString &Prepend(
const char *cs);
394 std::istream &ReadFile(std::istream &str);
395 std::istream &ReadLine(std::istream &str,
397 std::istream &ReadString(std::istream &str);
398 std::istream &ReadToDelim(std::istream &str,
char delim =
'\n');
399 std::istream &ReadToken(std::istream &str);
410 TString &ReplaceAll(
const char *s1,
const char *s2);
425 static Ssiz_t GetInitialCapacity();
426 static Ssiz_t GetResizeIncrement();
427 static Ssiz_t GetMaxWaste();
434 #if defined(__GNUC__) && !defined(__CINT__) 435 __attribute__((
format(printf, 1, 2)))
445 #if defined(R__TEMPLATE_OVERLOAD_BUG) 454 return left.append(right.
Data());
464 extern char *
Form(
const char *fmt, ...)
465 #if defined(__GNUC__) && !defined(__CINT__) 466 __attribute__((
format(printf, 1, 2)))
469 extern void Printf(
const char *fmt, ...)
470 #if defined(__GNUC__) && !defined(__CINT__) 471 __attribute__((
format(printf, 1, 2)))
474 extern char *
Strip(
const char *str,
char c =
' ');
475 extern char *
StrDup(
const char *str);
476 extern char *
Compress(
const char *str);
477 extern int EscChar(
const char *src,
char *dst,
int dstlen,
char *specchars,
479 extern int UnEscChar(
const char *src,
char *dst,
int dstlen,
char *specchars,
482 #ifdef NEED_STRCASECMP 483 extern int strcasecmp(
const char *str1,
const char *str2);
484 extern int strncasecmp(
const char *str1,
const char *str2,
Ssiz_t n);
494 {
return Replace(Length(), 0, cs, cs ? strlen(cs) : 0); }
497 {
return Replace(Length(), 0, cs, n); }
500 {
return Replace(Length(), 0, s.
Data(), s.
Length()); }
506 {
return Append(cs, cs ? strlen(cs) : 0); }
512 {
return Append(c); }
515 {
char s[32]; sprintf(s,
"%ld", i);
return operator+=(s); }
518 {
char s[32]; sprintf(s,
"%lu", i);
return operator+=(s); }
536 sprintf(s,
"%.17g", f);
547 sprintf(s,
"%lld", l);
555 sprintf(s,
"%llu", ul);
578 {
return (CompareTo(cs, cmp) == 0) ?
kTRUE :
kFALSE; }
581 {
return (CompareTo(st, cmp) == 0) ?
kTRUE :
kFALSE; }
584 {
return Index(s, s ? strlen(s) : 0, i, cmp); }
591 {
return Index(pat.
Data(), patlen, i, cmp); }
594 {
return Replace(pos, 0, cs, cs ? strlen(cs) : 0); }
597 {
return Replace(pos, 0, cs, n); }
600 {
return Replace(pos, 0, s.
Data(), s.
Length()); }
606 {
return Replace(0, 0, cs, cs ? strlen(cs) : 0); }
609 {
return Replace(0, 0, cs, n); }
612 {
return Replace(0, 0, s.
Data(), s.
Length()); }
618 {
return Replace(pos,
TMath::Max(0, Length()-pos), 0, 0); }
621 {
return Replace(pos, n, 0, 0); }
627 {
return Replace(pos, n, cs, cs ? strlen(cs) : 0); }
630 {
return Replace(pos, n, s.
Data(), s.
Length()); }
640 {
return ReplaceAll(s1.
Data(), s1.
Length(), s2, s2 ? strlen(s2) : 0); }
643 {
return ReplaceAll(s1, s1 ? strlen(s1) : 0, s2.
Data(), s2.
Length()); }
646 {
return ReplaceAll(s1, s1 ? strlen(s1) : 0, s2, s2 ? strlen(s2) : 0); }
659 {
return GetPointer()[i]; }
662 {
return GetPointer()[i]; }
665 { AssertElement(i);
return GetPointer()[i]; }
668 { AssertElement(i);
return GetPointer()[i]; }
686 return fStr.Data() + fBegin;
691 { AssertElement(i);
return fStr.GetPointer()[fBegin+i]; }
694 {
return fStr.GetPointer()[fBegin+i]; }
708 {
return !(s1 == s2); }
724 {
return !(s1 == s2); }
739 {
return (s2 == s1); }
742 {
return !(s2 == s1); }
761 {
return (s2 == s1); }
764 {
return (s2 == s1); }
767 {
return !(s1 == s2); }
770 {
return !(s1 == s2); }
773 {
return !(s1 == s2); }
776 {
return !(s2 == s1); }
779 {
return !(s2 == s1); }
788 std::string
printValue(
const std::string_view* val);
A zero length substring is legal.
TSubString & operator=(const char *s)
Assign char* to sub-string.
The concrete implementation of TBuffer for writing/reading to/from a ROOT file or socket...
UInt_t Hash(const TString &s)
char * Compress(const char *str)
Remove all blanks from the string str.
std::ostream & operator<<(std::ostream &str, const TString &s)
Write string to stream.
ATTENTION: this class is obsolete.
T ReadBuffer(TBufferFile *buf)
One of the template functions used to read objects from messages.
TString & ReplaceAll(const TString &s1, const TString &s2)
char & operator[](Ssiz_t i)
int UnEscChar(const char *src, char *dst, int dstlen, char *specchars, char escchar)
Un-escape specchars in src from escchar and copy to dst.
Buffer base class used for serializing objects.
Regular expression class.
This class implements a mutex interface.
Short_t Min(Short_t a, Short_t b)
TString & operator+=(const char *s)
std::istream & operator>>(std::istream &str, TString &s)
Read string from stream.
std::string printValue(const std::string_view *val)
Print a TString in the cling interpreter:
TString & Prepend(const char *cs)
static std::string format(double x, double y, int digits, int width)
TSubString(const TSubString &s)
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
TString & Insert(Ssiz_t pos, const char *s)
Bool_t operator>=(const TString &s1, const TString &s2)
TString & Replace(Ssiz_t pos, Ssiz_t n, const char *s)
const char * Data() const
const char * GetShortPointer() const
#define ClassDef(name, id)
Ssiz_t GetShortSize() const
TString & Append(const char *cs)
std::vector< std::vector< double > > Data
static Ssiz_t Recommend(Ssiz_t s)
TString operator+(const TString &s1, const TString &s2)
Use the special concatenation constructor.
void AssertElement(Ssiz_t nc) const
Check to make sure a string index is in range.
Bool_t operator!=(const TString &s1, const TString &s2)
char & operator()(Ssiz_t i)
Bool_t operator<=(const TString &s1, const TString &s2)
char & operator[](Ssiz_t i)
Return character at pos i from sub-string. Check validity of i.
Ssiz_t GetLongSize() const
Bool_t EqualTo(const char *cs, ECaseCompare cmp=kExact) const
char & operator()(Ssiz_t i)
Return character at pos i from sub-string. No check on i.
char * Strip(const char *str, char c= ' ')
Strip leading and trailing c (blanks by default) from a string.
char * Form(const char *fmt,...)
void SetLongCap(Ssiz_t s)
Bool_t IsWhitespace() const
The ROOT global object gROOT contains a list of all defined classes.
void SetLongPointer(char *p)
TString ToLower(const TString &s)
Return a lower-case version of str.
char * StrDup(const char *str)
Duplicate the string str.
TString & Remove(Ssiz_t pos)
RooCmdArg Index(RooCategory &icat)
TRObject operator()(const T1 &t1) const
void Copy(void *source, void *dest)
TString & Swap(TString &other)
void SetLongSize(Ssiz_t s)
void Printf(const char *fmt,...)
unsigned long long ULong64_t
Print a TSeq at the prompt:
void SetShortSize(Ssiz_t s)
Binding & operator=(OUT(*fun)(void))
int EscChar(const char *src, char *dst, int dstlen, char *specchars, char escchar)
Escape specchars in src with escchar and copy to dst.
Bool_t operator>(const TString &s1, const TString &s2)
Bool_t operator==(const TString &s1, const TString &s2)
const char * GetPointer() const
static Ssiz_t Align(Ssiz_t s)
Short_t Max(Short_t a, Short_t b)
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b
TString ToUpper(const TString &s)
Return an upper-case version of str.
const char * Data() const
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
Bool_t operator<(const TString &s1, const TString &s2)
Ssiz_t GetLongCap() const
int CompareTo(const char *cs, ECaseCompare cmp=kExact) const
Compare a string to char *cs2.
const char * GetLongPointer() const
static char * Format(const char *format, va_list ap)
Format a string in a circular formatting buffer (using a printf style format descriptor).
std::string & operator+=(std::string &left, const TString &right)
UInt_t Hash(ECaseCompare cmp=kExact) const
Return hash value.