TPIE

2362a60
tpie::bits::serialization_reader_base Class Referenceabstract

Inherited by tpie::serialization_reader, and tpie::serialization_reverse_reader.

Public Member Functions

void close ()
 
void read (char *const s, const memory_size_type n)
 Read n bytes from stream into buffer starting at s. More...
 
template<typename T >
void unserialize (T &v)
 Unserialize an unserializable item from the stream. More...
 
template<typename IT >
void unserialize (IT a, IT b)
 Unserialize a sequence of unserializable items from the stream. More...
 
stream_size_type file_size ()
 Size of file in bytes, including the header. More...
 
stream_size_type size ()
 Size of file in bytes, not including the header. More...
 

Static Public Member Functions

static memory_size_type block_size ()
 
static memory_size_type memory_usage ()
 

Protected Member Functions

void open (std::string path, bool reverse)
 
void read_block (const stream_size_type blk)
 
virtual void next_block ()=0
 

Protected Attributes

tpie::array< char > m_block
 
stream_size_type m_size
 
memory_size_type m_index
 
memory_size_type m_blockSize
 

Detailed Description

Definition at line 252 of file serialization_stream.h.

Member Function Documentation

stream_size_type tpie::bits::serialization_reader_base::file_size ( )

Size of file in bytes, including the header.

void tpie::bits::serialization_reader_base::read ( char *const  s,
const memory_size_type  n 
)
inline

Read n bytes from stream into buffer starting at s.

Parameters
sBuffer to contain the read data.
nNumber of bytes to read.

Definition at line 286 of file serialization_stream.h.

References tpie::array< T, Allocator >::get().

286  {
287  // TODO: inline some of this
288  char * i = s;
289  memory_size_type written = 0;
290  while (written != n) {
291  if (m_index >= m_blockSize) {
292  // virtual invocation
293  next_block();
294  }
295 
296  memory_size_type remaining = n - written;
297  memory_size_type blockRemaining = m_blockSize - m_index;
298 
299  memory_size_type readSize = std::min(remaining, blockRemaining);
300 
301  i = std::copy(m_block.get() + m_index,
302  m_block.get() + (m_index + readSize),
303  i);
304 
305  written += readSize;
306  m_index += readSize;
307  }
308  }
T * get()
Return a raw pointer to the array content.
Definition: array.h:531
template<typename T >
void tpie::bits::serialization_reader_base::unserialize ( T &  v)
inline

Unserialize an unserializable item from the stream.

An item of the given type must exist at the current point in the stream.

The code stream.unserialize(v) just calls unserialize(stream, v) via ADL.

Definition at line 320 of file serialization_stream.h.

References tpie::unserialize().

Referenced by tpie::pipelining::serialization_bits::input_t< dest_t >::go(), tpie::pipelining::serialization_bits::reverser_output_t< dest_t >::go(), tpie::pipelining::serialization_bits::buffer_output_t< dest_t >::go(), and unserialize().

320  {
321  using tpie::unserialize;
322  unserialize(*this, v);
323  }
void unserialize(S &src, foo &v)
Sample tpie::unserialize prototype.
void unserialize(T &v)
Unserialize an unserializable item from the stream.
template<typename IT >
void tpie::bits::serialization_reader_base::unserialize ( IT  a,
IT  b 
)
inline

Unserialize a sequence of unserializable items from the stream.

A sequence of the given item type must exist at the current point in the stream.

The code stream.unserialize(a, b) just calls unserialize(stream, a, b) via ADL.

Definition at line 335 of file serialization_stream.h.

References tpie::unserialize(), and unserialize().

335  {
336  using tpie::unserialize;
337  unserialize(*this, a, b);
338  }
void unserialize(S &src, foo &v)
Sample tpie::unserialize prototype.
void unserialize(T &v)
Unserialize an unserializable item from the stream.

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