| # Gaudi Framework, version v22r4 |

Home |  | Generated: Fri Sep 2 2011

Classes | Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Friends

# StreamBuffer Class Reference

The stream buffer is a small object collecting object data. More...

`#include <GaudiKernel/StreamBuffer.h>`

Collaboration diagram for StreamBuffer:
[legend]

List of all members.

## Classes
class | ContainedLink
| Definition of the contained link set. More...
class | DataIO
| A small base class to handle generic data streaming. More...
class | IdentifiedLink
| Definition of the contained link set. More...
class | Istream
| Reader for standard input streams. More...
class | Ostream
| Writer for standard output streams. More...
## Public Types
enum | Mode { UNINITIALIZED, READING, WRITING }
| Streamer mode. More...
enum | SwapAction { SINGLE_BYTE, SWAP, NOSWAP }
| Data Sawp actions. More...
enum | State { INVALID = -1, VALID }
| Link state defintions. More...
typedef std::vector < ContainedLink > | ContainedLinks
typedef std::vector < IdentifiedLink > | IdentifiedLinks
| Definition of the identifiable link set.
typedef void(* | AnalyzeFunction )(const void *data, int siz, const std::type_info &type)
| Definition of the buffer analyzer.
## Public Member Functions
| StreamBuffer (bool do_swap=true)
| Standard constructor.
virtual | ~StreamBuffer ()
| Standard destructor.
const char * | data () const
| Read access to data buffer.
char * | data ()
| write access to data buffer
void | erase ()
| Reset the buffer.
void | reserve (long len)
| Reserve buffer space; Default: 16 k buffer size.
void | extend (long len)
| Extend the buffer.
long | size () const
| Total buffer size.
ContainedLinks & | containedLinks ()
| Access to contained links.
const ContainedLinks & | containedLinks () const
| CONST Access to contained links.
IdentifiedLinks & | identifiedLinks ()
| Access to identified links.
const IdentifiedLinks & | identifiedLinks () const
| CONST Access to identified links.
void | setMode (Mode m)
| Set mode of the stream and allocate buffer.
bool | isReading () const
| Get stream buffer state.
bool | isWriting () const
| Get stream buffer state.
long | buffPointer () const
| Retrieve current buffer pointer.
void | setBuffPointer (long ptr)
| Retrieve current buffer pointer.
void | setAnalyzer (AnalyzeFunction fun=0)
| Enable user analysis function.
void | swapToBuffer (const void *source, int siz)
| Swap buffers: int, long, short, float and double.
void | swapFromBuffer (void *target, int siz)
| Swap buffers: int, long, short, float and double.
StreamBuffer & | writeBytes (const char *str, long len)
| Write string to output stream.
void | getIdentifiedLink (DataObject *&pObject, long &hint)
void | addIdentifiedLink (const DataObject *pObject, long hint)
void | getContainedLink (ContainedObject *&pObject, long &hint, long &link)
void | addContainedLink (const ContainedObject *pObject, long hint, long link)
StreamBuffer & | operator<< (longlong data)
| Output Streamer.
StreamBuffer & | operator>> (longlong &data)
| Input Streamer.
StreamBuffer & | operator<< (int data)
| Output Streamer.
StreamBuffer & | operator>> (int &data)
| Input Streamer.
StreamBuffer & | operator<< (unsigned int data)
| Output Streamer.
StreamBuffer & | operator>> (unsigned int &data)
| Input Streamer.
StreamBuffer & | operator<< (long data)
| Output Streamer.
StreamBuffer & | operator>> (long &data)
| Input Streamer.
StreamBuffer & | operator<< (unsigned long data)
| Output Streamer.
StreamBuffer & | operator>> (unsigned long &data)
| Input Streamer.
StreamBuffer & | operator<< (short data)
| Output Streamer.
StreamBuffer & | operator>> (short &data)
| Input Streamer.
StreamBuffer & | operator<< (unsigned short data)
| Output Streamer.
StreamBuffer & | operator>> (unsigned short &data)
| Input Streamer.
StreamBuffer & | operator<< (char data)
| Output Streamer.
StreamBuffer & | operator>> (char &data)
| Input Streamer.
StreamBuffer & | operator<< (unsigned char data)
| Output Streamer.
StreamBuffer & | operator>> (unsigned char &data)
| Input Streamer.
StreamBuffer & | operator<< (float data)
| Output Streamer.
StreamBuffer & | operator>> (float &data)
| Input Streamer.
StreamBuffer & | operator<< (double data)
| Output Streamer.
StreamBuffer & | operator>> (double &data)
| Input Streamer.
StreamBuffer & | operator>> (char *data)
| Streamer to read strings in (char*) format.
StreamBuffer & | operator<< (const char *data)
| Streamer to write strings in (char*) format.
StreamBuffer & | operator>> (std::string &data)
| Streamer to read strings in (std::string) format.
StreamBuffer & | operator<< (const std::string &data)
| Streamer to write strings in (std::string) format.
template<class TYPE >
StreamBuffer & | operator>> (TYPE *&refpObject)
| Streamer to read links to contained or identified objects.
StreamBuffer & | operator<< (const ContainedObject *pObject)
| Streamer to write links to contained objects.
StreamBuffer & | operator<< (const DataObject *pObject)
| Streamer to write links to identified objects.
void | serialize (DataIO &ioObject)
| Serialize the buffer using an IO object.
## Protected Member Functions
SwapAction | swapBuffer (int siz) const
| Check for byte swapping.
template<class TYPE >
StreamBuffer & | getObjectPointer (const DataObject *pObject, TYPE *&refpObject)
| Helper to distinguis between identified pointers and contained pointers.
template<class TYPE >
StreamBuffer & | getObjectPointer (const ContainedObject *pObject, TYPE *&refpObject)
| Helper to distinguis between identified pointers and contained pointers.
## Protected Attributes
Mode | m_mode
| Boolean indicating wether the stream is in read or write mode.
long | m_pointer
| Current buffer pointer.
long | m_length
| Total buffer length.
char * | m_buffer
| Pointer to heap buffer.
bool | m_swapEnabled
| Flag indicating swapping.
ContainedLinks | m_containedLinks
| Container with links to contained objects.
IdentifiedLinks | m_identifiedLinks
| Container with links to contained objects.
AnalyzeFunction | m_analyzer
| Hook function for analysis of data to the stream.
## Friends
class | DataObject
| DataObject is friend.

