59#define strtoull _strtoui64
63namespace std { using ::list; }
121 memcpy(data, s.c_str(),
n);
130 Error(
"TString::TString",
"Negative length!");
134 if (strlen(cs) < (
size_t)
n) {
135 Warning(
"TString::TString",
"Input string is shorter than requested size.");
146 char *data =
Init(1, 1);
164 Error(
"TString::TString",
"Negative length!");
169 while (
n--) data[
n] =
c;
192 fRep.fRaw = s.fRep.fRaw;
201 Ssiz_t len = substr.length();
202 char *data =
Init(len, len);
203 memcpy(data, substr.data(), len);
212 char *data =
Init(len, len);
213 memcpy(data, substr.
Data(), len);
222 Error(
"TString::TString",
"Negative first length!");
227 Error(
"TString::TString",
"Negative second length!");
234 char *data =
Init(tot, tot);
235 if (a1) memcpy(data, a1, n1);
236 if (a2) memcpy(data+n1, a2, n2);
254 Error(
"TString::Init",
"Negative length!");
258 Error(
"*TString::Init",
"Negative length!");
262 Error(
"TString::Init",
"capacity too large (%d, max = %d)", capacity,
MaxSize());
264 if (nchar > capacity)
269 if (capacity < kMinCap) {
274 data =
new char[cap+1];
360 fRep.fRaw = rhs.fRep.fRaw;
384 if (!rep)
return *
this;
387 Error(
"TString::Append",
"Negative length!");
394 Error(
"TString::Append",
"rep too large (%d, max = %d)", rep,
MaxSize()-len);
402 if (capac - tot >= 0) {
407 data =
new char[cap+1];
408 memcpy(data, p, len);
446 const char *cs1 =
Data();
450 for (; cs2[i]; ++i) {
451 if (i == len)
return -1;
452 if (cs1[i] != cs2[i])
return ((cs1[i] > cs2[i]) ? 1 : -1);
455 for (; cs2[i]; ++i) {
456 if (i == len)
return -1;
457 char c1 = tolower((
unsigned char)cs1[i]);
458 char c2 = tolower((
unsigned char)cs2[i]);
459 if (
c1 !=
c2)
return ((
c1 >
c2) ? 1 : -1);
462 return (i < len) ? 1 : 0;
475 const char *s2 = str.
Data();
479 if (len < slen) slen = len;
481 int result = memcmp(
s1, s2, slen);
482 if (result != 0)
return result;
485 for (; i < slen; ++i) {
486 char c1 = tolower((
unsigned char)
s1[i]);
487 char c2 = tolower((
unsigned char)s2[i]);
488 if (
c1 !=
c2)
return ((
c1 >
c2) ? 1 : -1);
493 if (len == slen)
return 0;
494 return (len > slen) ? 1 : -1;
504 const char *data =
Data();
506 if (data[
n] ==
c) count++;
525 const char *
f = strchr(
Data(),
c);
534 const char *
f = strpbrk(
Data(), cs);
543 return (((
x & 0x000000ffU) << 24) | ((
x & 0x0000ff00U) << 8) |
544 ((
x & 0x00ff0000U) >> 8) | ((
x & 0xff000000U) >> 24));
563 UInt_t len = str ? strlen(str) : 0;
581 if ((i = len*
sizeof(
char)%
sizeof(
UInt_t)) != 0) {
583 const char*
c = (
const char*)p;
591 const unsigned char *p = (
const unsigned char*)str;
604 if ((i = len*
sizeof(
char)%
sizeof(
UInt_t)) != 0) {
606 const char*
c = (
const char*)p;
636 const char*
c = (
const char*)p;
651 const unsigned char *p = (
const unsigned char*)
Data();
653 Mash(hv, toupper(*p));
687#if defined(_MSC_VER) && (_MSC_VER < 1800)
690 typedef unsigned long uint32_t;
691 typedef unsigned __int64 uint64_t;
701#define ROTL64(x,y) _rotl64(x,y)
702#define BIG_CONSTANT(x) (x)
707 return (
x <<
r) | (
x >> (64 -
r));
710#define ROTL64(x,y) rotl64(x,y)
711#define BIG_CONSTANT(x) (x##LLU)
745 static void MurmurHash3_x64_128(
const void * key,
const int len,
746 const uint32_t seed, uint64_t out[2] )
749 const int nblocks = len / 16;
760 const uint64_t * blocks = (
const uint64_t *)(data);
762 for(
int i = 0; i < nblocks; i++)
764 uint64_t k1 = getblock(blocks,i*2+0);
765 uint64_t k2 = getblock(blocks,i*2+1);
771 k2 *=
c2; k2 =
ROTL64(k2,33); k2 *=
c1; h2 ^= k2;
773 h2 =
ROTL64(h2,31); h2 +=
h1; h2 = h2*5+0x38495ab5;
785 case 15: k2 ^= uint64_t(tail[14]) << 48;
786 case 14: k2 ^= uint64_t(tail[13]) << 40;
787 case 13: k2 ^= uint64_t(tail[12]) << 32;
788 case 12: k2 ^= uint64_t(tail[11]) << 24;
789 case 11: k2 ^= uint64_t(tail[10]) << 16;
790 case 10: k2 ^= uint64_t(tail[ 9]) << 8;
791 case 9: k2 ^= uint64_t(tail[ 8]) << 0;
792 k2 *=
c2; k2 =
ROTL64(k2,33); k2 *=
c1; h2 ^= k2;
794 case 8: k1 ^= uint64_t(tail[ 7]) << 56;
795 case 7: k1 ^= uint64_t(tail[ 6]) << 48;
796 case 6: k1 ^= uint64_t(tail[ 5]) << 40;
797 case 5: k1 ^= uint64_t(tail[ 4]) << 32;
798 case 4: k1 ^= uint64_t(tail[ 3]) << 24;
799 case 3: k1 ^= uint64_t(tail[ 2]) << 16;
800 case 2: k1 ^= uint64_t(tail[ 1]) << 8;
801 case 1: k1 ^= uint64_t(tail[ 0]) << 0;
808 h1 ^= len; h2 ^= len;
819 ((uint64_t*)out)[0] =
h1;
820 ((uint64_t*)out)[1] = h2;
837 if (ntxt !=
sizeof(
void*)) {
838 uint64_t buf[2] = {0};
839 MurmurHash3_x64_128(txt, ntxt, 0x6384BA69, buf);
845 if (((
size_t)txt) %
sizeof(
void*)) {
848 if (
sizeof(
void*) >
sizeof(
UInt_t)) {
852 const unsigned char* ctxt = (
const unsigned char*) txt;
853 for (
unsigned int i = 0; i < 4; ++i) {
854 ret ^= ctxt[i] << (i * 8);
856 if (
sizeof(
void*) >
sizeof(
UInt_t)) {
858 for (
unsigned int i = 0; i < 4; ++i) {
859 ret ^= ctxt[i] << (i * 8);
874 if (tolower((
unsigned char)*p) != tolower((
unsigned char)*
q))
890 Error(
"TString::Index",
"Negative first pattern length!");
894 if (slen < startIndex + plen)
return kNPOS;
895 if (plen == 0)
return startIndex;
896 slen -= startIndex + plen;
897 const char *sp =
Data() + startIndex;
899 char first = *pattern;
900 for (
Ssiz_t i = 0; i <= slen; ++i)
901 if (sp[i] ==
first && memcmp(sp+i+1, pattern+1, plen-1) == 0)
902 return i + startIndex;
904 int first = tolower((
unsigned char) *pattern);
905 for (
Ssiz_t i = 0; i <= slen; ++i)
906 if (tolower((
unsigned char) sp[i]) ==
first &&
908 return i + startIndex;
918 const char *
f = strrchr(
Data(), (
unsigned char)
c);
939 const char *specials =
"^$.[]*+?";
951 const char *specials =
"[]*?";
970 Error(
"TString::Prepend",
"rep too large (%d, max = %d)", rep,
MaxSize()-len);
978 if (capac - tot >= 0) {
979 memmove(p + rep, p, len);
984 data =
new char[cap+1];
985 memcpy(data+rep, p, len);
1006 if (pos <= kNPOS || pos > len) {
1007 Error(
"TString::Replace",
1008 "first argument out of bounds: pos = %d, Length = %d", pos, len);
1012 Error(
"TString::Replace",
"Negative number of characters to remove!");
1016 Error(
"TString::Replace",
"Negative number of replacement characters!");
1023 Ssiz_t tot = len - n1 + n2;
1024 Ssiz_t rem = len - n1 - pos;
1029 if (capac - len + n1 >= n2) {
1033 if (n2) memmove(p + pos, cs, n2);
1034 memmove(p + pos + n2, p + pos + n1, rem);
1039 if (p + pos < cs && cs < p + len) {
1040 if (p + pos + n1 <= cs)
1043 memmove(p + pos, cs, n1);
1050 memmove(p + pos + n2, p + pos + n1, rem);
1053 if (n2) memmove(p + pos, cs, n2);
1058 char *data =
new char[cap+1];
1059 if (pos) memcpy(data, p, pos);
1060 if (n2 ) memcpy(data + pos, cs, n2);
1061 if (rem) memcpy(data + pos + n2, p + pos + n1, rem);
1078 if (
s1 && ls1 > 0) {
1096 const char *direct =
Data();
1100 while (start < end && direct[start] ==
c)
1103 while (start < end && direct[end-1] ==
c)
1113 Remove(send - start - (send - end), send - end);
1135 const char *direct =
Data();
1138 while (start < end && direct[start] ==
c)
1141 while (start < end && direct[end-1] ==
c)
1143 if (end == start) start = end =
kNPOS;
1155 *p = tolower((
unsigned char)*p);
1168 *p = toupper((
unsigned char)*p);
1179 Error(
"TString::AssertElement",
1180 "out of bounds: i = %d, Length = %d", i,
Length());
1189 if (newCap > ms - 1) {
1190 Error(
"TString::AdjustCapacity",
"capacity too large (%d, max = %d)",
1212 Error(
"TString::Clobber",
"capacity too large (%d, max = %d)", nc,
MaxSize());
1223 data =
new char[cap+1];
1240 if (len >= tot)
return;
1243 Error(
"TString::Clone",
"tot too large (%d, max = %d)", tot,
MaxSize());
1250 if (capac - tot < 0) {
1252 data =
new char[cap+1];
1253 memcpy(data, p, len);
1276 tobuf(buffer, nchars);
1282 for (
int i = 0; i < nchars; i++) buffer[i] = data[i];
1304 Error(
"TString::ReadBuffer",
"found case with nwh=%d and nchars=%d", nwh, nchars);
1308 char *data =
Init(nchars, nchars);
1310 for (
int i = 0; i < nchars; i++)
frombuf(buffer, &data[i]);
1331 TClass *clRef =
b.ReadClass(clReq, &tag);
1342 ::Error(
"TString::ReadObject",
"could not create object of class %s",
1350 b.CheckByteCount(startpos, tag, clRef);
1372 if (
b.IsReading()) {
1373 b.ReadTString(*
this);
1375 b.WriteTString(*
this);
1409 b.SetByteCount(cntpos);
1416#if defined(R__TEMPLATE_OVERLOAD_BUG)
1444 const char *data =
s1.Data();
1447 for (i = 0; s2[i]; ++i)
1448 if (data[i] != s2[i] || i == len)
return kFALSE;
1459 const char *uc = str.
Data();
1460 char *lc = (
char*)temp.
Data();
1462 while (
n--) { *lc++ = tolower((
unsigned char)*uc); uc++; }
1473 const char* uc = str.
Data();
1474 char* lc = (
char*)temp.
Data();
1476 while (
n--) { *lc++ = toupper((
unsigned char)*uc); uc++; }
1528 ::Obsolete(
"TString::GetInitialCapacity",
"v5-30-00",
"v5-32-00");
1536 ::Obsolete(
"TString::GetResizeIncrement",
"v5-30-00",
"v5-32-00");
1544 ::Obsolete(
"TString::GetMaxWaste",
"v5-30-00",
"v5-32-00");
1553 ::Obsolete(
"TString::InitialCapacity",
"v5-30-00",
"v5-32-00");
1562 ::Obsolete(
"TString::ResizeIncrement",
"v5-30-00",
"v5-32-00");
1572 ::Obsolete(
"TString::MaxWaste",
"v5-30-00",
"v5-32-00");
1590 : fStr((
TString&)str), fBegin(start), fExtent(nextent)
1599 if (start <
Length() && len > 0) {
1600 if (start+len >
Length())
1618 Ssiz_t len = pattern ? strlen(pattern) : 0;
1667 if (ss.
IsNull())
return *cs ==
'\0';
1671 for (i = 0; cs[i]; ++i)
1691 if (
s1.IsNull())
return s2.
IsNull();
1705 while (
n--) { *p = tolower((
unsigned char)*p); p++;}
1717 while (
n--) { *p = toupper((
unsigned char)*p); p++;}
1726 Error(
"TSubString::SubStringError",
1727 "out of bounds: start = %d, n = %d, sr = %d", start,
n, sr);
1736 Error(
"TSubString::AssertElement",
1737 "out of bounds: i = %d, Length = %d", i,
Length());
1745 const char *cp =
Data();
1758 const char *cp =
Data();
1760 if (len == 0)
return kFALSE;
1761 for (
Ssiz_t i = 0; i < len; ++i)
1762 if (!isalpha(cp[i]))
1773 const char *cp =
Data();
1775 if (len == 0)
return kFALSE;
1776 for (
Ssiz_t i = 0; i < len; ++i)
1777 if (!isalnum(cp[i]))
1790 const char *cp =
Data();
1792 if (len == 0)
return kFALSE;
1794 for (
Ssiz_t i = 0; i < len; ++i) {
1795 if (cp[i] !=
' ' && !isdigit(cp[i]))
return kFALSE;
1796 if (cp[i] ==
' ')
b++;
1797 if (isdigit(cp[i]))
d++;
1828 pos = tmp.
First(
',');
1830 pos = tmp.
Index(
"e-");
1831 if (pos >= 1) tmp.
Replace(pos, 2,
" ", 1);
1832 pos = tmp.
Index(
"e+");
1833 if (pos >= 1) tmp.
Replace(pos, 2,
" ", 1);
1834 pos = tmp.
Index(
"e");
1835 if (pos >= 1) tmp.
Replace(pos, 1,
" ", 1);
1836 pos = tmp.
First(
'-');
1837 if (pos == 0) tmp.
Replace(pos, 1,
" ", 1);
1838 pos = tmp.
First(
'+');
1839 if (pos == 0) tmp.
Replace(pos, 1,
" ", 1);
1852 const char *cp =
Data();
1854 if (len == 0)
return kFALSE;
1855 for (
Ssiz_t i = 0; i < len; ++i)
1856 if (!isxdigit(cp[i]))
1868 const char *cp =
Data();
1870 if (len == 0)
return kFALSE;
1871 for (
Ssiz_t i = 0; i < len; ++i)
1872 if (cp[i] !=
'0' && cp[i] !=
'1')
1884 const char *cp =
Data();
1886 if (len == 0)
return kFALSE;
1887 for (
Ssiz_t i = 0; i < len; ++i)
1888 if (!isdigit(cp[i]) || cp[i]==
'8' || cp[i]==
'9')
1900 const char *cp =
Data();
1902 if (len == 0)
return kFALSE;
1903 for (
Ssiz_t i = 0; i < len; ++i)
1904 if (!isdigit(cp[i]))
1917 if (base < 2 || base > 36) {
1918 Error(
"TString::IsInBaseN",
"base %d is not supported. Supported bases are {2,3,...,36}.", base);
1922 Error(
"TString::IsInBaseN",
"input string is empty.") ;
1927 TString str_ref0 =
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" ;
1951 if (end == -1)
return atoi(
Data());
1957 tmp += (*this)(start, end-start);
1958 start = end+1; end =
Index(
" ", start);
1962 tmp += (*this)(start, end-start);
1963 return atoi(tmp.
Data());
1978 if (end == -1)
return atoll(
Data());
1980 if (end == -1)
return _atoi64(
Data());
1987 tmp += (*this)(start, end-start);
1988 start = end+1; end =
Index(
" ", start);
1992 tmp += (*this)(start, end-start);
1994 return atoll(tmp.
Data());
1996 return _atoi64(tmp.
Data());
2018 if (comma == -1 && end == -1)
return atof(
Data());
2025 if (end == -1)
return atof(tmp.
Data());
2030 tmp2 += tmp(start, end-start);
2031 start = end+1; end = tmp.
Index(
" ", start);
2034 tmp2 += tmp(start, end-start);
2035 return atof(tmp2.
Data());
2054 if (base < 2 || base > 36) {
2055 Error(
"TString::Itoa",
"base %d is not supported. Supported bases are {2,3,...,36}.",base) ;
2059 Int_t quotient = value;
2062 buf +=
"0123456789abcdefghijklmnopqrstuvwxyz"[
TMath::Abs(quotient % base) ];
2066 if (value < 0) buf +=
'-';
2067 std::reverse(buf.begin(), buf.end());
2081 if (base < 2 || base > 36) {
2082 Error(
"TString::UItoa",
"base %d is not supported. Supported bases are {2,3,...,36}.",base);
2089 buf +=
"0123456789abcdefghijklmnopqrstuvwxyz"[ quotient % base ];
2092 std::reverse(buf.begin(), buf.end());
2106 if (base < 2 || base > 36) {
2107 Error(
"TString::LLtoa",
"base %d is not supported. Supported bases are {2,3,...,36}.",base);
2114 buf +=
"0123456789abcdefghijklmnopqrstuvwxyz"[
TMath::Abs(quotient % base) ];
2118 if (value < 0) buf +=
'-';
2119 std::reverse(buf.begin(), buf.end());
2133 if (base < 2 || base > 36) {
2134 Error(
"TString::ULLtoa",
"base %d is not supported. Supported bases are {2,3,...,36}.",base);
2141 buf +=
"0123456789abcdefghijklmnopqrstuvwxyz"[ quotient % base ];
2144 std::reverse(buf.begin(), buf.end());
2156 if (base_in < 2 || base_in > 36 || base_out < 2 || base_out > 36) {
2157 Error(
"TString::BaseConvert",
"only bases 2-36 are supported (base_in=%d, base_out=%d).", base_in, base_out);
2163 if (s_in_[0] ==
'-') {
2167 if (!isSigned && s_in_[0] ==
'+') s_in_.
Remove(0, 1);
2170 if (!s_in_.
Length()) s_in_ +=
'0';
2173 Error(
"TString::BaseConvert",
"s_in=\"%s\" is not in base %d", s_in.
Data(), base_in);
2180 Error(
"TString::BaseConvert",
"s_in=\"%s\" > %s = 2^64-1 in base %d.", s_in.
Data(), s_max.
Data(), base_in);
2185 if (s_in_ > s_max) {
2187 Error(
"TString::BaseConvert",
"s_in=\"%s\" > %s = 2^64-1 in base %d.", s_in.
Data(), s_max.
Data(), base_in);
2195 if (isSigned) s_out.
Prepend(
"-");
2204 if (!s)
return kTRUE;
2211 return strcmp(s, s2) == 0;
2212 return strcasecmp(s, s2) == 0;
2224 std::list<Int_t> splitIndex;
2226 Int_t i, start, nrDiff = 0;
2227 for (i = 0; i < delim.
Length(); i++) {
2229 while (start <
Length()) {
2231 if (pos ==
kNPOS)
break;
2232 splitIndex.push_back(pos);
2235 if (start > 0) nrDiff++;
2237 splitIndex.push_back(
Length());
2246 std::list<Int_t>::const_iterator it;
2248 for (it = splitIndex.begin(); it != splitIndex.end(); ++it) {
2250 for (it = splitIndex.begin(); it != (std::list<Int_t>::const_iterator) splitIndex.end(); ++it) {
2253 if (stop - 1 >= start + 1) {
2254 TString tok = (*this)(start+1, stop-start-1);
2270 Ssiz_t buflen = 20 + 20 * strlen(fmt);
2281 if (
n == -1 ||
n >= buflen) {
2317 va_start(ap,
va_(fmt));
2339 va_start(ap,
va_(fmt));
2354 static const int fld_size = 2048;
2355 TTHREAD_TLS(
char*) slowBuffer(
nullptr);
2356 TTHREAD_TLS(
int) slowBufferSize(0);
2358 if (hint == -1) hint = fld_size;
2359 if (hint > slowBufferSize) {
2360 delete [] slowBuffer;
2361 slowBufferSize = 2 * hint;
2362 if (hint < 0 || slowBufferSize < 0) {
2364 slowBuffer =
nullptr;
2367 slowBuffer =
new char[slowBufferSize];
2373 int n = vsnprintf(slowBuffer, slowBufferSize, format, ap);
2376 if (
n == -1 ||
n >= slowBufferSize) {
2377 if (
n == -1)
n = 2 * slowBufferSize;
2378 if (
n == slowBufferSize)
n++;
2400static char *
Format(
const char *format, va_list ap)
2402 static const int cb_size = 4096;
2403 static const int fld_size = 2048;
2406 TTHREAD_TLS_ARRAY(
char,cb_size,gFormbuf);
2407 TTHREAD_TLS(
char*) gBfree(
nullptr);
2408 TTHREAD_TLS(
char*) gEndbuf(
nullptr);
2410 if (gBfree ==
nullptr) {
2412 gEndbuf = &gFormbuf[cb_size-1];
2416 if (buf+fld_size > gEndbuf)
2422 int n = vsnprintf(buf, fld_size, format, ap);
2425 if (
n == -1 ||
n >= fld_size) {
2450 va_start(ap,
va_(fmt));
2464 va_start(ap,
va_(fmt));
2481 if (!s)
return nullptr;
2484 char *buf =
new char[
l+1];
2497 const char *t2 = s +
l - 1;
2498 while (*t2 ==
c && t2 > s)
2506 *(buf+(t2-
t1+1)) =
'\0';
2517 if (!str)
return nullptr;
2519 auto len = strlen(str)+1;
2520 char *s =
new char[len];
2521 if (s) strlcpy(s, str, len);
2532 if (!str)
return nullptr;
2534 const char *p = str;
2535 char *s, *
s1 =
new char[strlen(str)+1];
2551int EscChar(
const char *src,
char *dst,
int dstlen,
char *specchars,
2555 char *
q, *end = dst+dstlen-1;
2557 for (p = src,
q = dst; *p &&
q < end; ) {
2558 if (strchr(specchars, *p)) {
2575int UnEscChar(
const char *src,
char *dst,
int dstlen,
char *specchars,
char)
2578 char *
q, *end = dst+dstlen-1;
2580 for (p = src,
q = dst; *p &&
q < end; ) {
2581 if (strchr(specchars, *p))
2593#ifdef NEED_STRCASECMP
2597int strcasecmp(
const char *str1,
const char *str2)
2599 return strncasecmp(str1, str2, str2 ? strlen(str2)+1 : 0);
2605int strncasecmp(
const char *str1,
const char *str2,
Ssiz_t n)
2631std::string cling::printValue(
const TString* val) {
2639std::string cling::printValue(
const TSubString* val) {
2647std::string cling::printValue(
const std::string_view* val) {
2648 std::string str(*val);
void frombuf(char *&buf, Bool_t *x)
void tobuf(char *&buf, Bool_t x)
const ULong_t kBitsPerByte
unsigned long long ULong64_t
TBuffer & operator<<(TBuffer &buf, const Tmpl *obj)
void ErrorHandler(int level, const char *location, const char *fmt, std::va_list va)
General error handler function. It calls the user set error handler.
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
R__EXTERN Bool_t gPrintViaErrorHandler
void Obsolete(const char *function, const char *asOfVers, const char *removedFromVers)
Use this function to declare a function obsolete.
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
uint64_t rotl64(uint64_t x, int8_t r)
TString ToLower(const TString &str)
Return a lower-case version of str.
TString operator+(const TString &s, const char *cs)
Use the special concatenation constructor.
static int MemIsEqual(const char *p, const char *q, Ssiz_t n)
Returns false if strings are not equal.
TBuffer & operator>>(TBuffer &buf, TString *&s)
Read string from TBuffer. Function declared in ClassDef.
Bool_t operator==(const TString &s1, const char *s2)
Compare TString with a char *.
UInt_t Hash(const char *str)
Return a case-sensitive hash value (endian independent).
static char * SlowFormat(const char *format, va_list ap, int hint)
Format a string in a formatting buffer (using a printf style format descriptor).
TString ToUpper(const TString &str)
Return an upper-case version of str.
static UInt_t SwapInt(UInt_t x)
static void Mash(UInt_t &hash, UInt_t chars)
Utility used by Hash().
char * Compress(const char *str)
Remove all blanks from the string str.
int UnEscChar(const char *src, char *dst, int dstlen, char *specchars, char escchar)
Un-escape specchars in src from escchar and copy to dst.
void Printf(const char *fmt,...)
char * StrDup(const char *str)
Duplicate the string str.
int EscChar(const char *src, char *dst, int dstlen, char *specchars, char escchar)
Escape specchars in src with escchar and copy to dst.
#define R__VA_COPY(to, from)
Buffer base class used for serializing objects.
TClass instances represent classes, structs and namespaces in the ROOT type system.
void * New(ENewType defConstructor=kClassNew, Bool_t quiet=kFALSE) const
Return a pointer to a newly allocated object of this class.
void Streamer(void *obj, TBuffer &b, const TClass *onfile_class=0) const
virtual void SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
This code implements the MD5 message-digest algorithm.
const char * AsString() const
Return message digest as string.
void Update(const UChar_t *buf, UInt_t len)
Update TMD5 object to reflect the concatenation of another buffer full of bytes.
void Final()
MD5 finalization, ends an MD5 message-digest operation, writing the the message digest and zeroizing ...
virtual const char * GetName() const
Returns name of object.
Collectable string class.
TString Copy() const
Copy a string.
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...
static TString LLtoa(Long64_t value, Int_t base)
Converts a Long64_t to a TString with respect to the base specified (2-36).
void SetShortSize(Ssiz_t s)
char & operator()(Ssiz_t i)
Bool_t IsDec() const
Returns true if all characters in string are decimal digits (0-9).
void ToLower()
Change string to lower-case.
int CompareTo(const char *cs, ECaseCompare cmp=kExact) const
Compare a string to char *cs2.
static Ssiz_t MaxWaste(Ssiz_t mw=15)
Set maximum space that may be wasted in a string before doing a resize.
Int_t Atoi() const
Return integer value of string.
void SetLongSize(Ssiz_t s)
static const Ssiz_t kNPOS
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
Return true if string ends with the specified string.
TSubString Strip(EStripType s=kTrailing, char c=' ') const
Return a substring of self stripped at beginning and/or end.
TString()
TString default ctor.
Bool_t IsHex() const
Returns true if all characters in string are hexadecimal digits (0-9,a-f,A-F).
Double_t Atof() const
Return floating-point value contained in string.
Bool_t IsFloat() const
Returns kTRUE if string contains a floating point or integer number.
void Clear()
Clear string without changing its capacity.
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.
TString & Replace(Ssiz_t pos, Ssiz_t n, const char *s)
Ssiz_t First(char c) const
Find first occurrence of a character c.
const char * Data() const
static TString * ReadString(TBuffer &b, const TClass *clReq)
Read TString object from buffer.
Bool_t IsDigit() const
Returns true if all characters in string are digits (0-9) or white spaces, i.e.
Bool_t MaybeRegexp() const
Returns true if string contains one of the regexp characters "^$.[]*+?".
static Ssiz_t ResizeIncrement(Ssiz_t ri=16)
Set default resize increment for all TStrings. Default is 16.
UInt_t HashCase() const
Return a case-sensitive hash value (endian independent).
Bool_t IsOct() const
Returns true if all characters in string are octal digits (0-7).
virtual ~TString()
Delete a TString.
static Ssiz_t GetMaxWaste()
TString & ReplaceAll(const TString &s1, const TString &s2)
static Ssiz_t AdjustCapacity(Ssiz_t oldCap, Ssiz_t newCap)
Calculate a nice capacity greater than or equal to newCap.
TString MD5() const
Return the MD5 digest for this string, in a string representation.
void Resize(Ssiz_t n)
Resize the string. Truncate or add blanks as necessary.
Bool_t IsAlpha() const
Returns true if all characters in string are alphabetic.
UInt_t HashFoldCase() const
Return a case-insensitive hash value (endian independent).
Ssiz_t Last(char c) const
Find last occurrence of a character c.
void ToUpper()
Change string to upper case.
Bool_t IsAscii() const
Returns true if all characters in string are ascii.
TObjArray * Tokenize(const TString &delim) const
This function is used to isolate sequential tokens in a TString.
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
static Ssiz_t GetResizeIncrement()
void SetLongCap(Ssiz_t s)
TString & Prepend(const char *cs)
Bool_t IsBin() const
Returns true if all characters in string are binary digits (0,1).
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.
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...
Int_t CountChar(Int_t c) const
Return number of times character c occurs in the string.
UInt_t Hash(ECaseCompare cmp=kExact) const
Return hash value.
static void WriteString(TBuffer &b, const TString *a)
Write TString object to buffer.
virtual void FillBuffer(char *&buffer) const
Copy string into I/O buffer.
TString & operator=(char s)
Assign character c to TString.
TString & Remove(Ssiz_t pos)
static Ssiz_t InitialCapacity(Ssiz_t ic=15)
Set default initial capacity for all TStrings. Default is 15.
TString & Append(const char *cs)
Bool_t IsInBaseN(Int_t base) const
Returns true if all characters in string are expressed in the base specified (range=2-36),...
char * Init(Ssiz_t capacity, Ssiz_t nchar)
Private member function returning an empty string representation of size capacity and containing ncha...
Bool_t MaybeWildcard() const
Returns true if string contains one of the wildcard characters "[]*?".
void InitChar(char c)
Initialize a string with a single character.
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
static TString Itoa(Int_t value, Int_t base)
Converts an Int_t to a TString with respect to the base specified (2-36).
virtual Int_t Sizeof() const
Returns size string will occupy on I/O buffer.
void Clone(Ssiz_t nc)
Make self a distinct copy with capacity of at least tot, where tot cannot be smaller than the current...
void SetLongPointer(char *p)
Ssiz_t GetLongSize() const
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
static Ssiz_t GetInitialCapacity()
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
void AssertElement(Ssiz_t nc) const
Check to make sure a string index is in range.
virtual void ReadBuffer(char *&buffer)
Read string from I/O buffer.
Bool_t IsAlnum() const
Returns true if all characters in string are alphanumeric.
void FormImp(const char *fmt, va_list ap)
Formats a string using a printf style format descriptor.
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
void Clobber(Ssiz_t nc)
Clear string and make sure it has a capacity of nc.
static Ssiz_t Recommend(Ssiz_t s)
Long64_t Atoll() const
Return long long value of string.
A zero length substring is legal.
TSubString(const TString &s, Ssiz_t start, Ssiz_t len)
Private constructor.
TSubString & operator=(const char *s)
Assign char* to sub-string.
void ToUpper()
Convert sub-string to upper-case.
void SubStringError(Ssiz_t, Ssiz_t, Ssiz_t) const
Output error message.
char & operator[](Ssiz_t i)
Return character at pos i from sub-string. Check validity of i.
void AssertElement(Ssiz_t i) const
Check to make sure a sub-string index is in range.
void ToLower()
Convert sub-string to lower-case.
const char * Data() const
char & operator()(Ssiz_t i)
Return character at pos i from sub-string. No check on i.
Short_t Max(Short_t a, Short_t b)
Short_t Min(Short_t a, Short_t b)