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 #if __cplusplus >= 201700L 283 explicit operator std::string()
const {
return std::string(GetPointer(),Length()); }
284 explicit operator ROOT::Internal::TStringView()
const {
return ROOT::Internal::TStringView(GetPointer(),Length()); }
285 operator std::string_view()
const {
return std::string_view(GetPointer(),Length()); }
287 operator ROOT::Internal::TStringView()
const {
return ROOT::Internal::TStringView(GetPointer(),Length()); }
312 char &operator[](
Ssiz_t i);
314 char operator[](
Ssiz_t i)
const;
325 TString &Append(
const char *cs);
339 int CompareTo(
const char *cs,
ECaseCompare cmp = kExact)
const;
347 const char *
Data()
const {
return GetPointer(); }
351 Ssiz_t First(
char c)
const;
352 Ssiz_t First(
const char *cs)
const;
353 void Form(
const char *fmt, ...)
354 #if defined(__GNUC__) && !defined(__CINT__) 355 __attribute__((
format(printf, 2, 3)))
387 Ssiz_t Last(
char c)
const;
388 Ssiz_t Length()
const {
return IsLong() ? GetLongSize() : GetShortSize(); }
389 Bool_t MaybeRegexp()
const;
390 Bool_t MaybeWildcard()
const;
392 TString &Prepend(
const char *cs);
397 std::istream &ReadFile(std::istream &str);
398 std::istream &ReadLine(std::istream &str,
400 std::istream &ReadString(std::istream &str);
401 std::istream &ReadToDelim(std::istream &str,
char delim =
'\n');
402 std::istream &ReadToken(std::istream &str);
413 TString &ReplaceAll(
const char *s1,
const char *s2);
422 std::string_view
View()
const {
return std::string_view(GetPointer(),Length()); }
429 static Ssiz_t GetInitialCapacity();
430 static Ssiz_t GetResizeIncrement();
431 static Ssiz_t GetMaxWaste();
438 #if defined(__GNUC__) && !defined(__CINT__) 439 __attribute__((
format(printf, 1, 2)))
449 #if defined(R__TEMPLATE_OVERLOAD_BUG) 458 return left.append(right.
Data());
468 extern char *
Form(
const char *fmt, ...)
469 #if defined(__GNUC__) && !defined(__CINT__) 470 __attribute__((
format(printf, 1, 2)))
473 extern void Printf(
const char *fmt, ...)
474 #if defined(__GNUC__) && !defined(__CINT__) 475 __attribute__((
format(printf, 1, 2)))
478 extern char *
Strip(
const char *str,
char c =
' ');
479 extern char *
StrDup(
const char *str);
480 extern char *
Compress(
const char *str);
481 extern int EscChar(
const char *src,
char *dst,
int dstlen,
char *specchars,
483 extern int UnEscChar(
const char *src,
char *dst,
int dstlen,
char *specchars,
486 #ifdef NEED_STRCASECMP 487 extern int strcasecmp(
const char *str1,
const char *str2);
488 extern int strncasecmp(
const char *str1,
const char *str2,
Ssiz_t n);
498 {
return Replace(Length(), 0, cs, cs ? strlen(cs) : 0); }
501 {
return Replace(Length(), 0, cs, n); }
504 {
return Replace(Length(), 0, s.
Data(), s.
Length()); }
510 {
return Append(cs, cs ? strlen(cs) : 0); }
516 {
return Append(c); }
519 {
char s[32]; sprintf(s,
"%ld", i);
return operator+=(s); }
522 {
char s[32]; sprintf(s,
"%lu", i);
return operator+=(s); }
540 sprintf(s,
"%.17g", f);
551 sprintf(s,
"%lld", l);
559 sprintf(s,
"%llu", ul);
582 {
return (CompareTo(cs, cmp) == 0) ?
kTRUE :
kFALSE; }
585 {
return (CompareTo(st, cmp) == 0) ?
kTRUE :
kFALSE; }
588 {
return Index(s, s ? strlen(s) : 0, i, cmp); }
595 {
return Index(pat.
Data(), patlen, i, cmp); }
598 {
return Replace(pos, 0, cs, cs ? strlen(cs) : 0); }
601 {
return Replace(pos, 0, cs, n); }
604 {
return Replace(pos, 0, s.
Data(), s.
Length()); }
610 {
return Replace(0, 0, cs, cs ? strlen(cs) : 0); }
613 {
return Replace(0, 0, cs, n); }
616 {
return Replace(0, 0, s.
Data(), s.
Length()); }
622 {
return Replace(pos,
TMath::Max(0, Length()-pos), 0, 0); }
625 {
return Replace(pos, n, 0, 0); }
631 {
return Replace(pos, n, cs, cs ? strlen(cs) : 0); }
634 {
return Replace(pos, n, s.
Data(), s.
Length()); }
644 {
return ReplaceAll(s1.
Data(), s1.
Length(), s2, s2 ? strlen(s2) : 0); }
647 {
return ReplaceAll(s1, s1 ? strlen(s1) : 0, s2.
Data(), s2.
Length()); }
650 {
return ReplaceAll(s1, s1 ? strlen(s1) : 0, s2, s2 ? strlen(s2) : 0); }
663 {
return GetPointer()[i]; }
666 {
return GetPointer()[i]; }
669 { AssertElement(i);
return GetPointer()[i]; }
672 { AssertElement(i);
return GetPointer()[i]; }
690 return fStr.Data() + fBegin;
695 { AssertElement(i);
return fStr.GetPointer()[fBegin+i]; }
698 {
return fStr.GetPointer()[fBegin+i]; }
712 {
return !(s1 == s2); }
728 {
return !(s1 == s2); }
743 {
return (s2 == s1); }
746 {
return !(s2 == s1); }
765 {
return (s2 == s1); }
768 {
return (s2 == s1); }
771 {
return !(s1 == s2); }
774 {
return !(s1 == s2); }
777 {
return !(s1 == s2); }
780 {
return !(s2 == s1); }
783 {
return !(s2 == s1); }
792 std::string
printValue(
const std::string_view* val);
A zero length substring is legal.
TSubString & operator=(const char *s)
Assign char* to sub-string.
const char * GetShortPointer() const
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.
Bool_t EqualTo(const char *cs, ECaseCompare cmp=kExact) const
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.
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
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)
const char * Data() const
TSubString(const TSubString &s)
TString & Insert(Ssiz_t pos, const char *s)
TRObject operator()(const T1 &t1) const
UInt_t Hash(ECaseCompare cmp=kExact) const
Return hash value.
Bool_t operator>=(const TString &s1, const TString &s2)
TString & Replace(Ssiz_t pos, Ssiz_t n, const char *s)
#define ClassDef(name, id)
Ssiz_t GetLongCap() const
TString & Append(const char *cs)
std::vector< std::vector< double > > Data
static Ssiz_t Recommend(Ssiz_t s)
void AssertElement(Ssiz_t nc) const
Check to make sure a string index is in range.
TString operator+(const TString &s1, const TString &s2)
Use the special concatenation constructor.
std::string_view View() const
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 GetShortSize() const
char & operator()(Ssiz_t i)
Return character at pos i from sub-string. No check on i.
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
char * Form(const char *fmt,...)
void SetLongCap(Ssiz_t s)
The ROOT global object gROOT contains a list of all defined classes.
char * Strip(const char *str, char c=' ')
Strip leading and trailing c (blanks by default) from a string.
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.
const char * GetPointer() const
TString & Remove(Ssiz_t pos)
RooCmdArg Index(RooCategory &icat)
void Copy(void *source, void *dest)
TString & Swap(TString &other)
void SetLongSize(Ssiz_t s)
void Printf(const char *fmt,...)
Ssiz_t GetLongSize() const
unsigned long long ULong64_t
Print a TSeq at the prompt:
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
void SetShortSize(Ssiz_t s)
int CompareTo(const char *cs, ECaseCompare cmp=kExact) const
Compare a string to char *cs2.
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)
static Ssiz_t Align(Ssiz_t s)
Short_t Max(Short_t a, Short_t b)
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 * GetLongPointer() const
Bool_t IsWhitespace() const
Bool_t operator<(const TString &s1, const TString &s2)
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)
const char * Data() const