## Detailed Description

The stream buffer is a small object collecting object data.

The basic idea behind the StreamBuffer is generic object conversion. The StreamBuffer acts as a byte stream (hence inheriting from a std::string) and stores any information streamed to the buffer. Since the information must be represented in a generic way on the fly byte swapping is performed. However, not only primitive data can be stored in the buffer, but also pointers to DataObjects (symbolic links) and pointers to contained objects. Automatically during serialization the persistent references to the corresponding objects and containers must be stored. These objects are accessible from the StreamBuffer object.

"On the fly" data conversion to non persistent

Author:
  M.Frank

Definition at line 40 of file StreamBuffer.h.

## Member Typedef Documentation

typedef void(* StreamBuffer::AnalyzeFunction)(const void *data, int siz, const std::type_info &type)

Definition of the buffer analyzer.

Definition at line 153 of file StreamBuffer.h.

typedef std::vector<ContainedLink> StreamBuffer::ContainedLinks

Definition at line 149 of file StreamBuffer.h.

typedef std::vector<IdentifiedLink> StreamBuffer::IdentifiedLinks

Definition of the identifiable link set.

Definition at line 151 of file StreamBuffer.h.

## Member Enumeration Documentation

enum StreamBuffer::Mode

Streamer mode.

Enumerator:

  UNINITIALIZED |
  READING |
  WRITING |

Definition at line 114 of file StreamBuffer.h.

    {UNINITIALIZED, READING, WRITING};

enum StreamBuffer::State

Link state defintions.

Enumerator:

  INVALID |
  VALID |

Definition at line 118 of file StreamBuffer.h.

    {INVALID=-1, VALID };

enum StreamBuffer::SwapAction

Data Sawp actions.

Enumerator:

  SINGLE_BYTE |
  SWAP |
  NOSWAP |

Definition at line 116 of file StreamBuffer.h.

    {SINGLE_BYTE, SWAP, NOSWAP};

## Constructor & Destructor Documentation

StreamBuffer::StreamBuffer | ( | bool | do_swap = `true` ) | `[inline]`

Standard constructor.

Definition at line 207 of file StreamBuffer.h.

                                      :
        m_mode(UNINITIALIZED),
        m_pointer(0),
        m_length(0),
        m_buffer(0),
        m_swapEnabled(do_swap)
      {
        m_analyzer = 0;
      }

