TString


class description - source file - inheritance tree

class TString

    private:
void Clone() void Clone(Ssiz_t nc) protected:
TString TString(const char* a1, Ssiz_t n1, const char* a2, Ssiz_t n2) static Ssiz_t AdjustCapacity(Ssiz_t nc) void AssertElement(Ssiz_t nc) const void Clobber(Ssiz_t nc) void Cow() void Cow(Ssiz_t nc) void InitChar(char c) TStringRef* Pref() const public:
TString TString() TString TString(Ssiz_t ic) TString TString(const TString& s) TString TString(const char* s) TString TString(const char* s, Ssiz_t n) TString TString(char c) TString TString(char c, Ssiz_t s) TString TString(const TSubString& sub) TString Copy() const virtual void ~TString() TString& Append(const char* cs) TString& Append(const char* cs, Ssiz_t n) TString& Append(const TString& s) TString& Append(const TString& s, Ssiz_t n) TString& Append(char c, Ssiz_t rep = 1) Bool_t BeginsWith(const char* s, TString::ECaseCompare cmp = kExact) const Bool_t BeginsWith(const TString& pat, TString::ECaseCompare cmp = kExact) const Ssiz_t Capacity() const Ssiz_t Capacity(Ssiz_t n) TString& Chop() static TClass* Class() int CompareTo(const char* cs, TString::ECaseCompare cmp = kExact) const int CompareTo(const TString& st, TString::ECaseCompare cmp = kExact) const Bool_t Contains(const char* pat, TString::ECaseCompare cmp = kExact) const Bool_t Contains(const TString& pat, TString::ECaseCompare cmp = kExact) const Bool_t Contains(const TRegexp& pat) const Int_t CountChar(Int_t c) const const char* Data() const Bool_t EndsWith(const char* pat, TString::ECaseCompare cmp = kExact) const virtual void FillBuffer(char*& buffer) Ssiz_t First(char c) const Ssiz_t First(const char* cs) const static Ssiz_t GetInitialCapacity() static Ssiz_t GetMaxWaste() static Ssiz_t GetResizeIncrement() unsigned int Hash(TString::ECaseCompare cmp = kExact) const Ssiz_t Index(const char* pat, Ssiz_t i = 0, TString::ECaseCompare cmp = kExact) const Ssiz_t Index(const TString& s, Ssiz_t i = 0, TString::ECaseCompare cmp = kExact) const Ssiz_t Index(const char* pat, Ssiz_t patlen, Ssiz_t i, TString::ECaseCompare cmp) const Ssiz_t Index(const TString& s, Ssiz_t patlen, Ssiz_t i, TString::ECaseCompare cmp) const Ssiz_t Index(const TRegexp& pat, Ssiz_t i = 0) const Ssiz_t Index(const TRegexp& pat, Ssiz_t* ext, Ssiz_t i = 0) const static Ssiz_t InitialCapacity(Ssiz_t ic = 15) TString& Insert(Ssiz_t pos, const char* s) TString& Insert(Ssiz_t pos, const char* s, Ssiz_t extent) TString& Insert(Ssiz_t pos, const TString& s) TString& Insert(Ssiz_t pos, const TString& s, Ssiz_t extent) virtual TClass* IsA() const Bool_t IsAscii() const Bool_t IsNull() const Ssiz_t Last(char c) const Ssiz_t Length() const static Ssiz_t MaxWaste(Ssiz_t mw = 15) Bool_t MaybeRegexp() char* operator const char*() const char& operator()(Ssiz_t i) TSubString operator()(Ssiz_t start, Ssiz_t len) TSubString operator()(const TRegexp& re) TSubString operator()(const TRegexp& re, Ssiz_t start) char operator()(Ssiz_t i) const TSubString operator()(Ssiz_t start, Ssiz_t len) const TSubString operator()(const TRegexp& re) const TSubString operator()(const TRegexp& re, Ssiz_t start) const TString& operator+=(const char* s) TString& operator+=(const TString& s) TString& operator+=(char c) TString& operator+=(Short_t i) TString& operator+=(UShort_t i) TString& operator+=(Int_t i) TString& operator+=(UInt_t i) TString& operator+=(Long_t i) TString& operator+=(ULong_t i) TString& operator+=(Float_t f) TString& operator+=(Double_t f) TString& operator=(char s) TString& operator=(const char* s) TString& operator=(const TString& s) TString& operator=(const TSubString& s) char& operator[](Ssiz_t i) char operator[](Ssiz_t i) const TString& Prepend(const char* cs) TString& Prepend(const char* cs, Ssiz_t n) TString& Prepend(const TString& s) TString& Prepend(const TString& s, Ssiz_t n) TString& Prepend(char c, Ssiz_t rep = 1) virtual void ReadBuffer(char*& buffer) istream& ReadFile(istream& str) istream& ReadLine(istream& str, Bool_t skipWhite = kTRUE) static TString* ReadString(TBuffer& b, const TClass* clReq) istream& ReadString(istream& str) istream& ReadToDelim(istream& str, char delim = n) istream& ReadToken(istream& str) TString& Remove(Ssiz_t pos) TString& Remove(Ssiz_t pos, Ssiz_t n) TString& Replace(Ssiz_t pos, Ssiz_t n, const char* s) TString& Replace(Ssiz_t pos, Ssiz_t n, const char* s, Ssiz_t ns) TString& Replace(Ssiz_t pos, Ssiz_t n, const TString& s) TString& Replace(Ssiz_t pos, Ssiz_t n1, const TString& s, Ssiz_t n2) TString& ReplaceAll(const TString& s1, const TString& s2) TString& ReplaceAll(const TString& s1, const char* s2) TString& ReplaceAll(const char* s1, const TString& s2) TString& ReplaceAll(const char* s1, const char* s2) TString& ReplaceAll(const char* s1, Ssiz_t ls1, const char* s2, Ssiz_t ls2) void Resize(Ssiz_t n) static Ssiz_t ResizeIncrement(Ssiz_t ri = 16) virtual void ShowMembers(TMemberInspector& insp, char* parent) virtual Int_t Sizeof() const virtual void Streamer(TBuffer& b) void StreamerNVirtual(TBuffer& b) TSubString Strip(TString::EStripType s = kTrailing, char c = ) TSubString Strip(TString::EStripType s = kTrailing, char c = ) const TSubString SubString(const char* pat, Ssiz_t start = 0, TString::ECaseCompare cmp = kExact) TSubString SubString(const char* pat, Ssiz_t start = 0, TString::ECaseCompare cmp = kExact) const void ToLower() void ToUpper() static void WriteString(TBuffer& b, const TString* a)

