The Gaudi Framework  v37r0 (b608885e)
StreamBuffer.h
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2021 CERN for the benefit of the LHCb and ATLAS collaborations *
3 * *
4 * This software is distributed under the terms of the Apache version 2 licence, *
5 * copied verbatim in the file "LICENSE". *
6 * *
7 * In applying this licence, CERN does not waive the privileges and immunities *
8 * granted to it by virtue of its status as an Intergovernmental Organization *
9 * or submit itself to any jurisdiction. *
10 \***********************************************************************************/
11 #ifndef GAUDIKERNEL_STREAMBUFFER_H
12 #define GAUDIKERNEL_STREAMBUFFER_H 1
13 
14 // STL include files
15 #include <algorithm>
16 #include <cstdlib>
17 #include <cstring>
18 #include <iostream>
19 #include <list>
20 #include <string>
21 #include <typeinfo>
22 #include <vector>
23 
24 #include "GaudiKernel/Kernel.h"
25 #include "GaudiKernel/swab.h"
26 
27 // forward declarations
28 class StreamBuffer;
29 class DataObject;
30 class ContainedObject;
31 
51 class StreamBuffer /* : public std::string */
52 {
53 public:
55  class DataIO {
56  public:
58  DataIO() = default;
60  virtual ~DataIO() = default;
62  void badStreamMode() { throw( "Not acceptable stream mode!" ); }
64  virtual void serialize( StreamBuffer& stream ) {
65  if ( stream.isReading() )
66  load( stream );
67  else if ( stream.isWriting() )
68  dump( stream );
69  else
70  badStreamMode();
71  }
73  virtual void load( StreamBuffer& ) { badStreamMode(); }
75  virtual void dump( StreamBuffer& ) { badStreamMode(); }
76  };
77 
79  class Istream : public DataIO {
82 
83  public:
85  Istream( std::istream& str ) : m_stream( &str ) {}
86 
88  void load( StreamBuffer& stream ) override {
89  // Generic implementation for istreams:
90  int len;
91  ( *m_stream ) >> len;
92  stream.erase();
93  stream.reserve( len );
94  m_stream->read( stream.data(), len );
95  }
96  };
98  class Ostream : public DataIO {
100 
101  public:
103  Ostream( std::ostream& str ) : m_stream( &str ) {}
105  virtual ~Ostream() = default;
106 
108  void dump( StreamBuffer& stream ) override {
109  // Generic implementation for ostreams:
110  ( *m_stream ) << stream.buffPointer();
111  m_stream->write( stream.data(), stream.buffPointer() );
112  }
113  };
114 
115 public:
121  enum State { INVALID = -1, VALID };
124  public:
125  ContainedObject* first = nullptr;
126  long second = INVALID;
127  long third = INVALID;
128  ContainedLink() = default;
129  ContainedLink( ContainedObject* pObj, long hint, long link ) : first( pObj ), second( hint ), third( link ) {}
130  ContainedLink& operator=( const ContainedLink& copy ) = default;
131  };
134  public:
135  DataObject* first = nullptr;
136  long second = INVALID;
137  IdentifiedLink() = default;
138  IdentifiedLink( const IdentifiedLink& copy ) = default;
139  IdentifiedLink( DataObject* pObj, long hint ) : first( pObj ), second( hint ) {}
140  };
141 
146  typedef void ( *AnalyzeFunction )( const void* data, int siz, const std::type_info& type );
148  friend class DataObject;
149 
150 protected:
153 
155  mutable long m_pointer = 0;
156 
158  mutable long m_length = 0;
159 
161  mutable char* m_buffer = nullptr;
162 
164  bool m_swapEnabled = true;
165 
168 
171 
174 
176  SwapAction swapBuffer( int siz ) const;
177 
181  template <class TYPE>
182  StreamBuffer& getObjectPointer( const DataObject* /*pObject*/, TYPE*& refpObject ) {
184  DataObject* pObj = link.first;
186  refpObject = dynamic_cast<TYPE*>( pObj );
187  return *this;
188  }
192  template <class TYPE>
193  StreamBuffer& getObjectPointer( const ContainedObject* /*pObject*/, TYPE*& refpObject ) {
195  ContainedObject* pObj = link.first;
197  refpObject = dynamic_cast<TYPE*>( pObj );
198  return *this;
199  }
200 
201 public:
203  StreamBuffer( bool do_swap = true ) : m_swapEnabled( do_swap ) {}
205  virtual ~StreamBuffer() { ::free( m_buffer ); }
207  const char* data() const { return m_buffer; }
209  char* data() { return m_buffer; }
211  void erase() { m_pointer = 0; }
213  char* adopt() const {
214  char* ptr = m_buffer;
217  m_buffer = NULL; // char *
218  m_pointer = 0; // long
219  m_length = 0; // long
220  return ptr;
221  }
223  void reserve( long len ) {
224  if ( len > m_length ) {
225  m_length = ( len < 16384 ) ? 16384 : len;
226  m_buffer = (char*)::realloc( m_buffer, m_length );
227  }
228  }
230  void extend( long len ) {
231  if ( len + m_pointer > m_length ) {
232  // We have to be a bit generous here in order not to run too often
233  // into ::realloc().
234  long new_len = ( m_length < 16384 ) ? 16384 : 2 * m_length;
235  if ( m_length < len ) new_len += len;
236  reserve( new_len );
237  }
238  }
240  long size() const { return m_length; }
244  const ContainedLinks& containedLinks() const { return m_containedLinks; }
245 
250 
252  void setMode( Mode m ) {
253  m_mode = m;
254  m_pointer = 0;
257  }
258 
260  bool isReading() const { return m_mode == READING; }
261 
263  bool isWriting() const { return m_mode == WRITING; }
265  long buffPointer() const { return m_pointer; }
267  void setBuffPointer( long ptr ) { m_pointer = ptr; }
269  void setAnalyzer( AnalyzeFunction fun = nullptr ) { m_analyzer = fun; }
271  void swapToBuffer( const void* source, int siz );
272 
274  void swapFromBuffer( void* target, int siz );
275 
277  StreamBuffer& writeBytes( const char* str, long len ) {
278  extend( m_pointer + len + 4 );
279  *this << len;
280  std::copy_n( str, len, data() + buffPointer() );
281  m_pointer += len;
282  return *this;
283  }
284 
285  void getIdentifiedLink( DataObject*& pObject, long& hint ) {
287  pObject = l.first;
288  hint = l.second;
290  }
291  void addIdentifiedLink( const DataObject* pObject, long hint ) {
293  }
294 
295  void getContainedLink( ContainedObject*& pObject, long& hint, long& link ) {
297  pObject = l.first;
298  hint = l.second;
299  link = l.third;
301  }
302  void addContainedLink( const ContainedObject* pObject, long hint, long link ) {
303  m_containedLinks.push_back( ContainedLink( (ContainedObject*)pObject, hint, link ) );
304  }
305 
306 #ifdef USE_STREAM_ANALYSER
307 # define STREAM_ANALYSE( data, len ) \
308  if ( 0 != m_analyzer ) m_analyzer( &data, len, typeid( data ) )
309 #else
310 # define STREAM_ANALYSE( data, len )
311 #endif
312 
313 // Implement streamer macros for primivive data types.
314 #define IMPLEMENT_STREAMER( TYPE ) \
315  /* Output Streamer */ \
316  StreamBuffer& operator<<( TYPE data ) { \
317  swapToBuffer( &data, sizeof( data ) ); \
318  STREAM_ANALYSE( data, sizeof( data ) ); \
319  return *this; \
320  } \
321  /* Input Streamer */ \
322  StreamBuffer& operator>>( TYPE& data ) { \
323  swapFromBuffer( &data, sizeof( data ) ); \
324  return *this; \
325  }
326 // RootCint does not understand this macro....
327 // But we can easily live without it!
328 #undef IMPLEMENT_STREAMER
329 
331  StreamBuffer& operator<<( long long data ) {
332  swapToBuffer( &data, sizeof( data ) );
333  STREAM_ANALYSE( data, sizeof( data ) );
334  return *this;
335  }
337  StreamBuffer& operator>>( long long& data ) {
338  swapFromBuffer( &data, sizeof( data ) );
339  return *this;
340  }
343  swapToBuffer( &data, sizeof( data ) );
344  STREAM_ANALYSE( data, sizeof( data ) );
345  return *this;
346  }
349  swapFromBuffer( &data, sizeof( data ) );
350  return *this;
351  }
353  StreamBuffer& operator<<( unsigned int data ) {
354  swapToBuffer( &data, sizeof( data ) );
355  STREAM_ANALYSE( data, sizeof( data ) );
356  return *this;
357  }
359  StreamBuffer& operator>>( unsigned int& data ) {
360  swapFromBuffer( &data, sizeof( data ) );
361  return *this;
362  }
365  swapToBuffer( &data, sizeof( data ) );
366  STREAM_ANALYSE( data, sizeof( data ) );
367  return *this;
368  }
371  swapFromBuffer( &data, sizeof( data ) );
372  return *this;
373  }
375  StreamBuffer& operator<<( unsigned long data ) {
376  swapToBuffer( &data, sizeof( data ) );
377  STREAM_ANALYSE( data, sizeof( data ) );
378  return *this;
379  }
381  StreamBuffer& operator>>( unsigned long& data ) {
382  swapFromBuffer( &data, sizeof( data ) );
383  return *this;
384  }
387  swapToBuffer( &data, sizeof( data ) );
388  STREAM_ANALYSE( data, sizeof( data ) );
389  return *this;
390  }
393  swapFromBuffer( &data, sizeof( data ) );
394  return *this;
395  }
397  StreamBuffer& operator<<( unsigned short data ) {
398  swapToBuffer( &data, sizeof( data ) );
399  STREAM_ANALYSE( data, sizeof( data ) );
400  return *this;
401  }
403  StreamBuffer& operator>>( unsigned short& data ) {
404  swapFromBuffer( &data, sizeof( data ) );
405  return *this;
406  }
409  swapToBuffer( &data, sizeof( data ) );
410  STREAM_ANALYSE( data, sizeof( data ) );
411  return *this;
412  }
415  swapFromBuffer( &data, sizeof( data ) );
416  return *this;
417  }
419  StreamBuffer& operator<<( unsigned char data ) {
420  swapToBuffer( &data, sizeof( data ) );
421  STREAM_ANALYSE( data, sizeof( data ) );
422  return *this;
423  }
425  StreamBuffer& operator>>( unsigned char& data ) {
426  swapFromBuffer( &data, sizeof( data ) );
427  return *this;
428  }
431  swapToBuffer( &data, sizeof( data ) );
432  STREAM_ANALYSE( data, sizeof( data ) );
433  return *this;
434  }
437  swapFromBuffer( &data, sizeof( data ) );
438  return *this;
439  }
442  swapToBuffer( &data, sizeof( data ) );
443  STREAM_ANALYSE( data, sizeof( data ) );
444  return *this;
445  }
448  swapFromBuffer( &data, sizeof( data ) );
449  return *this;
450  }
453  long i, len;
454  *this >> len;
455  for ( i = 0, data[0] = 0; i < len; i++ ) { data[i] = m_buffer[m_pointer++]; }
456  return *this;
457  }
459  StreamBuffer& operator<<( const char* data ) {
460  const char* ptr = 0 == data ? "" : data;
461  size_t len = strlen( ptr ) + 1;
462  if ( 0 == m_analyzer )
463  writeBytes( ptr, len );
464  else { STREAM_ANALYSE( data, len ); }
465  return *this;
466  }
469  long i, len;
470  *this >> len;
471  for ( i = 0, data = ""; i < len; i++ ) { data.append( 1, m_buffer[m_pointer++] ); }
472  return *this;
473  }
476  if ( 0 == m_analyzer ) {
477  const char* ptr = data.c_str();
478  long len = data.length();
479  writeBytes( ptr, len );
480  } else {
481  STREAM_ANALYSE( data, sizeof( data ) );
482  }
483  return *this;
484  }
491  template <class TYPE>
492  StreamBuffer& operator>>( TYPE*& refpObject ) {
493  return getObjectPointer( refpObject, refpObject );
494  }
495 
503  STREAM_ANALYSE( pObject, sizeof( pObject ) );
504  addContainedLink( pObject, INVALID, INVALID );
505  return *this;
506  }
507 
514  StreamBuffer& operator<<( const DataObject* pObject ) {
515  STREAM_ANALYSE( pObject, sizeof( pObject ) );
516  addIdentifiedLink( pObject, INVALID );
517  return *this;
518  }
519 
526  void serialize( DataIO& ioObject ) {
527  ioObject.serialize( *this );
528  m_pointer = 0;
529  }
530 };
531 
532 #undef STREAM_ANALYSE
533 
536  switch ( siz ) {
537  case 1:
538  return SINGLE_BYTE;
539  default:
540 #if defined( __alpha ) && !defined( __VMS )
541  // return m_swapEnabled ? SWAP : NOSWAP;
542  return NOSWAP;
543 #elif defined( __sun ) && defined( __SVR4 ) && defined( __i386 )
544  // return m_swapEnabled ? SWAP : NOSWAP;
545  return NOSWAP;
546 #elif defined( __APPLE__ )
547  // return m_swapEnabled ? SWAP : NOSWAP;
548  return SWAP;
549 #elif defined( __linux ) && !defined( __powerpc )
550  // return m_swapEnabled ? SWAP : NOSWAP;
551  return NOSWAP;
552 #elif defined( BORLAND ) || defined( _WIN32 ) || defined( WIN32 )
553  // return m_swapEnabled ? SWAP : NOSWAP;
554  return NOSWAP;
555 #else
556  return m_swapEnabled ? SWAP : NOSWAP;
557 // return NOSWAP;
558 #endif
559  }
560 }
561 
563 inline void StreamBuffer::swapToBuffer( const void* source, int siz ) {
564  char buff[8], *tar, *src = (char*)source;
565  extend( m_pointer + siz );
566  tar = m_buffer + m_pointer;
567  switch ( swapBuffer( siz ) ) {
568  case SINGLE_BYTE:
569  *tar = *src;
570  break;
571  case SWAP:
572 #ifdef __APPLE__
573  for ( int i = 0, j = siz - 1; i < siz; i++, j-- ) tar[j] = src[i];
574 #else
575  ::_swab( src, buff, siz );
576 #endif
577  src = buff;
578  [[fallthrough]];
579  case NOSWAP:
580  std::copy_n( src, siz, tar );
581  break;
582  default:
583  break;
584  }
585  m_pointer += siz;
586 }
587 
589 inline void StreamBuffer::swapFromBuffer( void* target, int siz ) {
590  char* tar = (char*)target;
591  char* src = m_buffer + m_pointer;
592  switch ( swapBuffer( siz ) ) {
593  case SINGLE_BYTE:
594  *tar = *src;
595  break;
596  case SWAP:
597 #ifdef __APPLE__
598  for ( int i = 0, j = siz - 1; i < siz; i++, j-- ) tar[j] = src[i];
599 #else
600  ::_swab( src, tar, siz );
601 #endif
602  break;
603  case NOSWAP:
604  std::copy_n( src, siz, tar );
605  break;
606  default:
607  break;
608  }
609  m_pointer += siz;
610 }
611 
612 // Output serialize a vector of items
613 template <class T>
615  s << v.size();
616  for ( const auto& i : v ) s << i;
617  return s;
618 }
619 
620 // Input serialize a vector of items
621 template <class T>
623  long i, len;
624  s >> len;
625  v.clear();
626  for ( i = 0; i < len; i++ ) {
627  T temp;
628  s >> temp;
629  v.push_back( temp );
630  }
631  return s;
632 }
633 
634 // Output serialize a list of items
635 template <class T>
637  s << l.size();
638  for ( const auto& i : l ) s << i;
639  return s;
640 }
641 
642 // Input serialize a list of items
643 template <class T>
645  long len;
646  s >> len;
647  l.clear();
648  for ( long i = 0; i < len; i++ ) {
649  T temp;
650  s >> temp;
651  l.push_back( temp );
652  }
653  return s;
654 }
655 #endif // GAUDIKERNEL_STREAMBUFFER_H
StreamBuffer::operator<<
StreamBuffer & operator<<(const char *data)
Streamer to write strings in (char*) format.
Definition: StreamBuffer.h:459
StreamBuffer::Istream::m_stream
std::istream * m_stream
Reference to input stream.
Definition: StreamBuffer.h:81
StreamBuffer::identifiedLinks
IdentifiedLinks & identifiedLinks()
Access to identified links.
Definition: StreamBuffer.h:247
StreamBuffer::operator<<
StreamBuffer & operator<<(const std::string &data)
Streamer to write strings in (std::string) format.
Definition: StreamBuffer.h:475
StreamBuffer::operator>>
StreamBuffer & operator>>(int &data)
Input Streamer.
Definition: StreamBuffer.h:348
StreamBuffer::containedLinks
const ContainedLinks & containedLinks() const
CONST Access to contained links.
Definition: StreamBuffer.h:244
StreamBuffer::setBuffPointer
void setBuffPointer(long ptr)
Retrieve current buffer pointer.
Definition: StreamBuffer.h:267
StreamBuffer::adopt
char * adopt() const
Remove the data buffer and pass it to client. It's the client responsability to free the memory.
Definition: StreamBuffer.h:213
Write.stream
stream
Definition: Write.py:32
StreamBuffer::operator>>
StreamBuffer & operator>>(unsigned char &data)
Input Streamer.
Definition: StreamBuffer.h:425
StreamBuffer::operator<<
StreamBuffer & operator<<(float data)
Output Streamer.
Definition: StreamBuffer.h:430
StreamBuffer::addIdentifiedLink
void addIdentifiedLink(const DataObject *pObject, long hint)
Definition: StreamBuffer.h:291
StreamBuffer::m_buffer
char * m_buffer
Pointer to heap buffer.
Definition: StreamBuffer.h:161
std::string
STL class.
StreamBuffer::StreamBuffer
StreamBuffer(bool do_swap=true)
Standard constructor.
Definition: StreamBuffer.h:203
StreamBuffer::DataIO::~DataIO
virtual ~DataIO()=default
Standard destructor.
StreamBuffer::SWAP
@ SWAP
Definition: StreamBuffer.h:119
std::list
STL class.
StreamBuffer::operator<<
StreamBuffer & operator<<(short data)
Output Streamer.
Definition: StreamBuffer.h:386
StreamBuffer::Ostream::~Ostream
virtual ~Ostream()=default
Standard Destructor.
StreamBuffer::serialize
void serialize(DataIO &ioObject)
Serialize the buffer using an IO object.
Definition: StreamBuffer.h:526
StreamBuffer::m_containedLinks
ContainedLinks m_containedLinks
Container with links to contained objects.
Definition: StreamBuffer.h:167
gaudirun.s
string s
Definition: gaudirun.py:348
StreamBuffer::swapBuffer
SwapAction swapBuffer(int siz) const
Check for byte swapping.
Definition: StreamBuffer.h:535
std::vector< ContainedLink >
StreamBuffer::DataIO::badStreamMode
void badStreamMode()
Throw Exception.
Definition: StreamBuffer.h:62
std::type_info
StreamBuffer::DataIO::load
virtual void load(StreamBuffer &)
Template function to load stream data.
Definition: StreamBuffer.h:73
StreamBuffer::extend
void extend(long len)
Extend the buffer.
Definition: StreamBuffer.h:230
StreamBuffer::operator<<
StreamBuffer & operator<<(const DataObject *pObject)
Streamer to write links to identified objects.
Definition: StreamBuffer.h:514
StreamBuffer::operator<<
StreamBuffer & operator<<(unsigned short data)
Output Streamer.
Definition: StreamBuffer.h:397
StreamBuffer::m_mode
Mode m_mode
Boolean indicating wether the stream is in read or write mode.
Definition: StreamBuffer.h:152
StreamBuffer::operator<<
StreamBuffer & operator<<(unsigned long data)
Output Streamer.
Definition: StreamBuffer.h:375
StreamBuffer::SwapAction
SwapAction
Data Sawp actions.
Definition: StreamBuffer.h:119
StreamBuffer::buffPointer
long buffPointer() const
Retrieve current buffer pointer.
Definition: StreamBuffer.h:265
StreamBuffer::m_analyzer
AnalyzeFunction m_analyzer
Hook function for analysis of data to the stream.
Definition: StreamBuffer.h:173
std::vector::back
T back(T... args)
std::istream::read
T read(T... args)
StreamBuffer::operator<<
StreamBuffer & operator<<(const ContainedObject *pObject)
Streamer to write links to contained objects.
Definition: StreamBuffer.h:502
StreamBuffer::Istream::Istream
Istream(std::istream &str)
Constructor.
Definition: StreamBuffer.h:85
StreamBuffer::operator<<
StreamBuffer & operator<<(double data)
Output Streamer.
Definition: StreamBuffer.h:441
StreamBuffer::swapFromBuffer
void swapFromBuffer(void *target, int siz)
Swap buffers: int, long, short, float and double.
Definition: StreamBuffer.h:589
swab.h
StreamBuffer::m_swapEnabled
bool m_swapEnabled
Flag indicating swapping.
Definition: StreamBuffer.h:164
StreamBuffer::AnalyzeFunction
void(* AnalyzeFunction)(const void *data, int siz, const std::type_info &type)
Definition of the buffer analyzer.
Definition: StreamBuffer.h:146
std::ostream::write
T write(T... args)
StreamBuffer
Definition: StreamBuffer.h:52
StreamBuffer::READING
@ READING
Definition: StreamBuffer.h:117
StreamBuffer::Ostream
Writer for standard output streams.
Definition: StreamBuffer.h:98
std::vector::push_back
T push_back(T... args)
StreamBuffer::DataIO::serialize
virtual void serialize(StreamBuffer &stream)
Serialization method: loads/dumps streambuffer content.
Definition: StreamBuffer.h:64
compareOutputFiles.target
target
Definition: compareOutputFiles.py:489
StreamBuffer::operator>>
StreamBuffer & operator>>(unsigned short &data)
Input Streamer.
Definition: StreamBuffer.h:403
StreamBuffer::IdentifiedLinks
std::vector< IdentifiedLink > IdentifiedLinks
Definition of the identifiable link set.
Definition: StreamBuffer.h:144
std::copy_n
T copy_n(T... args)
StreamBuffer::swapToBuffer
void swapToBuffer(const void *source, int siz)
Swap buffers: int, long, short, float and double.
Definition: StreamBuffer.h:563
Gaudi::Units::m
constexpr double m
Definition: SystemOfUnits.h:108
StreamBuffer::State
State
Link state defintions.
Definition: StreamBuffer.h:121
ProduceConsume.j
j
Definition: ProduceConsume.py:101
std::ostream
STL class.
StreamBuffer::Istream::load
void load(StreamBuffer &stream) override
Data load method.
Definition: StreamBuffer.h:88
StreamBuffer::SINGLE_BYTE
@ SINGLE_BYTE
Definition: StreamBuffer.h:119
StreamBuffer::writeBytes
StreamBuffer & writeBytes(const char *str, long len)
Write string to output stream.
Definition: StreamBuffer.h:277
StreamBuffer::getObjectPointer
StreamBuffer & getObjectPointer(const ContainedObject *, TYPE *&refpObject)
Helper to distinguish between identified pointers and contained pointers.
Definition: StreamBuffer.h:193
operator<<
StreamBuffer & operator<<(StreamBuffer &s, const std::vector< T > &v)
Definition: StreamBuffer.h:614
StreamBuffer::operator>>
StreamBuffer & operator>>(unsigned long &data)
Input Streamer.
Definition: StreamBuffer.h:381
StreamBuffer::getObjectPointer
StreamBuffer & getObjectPointer(const DataObject *, TYPE *&refpObject)
Helper to distinguish between identified pointers and contained pointers.
Definition: StreamBuffer.h:182
StreamBuffer::containedLinks
ContainedLinks & containedLinks()
Access to contained links.
Definition: StreamBuffer.h:242
std::vector::erase
T erase(T... args)
StreamBuffer::isWriting
bool isWriting() const
Get stream buffer state.
Definition: StreamBuffer.h:263
StreamBuffer::operator<<
StreamBuffer & operator<<(char data)
Output Streamer.
Definition: StreamBuffer.h:408
StreamBuffer::identifiedLinks
const IdentifiedLinks & identifiedLinks() const
CONST Access to identified links.
Definition: StreamBuffer.h:249
StreamBuffer::setMode
void setMode(Mode m)
Set mode of the stream and allocate buffer.
Definition: StreamBuffer.h:252
StreamBuffer::operator<<
StreamBuffer & operator<<(long data)
Output Streamer.
Definition: StreamBuffer.h:364
StreamBuffer::size
long size() const
Total buffer size.
Definition: StreamBuffer.h:240
StreamBuffer::setAnalyzer
void setAnalyzer(AnalyzeFunction fun=nullptr)
Enable user analysis function.
Definition: StreamBuffer.h:269
StreamBuffer::data
char * data()
write access to data buffer
Definition: StreamBuffer.h:209
StreamBuffer::data
const char * data() const
Read access to data buffer.
Definition: StreamBuffer.h:207
StreamBuffer::isReading
bool isReading() const
Get stream buffer state.
Definition: StreamBuffer.h:260
StreamBuffer::~StreamBuffer
virtual ~StreamBuffer()
Standard destructor.
Definition: StreamBuffer.h:205
StreamBuffer::DataIO::dump
virtual void dump(StreamBuffer &)
Template function to save stream data.
Definition: StreamBuffer.h:75
std::vector::pop_back
T pop_back(T... args)
StreamBuffer::reserve
void reserve(long len)
Reserve buffer space; Default: 16 k buffer size.
Definition: StreamBuffer.h:223
StreamBuffer::operator<<
StreamBuffer & operator<<(int data)
Output Streamer.
Definition: StreamBuffer.h:342
StreamBuffer::operator>>
StreamBuffer & operator>>(char *data)
Streamer to read strings in (char*) format.
Definition: StreamBuffer.h:452
StreamBuffer::operator>>
StreamBuffer & operator>>(float &data)
Input Streamer.
Definition: StreamBuffer.h:436
StreamBuffer::operator>>
StreamBuffer & operator>>(std::string &data)
Streamer to read strings in (std::string) format.
Definition: StreamBuffer.h:468
StreamBuffer::operator<<
StreamBuffer & operator<<(long long data)
Output Streamer.
Definition: StreamBuffer.h:331
StreamBuffer::operator>>
StreamBuffer & operator>>(long &data)
Input Streamer.
Definition: StreamBuffer.h:370
StreamBuffer::UNINITIALIZED
@ UNINITIALIZED
Definition: StreamBuffer.h:117
StreamBuffer::Istream
Reader for standard input streams.
Definition: StreamBuffer.h:79
StreamBuffer::Ostream::dump
void dump(StreamBuffer &stream) override
Output dumper.
Definition: StreamBuffer.h:108
gaudirun.type
type
Definition: gaudirun.py:162
StreamBuffer::operator>>
StreamBuffer & operator>>(double &data)
Input Streamer.
Definition: StreamBuffer.h:447
StreamBuffer::Mode
Mode
Streamer mode.
Definition: StreamBuffer.h:117
gaudirun.l
dictionary l
Definition: gaudirun.py:582
std::vector::begin
T begin(T... args)
Kernel.h
StreamBuffer::operator>>
StreamBuffer & operator>>(short &data)
Input Streamer.
Definition: StreamBuffer.h:392
StreamBuffer::m_length
long m_length
Total buffer length.
Definition: StreamBuffer.h:158
StreamBuffer::m_pointer
long m_pointer
Current buffer pointer.
Definition: StreamBuffer.h:155
StreamBuffer::getIdentifiedLink
void getIdentifiedLink(DataObject *&pObject, long &hint)
Definition: StreamBuffer.h:285
StreamBuffer::erase
void erase()
Reset the buffer.
Definition: StreamBuffer.h:211
StreamBuffer::VALID
@ VALID
Definition: StreamBuffer.h:121
DataObject
Definition: DataObject.h:40
StreamBuffer::DataIO
A small base class to handle generic data streaming.
Definition: StreamBuffer.h:55
StreamBuffer::operator>>
StreamBuffer & operator>>(TYPE *&refpObject)
Streamer to read links to contained or identified objects.
Definition: StreamBuffer.h:492
Properties.v
v
Definition: Properties.py:123
operator>>
StreamBuffer & operator>>(StreamBuffer &s, std::vector< T > &v)
Definition: StreamBuffer.h:622
StreamBuffer::DataIO::DataIO
DataIO()=default
Standard constructor.
StreamBuffer::operator<<
StreamBuffer & operator<<(unsigned char data)
Output Streamer.
Definition: StreamBuffer.h:419
StreamBuffer::operator>>
StreamBuffer & operator>>(unsigned int &data)
Input Streamer.
Definition: StreamBuffer.h:359
std::vector::end
T end(T... args)
_swab
#define _swab(source, target, radix)
Definition: swab.h:17
StreamBuffer::addContainedLink
void addContainedLink(const ContainedObject *pObject, long hint, long link)
Definition: StreamBuffer.h:302
std::istream
STL class.
StreamBuffer::Ostream::m_stream
std::ostream * m_stream
Definition: StreamBuffer.h:99
StreamBuffer::NOSWAP
@ NOSWAP
Definition: StreamBuffer.h:119
STREAM_ANALYSE
#define STREAM_ANALYSE(data, len)
Definition: StreamBuffer.h:310
StreamBuffer::operator>>
StreamBuffer & operator>>(long long &data)
Input Streamer.
Definition: StreamBuffer.h:337
StreamBuffer::operator>>
StreamBuffer & operator>>(char &data)
Input Streamer.
Definition: StreamBuffer.h:414
StreamBuffer::WRITING
@ WRITING
Definition: StreamBuffer.h:117
StreamBuffer::ContainedLinks
std::vector< ContainedLink > ContainedLinks
Definition: StreamBuffer.h:142
ContainedObject
Definition: ContainedObject.h:41
StreamBuffer::m_identifiedLinks
IdentifiedLinks m_identifiedLinks
Container with links to contained objects.
Definition: StreamBuffer.h:170
StreamBuffer::getContainedLink
void getContainedLink(ContainedObject *&pObject, long &hint, long &link)
Definition: StreamBuffer.h:295
StreamBuffer::operator<<
StreamBuffer & operator<<(unsigned int data)
Output Streamer.
Definition: StreamBuffer.h:353
StreamBuffer::INVALID
@ INVALID
Definition: StreamBuffer.h:121
StreamBuffer::Ostream::Ostream
Ostream(std::ostream &str)
Standard constructor: pass reference to stream object.
Definition: StreamBuffer.h:103