virtual StreamBuffer::~StreamBuffer | ( | ) | `[inline, virtual]`

Standard destructor.

Definition at line 217 of file StreamBuffer.h.

                                {
        ::free( m_buffer );
      }

## Member Function Documentation

void StreamBuffer::addContainedLink | ( | const ContainedObject * | pObject,
|  | long | hint,
|  | long | link
| ) |  | `[inline]`

Definition at line 332 of file StreamBuffer.h.

                                                                                     {
        m_containedLinks.push_back( ContainedLink((ContainedObject*)pObject, hint, link) );
      }

void StreamBuffer::addIdentifiedLink | ( | const DataObject * | pObject,
|  | long | hint
| ) |  | `[inline]`

Definition at line 321 of file StreamBuffer.h.

                                                                      {
        m_identifiedLinks.push_back( IdentifiedLink((DataObject*)pObject, hint) );
      }

long StreamBuffer::buffPointer | ( | ) | const`[inline]`

Retrieve current buffer pointer.

Definition at line 289 of file StreamBuffer.h.

                                    {
        return m_pointer;
      }

ContainedLinks& StreamBuffer::containedLinks | ( | ) | `[inline]`

Access to contained links.

Definition at line 254 of file StreamBuffer.h.

                                         {
        return m_containedLinks;
      }

const ContainedLinks& StreamBuffer::containedLinks | ( | ) | const`[inline]`

CONST Access to contained links.

Definition at line 258 of file StreamBuffer.h.

                                                     {
        return m_containedLinks;
      }

const char* StreamBuffer::data | ( | ) | const`[inline]`

Read access to data buffer.

Definition at line 221 of file StreamBuffer.h.

                                    {
        return m_buffer;
      }

char* StreamBuffer::data | ( | ) | `[inline]`

write access to data buffer

Definition at line 225 of file StreamBuffer.h.

                     {
        return m_buffer;
      }

void StreamBuffer::erase | ( | ) | `[inline]`

Reset the buffer.

Definition at line 229 of file StreamBuffer.h.

                      {
        m_pointer = 0;
      }

void StreamBuffer::extend | ( | long | len ) | `[inline]`

Extend the buffer.

Definition at line 240 of file StreamBuffer.h.

                               {
        if ( len + m_pointer > m_length )    {
          // We have to be a bit generous here in order not to run too often
          // into ::realloc().
            long new_len = (m_length < 16384) ? 16384 : 2*m_length;
          if ( m_length < len ) new_len += len;
          reserve(new_len);
        }
      }

void StreamBuffer::getContainedLink | ( | ContainedObject *& | pObject,
|  | long & | hint,
|  | long & | link
| ) |  | `[inline]`

Definition at line 325 of file StreamBuffer.h.

                                                                                  {
        ContainedLink& l = m_containedLinks.back();
        pObject = l.first;
        hint    = l.second;
        link    = l.third;
        m_containedLinks.pop_back();
      }

void StreamBuffer::getIdentifiedLink | ( | DataObject *& | pObject,
|  | long & | hint
| ) |  | `[inline]`

Definition at line 315 of file StreamBuffer.h.

                                                                  {
        IdentifiedLink& l = m_identifiedLinks.back();
        pObject = l.first;
        hint    = l.second;
        m_identifiedLinks.pop_back();
      }

template<class TYPE >

StreamBuffer& StreamBuffer::getObjectPointer | ( | const DataObject * | pObject,
|  | TYPE *& | refpObject
| ) |  | `[inline, protected]`

Helper to distinguis between identified pointers and contained pointers.

This entry resolves identified pointers (= Pointers to DataObject instances.)

Definition at line 188 of file StreamBuffer.h.

                                                                                                         {
        IdentifiedLink& link = m_identifiedLinks.back();
        DataObject* pObj = link.first;
        m_identifiedLinks.pop_back();
        refpObject = dynamic_cast<TYPE*>(pObj);
        return *this;
      }

template<class TYPE >

StreamBuffer& StreamBuffer::getObjectPointer | ( | const ContainedObject * | pObject,
|  | TYPE *& | refpObject
| ) |  | `[inline, protected]`

Helper to distinguis between identified pointers and contained pointers.

This entry resolves contained pointers (= Pointers to ContainedObject instances.)