Data Members

    private:
static Ssiz_t fgInitialCapac Initial allocation Capacity static Ssiz_t fgResizeInc Resizing increment static Ssiz_t fgFreeboard Max empty space before reclaim protected:
char* fData ref. counted data (TStringRef is in front) public:
static const TString::EStripType kLeading static const TString::EStripType kTrailing static const TString::EStripType kBoth static const TString::ECaseCompare kExact static const TString::ECaseCompare kIgnoreCase


See also

TStringLong

Class Description

                                                                      
 TString                                                              
                                                                      
 Basic string class.                                                  
                                                                      
 Cannot be stored in a TCollection... use TObjString instead.         
                                                                      


Ssiz_t GetInitialCapacity()

Ssiz_t GetResizeIncrement()

Ssiz_t GetMaxWaste()
______________________________________________________________________________

TString()
 TString default ctor.

TString(Ssiz_t ic)
 Create TString able to contain ic characters.

TString(const char* cs)
 Create TString and initialize it with string cs.

TString(const char* cs, Ssiz_t n)
 Create TString and initialize it with the first n characters of cs.

void InitChar(char c)
 Initialize a string with a single character.

TString(char c, Ssiz_t n)
 Initialize the first n locations of a TString with character c.

TString(const TSubString& substr)
 Copy a TSubString in a TString.

~TString()
 Delete a TString. I.e. decrease its reference count. When 0 free space.

TString Append(char c, Ssiz_t rep)
 Append character c rep times to string.

Ssiz_t Capacity(Ssiz_t nc)
 Return string capacity. If nc != current capacity Clone() the string
 in a string with the desired capacity.

int CompareTo(const char* cs2, ECaseCompare cmp) const
 Compare a string to char *cs2.

int CompareTo(const TString& str, ECaseCompare cmp) const
 Compare a string to another string.

Int_t CountChar(Int_t c) const
 Return number of times character c occurs in the string.

TString Copy() const
 Copy a string.

