59 #define strtoull _strtoui64 63 namespace std { using ::list; }
121 memcpy(data, s.c_str(),
n);
156 while (n--) data[
n] = c;
179 fRep.fRaw =
s.fRep.fRaw;
188 Ssiz_t len = substr.length();
190 memcpy(data, substr.data(), len);
200 memcpy(data, substr.
Data(), len);
212 memcpy(data, a1, n1);
213 memcpy(data+n1, a2, n2);
230 if (capacity > MaxSize()) {
231 Error(
"TString::Init",
"capacity too large (%d, max = %d)", capacity, MaxSize());
232 capacity = MaxSize();
233 if (nchar > capacity)
238 if (capacity < kMinCap) {
240 data = GetShortPointer();
242 Ssiz_t cap = Recommend(capacity);
243 data =
new char[cap+1];
246 SetLongPointer(data);
263 return Replace(0, Length(), &c, 1);
276 return Replace(0, Length(), cs, strlen(cs));
289 return Replace(0, Length(), s.c_str(), s.length());
302 return Replace(0, Length(), s.data(), s.length());
334 return Replace(0, Length(), substr.
Data(), len);
342 if (!rep)
return *
this;
347 if (tot > MaxSize()) {
348 Error(
"TString::Append",
"rep too large (%d, max = %d)", rep, MaxSize()-len);
353 Ssiz_t capac = Capacity();
354 char *
data, *p = GetPointer();
356 if (capac - tot >= 0) {
360 Ssiz_t cap = AdjustCapacity(capac, tot);
361 data =
new char[cap+1];
362 memcpy(data, p, len);
366 SetLongPointer(data);
400 const char *cs1 = Data();
404 for (; cs2[i]; ++i) {
405 if (i == len)
return -1;
406 if (cs1[i] != cs2[i])
return ((cs1[i] > cs2[i]) ? 1 : -1);
409 for (; cs2[i]; ++i) {
410 if (i == len)
return -1;
411 char c1 = tolower((
unsigned char)cs1[i]);
412 char c2 = tolower((
unsigned char)cs2[i]);
413 if (c1 != c2)
return ((c1 > c2) ? 1 : -1);
416 return (i < len) ? 1 : 0;
428 const char *s1 = Data();
429 const char *s2 = str.
Data();
433 if (len < slen) slen = len;
435 int result = memcmp(s1, s2, slen);
436 if (result != 0)
return result;
439 for (; i < slen; ++i) {
440 char c1 = tolower((
unsigned char)s1[i]);
441 char c2 = tolower((
unsigned char)s2[i]);
442 if (c1 != c2)
return ((c1 > c2) ? 1 : -1);
447 if (len == slen)
return 0;
448 return (len > slen) ? 1 : -1;
457 Int_t len = Length();
458 const char *
data = Data();
460 if (data[
n] == c) count++;
479 const char *f = strchr(Data(), c);
480 return f ? f - Data() :
kNPOS;
488 const char *f = strpbrk(Data(), cs);
489 return f ? f - Data() :
kNPOS;
497 return (((x & 0x000000ffU) << 24) | ((x & 0x0000ff00U) << 8) |
498 ((x & 0x00ff0000U) >> 8) | ((x & 0xff000000U) >> 24));
517 UInt_t len = str ? strlen(str) : 0;
535 if ((i = len*
sizeof(
char)%
sizeof(
UInt_t)) != 0) {
537 const char* c = (
const char*)p;
545 const unsigned char *p = (
const unsigned char*)str;
548 memcpy(&h, p,
sizeof(
UInt_t));
558 if ((i = len*
sizeof(
char)%
sizeof(
UInt_t)) != 0) {
560 const char* c = (
const char*)p;
588 if ((i = Length()*
sizeof(
char)%
sizeof(
UInt_t)) != 0) {
590 const char* c = (
const char*)p;
605 const unsigned char *p = (
const unsigned char*)Data();
607 Mash(hv, toupper(*p));
618 return (cmp == kExact) ? HashCase() : HashFoldCase();
641 #if defined(_MSC_VER) && (_MSC_VER < 1800) 643 typedef unsigned char uint8_t;
644 typedef unsigned long uint32_t;
645 typedef unsigned __int64 uint64_t;
646 #else // defined(_MSC_VER) 649 #endif // !defined(_MSC_VER) 652 #if defined(_MSC_VER) 654 #define FORCE_INLINE __forceinline 656 #define ROTL64(x,y) _rotl64(x,y) 657 #define BIG_CONSTANT(x) (x) 658 #else // defined(_MSC_VER) 662 return (x << r) | (x >> (64 -
r));
665 #if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) <= 40101 667 #define FORCE_INLINE inline 671 #define FORCE_INLINE __attribute__((always_inline)) inline 673 #define ROTL64(x,y) rotl64(x,y) 674 #define BIG_CONSTANT(x) (x##LLU) 675 #endif // !defined(_MSC_VER) 683 FORCE_INLINE uint64_t getblock(
const uint64_t* p,
int i)
708 static void MurmurHash3_x64_128(
const void * key,
const int len,
709 const uint32_t seed, uint64_t out[2] )
711 const uint8_t *
data = (
const uint8_t*)key;
712 const int nblocks = len / 16;
723 const uint64_t * blocks = (
const uint64_t *)(data);
725 for(
int i = 0; i < nblocks; i++)
727 uint64_t k1 = getblock(blocks,i*2+0);
728 uint64_t k2 = getblock(blocks,i*2+1);
730 k1 *=
c1; k1 =
ROTL64(k1,31); k1 *=
c2; h1 ^= k1;
732 h1 =
ROTL64(h1,27); h1 += h2; h1 = h1*5+0x52dce729;
734 k2 *=
c2; k2 =
ROTL64(k2,33); k2 *=
c1; h2 ^= k2;
736 h2 =
ROTL64(h2,31); h2 +=
h1; h2 = h2*5+0x38495ab5;
742 const uint8_t * tail = (
const uint8_t*)(data + nblocks*16);
748 case 15: k2 ^= uint64_t(tail[14]) << 48;
749 case 14: k2 ^= uint64_t(tail[13]) << 40;
750 case 13: k2 ^= uint64_t(tail[12]) << 32;
751 case 12: k2 ^= uint64_t(tail[11]) << 24;
752 case 11: k2 ^= uint64_t(tail[10]) << 16;
753 case 10: k2 ^= uint64_t(tail[ 9]) << 8;
754 case 9: k2 ^= uint64_t(tail[ 8]) << 0;
755 k2 *=
c2; k2 =
ROTL64(k2,33); k2 *=
c1; h2 ^= k2;
757 case 8: k1 ^= uint64_t(tail[ 7]) << 56;
758 case 7: k1 ^= uint64_t(tail[ 6]) << 48;
759 case 6: k1 ^= uint64_t(tail[ 5]) << 40;
760 case 5: k1 ^= uint64_t(tail[ 4]) << 32;
761 case 4: k1 ^= uint64_t(tail[ 3]) << 24;
762 case 3: k1 ^= uint64_t(tail[ 2]) << 16;
763 case 2: k1 ^= uint64_t(tail[ 1]) << 8;
764 case 1: k1 ^= uint64_t(tail[ 0]) << 0;
765 k1 *=
c1; k1 =
ROTL64(k1,31); k1 *=
c2; h1 ^= k1;
771 h1 ^= len; h2 ^= len;
782 ((uint64_t*)out)[0] =
h1;
783 ((uint64_t*)out)[1] = h2;
800 if (ntxt !=
sizeof(
void*)) {
801 uint64_t buf[2] = {0};
802 MurmurHash3_x64_128(txt, ntxt, 0x6384BA69, buf);
808 if (((
size_t)txt) %
sizeof(
void*)) {
811 if (
sizeof(
void*) >
sizeof(
UInt_t)) {
815 const unsigned char* ctxt = (
const unsigned char*) txt;
816 for (
unsigned int i = 0; i < 4; ++i) {
817 ret ^= ctxt[i] << (i * 8);
819 if (
sizeof(
void*) >
sizeof(
UInt_t)) {
821 for (
unsigned int i = 0; i < 4; ++i) {
822 ret ^= ctxt[i] << (i * 8);
837 if (tolower((
unsigned char)*p) != tolower((
unsigned char)*q))
853 if (slen < startIndex + plen)
return kNPOS;
854 if (plen == 0)
return startIndex;
855 slen -= startIndex + plen;
856 const char *sp = Data() + startIndex;
858 char first = *pattern;
859 for (
Ssiz_t i = 0; i <= slen; ++i)
860 if (sp[i] == first && memcmp(sp+i+1, pattern+1, plen-1) == 0)
861 return i + startIndex;
863 int first = tolower((
unsigned char) *pattern);
864 for (
Ssiz_t i = 0; i <= slen; ++i)
865 if (tolower((
unsigned char) sp[i]) == first &&
867 return i + startIndex;
877 const char *f = strrchr(Data(), (
unsigned char) c);
878 return f ? f - Data() :
kNPOS;
898 const char *specials =
"^$.[]*+?";
900 if (First(specials) ==
kNPOS)
910 const char *specials =
"[]*?";
912 if (First(specials) ==
kNPOS)
922 if (!rep)
return *
this;
927 if (tot > MaxSize()) {
928 Error(
"TString::Prepend",
"rep too large (%d, max = %d)", rep, MaxSize()-len);
933 Ssiz_t capac = Capacity();
934 char *
data, *p = GetPointer();
936 if (capac - tot >= 0) {
937 memmove(p + rep, p, len);
941 Ssiz_t cap = AdjustCapacity(capac, tot);
942 data =
new char[cap+1];
943 memcpy(data+rep, p, len);
947 SetLongPointer(data);
964 if (pos <= kNPOS || pos > len) {
965 Error(
"TString::Replace",
966 "first argument out of bounds: pos = %d, Length = %d", pos, len);
973 Ssiz_t tot = len - n1 + n2;
974 Ssiz_t rem = len - n1 - pos;
976 Ssiz_t capac = Capacity();
977 char *p = GetPointer();
979 if (capac - len + n1 >= n2) {
983 if (n2) memmove(p + pos, cs, n2);
984 memmove(p + pos + n2, p + pos + n1, rem);
987 if (p + pos < cs && cs < p + len) {
988 if (p + pos + n1 <= cs)
991 memmove(p + pos, cs, n1);
998 memmove(p + pos + n2, p + pos + n1, rem);
1001 if (n2) memmove(p + pos, cs, n2);
1006 Ssiz_t cap = AdjustCapacity(capac, tot);
1007 char *
data =
new char[cap+1];
1008 if (pos) memcpy(data, p, pos);
1009 if (n2 ) memcpy(data + pos, cs, n2);
1010 if (rem) memcpy(data + pos + n2, p + pos + n1, rem);
1014 SetLongPointer(data);
1027 if (s1 && ls1 > 0) {
1029 while ((index =
Index(s1, ls1, index, kExact)) !=
kNPOS) {
1030 Replace(index, ls1, s2, ls2);
1045 const char *direct = Data();
1049 while (start < end && direct[start] == c)
1052 while (start < end && direct[end-1] == c)
1062 Remove(send - start - (send - end), send - end);
1074 Append(
' ', n-Length());
1084 const char *direct = Data();
1087 while (start < end && direct[start] == c)
1090 while (start < end && direct[end-1] == c)
1092 if (end == start) start = end =
kNPOS;
1102 char *p = GetPointer();
1104 *p = tolower((
unsigned char)*p);
1115 char *p = GetPointer();
1117 *p = toupper((
unsigned char)*p);
1127 if (i ==
kNPOS || i > Length())
1128 Error(
"TString::AssertElement",
1129 "out of bounds: i = %d, Length = %d", i, Length());
1138 if (newCap > ms - 1) {
1139 Error(
"TString::AdjustCapacity",
"capacity too large (%d, max = %d)",
1142 Ssiz_t cap = oldCap < ms / 2 - kAlignment ?
1143 Recommend(
TMath::Max(newCap, 2 * oldCap)) : ms - 1;
1152 Clobber(Capacity());
1160 if (nc > MaxSize()) {
1161 Error(
"TString::Clobber",
"capacity too large (%d, max = %d)", nc, MaxSize());
1169 char *
data = GetLongPointer();
1170 Ssiz_t cap = Recommend(nc);
1171 if (cap != Capacity()) {
1172 data =
new char[cap+1];
1175 SetLongPointer(data);
1189 if (len >= tot)
return;
1191 if (tot > MaxSize()) {
1192 Error(
"TString::Clone",
"tot too large (%d, max = %d)", tot, MaxSize());
1196 Ssiz_t capac = Capacity();
1197 char *
data, *p = GetPointer();
1199 if (capac - tot < 0) {
1200 Ssiz_t cap = Recommend(tot);
1201 data =
new char[cap+1];
1202 memcpy(data, p, len);
1206 SetLongPointer(data);
1220 Int_t nchars = Length();
1225 tobuf(buffer, nchars);
1230 const char *
data = GetPointer();
1231 for (
int i = 0; i < nchars; i++) buffer[i] = data[i];
1253 Error(
"TString::ReadBuffer",
"found case with nwh=%d and nchars=%d", nwh, nchars);
1259 for (
int i = 0; i < nchars; i++)
frombuf(buffer, &data[i]);
1291 ::Error(
"TString::ReadObject",
"could not create object of class %s",
1313 return Length()+
sizeof(
UChar_t);
1365 #if defined(R__TEMPLATE_OVERLOAD_BUG) 1396 for (i = 0; s2[i]; ++i)
1397 if (data[i] != s2[i] || i == len)
return kFALSE;
1408 const char *uc = str.
Data();
1409 char *lc = (
char*)temp.
Data();
1411 while (n--) { *lc++ = tolower((
unsigned char)*uc); uc++; }
1422 const char* uc = str.
Data();
1423 char* lc = (
char*)temp.
Data();
1425 while (n--) { *lc++ = toupper((
unsigned char)*uc); uc++; }
1467 snprintf(si,
sizeof(si),
"%ld", i);
1477 snprintf(si,
sizeof(si),
"%lu", i);
1487 snprintf(si,
sizeof(si),
"%lld", i);
1497 snprintf(si,
sizeof(si),
"%llu", i);
1515 snprintf(si,
sizeof(si),
"%ld", i);
1525 snprintf(si,
sizeof(si),
"%lu", i);
1535 snprintf(si,
sizeof(si),
"%lld", i);
1545 snprintf(si,
sizeof(si),
"%llu", i);
1557 ::Obsolete(
"TString::GetInitialCapacity",
"v5-30-00",
"v5-32-00");
1565 ::Obsolete(
"TString::GetResizeIncrement",
"v5-30-00",
"v5-32-00");
1573 ::Obsolete(
"TString::GetMaxWaste",
"v5-30-00",
"v5-32-00");
1582 ::Obsolete(
"TString::InitialCapacity",
"v5-30-00",
"v5-32-00");
1591 ::Obsolete(
"TString::ResizeIncrement",
"v5-30-00",
"v5-32-00");
1601 ::Obsolete(
"TString::MaxWaste",
"v5-30-00",
"v5-32-00");
1619 : fStr((
TString&)str), fBegin(start), fExtent(nextent)
1628 if (start <
Length() && len > 0) {
1629 if (start+len >
Length())
1647 Ssiz_t len = pattern ? strlen(pattern) : 0;
1696 if (ss.
IsNull())
return *cs ==
'\0';
1700 for (i = 0; cs[i]; ++i)
1734 while (n--) { *p = tolower((
unsigned char)*p); p++;}
1746 while (n--) { *p = toupper((
unsigned char)*p); p++;}
1755 Error(
"TSubString::SubStringError",
1756 "out of bounds: start = %d, n = %d, sr = %d", start, n, sr);
1765 Error(
"TSubString::AssertElement",
1766 "out of bounds: i = %d, Length = %d", i,
Length());
1774 const char *cp =
Data();
1787 const char *cp =
Data();
1789 if (len == 0)
return kFALSE;
1790 for (
Ssiz_t i = 0; i < len; ++i)
1791 if (!isalpha(cp[i]))
1802 const char *cp =
Data();
1804 if (len == 0)
return kFALSE;
1805 for (
Ssiz_t i = 0; i < len; ++i)
1806 if (!isalnum(cp[i]))
1819 const char *cp =
Data();
1821 if (len == 0)
return kFALSE;
1823 for (
Ssiz_t i = 0; i < len; ++i) {
1824 if (cp[i] !=
' ' && !isdigit(cp[i]))
return kFALSE;
1825 if (cp[i] ==
' ') b++;
1826 if (isdigit(cp[i])) d++;
1848 if (IsDigit())
return kTRUE;
1857 pos = tmp.
First(
',');
1859 pos = tmp.
Index(
"e-");
1860 if (pos >= 1) tmp.
Replace(pos, 2,
" ", 1);
1861 pos = tmp.
Index(
"e+");
1862 if (pos >= 1) tmp.
Replace(pos, 2,
" ", 1);
1863 pos = tmp.
Index(
"e");
1864 if (pos >= 1) tmp.
Replace(pos, 1,
" ", 1);
1865 pos = tmp.
First(
'-');
1866 if (pos == 0) tmp.
Replace(pos, 1,
" ", 1);
1867 pos = tmp.
First(
'+');
1868 if (pos == 0) tmp.
Replace(pos, 1,
" ", 1);
1881 const char *cp =
Data();
1883 if (len == 0)
return kFALSE;
1884 for (
Ssiz_t i = 0; i < len; ++i)
1885 if (!isxdigit(cp[i]))
1897 const char *cp =
Data();
1899 if (len == 0)
return kFALSE;
1900 for (
Ssiz_t i = 0; i < len; ++i)
1901 if (cp[i] !=
'0' && cp[i] !=
'1')
1913 const char *cp =
Data();
1915 if (len == 0)
return kFALSE;
1916 for (
Ssiz_t i = 0; i < len; ++i)
1917 if (!isdigit(cp[i]) || cp[i]==
'8' || cp[i]==
'9')
1929 const char *cp =
Data();
1931 if (len == 0)
return kFALSE;
1932 for (
Ssiz_t i = 0; i < len; ++i)
1933 if (!isdigit(cp[i]))
1946 if (base < 2 || base > 36) {
1947 Error(
"TString::IsInBaseN",
"base %d is not supported. Supported bases are {2,3,...,36}.", base);
1951 Error(
"TString::IsInBaseN",
"input string is empty.") ;
1956 TString str_ref0 =
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" ;
1980 if (end == -1)
return atoi(
Data());
1986 tmp += (*this)(start, end-start);
1987 start = end+1; end =
Index(
" ", start);
1991 tmp += (*this)(start, end-start);
1992 return atoi(tmp.
Data());
2007 if (end == -1)
return atoll(
Data());
2009 if (end == -1)
return _atoi64(
Data());
2016 tmp += (*this)(start, end-start);
2017 start = end+1; end =
Index(
" ", start);
2021 tmp += (*this)(start, end-start);
2023 return atoll(tmp.
Data());
2025 return _atoi64(tmp.
Data());
2047 if (comma == -1 && end == -1)
return atof(
Data());
2054 if (end == -1)
return atof(tmp.
Data());
2059 tmp2 += tmp(start, end-start);
2060 start = end+1; end = tmp.
Index(
" ", start);
2063 tmp2 += tmp(start, end-start);
2064 return atof(tmp2.
Data());
2083 if (base < 2 || base > 36) {
2084 Error(
"TString::Itoa",
"base %d is not supported. Supported bases are {2,3,...,36}.",base) ;
2088 Int_t quotient = value;
2091 buf +=
"0123456789abcdefghijklmnopqrstuvwxyz"[
TMath::Abs(quotient % base) ];
2095 if (value < 0) buf +=
'-';
2096 std::reverse(buf.begin(), buf.end());
2110 if (base < 2 || base > 36) {
2111 Error(
"TString::UItoa",
"base %d is not supported. Supported bases are {2,3,...,36}.",base);
2118 buf +=
"0123456789abcdefghijklmnopqrstuvwxyz"[ quotient % base ];
2121 std::reverse(buf.begin(), buf.end());
2135 if (base < 2 || base > 36) {
2136 Error(
"TString::LLtoa",
"base %d is not supported. Supported bases are {2,3,...,36}.",base);
2143 buf +=
"0123456789abcdefghijklmnopqrstuvwxyz"[
TMath::Abs(quotient % base) ];
2147 if (value < 0) buf +=
'-';
2148 std::reverse(buf.begin(), buf.end());
2162 if (base < 2 || base > 36) {
2163 Error(
"TString::ULLtoa",
"base %d is not supported. Supported bases are {2,3,...,36}.",base);
2170 buf +=
"0123456789abcdefghijklmnopqrstuvwxyz"[ quotient % base ];
2173 std::reverse(buf.begin(), buf.end());
2185 if (base_in < 2 || base_in > 36 || base_out < 2 || base_out > 36) {
2186 Error(
"TString::BaseConvert",
"only bases 2-36 are supported (base_in=%d, base_out=%d).", base_in, base_out);
2192 if (s_in_[0] ==
'-') {
2196 if (!isSigned && s_in_[0] ==
'+') s_in_.
Remove(0, 1);
2199 if (!s_in_.
Length()) s_in_ +=
'0';
2202 Error(
"TString::BaseConvert",
"s_in=\"%s\" is not in base %d", s_in.
Data(), base_in);
2209 Error(
"TString::BaseConvert",
"s_in=\"%s\" > %s = 2^64-1 in base %d.", s_in.
Data(), s_max.
Data(), base_in);
2214 if (s_in_ > s_max) {
2216 Error(
"TString::BaseConvert",
"s_in=\"%s\" > %s = 2^64-1 in base %d.", s_in.
Data(), s_max.
Data(), base_in);
2224 if (isSigned) s_out.
Prepend(
"-");
2233 if (!s)
return kTRUE;
2240 return strcmp(s, s2) == 0;
2241 return strcasecmp(s, s2) == 0;
2253 std::list<Int_t> splitIndex;
2255 Int_t i, start, nrDiff = 0;
2256 for (i = 0; i < delim.
Length(); i++) {
2258 while (start <
Length()) {
2260 if (pos ==
kNPOS)
break;
2261 splitIndex.push_back(pos);
2264 if (start > 0) nrDiff++;
2266 splitIndex.push_back(
Length());
2275 std::list<Int_t>::const_iterator it;
2277 for (it = splitIndex.begin(); it != splitIndex.end(); ++it) {
2279 for (it = splitIndex.begin(); it != (std::list<Int_t>::const_iterator) splitIndex.end(); ++it) {
2282 if (stop - 1 >= start + 1) {
2283 TString tok = (*this)(start+1, stop-start-1);
2299 Ssiz_t buflen = 20 + 20 * strlen(fmt);
2307 n = vsnprintf(GetPointer(), buflen, fmt, ap);
2310 if (n == -1 || n >= buflen) {
2325 SetSize(strlen(
Data()));
2346 va_start(ap,
va_(fmt));
2347 FormImp(
va_(fmt), ap);
2368 va_start(ap,
va_(fmt));
2381 static char *
SlowFormat(
const char *format, va_list ap,
int hint)
2383 static const int fld_size = 2048;
2384 TTHREAD_TLS(
char*) slowBuffer(0);
2385 TTHREAD_TLS(
int) slowBufferSize(0);
2387 if (hint == -1) hint = fld_size;
2388 if (hint > slowBufferSize) {
2389 delete [] slowBuffer;
2390 slowBufferSize = 2 * hint;
2391 if (hint < 0 || slowBufferSize < 0) {
2396 slowBuffer =
new char[slowBufferSize];
2402 int n = vsnprintf(slowBuffer, slowBufferSize, format, ap);
2405 if (n == -1 || n >= slowBufferSize) {
2406 if (n == -1) n = 2 * slowBufferSize;
2407 if (n == slowBufferSize) n++;
2429 static char *
Format(
const char *format, va_list ap)
2431 static const int cb_size = 4096;
2432 static const int fld_size = 2048;
2435 TTHREAD_TLS_ARRAY(
char,cb_size,gFormbuf);
2436 TTHREAD_TLS(
char*) gBfree(0);
2437 TTHREAD_TLS(
char*) gEndbuf(0);
2441 gEndbuf = &gFormbuf[cb_size-1];
2445 if (buf+fld_size > gEndbuf)
2451 int n = vsnprintf(buf, fld_size, format, ap);
2454 if (n == -1 || n >= fld_size) {
2479 va_start(ap,
va_(fmt));
2493 va_start(ap,
va_(fmt));
2513 char *buf =
new char[l+1];
2526 const char *t2 = s + l - 1;
2527 while (*t2 == c && t2 > s)
2534 strncpy(buf, t1, (
Ssiz_t) (t2-t1+1));
2535 *(buf+(t2-t1+1)) =
'\0';
2548 char *
s =
new char[strlen(str)+1];
2549 if (s) strcpy(s, str);
2562 const char *p = str;
2563 char *
s, *s1 =
new char[strlen(str)+1];
2579 int EscChar(
const char *src,
char *dst,
int dstlen,
char *specchars,
2583 char *
q, *end = dst+dstlen-1;
2585 for (p = src, q = dst; *p && q < end; ) {
2586 if (strchr(specchars, *p)) {
2603 int UnEscChar(
const char *src,
char *dst,
int dstlen,
char *specchars,
char)
2606 char *
q, *end = dst+dstlen-1;
2608 for (p = src, q = dst; *p && q < end; ) {
2609 if (strchr(specchars, *p))
2621 #ifdef NEED_STRCASECMP 2625 int strcasecmp(
const char *str1,
const char *str2)
2627 return strncasecmp(str1, str2, str2 ? strlen(str2)+1 : 0);
2633 int strncasecmp(
const char *str1,
const char *str2,
Ssiz_t n)
2676 std::string str(*val);
A zero length substring is legal.
static Ssiz_t GetMaxWaste()
virtual const char * GetName() const
Returns name of object.
void SetBufferOffset(Int_t offset=0)
void frombuf(char *&buf, Bool_t *x)
void ToLower()
Convert sub-string to lower-case.
TSubString & operator=(const char *s)
Assign char* to sub-string.
static TString Itoa(Int_t value, Int_t base)
Converts an Int_t to a TString with respect to the base specified (2-36).
TString operator+(const TString &s, const char *cs)
Use the special concatenation constructor.
static Ssiz_t MaxWaste(Ssiz_t mw=15)
Set maximum space that may be wasted in a string before doing a resize.
basic_string_view< char > string_view
char * Compress(const char *str)
Remove all blanks from the string str.
void Final()
MD5 finalization, ends an MD5 message-digest operation, writing the the message digest and zeroizing ...
void ToUpper()
Convert sub-string to upper-case.
Collectable string class.
char * Form(const char *va_(fmt),...)
Formats a string in a circular formatting buffer.
friend Bool_t operator==(const TSubString &s1, const TSubString &s2)
Compare two sub-strings.
TString & ReplaceAll(const TString &s1, const TString &s2)
char * StrDup(const char *str)
Duplicate the string str.
virtual void SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
Bool_t IsFloat() const
Returns kTRUE if string contains a floating point or integer number.
void Clone(Ssiz_t nc)
Make self a distinct copy with capacity of at least tot, where tot cannot be smaller than the current...
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...
void ToUpper()
Change string to upper case.
Buffer base class used for serializing objects.
virtual Int_t CheckByteCount(UInt_t startpos, UInt_t bcnt, const TClass *clss)=0
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
Bool_t operator==(const TString &s1, const char *s2)
Compare TString with a char *.
const char * AsString() const
Return message digest as string.
TString ToUpper(const TString &str)
Return an upper-case version of str.
Short_t Min(Short_t a, Short_t b)
void ToLower()
Change string to lower-case.
TString & operator=(char s)
Assign character c to TString.
virtual void WriteClass(const TClass *cl)=0
static Ssiz_t ResizeIncrement(Ssiz_t ri=16)
Set default resize increment for all TStrings. Default is 16.
TString Copy() const
Copy a string.
virtual void WriteTString(const TString &s)=0
TString ToLower(const TString &str)
Return a lower-case version of str.
TString & Prepend(const char *cs)
TBuffer & operator<<(TBuffer &buf, const TString *s)
Write TString or derived to TBuffer.
const char * Data() const
static void WriteString(TBuffer &b, const TString *a)
Write TString object to buffer.
void Obsolete(const char *function, const char *asOfVers, const char *removedFromVers)
Use this function to declare a function obsolete.
Bool_t MaybeWildcard() const
Returns true if string contains one of the wildcard characters "[]*?".
char * Init(Ssiz_t capacity, Ssiz_t nchar)
Private member function returning an empty string representation of size capacity and containing ncha...
UInt_t Hash(ECaseCompare cmp=kExact) const
Return hash value.
static int MemIsEqual(const char *p, const char *q, Ssiz_t n)
Returns false if strings are not equal.
TString & Replace(Ssiz_t pos, Ssiz_t n, const char *s)
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString...
virtual void ReadBuffer(char *&buffer)
Read string from I/O buffer.
This code implements the MD5 message-digest algorithm.
UInt_t HashFoldCase() const
Return a case-insensitive hash value (endian independent).
Bool_t IsAlnum() const
Returns true if all characters in string are alphanumeric.
void Init(TClassEdit::TInterpreterLookupHelper *helper)
static TString * ReadString(TBuffer &b, const TClass *clReq)
Read TString object from buffer.
void Clear()
Clear string without changing its capacity.
TString & Append(const char *cs)
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
Return true if string ends with the specified string.
static Ssiz_t GetInitialCapacity()
char * Strip(const char *s, char c)
Strip leading and trailing c (blanks by default) from a string.
void AssertElement(Ssiz_t nc) const
Check to make sure a string index is in range.
Ssiz_t First(char c) const
Find first occurrence of a character c.
void tobuf(char *&buf, Bool_t x)
Long64_t Atoll() const
Return long long value of string.
void Error(const char *location, const char *msgfmt,...)
Bool_t IsAlpha() const
Returns true if all characters in string are alphabetic.
char & operator()(Ssiz_t i)
static UInt_t SwapInt(UInt_t x)
Bool_t IsOct() const
Returns true if all characters in string are octal digits (0-7).
std::string printValue(const TDatime *val)
Print a TDatime at the prompt.
char & operator[](Ssiz_t i)
Return character at pos i from sub-string. Check validity of i.
R__EXTERN Bool_t gPrintViaErrorHandler
#define R__VA_COPY(to, from)
void Update(const UChar_t *buf, UInt_t len)
Update TMD5 object to reflect the concatenation of another buffer full of bytes.
char & operator()(Ssiz_t i)
Return character at pos i from sub-string. No check on i.
UInt_t HashCase() const
Return a case-sensitive hash value (endian independent).
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
TBuffer & operator>>(TBuffer &buf, TString *&s)
Read string from TBuffer. Function declared in ClassDef.
TString MD5() const
Return the MD5 digest for this string, in a string representation.
TSubString Strip(EStripType s=kTrailing, char c=' ') const
Return a substring of self stripped at beginning and/or end.
The ROOT global object gROOT contains a list of all defined classes.
virtual void SetByteCount(UInt_t cntpos, Bool_t packInVersion=kFALSE)=0
static Ssiz_t GetResizeIncrement()
int UnEscChar(const char *src, char *dst, int dstlen, char *specchars, char)
Un-escape specchars in src from escchar and copy to dst.
static constexpr double ms
static Ssiz_t InitialCapacity(Ssiz_t ic=15)
Set default initial capacity for all TStrings. Default is 15.
void FormImp(const char *fmt, va_list ap)
Formats a string using a printf style format descriptor.
void Clobber(Ssiz_t nc)
Clear string and make sure it has a capacity of nc.
TString & Remove(Ssiz_t pos)
RooCmdArg Index(RooCategory &icat)
Bool_t IsInBaseN(Int_t base) const
Returns true if all characters in string are expressed in the base specified (range=2-36), i.e.
Bool_t IsDec() const
Returns true if all characters in string are decimal digits (0-9).
TObjArray * Tokenize(const TString &delim) const
This function is used to isolate sequential tokens in a TString.
int EscChar(const char *src, char *dst, int dstlen, char *specchars, char escchar)
Escape specchars in src with escchar and copy to dst.
static char * SlowFormat(const char *format, va_list ap, int hint)
Format a string in a formatting buffer (using a printf style format descriptor).
Ssiz_t Last(char c) const
Find last occurrence of a character c.
Ssiz_t GetLongSize() const
unsigned long long ULong64_t
virtual Int_t Sizeof() const
Returns size string will occupy on I/O buffer.
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.
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
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...
static constexpr double s
int CompareTo(const char *cs, ECaseCompare cmp=kExact) const
Compare a string to char *cs2.
virtual void ReadTString(TString &s)=0
Bool_t IsAscii() const
Returns true if all characters in string are ascii.
void SubStringError(Ssiz_t, Ssiz_t, Ssiz_t) const
Output error message.
void ErrorHandler(int level, const char *location, const char *fmt, va_list va)
General error handler function. It calls the user set error handler.
TSubString(const TString &s, Ssiz_t start, Ssiz_t len)
Private constructor.
Short_t Max(Short_t a, Short_t b)
Bool_t IsHex() const
Returns true if all characters in string are hexadecimal digits (0-9,a-f,A-F).
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
uint64_t rotl64(uint64_t x, int8_t r)
Bool_t IsBin() const
Returns true if all characters in string are binary digits (0,1).
virtual TClass * ReadClass(const TClass *cl=0, UInt_t *objTag=0)=0
const size_t kBitsPerByte
Int_t CountChar(Int_t c) const
Return number of times character c occurs in the string.
Int_t Atoi() const
Return integer value of string.
static TString LLtoa(Long64_t value, Int_t base)
Converts a Long64_t to a TString with respect to the base specified (2-36).
TString()
TString default ctor.
Double_t Atof() const
Return floating-point value contained in string.
Bool_t IsDigit() const
Returns true if all characters in string are digits (0-9) or white spaces, i.e.
static void Mash(UInt_t &hash, UInt_t chars)
Utility used by Hash().
virtual void FillBuffer(char *&buffer) const
Copy string into I/O buffer.
UInt_t Hash(const char *str)
Return a case-sensitive hash value (endian independent).
static constexpr double sr
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...
void AssertElement(Ssiz_t i) const
Check to make sure a sub-string index is in range.
void Printf(const char *va_(fmt),...)
Formats a string in a circular formatting buffer and prints the string.
static Ssiz_t AdjustCapacity(Ssiz_t oldCap, Ssiz_t newCap)
Calculate a nice capacity greater than or equal to newCap.
Bool_t MaybeRegexp() const
Returns true if string contains one of the regexp characters "^$.[]*+?".
void InitChar(char c)
Initialize a string with a single character.
void Resize(Ssiz_t n)
Resize the string. Truncate or add blanks as necessary.
virtual ~TString()
Delete a TString.
static char * Format(const char *format, va_list ap)
Format a string in a circular formatting buffer (using a printf style format descriptor).
void * New(ENewType defConstructor=kClassNew, Bool_t quiet=kFALSE) const
Return a pointer to a newly allocated object of this class.
const char * Data() const