TBuffer


class description - source file - inheritance tree

class TBuffer : public TObject


    protected:
TBuffer TBuffer() TBuffer TBuffer(TBuffer&) void CheckCount(UInt_t offset) UInt_t CheckObject(UInt_t offset, TClass* cl, Bool_t readClass = kFALSE) void Expand(Int_t newsize) void operator=(TBuffer&) virtual void Read(Text_t* name) virtual void Write(Text_t* name, Int_t opt, Int_t bufs) public:
TBuffer TBuffer(TBuffer::EMode mode, Int_t bufsiz = kInitialSize, void* buf = 0) virtual void ~TBuffer() char* Buffer() Int_t BufferSize() void CheckByteCount(UInt_t startpos, UInt_t bcnt, TClass* clss) TClass* Class() void DetachBuffer() Int_t GetGlobalReadParam() Int_t GetGlobalWriteParam() void InitMap() virtual TClass* IsA() Bool_t IsReading() Bool_t IsWriting() Int_t Length() void MapObject(TObject* obj, UInt_t offset = 1) TBuffer& operator<<(Char_t c) TBuffer& operator<<(UChar_t c) TBuffer& operator<<(Short_t h) TBuffer& operator<<(UShort_t h) TBuffer& operator<<(Int_t i) TBuffer& operator<<(UInt_t i) TBuffer& operator<<(Long_t l) TBuffer& operator<<(ULong_t l) TBuffer& operator<<(Float_t f) TBuffer& operator<<(Double_t d) TBuffer& operator<<(Char_t* c) TBuffer& operator>>(Char_t& c) TBuffer& operator>>(UChar_t& c) TBuffer& operator>>(Short_t& h) TBuffer& operator>>(UShort_t& h) TBuffer& operator>>(Int_t& i) TBuffer& operator>>(UInt_t& i) TBuffer& operator>>(Long_t& l) TBuffer& operator>>(ULong_t& l) TBuffer& operator>>(Float_t& f) TBuffer& operator>>(Double_t& d) TBuffer& operator>>(Char_t* c) Int_t ReadArray(Char_t*& c) Int_t ReadArray(UChar_t*& c) Int_t ReadArray(Short_t*& h) Int_t ReadArray(UShort_t*& h) Int_t ReadArray(Int_t*& i) Int_t ReadArray(UInt_t*& i) Int_t ReadArray(Long_t*& l) Int_t ReadArray(ULong_t*& l) Int_t ReadArray(Float_t*& f) Int_t ReadArray(Double_t*& d) Int_t ReadBuf(void* buf, Int_t max) TClass* ReadClass(TClass* cl = 0, UInt_t* objTag = 0) void ReadFastArray(Char_t* c, Int_t n) void ReadFastArray(UChar_t* c, Int_t n) void ReadFastArray(Short_t* h, Int_t n) void ReadFastArray(UShort_t* h, Int_t n) void ReadFastArray(Int_t* i, Int_t n) void ReadFastArray(UInt_t* i, Int_t n) void ReadFastArray(Long_t* l, Int_t n) void ReadFastArray(ULong_t* l, Int_t n) void ReadFastArray(Float_t* f, Int_t n) void ReadFastArray(Double_t* d, Int_t n) TObject* ReadObject(TClass* cl) Int_t ReadStaticArray(Char_t* c) Int_t ReadStaticArray(UChar_t* c) Int_t ReadStaticArray(Short_t* h) Int_t ReadStaticArray(UShort_t* h) Int_t ReadStaticArray(Int_t* i) Int_t ReadStaticArray(UInt_t* i) Int_t ReadStaticArray(Long_t* l) Int_t ReadStaticArray(ULong_t* l) Int_t ReadStaticArray(Float_t* f) Int_t ReadStaticArray(Double_t* d) Text_t* ReadString(Text_t* s, Int_t max) Version_t ReadVersion(UInt_t* start = 0, UInt_t* bcnt = 0) virtual void Reset() void ResetMap() void SetBufferOffset(Int_t offset = 0) void SetByteCount(UInt_t cntpos, Bool_t packInVersion = kFALSE) void SetGlobalReadParam(Int_t mapsize) void SetGlobalWriteParam(Int_t mapsize) void SetReadMode() void SetReadParam(Int_t mapsize) void SetWriteMode() void SetWriteParam(Int_t mapsize) virtual void ShowMembers(TMemberInspector& insp, char* parent) virtual void Streamer(TBuffer& b) void WriteArray(Char_t* c, Int_t n) void WriteArray(UChar_t* c, Int_t n) void WriteArray(Short_t* h, Int_t n) void WriteArray(UShort_t* h, Int_t n) void WriteArray(Int_t* i, Int_t n) void WriteArray(UInt_t* i, Int_t n) void WriteArray(Long_t* l, Int_t n) void WriteArray(ULong_t* l, Int_t n) void WriteArray(Float_t* f, Int_t n) void WriteArray(Double_t* d, Int_t n) void WriteBuf(void* buf, Int_t max) void WriteClass(TClass* cl) void WriteFastArray(Char_t* c, Int_t n) void WriteFastArray(UChar_t* c, Int_t n) void WriteFastArray(Short_t* h, Int_t n) void WriteFastArray(UShort_t* h, Int_t n) void WriteFastArray(Int_t* i, Int_t n) void WriteFastArray(UInt_t* i, Int_t n) void WriteFastArray(Long_t* l, Int_t n) void WriteFastArray(ULong_t* l, Int_t n) void WriteFastArray(Float_t* f, Int_t n) void WriteFastArray(Double_t* d, Int_t n) void WriteObject(TObject* obj) void WriteString(Text_t* s) UInt_t WriteVersion(TClass* cl, Bool_t useBcnt = kFALSE)

