The Gaudi Framework  master (37c0b60a)
StreamBuffer.h
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2024 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( const ContainedLink& copy ) = default;
131  ContainedLink& operator=( const ContainedLink& copy ) = default;
132  };
135  public:
136  DataObject* first = nullptr;
137  long second = INVALID;
138  IdentifiedLink() = default;
139  IdentifiedLink( DataObject* pObj, long hint ) : first( pObj ), second( hint ) {}
140  IdentifiedLink( const IdentifiedLink& copy ) = default;
141  IdentifiedLink& operator=( const IdentifiedLink& copy ) = default;
142  };
143 
148  typedef void ( *AnalyzeFunction )( const void* data, int siz, const std::type_info& type );
150  friend class DataObject;
151 
152 protected:
155 
157  mutable long m_pointer = 0;
158 
160  mutable long m_length = 0;
161 
163  mutable char* m_buffer = nullptr;
164 
166  bool m_swapEnabled = true;
167 
170 
173 
176 
178  SwapAction swapBuffer( int siz ) const;
179 
183  template <class TYPE>
184  StreamBuffer& getObjectPointer( const DataObject* /*pObject*/, TYPE*& refpObject ) {
186  DataObject* pObj = link.first;
188  refpObject = dynamic_cast<TYPE*>( pObj );
189  return *this;
190  }
194  template <class TYPE>
195  StreamBuffer& getObjectPointer( const ContainedObject* /*pObject*/, TYPE*& refpObject ) {
197  ContainedObject* pObj = link.first;
199  refpObject = dynamic_cast<TYPE*>( pObj );
200  return *this;
201  }
202 
203 public:
205  StreamBuffer( bool do_swap = true ) : m_swapEnabled( do_swap ) {}
207  virtual ~StreamBuffer() { ::free( m_buffer ); }
209  const char* data() const { return m_buffer; }
211  char* data() { return m_buffer; }
213  void erase() { m_pointer = 0; }
215  char* adopt() const {
216  char* ptr = m_buffer;
219  m_buffer = NULL; // char *
220  m_pointer = 0; // long
221  m_length = 0; // long
222  return ptr;
223  }
225  void reserve( long len ) {
226  if ( len > m_length ) {
227  m_length = ( len < 16384 ) ? 16384 : len;
228  m_buffer = (char*)::realloc( m_buffer, m_length );
229  }
230  }
232  void extend( long len ) {
233  if ( len + m_pointer > m_length ) {
234  // We have to be a bit generous here in order not to run too often
235  // into ::realloc().
236  long new_len = ( m_length < 16384 ) ? 16384 : 2 * m_length;
237  if ( m_length < len ) new_len += len;
238  reserve( new_len );
239  }
240  }
242  long size() const { return m_length; }
246  const ContainedLinks& containedLinks() const { return m_containedLinks; }
247 
252 
254  void setMode( Mode m ) {
255  m_mode = m;
256  m_pointer = 0;
259  }
260 
262  bool isReading() const { return m_mode == READING; }
263 
265  bool isWriting() const { return m_mode == WRITING; }
267  long buffPointer() const { return m_pointer; }
269  void setBuffPointer( long ptr ) { m_pointer = ptr; }
271  void setAnalyzer( AnalyzeFunction fun = nullptr ) { m_analyzer = fun; }
273  void swapToBuffer( const void* source, int siz );
274 
276  void swapFromBuffer( void* target, int siz );
277 
279  StreamBuffer& writeBytes( const char* str, long len ) {
280  extend( m_pointer + len + 4 );
281  *this << len;
282  std::copy_n( str, len, data() + buffPointer() );
283  m_pointer += len;
284  return *this;
285  }
286 
287  void getIdentifiedLink( DataObject*& pObject, long& hint ) {
289  pObject = l.first;
290  hint = l.second;
292  }
293  void addIdentifiedLink( const DataObject* pObject, long hint ) {
295  }
296 
297  void getContainedLink( ContainedObject*& pObject, long& hint, long& link ) {
299  pObject = l.first;
300  hint = l.second;
301  link = l.third;
303  }
304  void addContainedLink( const ContainedObject* pObject, long hint, long link ) {
305  m_containedLinks.push_back( ContainedLink( (ContainedObject*)pObject, hint, link ) );
306  }
307 
308 #ifdef USE_STREAM_ANALYSER
309 # define STREAM_ANALYSE( data, len ) \
310  if ( 0 != m_analyzer ) m_analyzer( &data, len, typeid( data ) )
311 #else
312 # define STREAM_ANALYSE( data, len )
313 #endif
314 
315 // Implement streamer macros for primivive data types.
316 #define IMPLEMENT_STREAMER( TYPE ) \
317  /* Output Streamer */ \
318  StreamBuffer& operator<<( TYPE data ) { \
319  swapToBuffer( &data, sizeof( data ) ); \
320  STREAM_ANALYSE( data, sizeof( data ) ); \
321  return *this; \
322  } \
323  /* Input Streamer */ \
324  StreamBuffer& operator>>( TYPE& data ) { \
325  swapFromBuffer( &data, sizeof( data ) ); \
326  return *this; \
327  }
328 // RootCint does not understand this macro....
329 // But we can easily live without it!
330 #undef IMPLEMENT_STREAMER
331 
333  StreamBuffer& operator<<( long long data ) {
334  swapToBuffer( &data, sizeof( data ) );
335  STREAM_ANALYSE( data, sizeof( data ) );
336  return *this;
337  }
339  StreamBuffer& operator>>( long long& data ) {
340  swapFromBuffer( &data, sizeof( data ) );
341  return *this;
342  }
345  swapToBuffer( &data, sizeof( data ) );
346  STREAM_ANALYSE( data, sizeof( data ) );
347  return *this;
348  }
351  swapFromBuffer( &data, sizeof( data ) );
352  return *this;
353  }
355  StreamBuffer& operator<<( unsigned int data ) {
356  swapToBuffer( &data, sizeof( data ) );
357  STREAM_ANALYSE( data, sizeof( data ) );
358  return *this;
359  }
361  StreamBuffer& operator>>( unsigned int& data ) {
362  swapFromBuffer( &data, sizeof( data ) );
363  return *this;
364  }
367  swapToBuffer( &data, sizeof( data ) );
368  STREAM_ANALYSE( data, sizeof( data ) );
369  return *this;
370  }
373  swapFromBuffer( &data, sizeof( data ) );
374  return *this;
375  }
377  StreamBuffer& operator<<( unsigned long data ) {
378  swapToBuffer( &data, sizeof( data ) );
379  STREAM_ANALYSE( data, sizeof( data ) );
380  return *this;
381  }
383  StreamBuffer& operator>>( unsigned long& data ) {
384  swapFromBuffer( &data, sizeof( data ) );
385  return *this;
386  }
389  swapToBuffer( &data, sizeof( data ) );
390  STREAM_ANALYSE( data, sizeof( data ) );
391  return *this;
392  }
395  swapFromBuffer( &data, sizeof( data ) );
396  return *this;
397  }
399  StreamBuffer& operator<<( unsigned short data ) {
400  swapToBuffer( &data, sizeof( data ) );
401  STREAM_ANALYSE( data, sizeof( data ) );
402  return *this;
403  }
405  StreamBuffer& operator>>( unsigned short& data ) {
406  swapFromBuffer( &data, sizeof( data ) );
407  return *this;
408  }
411  swapToBuffer( &data, sizeof( data ) );
412  STREAM_ANALYSE( data, sizeof( data ) );
413  return *this;
414  }
417  swapFromBuffer( &data, sizeof( data ) );
418  return *this;
419  }
421  StreamBuffer& operator<<( unsigned char data ) {
422  swapToBuffer( &data, sizeof( data ) );
423  STREAM_ANALYSE( data, sizeof( data ) );
424  return *this;
425  }
427  StreamBuffer& operator>>( unsigned char& data ) {
428  swapFromBuffer( &data, sizeof( data ) );
429  return *this;
430  }
433  swapToBuffer( &data, sizeof( data ) );
434  STREAM_ANALYSE( data, sizeof( data ) );
435  return *this;
436  }
439  swapFromBuffer( &data, sizeof( data ) );
440  return *this;
441  }
444  swapToBuffer( &data, sizeof( data ) );
445  STREAM_ANALYSE( data, sizeof( data ) );
446  return *this;
447  }
450  swapFromBuffer( &data, sizeof( data ) );
451  return *this;
452  }
455  long i, len;
456  *this >> len;
457  for ( i = 0, data[0] = 0; i < len; i++ ) { data[i] = m_buffer[m_pointer++]; }
458  return *this;
459  }
461  StreamBuffer& operator<<( const char* data ) {
462  const char* ptr = 0 == data ? "" : data;
463  size_t len = strlen( ptr ) + 1;
464  if ( 0 == m_analyzer )
465  writeBytes( ptr, len );
466  else { STREAM_ANALYSE( data, len ); }
467  return *this;
468  }
471  long i, len;
472  *this >> len;
473  for ( i = 0, data = ""; i < len; i++ ) { data.append( 1, m_buffer[m_pointer++] ); }
474  return *this;
475  }
478  if ( 0 == m_analyzer ) {
479  const char* ptr = data.c_str();
480  long len = data.length();
481  writeBytes( ptr, len );
482  } else {
483  STREAM_ANALYSE( data, sizeof( data ) );
484  }
485  return *this;
486  }
493  template <class TYPE>
494  StreamBuffer& operator>>( TYPE*& refpObject ) {
495  return getObjectPointer( refpObject, refpObject );
496  }
497 
505  STREAM_ANALYSE( pObject, sizeof( pObject ) );
506  addContainedLink( pObject, INVALID, INVALID );
507  return *this;
508  }
509 
516  StreamBuffer& operator<<( const DataObject* pObject ) {
517  STREAM_ANALYSE( pObject, sizeof( pObject ) );
518  addIdentifiedLink( pObject, INVALID );
519  return *this;
520  }
521 
528  void serialize( DataIO& ioObject ) {
529  ioObject.serialize( *this );
530  m_pointer = 0;
531  }
532 };
533 
534 #undef STREAM_ANALYSE
535 
538  switch ( siz ) {
539  case 1:
540  return SINGLE_BYTE;
541  default:
542 #if defined( __alpha ) && !defined( __VMS )
543  // return m_swapEnabled ? SWAP : NOSWAP;
544  return NOSWAP;
545 #elif defined( __sun ) && defined( __SVR4 ) && defined( __i386 )
546  // return m_swapEnabled ? SWAP : NOSWAP;
547  return NOSWAP;
548 #elif defined( __APPLE__ )
549  // return m_swapEnabled ? SWAP : NOSWAP;
550  return SWAP;
551 #elif defined( __linux ) && !defined( __powerpc )
552  // return m_swapEnabled ? SWAP : NOSWAP;
553  return NOSWAP;
554 #elif defined( BORLAND ) || defined( _WIN32 ) || defined( WIN32 )
555  // return m_swapEnabled ? SWAP : NOSWAP;
556  return NOSWAP;
557 #else
558  return m_swapEnabled ? SWAP : NOSWAP;
559 // return NOSWAP;
560 #endif
561  }
562 }
563 
565 inline void StreamBuffer::swapToBuffer( const void* source, int siz ) {
566  char buff[8], *tar, *src = (char*)source;
567  extend( m_pointer + siz );
568  tar = m_buffer + m_pointer;
569  switch ( swapBuffer( siz ) ) {
570  case SINGLE_BYTE:
571  *tar = *src;
572  break;
573  case SWAP:
574 #ifdef __APPLE__
575  for ( int i = 0, j = siz - 1; i < siz; i++, j-- ) tar[j] = src[i];
576 #else
577  ::_swab( src, buff, siz );
578 #endif
579  src = buff;
580  [[fallthrough]];
581  case NOSWAP:
582  std::copy_n( src, siz, tar );
583  break;
584  default:
585  break;
586  }
587  m_pointer += siz;
588 }
589 
591 inline void StreamBuffer::swapFromBuffer( void* target, int siz ) {
592  char* tar = (char*)target;
593  char* src = m_buffer + m_pointer;
594  switch ( swapBuffer( siz ) ) {
595  case SINGLE_BYTE:
596  *tar = *src;
597  break;
598  case SWAP:
599 #ifdef __APPLE__
600  for ( int i = 0, j = siz - 1; i < siz; i++, j-- ) tar[j] = src[i];
601 #else
602  ::_swab( src, tar, siz );
603 #endif
604  break;
605  case NOSWAP:
606  std::copy_n( src, siz, tar );
607  break;
608  default:
609  break;
610  }
611  m_pointer += siz;
612 }
613 
614 // Output serialize a vector of items
615 template <class T>
617  s << v.size();
618  for ( const auto& i : v ) s << i;
619  return s;
620 }
621 
622 // Input serialize a vector of items
623 template <class T>
625  long i, len;
626  s >> len;
627  v.clear();
628  for ( i = 0; i < len; i++ ) {
629  T temp;
630  s >> temp;
631  v.push_back( temp );
632  }
633  return s;
634 }
635 
636 // Output serialize a list of items
637 template <class T>
639  s << l.size();
640  for ( const auto& i : l ) s << i;
641  return s;
642 }
643 
644 // Input serialize a list of items
645 template <class T>
647  long len;
648  s >> len;
649  l.clear();
650  for ( long i = 0; i < len; i++ ) {
651  T temp;
652  s >> temp;
653  l.push_back( temp );
654  }
655  return s;
656 }
657 #endif // GAUDIKERNEL_STREAMBUFFER_H
StreamBuffer::operator<<
StreamBuffer & operator<<(const char *data)
Streamer to write strings in (char*) format.
Definition: StreamBuffer.h:461
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:249
StreamBuffer::operator<<
StreamBuffer & operator<<(const std::string &data)
Streamer to write strings in (std::string) format.
Definition: StreamBuffer.h:477
StreamBuffer::operator>>
StreamBuffer & operator>>(int &data)
Input Streamer.
Definition: StreamBuffer.h:350
StreamBuffer::containedLinks
const ContainedLinks & containedLinks() const
CONST Access to contained links.
Definition: StreamBuffer.h:246
StreamBuffer::setBuffPointer
void setBuffPointer(long ptr)
Retrieve current buffer pointer.
Definition: StreamBuffer.h:269
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:215
Write.stream
stream
Definition: Write.py:32
StreamBuffer::operator>>
StreamBuffer & operator>>(unsigned char &data)
Input Streamer.
Definition: StreamBuffer.h:427
StreamBuffer::operator<<
StreamBuffer & operator<<(float data)
Output Streamer.
Definition: StreamBuffer.h:432
StreamBuffer::addIdentifiedLink
void addIdentifiedLink(const DataObject *pObject, long hint)
Definition: StreamBuffer.h:293
StreamBuffer::m_buffer
char * m_buffer
Pointer to heap buffer.
Definition: StreamBuffer.h:163
std::string
STL class.
StreamBuffer::StreamBuffer
StreamBuffer(bool do_swap=true)
Standard constructor.
Definition: StreamBuffer.h:205
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:388
StreamBuffer::Ostream::~Ostream
virtual ~Ostream()=default
Standard Destructor.
StreamBuffer::serialize
void serialize(DataIO &ioObject)
Serialize the buffer using an IO object.
Definition: StreamBuffer.h:528
StreamBuffer::m_containedLinks
ContainedLinks m_containedLinks
Container with links to contained objects.
Definition: StreamBuffer.h:169
gaudirun.s
string s
Definition: gaudirun.py:346
StreamBuffer::swapBuffer
SwapAction swapBuffer(int siz) const
Check for byte swapping.
Definition: StreamBuffer.h:537
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:232
StreamBuffer::operator<<
StreamBuffer & operator<<(const DataObject *pObject)
Streamer to write links to identified objects.
Definition: StreamBuffer.h:516
StreamBuffer::operator<<
StreamBuffer & operator<<(unsigned short data)
Output Streamer.
Definition: StreamBuffer.h:399
StreamBuffer::m_mode
Mode m_mode
Boolean indicating wether the stream is in read or write mode.
Definition: StreamBuffer.h:154
StreamBuffer::operator<<
StreamBuffer & operator<<(unsigned long data)
Output Streamer.
Definition: StreamBuffer.h:377
StreamBuffer::SwapAction
SwapAction
Data Sawp actions.
Definition: StreamBuffer.h:119
StreamBuffer::buffPointer
long buffPointer() const
Retrieve current buffer pointer.
Definition: StreamBuffer.h:267
StreamBuffer::m_analyzer
AnalyzeFunction m_analyzer
Hook function for analysis of data to the stream.
Definition: StreamBuffer.h:175
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:504
StreamBuffer::Istream::Istream
Istream(std::istream &str)
Constructor.
Definition: StreamBuffer.h:85
StreamBuffer::operator<<
StreamBuffer & operator<<(double data)
Output Streamer.
Definition: StreamBuffer.h:443
StreamBuffer::swapFromBuffer
void swapFromBuffer(void *target, int siz)
Swap buffers: int, long, short, float and double.
Definition: StreamBuffer.h:591
swab.h
StreamBuffer::m_swapEnabled
bool m_swapEnabled
Flag indicating swapping.
Definition: StreamBuffer.h:166
StreamBuffer::AnalyzeFunction
void(* AnalyzeFunction)(const void *data, int siz, const std::type_info &type)
Definition of the buffer analyzer.
Definition: StreamBuffer.h:148
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:405
StreamBuffer::IdentifiedLinks
std::vector< IdentifiedLink > IdentifiedLinks
Definition of the identifiable link set.
Definition: StreamBuffer.h:146
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:565
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:104
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:279
StreamBuffer::getObjectPointer
StreamBuffer & getObjectPointer(const ContainedObject *, TYPE *&refpObject)
Helper to distinguish between identified pointers and contained pointers.
Definition: StreamBuffer.h:195
operator<<
StreamBuffer & operator<<(StreamBuffer &s, const std::vector< T > &v)
Definition: StreamBuffer.h:616
StreamBuffer::operator>>
StreamBuffer & operator>>(unsigned long &data)
Input Streamer.
Definition: StreamBuffer.h:383
StreamBuffer::getObjectPointer
StreamBuffer & getObjectPointer(const DataObject *, TYPE *&refpObject)
Helper to distinguish between identified pointers and contained pointers.
Definition: StreamBuffer.h:184
StreamBuffer::containedLinks
ContainedLinks & containedLinks()
Access to contained links.
Definition: StreamBuffer.h:244
std::vector::erase
T erase(T... args)
StreamBuffer::isWriting
bool isWriting() const
Get stream buffer state.
Definition: StreamBuffer.h:265
StreamBuffer::operator<<
StreamBuffer & operator<<(char data)
Output Streamer.
Definition: StreamBuffer.h:410
StreamBuffer::identifiedLinks
const IdentifiedLinks & identifiedLinks() const
CONST Access to identified links.
Definition: StreamBuffer.h:251
StreamBuffer::setMode
void setMode(Mode m)
Set mode of the stream and allocate buffer.
Definition: StreamBuffer.h:254
StreamBuffer::operator<<
StreamBuffer & operator<<(long data)
Output Streamer.
Definition: StreamBuffer.h:366
StreamBuffer::size
long size() const
Total buffer size.
Definition: StreamBuffer.h:242
StreamBuffer::setAnalyzer
void setAnalyzer(AnalyzeFunction fun=nullptr)
Enable user analysis function.
Definition: StreamBuffer.h:271
StreamBuffer::data
char * data()
write access to data buffer
Definition: StreamBuffer.h:211
StreamBuffer::data
const char * data() const
Read access to data buffer.
Definition: StreamBuffer.h:209
StreamBuffer::isReading
bool isReading() const
Get stream buffer state.
Definition: StreamBuffer.h:262
StreamBuffer::~StreamBuffer
virtual ~StreamBuffer()
Standard destructor.
Definition: StreamBuffer.h:207
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:225
StreamBuffer::operator<<
StreamBuffer & operator<<(int data)
Output Streamer.
Definition: StreamBuffer.h:344
StreamBuffer::operator>>
StreamBuffer & operator>>(char *data)
Streamer to read strings in (char*) format.
Definition: StreamBuffer.h:454
StreamBuffer::operator>>
StreamBuffer & operator>>(float &data)
Input Streamer.
Definition: StreamBuffer.h:438
StreamBuffer::operator>>
StreamBuffer & operator>>(std::string &data)
Streamer to read strings in (std::string) format.
Definition: StreamBuffer.h:470
StreamBuffer::operator<<
StreamBuffer & operator<<(long long data)
Output Streamer.
Definition: StreamBuffer.h:333
StreamBuffer::operator>>
StreamBuffer & operator>>(long &data)
Input Streamer.
Definition: StreamBuffer.h:372
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:160
StreamBuffer::operator>>
StreamBuffer & operator>>(double &data)
Input Streamer.
Definition: StreamBuffer.h:449
StreamBuffer::Mode
Mode
Streamer mode.
Definition: StreamBuffer.h:117
gaudirun.l
dictionary l
Definition: gaudirun.py:583
std::vector::begin
T begin(T... args)
Kernel.h
StreamBuffer::operator>>
StreamBuffer & operator>>(short &data)
Input Streamer.
Definition: StreamBuffer.h:394
StreamBuffer::m_length
long m_length
Total buffer length.
Definition: StreamBuffer.h:160
StreamBuffer::m_pointer
long m_pointer
Current buffer pointer.
Definition: StreamBuffer.h:157
StreamBuffer::getIdentifiedLink
void getIdentifiedLink(DataObject *&pObject, long &hint)
Definition: StreamBuffer.h:287
StreamBuffer::erase
void erase()
Reset the buffer.
Definition: StreamBuffer.h:213
StreamBuffer::VALID
@ VALID
Definition: StreamBuffer.h:121
DataObject
Definition: DataObject.h:36
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:494
Properties.v
v
Definition: Properties.py:122
operator>>
StreamBuffer & operator>>(StreamBuffer &s, std::vector< T > &v)
Definition: StreamBuffer.h:624
StreamBuffer::DataIO::DataIO
DataIO()=default
Standard constructor.
StreamBuffer::operator<<
StreamBuffer & operator<<(unsigned char data)
Output Streamer.
Definition: StreamBuffer.h:421
StreamBuffer::operator>>
StreamBuffer & operator>>(unsigned int &data)
Input Streamer.
Definition: StreamBuffer.h:361
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:304
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:312
StreamBuffer::operator>>
StreamBuffer & operator>>(long long &data)
Input Streamer.
Definition: StreamBuffer.h:339
StreamBuffer::operator>>
StreamBuffer & operator>>(char &data)
Input Streamer.
Definition: StreamBuffer.h:416
StreamBuffer::WRITING
@ WRITING
Definition: StreamBuffer.h:117
StreamBuffer::ContainedLinks
std::vector< ContainedLink > ContainedLinks
Definition: StreamBuffer.h:144
ContainedObject
Definition: ContainedObject.h:41
StreamBuffer::m_identifiedLinks
IdentifiedLinks m_identifiedLinks
Container with links to contained objects.
Definition: StreamBuffer.h:172
StreamBuffer::getContainedLink
void getContainedLink(ContainedObject *&pObject, long &hint, long &link)
Definition: StreamBuffer.h:297
StreamBuffer::operator<<
StreamBuffer & operator<<(unsigned int data)
Output Streamer.
Definition: StreamBuffer.h:355
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