unsigned Hash(ECaseCompare cmp) const
 Return hash value.

Ssiz_t Index(const char* pattern, Ssiz_t plen, Ssiz_t startIndex, ECaseCompare cmp) const
 Search for a string in the TString. Plen is the length of pattern,
 startIndex is the index from which to start and cmp selects the type
 of case-comparison.

Bool_t MaybeRegexp()
 Returns true if string contains one of the regexp characters "^$.[]*+?".

TString Prepend(char c, Ssiz_t rep)
 Prepend characters to self.

TString Replace(Ssiz_t pos, Ssiz_t n1, const char* cs, Ssiz_t n2)
 Remove at most n1 characters from self beginning at pos,
 and replace them with the first n2 characters of cs.

TString ReplaceAll(const char *s1, Ssiz_t ls1, const char *s2, Ssiz_t ls2)
 Find & Replace ls1 symbols of s1 with ls2 symbols of s2 if any.

void Resize(Ssiz_t n)
 Resize the string. Truncate or add blanks as necessary.

TSubString Strip(EStripType st, char c)
 Return a substring of self stripped at beginning and/or end.

TSubString Strip(EStripType st, char c) const
 Just use the "non-const" version, adjusting the return type.

void ToLower()
 Change string to lower-case.

void ToUpper()
 Change string to upper case.

void AssertElement(Ssiz_t i) const
 Check to make sure a string index is in range.

TString(const char* a1, Ssiz_t n1, const char* a2, Ssiz_t n2)
 Special constructor to initialize with the concatenation of a1 and a2.

Ssiz_t AdjustCapacity(Ssiz_t nc)
 Calculate a nice capacity greater than or equal to nc.

void Clobber(Ssiz_t nc)
 Clear string and make sure it has a capacity of nc.

void Clone()
 Make string a distinct copy; preserve previous contents.

void Clone(Ssiz_t nc)
 Make self a distinct copy with capacity of at least nc.
 Preserve previous contents.

void FillBuffer(char *&buffer)
 Copy string into I/O buffer.

void ReadBuffer(char *&buffer)
 Read string from I/O buffer.

TString* ReadString(TBuffer &b, const TClass *clReq)
 Read TString object from buffer. Simplified version of
 TBuffer::ReadObject (does not keep track of multiple
 references to same string).  We need to have it here
 because TBuffer::ReadObject can only handle descendant
 of TObject

Int_t Sizeof() const
 Returns size string will occupy on I/O buffer.

void Streamer(TBuffer &b)
 Stream a string object

void WriteString(TBuffer &b, const TString *a)
 Write TString object to buffer. Simplified version of
 TBuffer::WriteObject (does not keep track of multiple
 references to the same string).  We need to have it here
 because TBuffer::ReadObject can only handle descendant
 of TObject

Ssiz_t InitialCapacity(Ssiz_t ic)
 Set default initial capacity for all TStrings. Default is 15.

Ssiz_t ResizeIncrement(Ssiz_t ri)
 Set default resize increment for all TStrings. Default is 16.

Ssiz_t MaxWaste(Ssiz_t mw)
 Set maximum space that may be wasted in a string before doing a resize.
 Default is 15.

TSubString SubString(const char* pattern, Ssiz_t startIndex, ECaseCompare cmp)
 Returns a substring matching "pattern", or the null substring
 if there is no such match.  It would be nice if this could be yet another
 overloaded version of operator(), but this would result in a type
 conversion ambiguity with operator(Ssiz_t, Ssiz_t).

TSubString SubString(const char* pattern, Ssiz_t startIndex, ECaseCompare cmp) const
 Return sub-string matching pattern, starting at index. Cmp selects
 the type of case conversion.

Bool_t IsAscii() const
 Return true if all characters in string are ascii.

Bool_t EndsWith(const char *s, ECaseCompare cmp) const