Data Members

protected:
Bool_t fMode Read or write mode Int_t fVersion Buffer format version Int_t fBufSize Size of buffer char* fBuffer Buffer used to store objects char* fBufCur Current position in buffer char* fBufMax End of buffer Int_t fMapCount Number of objects or classes in map Int_t fMapSize Default size of map TExMap* fReadMap Map containing id,object references during reading TExMap* fWriteMap Map containing object,id pairs during writing static Int_t fgMapSize Default map size for all TBuffer objects public:
static const TBuffer::EMode kRead static const TBuffer::EMode kWrite static const enum TObject:: kInitialSize static const enum TObject:: kMinimalSize static const enum TObject:: kMapSize


See also

TMessage

Class Description

                                                                      
 TBuffer                                                              
                                                                      
 Buffer base class used for serializing objects.                      
                                                                      


TBuffer(EMode mode, Int_t bufsiz, void *buf)
 Create an I/O buffer object. Mode should be either TBuffer::kRead or
 TBuffer::kWrite. By default the I/O buffer has a size of
 TBuffer::kInitialSize (1024) bytes.

~TBuffer()
 Delete an I/O buffer object.

void CheckCount(UInt_t offset)
 Check if offset is not too large (< kMaxMapCount) when writing.

UInt_t CheckObject(UInt_t offset, const TClass *cl, Bool_t readClass)
 Check for object in the read map. If the object is 0 it still has to be
 read. Try to read it from the buffer starting at location offset. If the
 object is -1 then it really does not exist and we return 0. If the object
 exists just return the offset.

void Expand(Int_t newsize)
 Expand the I/O buffer to newsize bytes.

void MapObject(const TObject *obj, UInt_t offset)
 Add object to the fWriteMap or fReadMap containers (depending on the mode).
 If obj is not 0 add object to the map (in read mode also add 0 objects to
 the map). This method may only be called outside this class just before
 calling obj->Streamer() to prevent self reference of obj, in case obj
 contains (via via) a pointer to itself. In that case offset must be 1
 (default value for offset).

void SetReadParam(Int_t mapsize)
 Set the initial size of the map used to store object and class
 references during reading. The default size is kMapSize=67.
 Increasing the default has the benefit that when reading many
 small objects the map does not need to be resized too often
 (the system is always dynamic, even with the default everything
 will work, only the initial resizing will cost some time).
 This method can only be called directly after the creation of
 the TBuffer, before any reading is done. Globally this option
 can be changed using SetGlobalReadParam().

void SetWriteParam(Int_t mapsize)
 Set the initial size of the hashtable used to store object and class
 references during writing. The default size is kMapSize=67.
 Increasing the default has the benefit that when writing many
 small objects the hashtable does not get too many collisions
 (the system is always dynamic, even with the default everything
 will work, only a large number of collisions will cost performance).
 For optimal performance hashsize should always be a prime.
 This method can only be called directly after the creation of
 the TBuffer, before any writing is done. Globally this option
 can be changed using SetGlobalWriteParam().

void InitMap()
 Create the fWriteMap or fReadMap containers and initialize them
 with the null object.

void ResetMap()
 Delete existing fWriteMap or fReadMap and reset map counter.

void SetByteCount(UInt_t cntpos, Bool_t packInVersion)
 Set byte count at position cntpos in the buffer. Generate warning if
 count larger than kMaxMapCount. The count is excluded its own size.

void CheckByteCount(UInt_t startpos, UInt_t bcnt, const TClass *clss)
 Check byte count with current buffer position. They should
 match. If not print warning and position buffer in correct
 place determined by the byte count. Startpos is position of
 first byte where the byte count is written in buffer.

