Joedb 10.2.1
The Journal-Only Embedded Database
Loading...
Searching...
No Matches
filebuf.h
Go to the documentation of this file.
1#ifndef joedb_filebuf_declared
2#define joedb_filebuf_declared
3
5
6#include <streambuf>
7#include <array>
8#include <cstring>
9
10namespace joedb
11{
12 ///
13 /// https://en.cppreference.com/w/cpp/io/basic_streambuf.html
14 ///
15 /// @ingroup journal
16 class filebuf: public std::streambuf
17 {
18 private:
19 Abstract_File &file;
20
21 static constexpr size_t buffer_size = (1 << 13);
22 std::array<char, buffer_size> buffer;
23
24 pos_type in_pos;
25 pos_type out_pos;
26
27 void syncg();
28 void syncp();
29
30 protected:
31 pos_type seekoff
32 (
33 off_type off,
34 std::ios_base::seekdir dir,
35 std::ios_base::openmode which
36 ) override;
37
38 pos_type seekpos(pos_type pos, std::ios_base::openmode which) override;
39 int sync() override;
40 std::streamsize showmanyc() override;
41 int_type underflow() override;
42 std::streamsize xsgetn(char_type* s, std::streamsize count) override;
43 std::streamsize xsputn(const char_type* s, std::streamsize count) override;
44 int_type overflow(int_type ch) override;
45 int_type pbackfail(int_type c) override;
46
47 public:
49
50 Abstract_File &get_file() {return file;}
51 const Abstract_File &get_file() const {return file;}
52
53 ~filebuf() override;
54 };
55}
56
57#endif
https://en.cppreference.com/w/cpp/io/basic_streambuf.html
Definition filebuf.h:17
int sync() override
Definition filebuf.cpp:75
pos_type seekpos(pos_type pos, std::ios_base::openmode which) override
Definition filebuf.cpp:58
pos_type seekoff(off_type off, std::ios_base::seekdir dir, std::ios_base::openmode which) override
Definition filebuf.cpp:30
std::streamsize showmanyc() override
Definition filebuf.cpp:84
~filebuf() override
Definition filebuf.cpp:226
int_type pbackfail(int_type c) override
Definition filebuf.cpp:186
int_type overflow(int_type ch) override
Definition filebuf.cpp:170
std::streamsize xsputn(const char_type *s, std::streamsize count) override
Definition filebuf.cpp:149
int_type underflow() override
Definition filebuf.cpp:94
Abstract_File & get_file()
Definition filebuf.h:50
const Abstract_File & get_file() const
Definition filebuf.h:51
std::streamsize xsgetn(char_type *s, std::streamsize count) override
Definition filebuf.cpp:110