TPIE

11a2c2d
tpie::serialization_reader Class Reference

Inherits tpie::bits::serialization_reader_base.

Public Member Functions

void open (std::string path)
 
void open (temp_file &tempFile)
 
bool can_read ()
 
stream_size_type offset ()
 Number of bytes read, not including the header. More...
 
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 next_block () override
 
void open (std::string path, bool reverse)
 
void read_block (const stream_size_type blk)
 

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 358 of file serialization_stream.h.

Member Function Documentation

◆ file_size()

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

Size of file in bytes, including the header.

◆ offset()

stream_size_type tpie::serialization_reader::offset ( )

Number of bytes read, not including the header.

For progress reporting.

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

◆ read()

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

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 287 of file serialization_stream.h.

287  {
288  // TODO: inline some of this
289  char * i = s;
290  memory_size_type written = 0;
291  while (written != n) {
292  if (m_index >= m_blockSize) {
293  // virtual invocation
294  next_block();
295  }
296 
297  memory_size_type remaining = n - written;
298  memory_size_type blockRemaining = m_blockSize - m_index;
299 
300  memory_size_type readSize = std::min(remaining, blockRemaining);
301 
302  i = std::copy(m_block.get() + m_index,
303  m_block.get() + (m_index + readSize),
304  i);
305 
306  written += readSize;
307  m_index += readSize;
308  }
309  }

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

◆ size()

◆ unserialize() [1/2]

template<typename IT >
void tpie::bits::serialization_reader_base::unserialize ( IT  a,
IT  b 
)
inlineinherited

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 336 of file serialization_stream.h.

336  {
337  using tpie::unserialize;
338  unserialize(*this, a, b);
339  }

References tpie::unserialize().

◆ unserialize() [2/2]

template<typename T >
void tpie::bits::serialization_reader_base::unserialize ( T &  v)
inlineinherited

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 321 of file serialization_stream.h.

321  {
322  using tpie::unserialize;
323  unserialize(*this, v);
324  }

References tpie::unserialize().

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


The documentation for this class was generated from the following file:
std::copy
tpie::array_iter_base< TT, forward > copy(InputIterator first, InputIterator last, tpie::array_iter_base< TT, forward > d_first)
std::copy template specialization for tpie::array as output.
Definition: array.h:743
tpie::bits::serialization_reader_base::unserialize
void unserialize(T &v)
Unserialize an unserializable item from the stream.
Definition: serialization_stream.h:321
tpie::unserialize
void unserialize(S &src, foo &v)
Sample tpie::unserialize prototype.
tpie::array::get
T * get()
Return a raw pointer to the array content.
Definition: array.h:536