PIP 5.6.1
Platform-Independent Primitives
Public Member Functions | Related Functions | List of all members
PIBinaryStream< P > Class Template Reference

CRTP interface for binary serialization streams. More...

#include <pibinarystream.h>

Public Member Functions

bool binaryStreamAppend (const void *d, size_t s)
 Writes raw bytes to the underlying stream.
 
bool binaryStreamTake (void *d, size_t s)
 Reads raw bytes from the underlying stream and sets read error state on short reads.
 
ssize_t binaryStreamSize () const
 Returns remaining readable byte count. More...
 
template<typename T >
void binaryStreamAppend (T v)
 Writes one trivially copied value as raw bytes.
 
int binaryStreamTakeInt ()
 Reads one int value from the stream.
 
bool wasReadError () const
 Returns whether there has been an incomplete read since last resetReadError() or after the stream was created.
 
void resetReadError ()
 Reset incomplete read flag.
 

Related Functions

(Note that these are not member functions.)

#define BINARY_STREAM_FRIEND(T)
 Declares templated binary stream operators as friends of T.
 
#define BINARY_STREAM_WRITE(T)
 Starts definition of a templated binary write operator for T.
 
#define BINARY_STREAM_READ(T)
 Starts definition of a templated binary read operator for T.
 

Detailed Description

template<typename P>
class PIBinaryStream< P >

CRTP interface for binary serialization streams.

Derived stream classes should implement:

bool binaryStreamAppendImp (const void * d, size_t s);
bool binaryStreamTakeImp (void * d, size_t s);
ssize_t binaryStreamSizeImp () const;
return s
Store operator.
Definition: pisystemmonitor.h:312

binaryStreamSizeImp() should return -1 when the remaining size is unknown. See details Input/Output stream.

Member Function Documentation

◆ binaryStreamSize()

template<typename P >
ssize_t PIBinaryStream< P >::binaryStreamSize ( ) const
inline

Returns remaining readable byte count.

Returns -1 when the stream cannot report its remaining size.