Int_t ReadBuf(void *buf, Int_t max)
 Read max bytes from the I/O buffer into buf. The function returns
 the actual number of bytes read. The buffer buf is advanced by
 the number of bytes read.

void WriteBuf(const void *buf, Int_t max)
 Write max bytes from buf into the I/O buffer. The buffer buf is advanced
 by the number of bytes (max) written.

Text_t* ReadString(Text_t *s, Int_t max)
 Read string from I/O buffer. String is read till 0 character is
 found or till max-1 characters are read (i.e. string s has max
 bytes allocated).

void WriteString(const Text_t *s)
 Write string to I/O buffer. Writes string upto and including the
 terminating 0.

Int_t ReadArray(Char_t *&c)
 Read array of characters from the I/O buffer. Returns the number of
 characters read. If argument is a 0 pointer then space will be
 allocated for the array.

Int_t ReadArray(Short_t *&h)
 Read array of shorts from the I/O buffer. Returns the number of shorts
 read. If argument is a 0 pointer then space will be allocated for the
 array.

Int_t ReadArray(Int_t *&ii)
 Read array of ints from the I/O buffer. Returns the number of ints
 read. If argument is a 0 pointer then space will be allocated for the
 array.

Int_t ReadArray(Long_t *&ll)
 Read array of longs from the I/O buffer. Returns the number of longs
 read. If argument is a 0 pointer then space will be allocated for the
 array.

Int_t ReadArray(Float_t *&f)
 Read array of floats from the I/O buffer. Returns the number of floats
 read. If argument is a 0 pointer then space will be allocated for the
 array.

Int_t ReadArray(Double_t *&d)
 Read array of doubles from the I/O buffer. Returns the number of doubles
 read. If argument is a 0 pointer then space will be allocated for the
 array.

Int_t ReadStaticArray(Char_t *c)
 Read array of characters from the I/O buffer. Returns the number of
 characters read.

Int_t ReadStaticArray(Short_t *h)
 Read array of shorts from the I/O buffer. Returns the number of shorts
 read.

Int_t ReadStaticArray(Int_t *ii)
 Read array of ints from the I/O buffer. Returns the number of ints
 read.

Int_t ReadStaticArray(Long_t *ll)
 Read array of longs from the I/O buffer. Returns the number of longs
 read.

Int_t ReadStaticArray(Float_t *f)
 Read array of floats from the I/O buffer. Returns the number of floats
 read.

Int_t ReadStaticArray(Double_t *d)
 Read array of doubles from the I/O buffer. Returns the number of doubles
 read.

void ReadFastArray(Char_t *c, Int_t n)
 Read array of n characters from the I/O buffer.

void ReadFastArray(Short_t *h, Int_t n)
 Read array of n shorts from the I/O buffer.

void ReadFastArray(Int_t *ii, Int_t n)
 Read array of n ints from the I/O buffer.

void ReadFastArray(Long_t *ll, Int_t n)
 Read array of n longs from the I/O buffer.

void ReadFastArray(Float_t *f, Int_t n)
 Read array of n floats from the I/O buffer.

void ReadFastArray(Double_t *d, Int_t n)
 Read array of n doubles from the I/O buffer.

void WriteArray(const Char_t *c, Int_t n)
 Write array of n characters into the I/O buffer.

void WriteArray(const Short_t *h, Int_t n)
 Write array of n shorts into the I/O buffer.

void WriteArray(const Int_t *ii, Int_t n)
 Write array of n ints into the I/O buffer.

void WriteArray(const Long_t *ll, Int_t n)
 Write array of n longs into the I/O buffer.

void WriteArray(const Float_t *f, Int_t n)
 Write array of n floats into the I/O buffer.

void WriteArray(const Double_t *d, Int_t n)
 Write array of n doubles into the I/O buffer.

void WriteFastArray(const Char_t *c, Int_t n)
 Write array of n characters into the I/O buffer.

void WriteFastArray(const Short_t *h, Int_t n)
 Write array of n shorts into the I/O buffer.

void WriteFastArray(const Int_t *ii, Int_t n)
 Write array of n ints into the I/O buffer.

void WriteFastArray(const Long_t *ll, Int_t n)
 Write array of n longs into the I/O buffer.

void WriteFastArray(const Float_t *f, Int_t n)
 Write array of n floats into the I/O buffer.

void WriteFastArray(const Double_t *d, Int_t n)
 Write array of n doubles into the I/O buffer.

TObject* ReadObject(const TClass *clReq)
 Read object from I/O buffer. clReq can be used to cross check
 if the actually read object is of the requested class.

void WriteObject(const TObject *obj)
 Write object to I/O buffer.