Definition at line 198 of file StreamBuffer.h.

                                                                                                              {
        ContainedLink& link = m_containedLinks.back();
        ContainedObject* pObj = link.first;
        m_containedLinks.pop_back();
        refpObject = dynamic_cast<TYPE*>(pObj);
        return *this;
      }

IdentifiedLinks& StreamBuffer::identifiedLinks | ( | ) | `[inline]`

Access to identified links.

Definition at line 263 of file StreamBuffer.h.

                                           {
        return m_identifiedLinks;
      }

const IdentifiedLinks& StreamBuffer::identifiedLinks | ( | ) | const`[inline]`

CONST Access to identified links.

Definition at line 267 of file StreamBuffer.h.

                                                       {
        return m_identifiedLinks;
      }

bool StreamBuffer::isReading | ( | ) | const`[inline]`

Get stream buffer state.

Definition at line 280 of file StreamBuffer.h.

                                    {
        return m_mode == READING;
      }

bool StreamBuffer::isWriting | ( | ) | const`[inline]`

Get stream buffer state.

Definition at line 285 of file StreamBuffer.h.

                                    {
        return m_mode == WRITING;
      }

StreamBuffer& StreamBuffer::operator<< | ( | long | data ) | `[inline]`

Output Streamer.

Definition at line 393 of file StreamBuffer.h.

                                                {
        swapToBuffer(&data, sizeof(data));
        STREAM_ANALYSE(data, sizeof(data));
        return *this;
      }

StreamBuffer& StreamBuffer::operator<< | ( | const ContainedObject * | pObject ) | `[inline]`

Streamer to write links to contained objects.

Links to contained objects are not stored immediately, but collected instead and analyzed later.

Parameters:

  pObject | Pointer to object to be loaded.

Returns:
  Reference to StreamBuffer object

Definition at line 537 of file StreamBuffer.h.

                                                                 {
        STREAM_ANALYSE(pObject, sizeof(pObject));
        addContainedLink(pObject, INVALID, INVALID);
        return *this;
      }

StreamBuffer& StreamBuffer::operator<< | ( | unsigned long | data ) | `[inline]`

Output Streamer.

Definition at line 404 of file StreamBuffer.h.

                                                         {
        swapToBuffer(&data, sizeof(data));
        STREAM_ANALYSE(data, sizeof(data));
        return *this;
      }

StreamBuffer& StreamBuffer::operator<< | ( | short | data ) | `[inline]`

Output Streamer.

Definition at line 415 of file StreamBuffer.h.

                                                 {
        swapToBuffer(&data, sizeof(data));
        STREAM_ANALYSE(data, sizeof(data));
        return *this;
      }

StreamBuffer& StreamBuffer::operator<< | ( | unsigned short | data ) | `[inline]`

Output Streamer.

Definition at line 426 of file StreamBuffer.h.

                                                          {
        swapToBuffer(&data, sizeof(data));
        STREAM_ANALYSE(data, sizeof(data));
        return *this;
      }

StreamBuffer& StreamBuffer::operator<< | ( | char | data ) | `[inline]`

Output Streamer.

Definition at line 437 of file StreamBuffer.h.

                                                {
        swapToBuffer(&data, sizeof(data));
        STREAM_ANALYSE(data, sizeof(data));
        return *this;
      }

StreamBuffer& StreamBuffer::operator<< | ( | unsigned char | data ) | `[inline]`

Output Streamer.

Definition at line 448 of file StreamBuffer.h.

                                                         {
        swapToBuffer(&data, sizeof(data));
        STREAM_ANALYSE(data, sizeof(data));
        return *this;
      }

StreamBuffer& StreamBuffer::operator<< | ( | float | data ) | `[inline]`

Output Streamer.

Definition at line 459 of file StreamBuffer.h.

                                                 {
        swapToBuffer(&data, sizeof(data));
        STREAM_ANALYSE(data, sizeof(data));
        return *this;
      }

StreamBuffer& StreamBuffer::operator<< | ( | double | data ) | `[inline]`

Output Streamer.

Definition at line 470 of file StreamBuffer.h.

                                                  {
        swapToBuffer(&data, sizeof(data));
        STREAM_ANALYSE(data, sizeof(data));
        return *this;
      }

StreamBuffer& StreamBuffer::operator<< | ( | const char * | data ) | `[inline]`

Streamer to write strings in (char*) format.

