28 #pragma warning( disable: 4290 )
37 #pragma warning( disable: 4200 )
52 static inline memory_size_type
memory_usage(
bool includeDefaultFileAccessor=
true) {
53 memory_size_type x =
sizeof(
file);
54 if (includeDefaultFileAccessor)
68 file(
double blockFactor=1.0,
70 file_base(sizeof(T), blockFactor, fileAccessor) {};
89 inline static memory_size_type
memory_usage(
double blockFactor=1.0) {
176 template <
typename IT>
177 inline void write(
const IT & start,
const IT & end) {
186 template <
typename IT>
187 inline void read(
const IT & start,
const IT & end) {
208 #endif //_TPIE_FILE_H
static void write_array(Stream &stream, const IT &start, const IT &end)
Write several items to the stream.
const item_type & read_back()
Read an item from the stream.
Central stream abstraction.
file file_type
Type of underlying file object.
static void read_array(Stream &stream, const IT &start, const IT &end)
Reads several items from the stream.
memory_size_type block_items() const
Fetch number of items per block.
void write(const item_type &item)
Write an item to the stream.
Basic file and stream operations.
Central file abstraction.
stream_size_type offset() const
Calculate the current offset in the stream.
memory_size_type m_index
Item index into the current block, or maxint if we don't have a block.
T item_type
Type of items stored in the file.
void attach_inner(file_base &f)
Attach to the given tpie::file. If necessary, detach first.
T item_type
Type of items stored in the stream.
void detach_inner()
Detach from a tpie::file.
bool is_writable() const
Check if we can write to the file.
void write(const IT &start, const IT &end)
Write several items to the stream.
Stream in file. We support multiple streams per file.
This is the type of our block buffers.
void seek(stream_offset_type offset, offset_type whence=beginning)
Moves the logical offset in the stream.
static memory_size_type memory_usage(bool includeDefaultFileAccessor=true)
Calculate the memory usage of a file.
void write_update()
Call whenever the current block buffer is modified.
const item_type & read()
Read an item from the stream.
static memory_size_type memory_usage(double blockFactor=1.0)
Calculate the memory usage of a stream.
file(double blockFactor=1.0, file_accessor::file_accessor *fileAccessor=NULL)
Construct a file object with the given block factor and file accessor.
memory_size_type block_size() const
Get the size of a block in bytes.
bool is_open() const
Check if file is open.
void update_block()
Fetch block from disk as indicated by m_nextBlock, writing old block to disk if needed.
void attach(file &f)
Attach to the given tpie::file. If necessary, detach first.
void detach()
Detach from a tpie::file.
block_t * m_block
Current block.
item_type & read_mutable()
Read a mutable item from the stream.
stream_size_type size() const
Get the size of the file measured in items.
static memory_size_type memory_usage()
Return memory usage of this file accessor.
void read(const IT &start, const IT &end)
Reads several items from the stream.