TClass* ReadClass(const TClass *clReq, UInt_t *objTag)
 Read class definition from I/O buffer. clReq can be used to cross check
 if the actually read object is of the requested class. objTag is
 set in case the object is a reference to an already read object.

void WriteClass(const TClass *cl)
 Write class description to I/O buffer.

Version_t ReadVersion(UInt_t *startpos, UInt_t *bcnt)
 Read class version from I/O buffer.

UInt_t WriteVersion(const TClass *cl, Bool_t useBcnt)
 Write class version to I/O buffer.

void SetGlobalReadParam(Int_t mapsize)
 Set the initial size of the map used to store object and class
 references during reading. The default size is kMapSize=67.
 Increasing the default has the benefit that when reading many
 small objects the array does not need to be resized too often
 (the system is always dynamic, even with the default everything
 will work, only the initial resizing will cost some time).
 Per TBuffer object this option can be changed using SetReadParam().

void SetGlobalWriteParam(Int_t mapsize)
 Set the initial size of the hashtable used to store object and class
 references during writing. The default size is kMapSize=67.
 Increasing the default has the benefit that when writing many
 small objects the hashtable does not get too many collisions
 (the system is always dynamic, even with the default everything
 will work, only a large number of collisions will cost performance).
 For optimal performance hashsize should always be a prime.
 Per TBuffer object this option can be changed using SetWriteParam().

Int_t GetGlobalReadParam()
 Get default read map size.

Int_t GetGlobalWriteParam()
 Get default write map size.

void SetReadMode()
 Set buffer in read mode.

void SetWriteMode()
 Set buffer in write mode.



Inline Functions


            TBuffer TBuffer(TBuffer&)
               void operator=(TBuffer&)
               void Read(Text_t* name)
               void Write(Text_t* name, Int_t opt, Int_t bufs)
            TBuffer TBuffer(TBuffer::EMode mode, Int_t bufsiz = kInitialSize, void* buf = 0)
               void Reset()
               void SetBufferOffset(Int_t offset = 0)
              char* Buffer()
              Int_t BufferSize()
               void DetachBuffer()
              Int_t Length()
             Bool_t IsReading()
             Bool_t IsWriting()
              Int_t ReadArray(Long_t*& l)
              Int_t ReadArray(ULong_t*& l)
              Int_t ReadArray(Float_t*& f)
              Int_t ReadArray(Double_t*& d)
              Int_t ReadStaticArray(Long_t* l)
              Int_t ReadStaticArray(ULong_t* l)
              Int_t ReadStaticArray(Float_t* f)
              Int_t ReadStaticArray(Double_t* d)
               void WriteArray(Long_t* l, Int_t n)
               void WriteArray(ULong_t* l, Int_t n)
               void WriteArray(Float_t* f, Int_t n)
               void WriteArray(Double_t* d, Int_t n)
               void ReadFastArray(Long_t* l, Int_t n)
               void ReadFastArray(ULong_t* l, Int_t n)
               void ReadFastArray(Float_t* f, Int_t n)
               void ReadFastArray(Double_t* d, Int_t n)
               void WriteFastArray(Long_t* l, Int_t n)
               void WriteFastArray(ULong_t* l, Int_t n)
               void WriteFastArray(Float_t* f, Int_t n)
               void WriteFastArray(Double_t* d, Int_t n)
           TBuffer& operator>>(Char_t& c)
           TBuffer& operator>>(UChar_t& c)
           TBuffer& operator>>(Short_t& h)
           TBuffer& operator>>(UShort_t& h)
           TBuffer& operator>>(Int_t& i)
           TBuffer& operator>>(UInt_t& i)
           TBuffer& operator>>(Long_t& l)
           TBuffer& operator>>(ULong_t& l)
           TBuffer& operator>>(Float_t& f)
           TBuffer& operator>>(Double_t& d)
           TBuffer& operator>>(Char_t* c)
           TBuffer& operator<<(Char_t c)
           TBuffer& operator<<(UChar_t c)
           TBuffer& operator<<(Short_t h)
           TBuffer& operator<<(UShort_t h)
           TBuffer& operator<<(Int_t i)
           TBuffer& operator<<(UInt_t i)
           TBuffer& operator<<(Long_t l)
           TBuffer& operator<<(ULong_t l)
           TBuffer& operator<<(Float_t f)
           TBuffer& operator<<(Double_t d)
           TBuffer& operator<<(Char_t* c)
            TClass* Class()
            TClass* IsA()
               void ShowMembers(TMemberInspector& insp, char* parent)
               void Streamer(TBuffer& b)


Author: Fons Rademakers 04/05/96
Last update: 2.22/08 06/07/99 19.17.41 by Fons Rademakers
Copyright (c) 1995-1999, The ROOT System, All rights reserved. *


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.