Definition at line 490 of file StreamBuffer.h.

                                                     {
        const char* ptr = 0 == data ? "" : data;
        int len = strlen(ptr)+1;
        if ( 0 == m_analyzer )
          writeBytes(ptr, len);
        else  {
          STREAM_ANALYSE(data, len);
        }
        return *this;
      }

StreamBuffer& StreamBuffer::operator<< | ( | const DataObject * | pObject ) | `[inline]`

Streamer to write links to identified objects.

Links to identified objects are not stored immediately, but collected instead and analyzed later.

Parameters:

  pObject | Pointer to object to be loaded.

Returns:
  Reference to StreamBuffer object

Definition at line 549 of file StreamBuffer.h.

                                                            {
        STREAM_ANALYSE(pObject, sizeof(pObject));
        addIdentifiedLink(pObject, INVALID);
        return *this;
      }

StreamBuffer& StreamBuffer::operator<< | ( | const std::string & | data ) | `[inline]`

Streamer to write strings in (std::string) format.

Definition at line 510 of file StreamBuffer.h.

                                                        {
        if ( 0 == m_analyzer)   {
          const char* ptr = data.c_str();
          long len = data.length();
          writeBytes(ptr, len);
        }
        else    {
          STREAM_ANALYSE(data, sizeof(data));
        }
        return *this;
      }

StreamBuffer& StreamBuffer::operator<< | ( | longlong | data ) | `[inline]`

Output Streamer.

Definition at line 360 of file StreamBuffer.h.

                                                    {
        swapToBuffer(&data, sizeof(data));
        STREAM_ANALYSE(data, sizeof(data));
        return *this;
      }

StreamBuffer& StreamBuffer::operator<< | ( | int | data ) | `[inline]`

Output Streamer.

Definition at line 371 of file StreamBuffer.h.

                                               {
        swapToBuffer(&data, sizeof(data));
        STREAM_ANALYSE(data, sizeof(data));
        return *this;
      }

StreamBuffer& StreamBuffer::operator<< | ( | unsigned int | data ) | `[inline]`

Output Streamer.

Definition at line 382 of file StreamBuffer.h.

                                                        {
        swapToBuffer(&data, sizeof(data));
        STREAM_ANALYSE(data, sizeof(data));
        return *this;
      }

StreamBuffer& StreamBuffer::operator>> | ( | std::string & | data ) | `[inline]`

Streamer to read strings in (std::string) format.

Definition at line 501 of file StreamBuffer.h.

                                                  {
        long i, len;
        *this >> len;
        for ( i = 0, data = ""; i < len; i++ )    {
          data.append( 1, m_buffer[m_pointer++] );
        }
        return *this;
      }

StreamBuffer& StreamBuffer::operator>> | ( | unsigned int & | data ) | `[inline]`

Input Streamer.

Definition at line 388 of file StreamBuffer.h.

                                                        {
        swapFromBuffer(&data, sizeof(data));
        return *this;
      }

StreamBuffer& StreamBuffer::operator>> | ( | float & | data ) | `[inline]`

Input Streamer.

Definition at line 465 of file StreamBuffer.h.

                                                 {
        swapFromBuffer(&data, sizeof(data));
        return *this;
      }

StreamBuffer& StreamBuffer::operator>> | ( | unsigned char & | data ) | `[inline]`

Input Streamer.

Definition at line 454 of file StreamBuffer.h.

                                                         {
        swapFromBuffer(&data, sizeof(data));
        return *this;
      }

StreamBuffer& StreamBuffer::operator>> | ( | unsigned short & | data ) | `[inline]`

Input Streamer.

Definition at line 432 of file StreamBuffer.h.

                                                          {
        swapFromBuffer(&data, sizeof(data));
        return *this;
      }

StreamBuffer& StreamBuffer::operator>> | ( | unsigned long & | data ) | `[inline]`

Input Streamer.

Definition at line 410 of file StreamBuffer.h.

                                                         {
        swapFromBuffer(&data, sizeof(data));
        return *this;
      }

StreamBuffer& StreamBuffer::operator>> | ( | short & | data ) | `[inline]`

Input Streamer.

Definition at line 421 of file StreamBuffer.h.

                                                 {
        swapFromBuffer(&data, sizeof(data));
        return *this;
      }

StreamBuffer& StreamBuffer::operator>> | ( | char * | data ) | `[inline]`

Streamer to read strings in (char*) format.

