20 #ifndef TPIE_FILE_ACCESSOR_STREAM_ACCESSOR_H
21 #define TPIE_FILE_ACCESSOR_STREAM_ACCESSOR_H
26 namespace file_accessor {
28 template <
typename file_accessor_t>
32 stream_size_type blockNumber,
33 memory_size_type itemCount)
override
35 stream_size_type loc = this->
header_size() + blockNumber*this->block_size();
36 this->m_fileAccessor.seek_i(loc);
37 stream_size_type offset = blockNumber*this->block_items();
38 if (offset + itemCount > this->
size()) itemCount =
static_cast<memory_size_type
>(this->
size() - offset);
39 memory_size_type z=itemCount*this->item_size();
40 this->m_fileAccessor.read_i(data, z);
45 stream_size_type blockNumber,
46 memory_size_type itemCount)
override
48 stream_size_type loc = this->
header_size() + blockNumber*this->block_size();
52 this->m_fileAccessor.seek_i(loc);
53 stream_size_type offset = blockNumber*this->block_items();
54 memory_size_type z=itemCount*this->item_size();
55 this->m_fileAccessor.write_i(data, z);
56 if (offset+itemCount > this->
size()) this->set_size(offset+itemCount);
63 #endif // TPIE_FILE_ACCESSOR_STREAM_ACCESSOR_H
virtual memory_size_type read_block(void *data, stream_size_type blockNumber, memory_size_type itemCount) override
Read the given number of items from the given block into the given buffer.
stream_size_type size() const
Number of items in stream.
memory_size_type header_size() const
The size of header and user data with padding included.
Reads and writes stream headers, user data and blocks from TPIE streams.
virtual void write_block(const void *data, stream_size_type blockNumber, memory_size_type itemCount) override
Write the given number of items from the given buffer into the given block.