CFEL - ASG Software Suite  2.5.0
CASS
Public Member Functions | Private Member Functions | Private Attributes | List of all members
cass::Serializer Class Reference

A string serializer. More...

#include <serializer.hpp>

+ Inheritance diagram for cass::Serializer:
+ Collaboration diagram for cass::Serializer:

Public Member Functions

 Serializer (int compressionlevel=Z_BEST_COMPRESSION)
 constructor. More...
 
 Serializer (const std::string &string)
 constructor More...
 
 ~Serializer ()
 destructor. More...
 
const std::string buffer () const
 retrieve a const reference to the compressed string. More...
 
- Public Member Functions inherited from cass::SerializerBackend
 SerializerBackend ()
 constructor More...
 
void flush ()
 flush the stream More...
 
std::ostream & writeToStream (const char *data, std::streamsize n)
 write data to the stream More...
 
std::istream & readFromStream (char *data, std::streamsize n)
 read data from the stream More...
 
template<typename Type >
void add (const Type &value)
 add arbitrary value to the stream More...
 
template<typename Type >
Type retrieve ()
 read arbitrary value from stream More...
 
void startChecksumGroupForRead ()
 control checksum calculation for the next values added More...
 
bool endChecksumGroupForRead ()
 
void startChecksumGroupForWrite ()
 control checksum for writing to stream More...
 
void endChecksumGroupForWrite ()
 

Private Member Functions

std::string compress (const std::string &str) const
 Compress a STL string using zlib with given compression level and return the binary data. More...
 
std::string decompress (const std::string &str) const
 Decompress an STL string using zlib and return the inflated data. More...
 

Private Attributes

int _compresslevel
 

Additional Inherited Members

- Protected Member Functions inherited from cass::SerializerBackend
void addToOutChecksum (const char *data, std::streamsize len)
 fletcher16 algorithm for 8 bit input More...
 
void addToInChecksum (const char *data, std::streamsize len)
 fletcher16 algorithm for 8 bit input More...
 
- Protected Attributes inherited from cass::SerializerBackend
std::iostream * _stream
 the string to serialize the objects to (buffer) More...
 
uint16_t r_sum1
 sum 1 for reading More...
 
uint16_t r_sum2
 sum 2 for reading More...
 
uint16_t w_sum1
 sum 1 for writing More...
 
uint16_t w_sum2
 sum 2 for writing More...
 
bool _checkSumGroupStartedForRead
 flag to enable getting parts to a checksum More...
 
bool _checkSumGroupStartedForWrite
 flag to enable adding parts to a checksum More...
 

Detailed Description

A string serializer.

class that will serialize / de serialize Serializable classes to a stringstream

The resulting buffer will be compressed and the string to be read from will be decompressed before reading from it

Author
Lutz Foucar
Stephan Kassemeyer

Definition at line 287 of file serializer.hpp.

Constructor & Destructor Documentation

cass::Serializer::Serializer ( int  compressionlevel = Z_BEST_COMPRESSION)
inlineexplicit

constructor.

will open the stream in binary writing mode

Parameters
compressionlevelthe level for the z-lib compression. Default is best compression

Definition at line 297 of file serializer.hpp.

References cass::SerializerBackend::_stream.

cass::Serializer::Serializer ( const std::string &  string)
inline

constructor

will open the provided string for reading in binary mode after it is decompressed

Parameters
stringthe compressed string that we want to read from

Definition at line 310 of file serializer.hpp.

References cass::SerializerBackend::_stream, and decompress().

cass::Serializer::~Serializer ( )
inline

destructor.

deletes stream object

Definition at line 320 of file serializer.hpp.

References cass::SerializerBackend::_stream.

Member Function Documentation

const std::string cass::Serializer::buffer ( ) const
inline

retrieve a const reference to the compressed string.

Returns
const string of our stringstream

Definition at line 329 of file serializer.hpp.

References cass::SerializerBackend::_stream, and compress().

Referenced by jocassview::TCPClient::results().

std::string cass::Serializer::compress ( const std::string &  str) const
inlineprivate

Compress a STL string using zlib with given compression level and return the binary data.

Copyright 2007 Timo Bingmann tb@pa.nosp@m.nthe.nosp@m.ma.ne.nosp@m.t Distributed under the Boost Software License, Version 1.0. (See http://www.boost.org/LICENSE_1_0.txt)

Returns
a compressed string
Parameters
str

z_stream is zlib's control structure

set the z_stream's input

retrieve the compressed bytes blockwise

append the block to the output string

an error occurred that was not EOF

Definition at line 345 of file serializer.hpp.

References _compresslevel.

Referenced by buffer().

std::string cass::Serializer::decompress ( const std::string &  str) const
inlineprivate

Decompress an STL string using zlib and return the inflated data.

Copyright 2007 Timo Bingmann tb@pa.nosp@m.nthe.nosp@m.ma.ne.nosp@m.t Distributed under the Boost Software License, Version 1.0. (See http://www.boost.org/LICENSE_1_0.txt)

Returns
the de-ccompressed string
Parameters
strthe compressed string

z_stream is zlib's control structure

get the decompressed bytes blockwise using repeated calls to inflate

an error occurred that was not EOF

Definition at line 409 of file serializer.hpp.

Referenced by Serializer().

Member Data Documentation

int cass::Serializer::_compresslevel
private

Definition at line 463 of file serializer.hpp.

Referenced by compress().


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