Definition at line 481 of file StreamBuffer.h.

                                              {
        long i, len;
        *this >> len;
        for ( i = 0, data[0]=0; i < len; i++ )    {
          data[i] = m_buffer[m_pointer++];
        }
        return *this;
      }

template<class TYPE >

StreamBuffer& StreamBuffer::operator>> | ( | TYPE *& | refpObject ) | `[inline]`

Streamer to read links to contained or identified objects.

The specified internal function call distinguishes between contained and identified objects.

Parameters:

  refpObject | Reference to pointer to object to be loaded.

Returns:
  Reference to StreamBuffer object

Definition at line 527 of file StreamBuffer.h.

                                                                              {
        return getObjectPointer(refpObject, refpObject);
      }

StreamBuffer& StreamBuffer::operator>> | ( | long & | data ) | `[inline]`

Input Streamer.

Definition at line 399 of file StreamBuffer.h.

                                                {
        swapFromBuffer(&data, sizeof(data));
        return *this;
      }

StreamBuffer& StreamBuffer::operator>> | ( | longlong & | data ) | `[inline]`

Input Streamer.

Definition at line 366 of file StreamBuffer.h.

                                                    {
        swapFromBuffer(&data, sizeof(data));
        return *this;
      }

StreamBuffer& StreamBuffer::operator>> | ( | double & | data ) | `[inline]`

Input Streamer.

Definition at line 476 of file StreamBuffer.h.

                                                  {
        swapFromBuffer(&data, sizeof(data));
        return *this;
      }

StreamBuffer& StreamBuffer::operator>> | ( | int & | data ) | `[inline]`

Input Streamer.

Definition at line 377 of file StreamBuffer.h.

                                               {
        swapFromBuffer(&data, sizeof(data));
        return *this;
      }

StreamBuffer& StreamBuffer::operator>> | ( | char & | data ) | `[inline]`

Input Streamer.

Definition at line 443 of file StreamBuffer.h.

                                                {
        swapFromBuffer(&data, sizeof(data));
        return *this;
      }

void StreamBuffer::reserve | ( | long | len ) | `[inline]`

Reserve buffer space; Default: 16 k buffer size.

Definition at line 233 of file StreamBuffer.h.

                               {
        if ( len > m_length )   {
          m_length = (len < 16384) ? 16384 : len;
          m_buffer = (char*)::realloc (m_buffer,m_length);
        }
      }

void StreamBuffer::serialize | ( | DataIO & | ioObject ) | `[inline]`

Serialize the buffer using an IO object.

The streambuffer object will make use of a DataIO object, which can be specialized for streaming to any representation like e.g. disk files, Root files, Objectivity etc.

Parameters:

  ioObject | Reference to data IO object.

Definition at line 561 of file StreamBuffer.h.

                                         {
        ioObject.serialize ( *this );
        m_pointer = 0;
      }

void StreamBuffer::setAnalyzer | ( | AnalyzeFunction | fun = `0` ) | `[inline]`

Enable user analysis function.

Definition at line 297 of file StreamBuffer.h.

                                               {
        m_analyzer = fun;
      }

void StreamBuffer::setBuffPointer | ( | long | ptr ) | `[inline]`

Retrieve current buffer pointer.

Definition at line 293 of file StreamBuffer.h.

                                      {
        m_pointer = ptr;
      }

void StreamBuffer::setMode | ( | Mode | m ) | `[inline]`

Set mode of the stream and allocate buffer.

Definition at line 272 of file StreamBuffer.h.

                            {
        m_mode = m;
        m_pointer = 0;
        m_containedLinks.erase (m_containedLinks.begin(), m_containedLinks.end());
        m_identifiedLinks.erase(m_identifiedLinks.begin(),m_identifiedLinks.end());
      }

long StreamBuffer::size | ( | void | ) | const`[inline]`

Total buffer size.

Definition at line 250 of file StreamBuffer.h.

                            {
        return m_length;
      }

StreamBuffer::SwapAction StreamBuffer::swapBuffer | ( | int | siz ) | const`[inline, protected]`

Check for byte swapping.

