Public Types | |
enum | offset_type { beginning, end, current } |
Type describing how we should interpret the offset supplied to seek. More... | |
Public Member Functions | |
void | seek (stream_offset_type offset, offset_type whence=beginning) throw (stream_exception) |
Moves the logical offset in the stream. More... | |
stream_size_type | offset () const throw () |
Calculate the current offset in the stream. More... | |
bool | can_read () const throw () |
Check if we can read an item with read(). More... | |
bool | can_read_back () const throw () |
Check if we can read an item with read_back(). More... | |
stream_size_type | size () const throw () |
Get the size of the file measured in items. More... | |
Protected Member Functions | |
void | initialize () |
void | update_block () |
Fetch block from disk as indicated by m_nextBlock, writing old block to disk if needed. More... | |
Static Protected Member Functions | |
template<typename IT , typename Stream > | |
static void | read_array (Stream &stream, const IT &start, const IT &end) throw (stream_exception) |
Reads several items from the stream. More... | |
template<typename IT , typename Stream > | |
static void | write_array (Stream &stream, const IT &start, const IT &end) throw (stream_exception) |
Write several items to the stream. More... | |
Protected Attributes | |
memory_size_type | m_index |
Item index into the current block, or maxint if we don't have a block. More... | |
stream_size_type | m_nextBlock |
After a cross-block seek: Block index of next block, or maxint if the current block is good enough OR if we haven't read/written anything yet. More... | |
memory_size_type | m_nextIndex |
After a cross-block seek: Item index into next block. More... | |
stream_size_type | m_blockStartIndex |
The file-level item index of the first item in the current block. More... | |
Definition at line 35 of file stream_crtp.h.
enum tpie::stream_crtp::offset_type |
Type describing how we should interpret the offset supplied to seek.
Definition at line 38 of file stream_crtp.h.
|
inline |
Check if we can read an item with read().
This is logically equivalent to:
but it might be faster.
Definition at line 108 of file stream_crtp.h.
|
inline |
Check if we can read an item with read_back().
Definition at line 119 of file stream_crtp.h.
|
inline |
Calculate the current offset in the stream.
Definition at line 90 of file stream_crtp.h.
Referenced by tpie::stream_crtp< stream >::can_read(), and tpie::stream_crtp< stream >::seek().
|
inlinestaticprotected |
Reads several items from the stream.
Implementation note: If your iterator type is efficiently copyable with std::copy, then this will also read efficiently from the internal TPIE buffer.
IT | The type of Random Access Iterators used to supply the items. |
start | Iterator to the first spot to write to. |
end | Iterator past the last spot to write to. |
end_of_stream_exception | If there are not enough elements in the stream to fill all the spots between start and end. |
Definition at line 165 of file stream_crtp.h.
|
inline |
Moves the logical offset in the stream.
offset | Where to move the logical offset to. |
whence | Move the offset relative to what. |
Definition at line 50 of file stream_crtp.h.
|
inline |
Get the size of the file measured in items.
Definition at line 132 of file stream_crtp.h.
Referenced by tpie::stream_crtp< stream >::can_read(), and tpie::stream_crtp< stream >::seek().
|
protected |
Fetch block from disk as indicated by m_nextBlock, writing old block to disk if needed.
Update m_block, m_index, m_nextBlock and m_nextIndex. If m_nextBlock is maxint, use next block is the one numbered m_block->number+1. m_index is updated with the value of m_nextIndex.
|
inlinestaticprotected |
Write several items to the stream.
Implementation note: If your iterator type is efficiently copyable with std::copy, then this will also write efficiently into the internal TPIE buffer.
IT | The type of Random Access Iterators used to supply the items. |
start | Iterator to the first item to write. |
end | Iterator past the last item to write. |
Definition at line 211 of file stream_crtp.h.
|
protected |
The file-level item index of the first item in the current block.
When m_block is not the null block, this should be equal to m_block->number * block_items().
Definition at line 255 of file stream_crtp.h.
Referenced by tpie::stream_crtp< stream >::can_read_back(), and tpie::stream_crtp< stream >::offset().
|
protected |
Item index into the current block, or maxint if we don't have a block.
Definition at line 244 of file stream_crtp.h.
Referenced by tpie::stream_crtp< stream >::can_read(), tpie::stream_crtp< stream >::can_read_back(), tpie::stream_crtp< stream >::offset(), and tpie::stream_crtp< stream >::seek().
|
protected |
After a cross-block seek: Block index of next block, or maxint if the current block is good enough OR if we haven't read/written anything yet.
Definition at line 248 of file stream_crtp.h.
Referenced by tpie::stream_crtp< stream >::can_read_back(), tpie::stream_crtp< stream >::offset(), and tpie::stream_crtp< stream >::seek().
|
protected |
After a cross-block seek: Item index into next block.
Otherwise, maxint as with m_nextBlock.
Definition at line 251 of file stream_crtp.h.
Referenced by tpie::stream_crtp< stream >::can_read_back(), tpie::stream_crtp< stream >::offset(), and tpie::stream_crtp< stream >::seek().