Joedb 10.2.0
The Journal-Only Embedded Database
Loading...
Searching...
No Matches
File_Iterator.h
Go to the documentation of this file.
1#ifndef joedb_File_Iterator_declared
2#define joedb_File_Iterator_declared
3
5
6namespace joedb
7{
8 /// @ingroup journal
10 {
11 private:
12 int64_t position = 0;
13
14 protected:
16
17 public:
19
20 void seek(int64_t new_position) noexcept
21 {
22 position = new_position;
23 }
24
25 int64_t get_position() const noexcept {return position;}
26
27 size_t read(char *data, size_t size)
28 {
29 const size_t result = file.pread(data, size, position);
30 position += result;
31 return result;
32 }
33
34 void write(const char *data, size_t size)
35 {
36 file.pwrite(data, size, position);
37 position += size;
38 }
39 };
40}
41
42#endif
virtual void pwrite(const char *data, size_t size, int64_t offset)
Write a range of bytes. Extend file size if necessary.
virtual size_t pread(char *data, size_t size, int64_t offset) const
Read a range of bytes.
int64_t get_position() const noexcept
void write(const char *data, size_t size)
File_Iterator(Abstract_File &file)
void seek(int64_t new_position) noexcept
size_t read(char *data, size_t size)
Abstract_File & file