Definition at line 570 of file StreamBuffer.h.

                                                                            {
      switch(siz)   {
      case 1:
        return SINGLE_BYTE;
      default:
    #if defined(__alpha) && !defined(__VMS)
    //    return m_swapEnabled ? SWAP : NOSWAP;
        return NOSWAP;
    #elif defined(__sun) && defined(__SVR4) && defined(__i386)
    //    return m_swapEnabled ? SWAP : NOSWAP;
        return NOSWAP;
    #elif defined(__APPLE__)
    //    return m_swapEnabled ? SWAP : NOSWAP;
        return SWAP;
    #elif defined(__linux) && !defined(__powerpc)
    //    return m_swapEnabled ? SWAP : NOSWAP;
        return NOSWAP;
    #elif defined(BORLAND) || defined(_WIN32) || defined(WIN32)
    //    return m_swapEnabled ? SWAP : NOSWAP;
        return NOSWAP;
    #else
        return m_swapEnabled ? SWAP : NOSWAP;
    //    return NOSWAP;
    #endif
      }
    }

void StreamBuffer::swapFromBuffer | ( | void * | target,
|  | int | siz
| ) |  | `[inline]`

Swap buffers: int, long, short, float and double.

Swap bytes from the stream buffer to target buffer with arbitray size.

Definition at line 621 of file StreamBuffer.h.

                                                                    {
      char* tar = (char*)target;
      char* src = (char*)m_buffer+m_pointer;
      switch ( swapBuffer(siz) )   {
      case SINGLE_BYTE:
        *tar = *src;
        break;
      case SWAP:
    #ifdef __APPLE__
        for(int i = 0,j = siz-1;i<siz;i++,j--) tar[j] = src[i];
    #else
        ::_swab (src, tar, siz);
    #endif
        break;
      case NOSWAP:
        ::memcpy(tar, src, siz);
        break;
      }
      m_pointer += siz;
    }

void StreamBuffer::swapToBuffer | ( | const void * | source,
|  | int | siz
| ) |  | `[inline]`

Swap buffers: int, long, short, float and double.

Swap bytes from a source buffer to the stream buffer with arbitray size.

Definition at line 598 of file StreamBuffer.h.

                                                                        {
      char buff[8], *tar, *src = (char*)source;
      extend (m_pointer+siz);
      tar = (char*)m_buffer+m_pointer;
      switch ( swapBuffer(siz) )   {
      case SINGLE_BYTE:
        *tar = *src;
        break;
      case SWAP:
    #ifdef __APPLE__
        for(int i = 0,j = siz-1;i<siz;i++,j--) tar[j] = src[i];
    #else
        ::_swab (src, buff, siz);
    #endif
        src = buff;
      case NOSWAP:
        memcpy(tar, src, siz);
        break;
      }
      m_pointer += siz;
    }

StreamBuffer& StreamBuffer::writeBytes | ( | const char * | str,
|  | long | len
| ) |  | `[inline]`

Write string to output stream.

Definition at line 307 of file StreamBuffer.h.

                                                               {
        extend( m_pointer+len+4 );
        *this << len;
        memcpy(data()+buffPointer(), str, len);
        m_pointer += len;
        return *this;
      }

## Friends And Related Function Documentation

friend class DataObject`[friend]`

DataObject is friend.

Definition at line 155 of file StreamBuffer.h.

## Member Data Documentation

AnalyzeFunction StreamBuffer::m_analyzer`[protected]`

Hook function for analysis of data to the stream.

Definition at line 180 of file StreamBuffer.h.

char* StreamBuffer::m_buffer`[protected]`

Pointer to heap buffer.

Definition at line 168 of file StreamBuffer.h.

ContainedLinks StreamBuffer::m_containedLinks`[protected]`

Container with links to contained objects.

Definition at line 174 of file StreamBuffer.h.

IdentifiedLinks StreamBuffer::m_identifiedLinks`[protected]`

Container with links to contained objects.

Definition at line 177 of file StreamBuffer.h.

long StreamBuffer::m_length`[protected]`

Total buffer length.

Definition at line 165 of file StreamBuffer.h.

Mode StreamBuffer::m_mode`[protected]`

Boolean indicating wether the stream is in read or write mode.

Definition at line 159 of file StreamBuffer.h.

long StreamBuffer::m_pointer`[protected]`

Current buffer pointer.

Definition at line 162 of file StreamBuffer.h.

bool StreamBuffer::m_swapEnabled`[protected]`

Flag indicating swapping.

Definition at line 171 of file StreamBuffer.h.

The documentation for this class was generated from the following file:

- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v22r4/GaudiKernel/GaudiKernel/StreamBuffer.h

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines