00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef ROOT_TString
00013 #define ROOT_TString
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef __CINT__
00027 #include <string.h>
00028 #include <stdio.h>
00029 #endif
00030
00031 #ifndef ROOT_TRefCnt
00032 #include "TRefCnt.h"
00033 #endif
00034
00035 #ifndef ROOT_Riosfwd
00036 #include "Riosfwd.h"
00037 #endif
00038
00039 #ifndef ROOT_TMathBase
00040 #include "TMathBase.h"
00041 #endif
00042
00043 #include <stdarg.h>
00044 #include <string>
00045
00046 #ifdef R__GLOBALSTL
00047 namespace std { using ::string; }
00048 #endif
00049
00050 class TRegexp;
00051 class TPRegexp;
00052 class TString;
00053 class TSubString;
00054 class TObjArray;
00055 class TVirtualMutex;
00056
00057 R__EXTERN TVirtualMutex *gStringMutex;
00058
00059 TString operator+(const TString &s1, const TString &s2);
00060 TString operator+(const TString &s, const char *cs);
00061 TString operator+(const char *cs, const TString &s);
00062 TString operator+(const TString &s, char c);
00063 TString operator+(const TString &s, Long_t i);
00064 TString operator+(const TString &s, ULong_t i);
00065 TString operator+(const TString &s, Long64_t i);
00066 TString operator+(const TString &s, ULong64_t i);
00067 TString operator+(char c, const TString &s);
00068 TString operator+(Long_t i, const TString &s);
00069 TString operator+(ULong_t i, const TString &s);
00070 TString operator+(Long64_t i, const TString &s);
00071 TString operator+(ULong64_t i, const TString &s);
00072 Bool_t operator==(const TString &s1, const TString &s2);
00073 Bool_t operator==(const TString &s1, const char *s2);
00074 Bool_t operator==(const TSubString &s1, const TSubString &s2);
00075 Bool_t operator==(const TSubString &s1, const TString &s2);
00076 Bool_t operator==(const TSubString &s1, const char *s2);
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088 class TStringRef : public TRefCnt {
00089
00090 friend class TString;
00091 friend class TStringLong;
00092 friend class TSubString;
00093
00094 private:
00095 Ssiz_t fCapacity;
00096 Ssiz_t fNchars;
00097
00098 void UnLink();
00099
00100 Ssiz_t Length() const { return fNchars; }
00101 Ssiz_t Capacity() const { return fCapacity; }
00102 char *Data() const { return (char*)(this+1); }
00103
00104 char &operator[](Ssiz_t i) { return ((char*)(this+1))[i]; }
00105 char operator[](Ssiz_t i) const { return ((char*)(this+1))[i]; }
00106
00107 Ssiz_t First(char c) const;
00108 Ssiz_t First(const char *s) const;
00109 UInt_t Hash() const;
00110 UInt_t HashFoldCase() const;
00111 Ssiz_t Last(char) const;
00112
00113 static TStringRef *GetRep(Ssiz_t capac, Ssiz_t nchar);
00114 };
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125 class TSubString {
00126
00127 friend class TStringLong;
00128 friend class TString;
00129
00130 friend Bool_t operator==(const TSubString &s1, const TSubString &s2);
00131 friend Bool_t operator==(const TSubString &s1, const TString &s2);
00132 friend Bool_t operator==(const TSubString &s1, const char *s2);
00133
00134 private:
00135 TString &fStr;
00136 Ssiz_t fBegin;
00137 Ssiz_t fExtent;
00138
00139
00140 TSubString(const TString &s, Ssiz_t start, Ssiz_t len);
00141
00142 protected:
00143 void SubStringError(Ssiz_t, Ssiz_t, Ssiz_t) const;
00144 void AssertElement(Ssiz_t i) const;
00145
00146 public:
00147 TSubString(const TSubString &s)
00148 : fStr(s.fStr), fBegin(s.fBegin), fExtent(s.fExtent) { }
00149
00150 TSubString &operator=(const char *s);
00151 TSubString &operator=(const TString &s);
00152 TSubString &operator=(const TSubString &s);
00153 char &operator()(Ssiz_t i);
00154 char &operator[](Ssiz_t i);
00155 char operator()(Ssiz_t i) const;
00156 char operator[](Ssiz_t i) const;
00157
00158 const char *Data() const;
00159 Ssiz_t Length() const { return fExtent; }
00160 Ssiz_t Start() const { return fBegin; }
00161 TString& String() { return fStr; }
00162 void ToLower();
00163 void ToUpper();
00164
00165
00166 Bool_t IsNull() const { return fBegin == kNPOS; }
00167 int operator!() const { return fBegin == kNPOS; }
00168 };
00169
00170
00171
00172
00173
00174
00175
00176 class TString {
00177
00178 friend class TSubString;
00179 friend class TStringRef;
00180
00181 friend TString operator+(const TString &s1, const TString &s2);
00182 friend TString operator+(const TString &s, const char *cs);
00183 friend TString operator+(const char *cs, const TString &s);
00184 friend TString operator+(const TString &s, char c);
00185 friend TString operator+(const TString &s, Long_t i);
00186 friend TString operator+(const TString &s, ULong_t i);
00187 friend TString operator+(const TString &s, Long64_t i);
00188 friend TString operator+(const TString &s, ULong64_t i);
00189 friend TString operator+(char c, const TString &s);
00190 friend TString operator+(Long_t i, const TString &s);
00191 friend TString operator+(ULong_t i, const TString &s);
00192 friend TString operator+(Long64_t i, const TString &s);
00193 friend TString operator+(ULong64_t i, const TString &s);
00194 friend Bool_t operator==(const TString &s1, const TString &s2);
00195 friend Bool_t operator==(const TString &s1, const char *s2);
00196
00197 private:
00198 static Ssiz_t fgInitialCapac;
00199 static Ssiz_t fgResizeInc;
00200 static Ssiz_t fgFreeboard;
00201
00202 void Clone();
00203 void Clone(Ssiz_t nc);
00204 void FormImp(const char *fmt, va_list ap);
00205
00206 protected:
00207 char *fData;
00208
00209
00210 TString(const char *a1, Ssiz_t n1, const char *a2, Ssiz_t n2);
00211 TStringRef *Pref() const { return (((TStringRef*) fData) - 1); }
00212 void AssertElement(Ssiz_t nc) const;
00213 void Clobber(Ssiz_t nc);
00214 void Cow();
00215 void Cow(Ssiz_t nc);
00216 static Ssiz_t AdjustCapacity(Ssiz_t nc);
00217 void InitChar(char c);
00218
00219 public:
00220 enum EStripType { kLeading = 0x1, kTrailing = 0x2, kBoth = 0x3 };
00221 enum ECaseCompare { kExact, kIgnoreCase };
00222
00223 TString();
00224 explicit TString(Ssiz_t ic);
00225 TString(const TString &s) :
00226 fData(s.fData) { Pref()->AddReference(); }
00227
00228 TString(const char *s);
00229 TString(const char *s, Ssiz_t n);
00230 TString(const std::string &s);
00231 TString(char c) : fData(0) { InitChar(c); }
00232 TString(char c, Ssiz_t s);
00233 TString(const TSubString &sub);
00234
00235 virtual ~TString();
00236
00237
00238 virtual void FillBuffer(char *&buffer);
00239 virtual void ReadBuffer(char *&buffer);
00240 virtual Int_t Sizeof() const;
00241
00242 static TString *ReadString(TBuffer &b, const TClass *clReq);
00243 static void WriteString(TBuffer &b, const TString *a);
00244
00245 friend TBuffer &operator<<(TBuffer &b, const TString *obj);
00246
00247
00248 Bool_t Gets(FILE *fp, Bool_t chop=kTRUE);
00249 void Puts(FILE *fp);
00250
00251
00252 operator const char*() const { return fData; }
00253
00254
00255 TString &operator=(char s);
00256 TString &operator=(const char *s);
00257 TString &operator=(const TString &s);
00258 TString &operator=(const std::string &s);
00259 TString &operator=(const TSubString &s);
00260 TString &operator+=(const char *s);
00261 TString &operator+=(const TString &s);
00262 TString &operator+=(char c);
00263 TString &operator+=(Short_t i);
00264 TString &operator+=(UShort_t i);
00265 TString &operator+=(Int_t i);
00266 TString &operator+=(UInt_t i);
00267 TString &operator+=(Long_t i);
00268 TString &operator+=(ULong_t i);
00269 TString &operator+=(Float_t f);
00270 TString &operator+=(Double_t f);
00271 TString &operator+=(Long64_t i);
00272 TString &operator+=(ULong64_t i);
00273
00274
00275 char &operator[](Ssiz_t i);
00276 char &operator()(Ssiz_t i);
00277 char operator[](Ssiz_t i) const;
00278 char operator()(Ssiz_t i) const;
00279 TSubString operator()(Ssiz_t start, Ssiz_t len) const;
00280 TSubString operator()(const TRegexp &re) const;
00281 TSubString operator()(const TRegexp &re, Ssiz_t start) const;
00282 TSubString operator()(TPRegexp &re) const;
00283 TSubString operator()(TPRegexp &re, Ssiz_t start) const;
00284 TSubString SubString(const char *pat, Ssiz_t start = 0,
00285 ECaseCompare cmp = kExact) const;
00286
00287
00288 TString &Append(const char *cs);
00289 TString &Append(const char *cs, Ssiz_t n);
00290 TString &Append(const TString &s);
00291 TString &Append(const TString &s, Ssiz_t n);
00292 TString &Append(char c, Ssiz_t rep = 1);
00293 Int_t Atoi() const;
00294 Long64_t Atoll() const;
00295 Double_t Atof() const;
00296 Bool_t BeginsWith(const char *s, ECaseCompare cmp = kExact) const;
00297 Bool_t BeginsWith(const TString &pat, ECaseCompare cmp = kExact) const;
00298 Ssiz_t Capacity() const { return Pref()->Capacity(); }
00299 Ssiz_t Capacity(Ssiz_t n);
00300 TString &Chop();
00301 void Clear();
00302 int CompareTo(const char *cs, ECaseCompare cmp = kExact) const;
00303 int CompareTo(const TString &st, ECaseCompare cmp = kExact) const;
00304 Bool_t Contains(const char *pat, ECaseCompare cmp = kExact) const;
00305 Bool_t Contains(const TString &pat, ECaseCompare cmp = kExact) const;
00306 Bool_t Contains(const TRegexp &pat) const;
00307 Bool_t Contains(TPRegexp &pat) const;
00308 Int_t CountChar(Int_t c) const;
00309 TString Copy() const;
00310 const char *Data() const { return fData; }
00311 Bool_t EndsWith(const char *pat, ECaseCompare cmp = kExact) const;
00312 Ssiz_t First(char c) const { return Pref()->First(c); }
00313 Ssiz_t First(const char *cs) const { return Pref()->First(cs); }
00314 void Form(const char *fmt, ...)
00315 #if defined(__GNUC__) && !defined(__CINT__)
00316 __attribute__((format(printf, 2, 3)))
00317 #endif
00318 ;
00319 UInt_t Hash(ECaseCompare cmp = kExact) const;
00320 Ssiz_t Index(const char *pat, Ssiz_t i = 0,
00321 ECaseCompare cmp = kExact) const;
00322 Ssiz_t Index(const TString &s, Ssiz_t i = 0,
00323 ECaseCompare cmp = kExact) const;
00324 Ssiz_t Index(const char *pat, Ssiz_t patlen, Ssiz_t i,
00325 ECaseCompare cmp) const;
00326 Ssiz_t Index(const TString &s, Ssiz_t patlen, Ssiz_t i,
00327 ECaseCompare cmp) const;
00328 Ssiz_t Index(const TRegexp &pat, Ssiz_t i = 0) const;
00329 Ssiz_t Index(const TRegexp &pat, Ssiz_t *ext, Ssiz_t i = 0) const;
00330 Ssiz_t Index(TPRegexp &pat, Ssiz_t i = 0) const;
00331 Ssiz_t Index(TPRegexp &pat, Ssiz_t *ext, Ssiz_t i = 0) const;
00332 TString &Insert(Ssiz_t pos, const char *s);
00333 TString &Insert(Ssiz_t pos, const char *s, Ssiz_t extent);
00334 TString &Insert(Ssiz_t pos, const TString &s);
00335 TString &Insert(Ssiz_t pos, const TString &s, Ssiz_t extent);
00336 Bool_t IsAscii() const;
00337 Bool_t IsAlpha() const;
00338 Bool_t IsAlnum() const;
00339 Bool_t IsDigit() const;
00340 Bool_t IsFloat() const;
00341 Bool_t IsHex() const;
00342 Bool_t IsNull() const { return Pref()->fNchars == 0; }
00343 Bool_t IsWhitespace() const { return (Length() == CountChar(' ')); }
00344 Ssiz_t Last(char c) const { return Pref()->Last(c); }
00345 Ssiz_t Length() const { return Pref()->fNchars; }
00346 Bool_t MaybeRegexp() const;
00347 Bool_t MaybeWildcard() const;
00348 TString &Prepend(const char *cs);
00349 TString &Prepend(const char *cs, Ssiz_t n);
00350 TString &Prepend(const TString &s);
00351 TString &Prepend(const TString &s, Ssiz_t n);
00352 TString &Prepend(char c, Ssiz_t rep = 1);
00353 istream &ReadFile(istream &str);
00354 istream &ReadLine(istream &str,
00355 Bool_t skipWhite = kTRUE);
00356 istream &ReadString(istream &str);
00357 istream &ReadToDelim(istream &str, char delim = '\n');
00358 istream &ReadToken(istream &str);
00359 TString &Remove(Ssiz_t pos);
00360 TString &Remove(Ssiz_t pos, Ssiz_t n);
00361 TString &Remove(EStripType s, char c);
00362 TString &Replace(Ssiz_t pos, Ssiz_t n, const char *s);
00363 TString &Replace(Ssiz_t pos, Ssiz_t n, const char *s, Ssiz_t ns);
00364 TString &Replace(Ssiz_t pos, Ssiz_t n, const TString &s);
00365 TString &Replace(Ssiz_t pos, Ssiz_t n1, const TString &s, Ssiz_t n2);
00366 TString &ReplaceAll(const TString &s1, const TString &s2);
00367 TString &ReplaceAll(const TString &s1, const char *s2);
00368 TString &ReplaceAll(const char *s1, const TString &s2);
00369 TString &ReplaceAll(const char *s1, const char *s2);
00370 TString &ReplaceAll(const char *s1, Ssiz_t ls1, const char *s2, Ssiz_t ls2);
00371 void Resize(Ssiz_t n);
00372 TSubString Strip(EStripType s = kTrailing, char c = ' ') const;
00373 void ToLower();
00374 void ToUpper();
00375 TObjArray *Tokenize(const TString &delim) const;
00376 Bool_t Tokenize(TString &tok, Ssiz_t &from, const char *delim = " ") const;
00377
00378
00379 static UInt_t Hash(const void *txt, Int_t ntxt);
00380 static Ssiz_t InitialCapacity(Ssiz_t ic = 15);
00381 static Ssiz_t MaxWaste(Ssiz_t mw = 15);
00382 static Ssiz_t ResizeIncrement(Ssiz_t ri = 16);
00383 static Ssiz_t GetInitialCapacity();
00384 static Ssiz_t GetResizeIncrement();
00385 static Ssiz_t GetMaxWaste();
00386 static TString Format(const char *fmt, ...)
00387 #if defined(__GNUC__) && !defined(__CINT__)
00388 __attribute__((format(printf, 1, 2)))
00389 #endif
00390 ;
00391
00392 ClassDef(TString,1)
00393 };
00394
00395
00396 istream &operator>>(istream &str, TString &s);
00397 ostream &operator<<(ostream &str, const TString &s);
00398 #if defined(R__TEMPLATE_OVERLOAD_BUG)
00399 template <>
00400 #endif
00401 TBuffer &operator>>(TBuffer &buf, TString *&sp);
00402
00403 TString ToLower(const TString &s);
00404 TString ToUpper(const TString &s);
00405
00406 inline UInt_t Hash(const TString &s) { return s.Hash(); }
00407 inline UInt_t Hash(const TString *s) { return s->Hash(); }
00408 UInt_t Hash(const char *s);
00409
00410 extern char *Form(const char *fmt, ...)
00411 #if defined(__GNUC__) && !defined(__CINT__)
00412 __attribute__((format(printf, 1, 2)))
00413 #endif
00414 ;
00415 extern void Printf(const char *fmt, ...)
00416 #if defined(__GNUC__) && !defined(__CINT__)
00417 __attribute__((format(printf, 1, 2)))
00418 #endif
00419 ;
00420 extern char *Strip(const char *str, char c = ' ');
00421 extern char *StrDup(const char *str);
00422 extern char *Compress(const char *str);
00423 extern int EscChar(const char *src, char *dst, int dstlen, char *specchars,
00424 char escchar);
00425 extern int UnEscChar(const char *src, char *dst, int dstlen, char *specchars,
00426 char escchar);
00427
00428 #ifdef NEED_STRCASECMP
00429 extern int strcasecmp(const char *str1, const char *str2);
00430 extern int strncasecmp(const char *str1, const char *str2, Ssiz_t n);
00431 #endif
00432
00433
00434
00435
00436
00437
00438
00439
00440 inline void TStringRef::UnLink()
00441 { if (RemoveReference() == 0) delete [] (char*)this; }
00442
00443 inline void TString::Cow()
00444 { if (Pref()->References() > 1) Clone(); }
00445
00446 inline void TString::Cow(Ssiz_t nc)
00447 { if (Pref()->References() > 1 || Capacity() < nc) Clone(nc); }
00448
00449 inline TString &TString::Append(const char *cs)
00450 { return Replace(Length(), 0, cs, cs ? strlen(cs) : 0); }
00451
00452 inline TString &TString::Append(const char *cs, Ssiz_t n)
00453 { return Replace(Length(), 0, cs, n); }
00454
00455 inline TString &TString::Append(const TString &s)
00456 { return Replace(Length(), 0, s.Data(), s.Length()); }
00457
00458 inline TString &TString::Append(const TString &s, Ssiz_t n)
00459 { return Replace(Length(), 0, s.Data(), TMath::Min(n, s.Length())); }
00460
00461 inline TString &TString::operator+=(const char *cs)
00462 { return Append(cs, cs ? strlen(cs) : 0); }
00463
00464 inline TString &TString::operator+=(const TString &s)
00465 { return Append(s.Data(), s.Length()); }
00466
00467 inline TString &TString::operator+=(char c)
00468 { return Append(c); }
00469
00470 inline TString &TString::operator+=(Long_t i)
00471 { char s[32]; sprintf(s, "%ld", i); return operator+=(s); }
00472
00473 inline TString &TString::operator+=(ULong_t i)
00474 { char s[32]; sprintf(s, "%lu", i); return operator+=(s); }
00475
00476 inline TString &TString::operator+=(Short_t i)
00477 { return operator+=((Long_t) i); }
00478
00479 inline TString &TString::operator+=(UShort_t i)
00480 { return operator+=((ULong_t) i); }
00481
00482 inline TString &TString::operator+=(Int_t i)
00483 { return operator+=((Long_t) i); }
00484
00485 inline TString &TString::operator+=(UInt_t i)
00486 { return operator+=((ULong_t) i); }
00487
00488 inline TString &TString::operator+=(Double_t f)
00489 { char s[32]; sprintf(s, "%.17g", f); return operator+=(s); }
00490
00491 inline TString &TString::operator+=(Float_t f)
00492 { return operator+=((Double_t) f); }
00493
00494 inline TString &TString::operator+=(Long64_t l)
00495 { char s[32]; sprintf(s, "%lld", l); return operator+=(s); }
00496
00497 inline TString &TString::operator+=(ULong64_t ul)
00498 { char s[32]; sprintf(s, "%llu", ul); return operator+=(s); }
00499
00500 inline Bool_t TString::BeginsWith(const char *s, ECaseCompare cmp) const
00501 { return Index(s, s ? strlen(s) : (Ssiz_t)0, (Ssiz_t)0, cmp) == 0; }
00502
00503 inline Bool_t TString::BeginsWith(const TString &pat, ECaseCompare cmp) const
00504 { return Index(pat.Data(), pat.Length(), (Ssiz_t)0, cmp) == 0; }
00505
00506 inline Bool_t TString::Contains(const TString &pat, ECaseCompare cmp) const
00507 { return Index(pat.Data(), pat.Length(), (Ssiz_t)0, cmp) != kNPOS; }
00508
00509 inline Bool_t TString::Contains(const char *s, ECaseCompare cmp) const
00510 { return Index(s, s ? strlen(s) : 0, (Ssiz_t)0, cmp) != kNPOS; }
00511
00512 inline Bool_t TString::Contains(const TRegexp &pat) const
00513 { return Index(pat, (Ssiz_t)0) != kNPOS; }
00514
00515 inline Bool_t TString::Contains(TPRegexp &pat) const
00516 { return Index(pat, (Ssiz_t)0) != kNPOS; }
00517
00518 inline Ssiz_t TString::Index(const char *s, Ssiz_t i, ECaseCompare cmp) const
00519 { return Index(s, s ? strlen(s) : 0, i, cmp); }
00520
00521 inline Ssiz_t TString::Index(const TString &s, Ssiz_t i, ECaseCompare cmp) const
00522 { return Index(s.Data(), s.Length(), i, cmp); }
00523
00524 inline Ssiz_t TString::Index(const TString &pat, Ssiz_t patlen, Ssiz_t i,
00525 ECaseCompare cmp) const
00526 { return Index(pat.Data(), patlen, i, cmp); }
00527
00528 inline TString &TString::Insert(Ssiz_t pos, const char *cs)
00529 { return Replace(pos, 0, cs, cs ? strlen(cs) : 0); }
00530
00531 inline TString &TString::Insert(Ssiz_t pos, const char *cs, Ssiz_t n)
00532 { return Replace(pos, 0, cs, n); }
00533
00534 inline TString &TString::Insert(Ssiz_t pos, const TString &s)
00535 { return Replace(pos, 0, s.Data(), s.Length()); }
00536
00537 inline TString &TString::Insert(Ssiz_t pos, const TString &s, Ssiz_t n)
00538 { return Replace(pos, 0, s.Data(), TMath::Min(n, s.Length())); }
00539
00540 inline TString &TString::Prepend(const char *cs)
00541 { return Replace(0, 0, cs, cs ? strlen(cs) : 0); }
00542
00543 inline TString &TString::Prepend(const char *cs, Ssiz_t n)
00544 { return Replace(0, 0, cs, n); }
00545
00546 inline TString &TString::Prepend(const TString &s)
00547 { return Replace(0, 0, s.Data(), s.Length()); }
00548
00549 inline TString &TString::Prepend(const TString &s, Ssiz_t n)
00550 { return Replace(0, 0, s.Data(), TMath::Min(n, s.Length())); }
00551
00552 inline TString &TString::Remove(Ssiz_t pos)
00553 { return Replace(pos, TMath::Max(0, Length()-pos), 0, 0); }
00554
00555 inline TString &TString::Remove(Ssiz_t pos, Ssiz_t n)
00556 { return Replace(pos, n, 0, 0); }
00557
00558 inline TString &TString::Chop()
00559 { return Remove(TMath::Max(0, Length()-1)); }
00560
00561 inline TString &TString::Replace(Ssiz_t pos, Ssiz_t n, const char *cs)
00562 { return Replace(pos, n, cs, cs ? strlen(cs) : 0); }
00563
00564 inline TString &TString::Replace(Ssiz_t pos, Ssiz_t n, const TString& s)
00565 { return Replace(pos, n, s.Data(), s.Length()); }
00566
00567 inline TString &TString::Replace(Ssiz_t pos, Ssiz_t n1, const TString &s,
00568 Ssiz_t n2)
00569 { return Replace(pos, n1, s.Data(), TMath::Min(s.Length(), n2)); }
00570
00571 inline TString &TString::ReplaceAll(const TString &s1, const TString &s2)
00572 { return ReplaceAll(s1.Data(), s1.Length(), s2.Data(), s2.Length()) ; }
00573
00574 inline TString &TString::ReplaceAll(const TString &s1, const char *s2)
00575 { return ReplaceAll(s1.Data(), s1.Length(), s2, s2 ? strlen(s2) : 0); }
00576
00577 inline TString &TString::ReplaceAll(const char *s1, const TString &s2)
00578 { return ReplaceAll(s1, s1 ? strlen(s1) : 0, s2.Data(), s2.Length()); }
00579
00580 inline TString &TString::ReplaceAll(const char *s1,const char *s2)
00581 { return ReplaceAll(s1, s1 ? strlen(s1) : 0, s2, s2 ? strlen(s2) : 0); }
00582
00583 inline char &TString::operator()(Ssiz_t i)
00584 { Cow(); return fData[i]; }
00585
00586 inline char TString::operator[](Ssiz_t i) const
00587 { AssertElement(i); return fData[i]; }
00588
00589 inline char TString::operator()(Ssiz_t i) const
00590 { return fData[i]; }
00591
00592 inline const char *TSubString::Data() const
00593 {
00594
00595
00596
00597
00598
00599
00600
00601
00602
00603
00604
00605
00606
00607
00608 return fStr.Data() + fBegin;
00609 }
00610
00611
00612 inline char TSubString::operator[](Ssiz_t i) const
00613 { AssertElement(i); return fStr.fData[fBegin+i]; }
00614
00615 inline char TSubString::operator()(Ssiz_t i) const
00616 { return fStr.fData[fBegin+i]; }
00617
00618 inline TSubString &TSubString::operator=(const TSubString &s)
00619 { fStr = s.fStr; fBegin = s.fBegin; fExtent = s.fExtent; return *this; }
00620
00621
00622
00623 #if !defined(R__ALPHA)
00624 inline Bool_t operator==(const TString &s1, const TString &s2)
00625 {
00626 return ((s1.Length() == s2.Length()) &&
00627 !memcmp(s1.Data(), s2.Data(), s1.Length()));
00628 }
00629 #endif
00630
00631 inline Bool_t operator!=(const TString &s1, const TString &s2)
00632 { return !(s1 == s2); }
00633
00634 inline Bool_t operator<(const TString &s1, const TString &s2)
00635 { return s1.CompareTo(s2) < 0; }
00636
00637 inline Bool_t operator>(const TString &s1, const TString &s2)
00638 { return s1.CompareTo(s2) > 0; }
00639
00640 inline Bool_t operator<=(const TString &s1, const TString &s2)
00641 { return s1.CompareTo(s2) <= 0; }
00642
00643 inline Bool_t operator>=(const TString &s1, const TString &s2)
00644 { return s1.CompareTo(s2) >= 0; }
00645
00646
00647 inline Bool_t operator!=(const TString &s1, const char *s2)
00648 { return !(s1 == s2); }
00649
00650 inline Bool_t operator<(const TString &s1, const char *s2)
00651 { return s1.CompareTo(s2) < 0; }
00652
00653 inline Bool_t operator>(const TString &s1, const char *s2)
00654 { return s1.CompareTo(s2) > 0; }
00655
00656 inline Bool_t operator<=(const TString &s1, const char *s2)
00657 { return s1.CompareTo(s2) <= 0; }
00658
00659 inline Bool_t operator>=(const TString &s1, const char *s2)
00660 { return s1.CompareTo(s2) >= 0; }
00661
00662 inline Bool_t operator==(const char *s1, const TString &s2)
00663 { return (s2 == s1); }
00664
00665 inline Bool_t operator!=(const char *s1, const TString &s2)
00666 { return !(s2 == s1); }
00667
00668 inline Bool_t operator<(const char *s1, const TString &s2)
00669 { return s2.CompareTo(s1) > 0; }
00670
00671 inline Bool_t operator>(const char *s1, const TString &s2)
00672 { return s2.CompareTo(s1) < 0; }
00673
00674 inline Bool_t operator<=(const char *s1, const TString &s2)
00675 { return s2.CompareTo(s1) >= 0; }
00676
00677 inline Bool_t operator>=(const char *s1, const TString &s2)
00678 { return s2.CompareTo(s1) <= 0; }
00679
00680
00681
00682
00683
00684 inline Bool_t operator==(const TString &s1, const TSubString &s2)
00685 { return (s2 == s1); }
00686
00687 inline Bool_t operator==(const char *s1, const TSubString &s2)
00688 { return (s2 == s1); }
00689
00690 inline Bool_t operator!=(const TSubString &s1, const char *s2)
00691 { return !(s1 == s2); }
00692
00693 inline Bool_t operator!=(const TSubString &s1, const TString &s2)
00694 { return !(s1 == s2); }
00695
00696 inline Bool_t operator!=(const TSubString &s1, const TSubString &s2)
00697 { return !(s1 == s2); }
00698
00699 inline Bool_t operator!=(const TString &s1, const TSubString &s2)
00700 { return !(s2 == s1); }
00701
00702 inline Bool_t operator!=(const char *s1, const TSubString &s2)
00703 { return !(s2 == s1); }
00704
00705 #endif