Loading [MathJax]/extensions/tex2jax.js
Go to the documentation of this file.
63 else if (
stream.isWriting() )
106 ( *m_stream ) <<
stream.buffPointer();
179 template <
class TYPE>
184 refpObject =
dynamic_cast<TYPE*
>( pObj );
190 template <
class TYPE>
195 refpObject =
dynamic_cast<TYPE*
>( pObj );
223 m_length = ( len < 16384 ) ? 16384 : len;
233 if (
m_length < len ) new_len += len;
304 #ifdef USE_STREAM_ANALYSER
305 # define STREAM_ANALYSE( data, len ) \
306 if ( 0 != m_analyzer ) m_analyzer( &data, len, typeid( data ) )
308 # define STREAM_ANALYSE( data, len )
312 #define IMPLEMENT_STREAMER( TYPE ) \
314 StreamBuffer& operator<<( TYPE data ) { \
315 swapToBuffer( &data, sizeof( data ) ); \
316 STREAM_ANALYSE( data, sizeof( data ) ); \
320 StreamBuffer& operator>>( TYPE& data ) { \
321 swapFromBuffer( &data, sizeof( data ) ); \
326 #undef IMPLEMENT_STREAMER
458 const char* ptr = 0 ==
data ?
"" :
data;
459 size_t len = strlen( ptr ) + 1;
475 const char* ptr =
data.c_str();
476 long len =
data.length();
489 template <
class TYPE>
530 #undef STREAM_ANALYSE
538 #if defined( __alpha ) && !defined( __VMS )
541 #elif defined( __sun ) && defined( __SVR4 ) && defined( __i386 )
544 #elif defined( __APPLE__ )
547 #elif defined( __linux ) && !defined( __powerpc )
559 char buff[8], *tar, *src = (
char*)source;
568 for (
int i = 0,
j = siz - 1; i < siz; i++,
j-- ) tar[
j] = src[i];
570 ::swab( src, buff, siz );
575 std::copy_n( src, siz, tar );
585 char* tar = (
char*)
target;
593 for (
int i = 0,
j = siz - 1; i < siz; i++,
j-- ) tar[
j] = src[i];
595 ::swab( src, tar, siz );
599 std::copy_n( src, siz, tar );
611 for (
const auto& i :
v )
s << i;
621 for ( i = 0; i < len; i++ ) {
633 for (
const auto& i :
l )
s << i;
643 for (
long i = 0; i < len; i++ ) {
StreamBuffer & operator<<(const char *data)
Streamer to write strings in (char*) format.
std::istream * m_stream
Reference to input stream.
IdentifiedLinks & identifiedLinks()
Access to identified links.
StreamBuffer & operator<<(const std::string &data)
Streamer to write strings in (std::string) format.
ContainedLink & operator=(const ContainedLink ©)=default
StreamBuffer & operator>>(int &data)
Input Streamer.
const ContainedLinks & containedLinks() const
CONST Access to contained links.
void setBuffPointer(long ptr)
Retrieve current buffer pointer.
char * adopt() const
Remove the data buffer and pass it to client. It's the client responsability to free the memory.
StreamBuffer & operator>>(unsigned char &data)
Input Streamer.
StreamBuffer & operator<<(float data)
Output Streamer.
Definition of the contained link set.
void addIdentifiedLink(const DataObject *pObject, long hint)
char * m_buffer
Pointer to heap buffer.
StreamBuffer(bool do_swap=true)
Standard constructor.
virtual ~DataIO()=default
Standard destructor.
StreamBuffer & operator<<(short data)
Output Streamer.
virtual ~Ostream()=default
Standard Destructor.
void serialize(DataIO &ioObject)
Serialize the buffer using an IO object.
ContainedLinks m_containedLinks
Container with links to contained objects.
SwapAction swapBuffer(int siz) const
Check for byte swapping.
void badStreamMode()
Throw Exception.
virtual void load(StreamBuffer &)
Template function to load stream data.
ContainedLink(ContainedObject *pObj, long hint, long link)
void extend(long len)
Extend the buffer.
StreamBuffer & operator<<(const DataObject *pObject)
Streamer to write links to identified objects.
StreamBuffer & operator<<(unsigned short data)
Output Streamer.
Mode m_mode
Boolean indicating wether the stream is in read or write mode.
StreamBuffer & operator<<(unsigned long data)
Output Streamer.
SwapAction
Data Sawp actions.
long buffPointer() const
Retrieve current buffer pointer.
Definition of the contained link set.
AnalyzeFunction m_analyzer
Hook function for analysis of data to the stream.
StreamBuffer & operator<<(const ContainedObject *pObject)
Streamer to write links to contained objects.
Istream(std::istream &str)
Constructor.
StreamBuffer & operator<<(double data)
Output Streamer.
void swapFromBuffer(void *target, int siz)
Swap buffers: int, long, short, float and double.
bool m_swapEnabled
Flag indicating swapping.
void(* AnalyzeFunction)(const void *data, int siz, const std::type_info &type)
Definition of the buffer analyzer.
Writer for standard output streams.
virtual void serialize(StreamBuffer &stream)
Serialization method: loads/dumps streambuffer content.
StreamBuffer & operator>>(unsigned short &data)
Input Streamer.
std::vector< IdentifiedLink > IdentifiedLinks
Definition of the identifiable link set.
ContainedLink(const ContainedLink ©)=default
void swapToBuffer(const void *source, int siz)
Swap buffers: int, long, short, float and double.
IdentifiedLink & operator=(const IdentifiedLink ©)=default
State
Link state defintions.
void load(StreamBuffer &stream) override
Data load method.
StreamBuffer & writeBytes(const char *str, long len)
Write string to output stream.
StreamBuffer & getObjectPointer(const ContainedObject *, TYPE *&refpObject)
Helper to distinguish between identified pointers and contained pointers.
StreamBuffer & operator<<(StreamBuffer &s, const std::vector< T > &v)
StreamBuffer & operator>>(unsigned long &data)
Input Streamer.
StreamBuffer & getObjectPointer(const DataObject *, TYPE *&refpObject)
Helper to distinguish between identified pointers and contained pointers.
IdentifiedLink(DataObject *pObj, long hint)
ContainedLinks & containedLinks()
Access to contained links.
bool isWriting() const
Get stream buffer state.
StreamBuffer & operator<<(char data)
Output Streamer.
const IdentifiedLinks & identifiedLinks() const
CONST Access to identified links.
void setMode(Mode m)
Set mode of the stream and allocate buffer.
StreamBuffer & operator<<(long data)
Output Streamer.
long size() const
Total buffer size.
void setAnalyzer(AnalyzeFunction fun=nullptr)
Enable user analysis function.
char * data()
write access to data buffer
const char * data() const
Read access to data buffer.
bool isReading() const
Get stream buffer state.
virtual ~StreamBuffer()
Standard destructor.
virtual void dump(StreamBuffer &)
Template function to save stream data.
void reserve(long len)
Reserve buffer space; Default: 16 k buffer size.
StreamBuffer & operator<<(int data)
Output Streamer.
StreamBuffer & operator>>(char *data)
Streamer to read strings in (char*) format.
StreamBuffer & operator>>(float &data)
Input Streamer.
StreamBuffer & operator>>(std::string &data)
Streamer to read strings in (std::string) format.
StreamBuffer & operator<<(long long data)
Output Streamer.
StreamBuffer & operator>>(long &data)
Input Streamer.
Reader for standard input streams.
void dump(StreamBuffer &stream) override
Output dumper.
StreamBuffer & operator>>(double &data)
Input Streamer.
StreamBuffer & operator>>(short &data)
Input Streamer.
long m_length
Total buffer length.
long m_pointer
Current buffer pointer.
void getIdentifiedLink(DataObject *&pObject, long &hint)
void erase()
Reset the buffer.
A small base class to handle generic data streaming.
IdentifiedLink(const IdentifiedLink ©)=default
StreamBuffer & operator>>(TYPE *&refpObject)
Streamer to read links to contained or identified objects.
StreamBuffer & operator>>(StreamBuffer &s, std::vector< T > &v)
DataIO()=default
Standard constructor.
StreamBuffer & operator<<(unsigned char data)
Output Streamer.
StreamBuffer & operator>>(unsigned int &data)
Input Streamer.
void addContainedLink(const ContainedObject *pObject, long hint, long link)
#define STREAM_ANALYSE(data, len)
StreamBuffer & operator>>(long long &data)
Input Streamer.
StreamBuffer & operator>>(char &data)
Input Streamer.
std::vector< ContainedLink > ContainedLinks
IdentifiedLinks m_identifiedLinks
Container with links to contained objects.
void getContainedLink(ContainedObject *&pObject, long &hint, long &link)
StreamBuffer & operator<<(unsigned int data)
Output Streamer.
Ostream(std::ostream &str)
Standard constructor: pass reference to stream object.