Inline Functions


        TStringRef* Pref() const
               void Cow()
               void Cow(Ssiz_t nc)
            TString TString(char c, Ssiz_t s)
            TString TString(const TSubString& sub)
              char* operator const char*() const
           TString& operator=(char s)
           TString& operator=(const char* s)
           TString& operator=(const TString& s)
           TString& operator=(const TSubString& s)
           TString& operator+=(const char* s)
           TString& operator+=(const TString& s)
           TString& operator+=(char c)
           TString& operator+=(Short_t i)
           TString& operator+=(UShort_t i)
           TString& operator+=(Int_t i)
           TString& operator+=(UInt_t i)
           TString& operator+=(Long_t i)
           TString& operator+=(ULong_t i)
           TString& operator+=(Float_t f)
           TString& operator+=(Double_t f)
              char& operator[](Ssiz_t i)
              char& operator()(Ssiz_t i)
         TSubString operator()(Ssiz_t start, Ssiz_t len)
         TSubString operator()(const TRegexp& re)
         TSubString operator()(const TRegexp& re, Ssiz_t start)
               char operator[](Ssiz_t i) const
               char operator()(Ssiz_t i) const
         TSubString operator()(Ssiz_t start, Ssiz_t len) const
         TSubString operator()(const TRegexp& re) const
         TSubString operator()(const TRegexp& re, Ssiz_t start) const
           TString& Append(const char* cs, Ssiz_t n)
           TString& Append(const TString& s)
           TString& Append(const TString& s, Ssiz_t n)
           TString& Append(char c, Ssiz_t rep = 1)
             Bool_t BeginsWith(const char* s, TString::ECaseCompare cmp = kExact) const
             Bool_t BeginsWith(const TString& pat, TString::ECaseCompare cmp = kExact) const
             Ssiz_t Capacity(Ssiz_t n)
           TString& Chop()
             Bool_t Contains(const char* pat, TString::ECaseCompare cmp = kExact) const
             Bool_t Contains(const TString& pat, TString::ECaseCompare cmp = kExact) const
             Bool_t Contains(const TRegexp& pat) const
        const char* Data() const
             Ssiz_t First(char c) const
             Ssiz_t First(const char* cs) const
             Ssiz_t Index(const TString& s, Ssiz_t i = 0, TString::ECaseCompare cmp = kExact) const
             Ssiz_t Index(const char* pat, Ssiz_t patlen, Ssiz_t i, TString::ECaseCompare cmp) const
             Ssiz_t Index(const TString& s, Ssiz_t patlen, Ssiz_t i, TString::ECaseCompare cmp) const
             Ssiz_t Index(const TRegexp& pat, Ssiz_t i = 0) const
             Ssiz_t Index(const TRegexp& pat, Ssiz_t* ext, Ssiz_t i = 0) const
           TString& Insert(Ssiz_t pos, const char* s)
           TString& Insert(Ssiz_t pos, const char* s, Ssiz_t extent)
           TString& Insert(Ssiz_t pos, const TString& s)
           TString& Insert(Ssiz_t pos, const TString& s, Ssiz_t extent)
             Bool_t IsNull() const
             Ssiz_t Last(char c) const
             Ssiz_t Length() const
           TString& Prepend(const char* cs, Ssiz_t n)
           TString& Prepend(const TString& s)
           TString& Prepend(const TString& s, Ssiz_t n)
           TString& Prepend(char c, Ssiz_t rep = 1)
           istream& ReadFile(istream& str)
           istream& ReadLine(istream& str, Bool_t skipWhite = kTRUE)
           istream& ReadString(istream& str)
           istream& ReadToDelim(istream& str, char delim = n)
           istream& ReadToken(istream& str)
           TString& Remove(Ssiz_t pos)
           TString& Remove(Ssiz_t pos, Ssiz_t n)
           TString& Replace(Ssiz_t pos, Ssiz_t n, const char* s, Ssiz_t ns)
           TString& Replace(Ssiz_t pos, Ssiz_t n, const TString& s)
           TString& Replace(Ssiz_t pos, Ssiz_t n1, const TString& s, Ssiz_t n2)
           TString& ReplaceAll(const TString& s1, const char* s2)
           TString& ReplaceAll(const char* s1, const TString& s2)
           TString& ReplaceAll(const char* s1, const char* s2)
           TString& ReplaceAll(const char* s1, Ssiz_t ls1, const char* s2, Ssiz_t ls2)
            TClass* Class()
            TClass* IsA() const
               void ShowMembers(TMemberInspector& insp, char* parent)
               void StreamerNVirtual(TBuffer& b)


Author: Fons Rademakers 04/08/95
Last update: root/base:$Name: $:$Id: TString.cxx,v 1.18 2002/12/05 15:31:03 rdm Exp $
Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *


ROOT page - Class index - Top of the page

This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.