Joedb 10.2.1
The Journal-Only Embedded Database
Loading...
Searching...
No Matches
fstream.h
Go to the documentation of this file.
1#ifndef joedb_fstream_declared
2#define joedb_fstream_declared
3
6
7#include <iostream>
8#include <istream>
9#include <ostream>
10
11namespace joedb
12{
13 namespace detail
14 {
15 struct fstream_Parent
16 {
17 protected:
18 joedb::File file;
20
21 public:
22 fstream_Parent(const char *file_name, Open_Mode mode):
23 file(file_name, mode),
24 buf(file)
25 {
26 }
27 };
28 }
29
30 /// @ingroup journal
31 class fstream: private detail::fstream_Parent, public std::iostream
32 {
33 public:
34 fstream(const char *file_name, Open_Mode mode):
35 fstream_Parent(file_name, mode),
36 std::iostream(&(detail::fstream_Parent::buf))
37 {
38 }
39
40 fstream(const std::string &file_name, Open_Mode mode):
41 fstream(file_name.c_str(), mode)
42 {
43 }
44 };
45
46 /// @ingroup journal
47 class ifstream: private detail::fstream_Parent, public std::istream
48 {
49 public:
50 ifstream(const char *file_name, Open_Mode mode = Open_Mode::read_existing):
51 fstream_Parent(file_name, mode),
52 std::istream(&(detail::fstream_Parent::buf))
53 {
54 }
55
56 ifstream(const std::string &file_name, Open_Mode mode = Open_Mode::read_existing):
57 ifstream(file_name.c_str(), mode)
58 {
59 }
60 };
61
62 /// @ingroup journal
63 class ofstream: private detail::fstream_Parent, public std::ostream
64 {
65 public:
66 ofstream(const char *file_name, Open_Mode mode):
67 fstream_Parent(file_name, mode),
68 std::ostream(&(detail::fstream_Parent::buf))
69 {
70 }
71
72 ofstream(const std::string &file_name, Open_Mode mode):
73 ofstream(file_name.c_str(), mode)
74 {
75 }
76 };
77}
78
79#endif
https://en.cppreference.com/w/cpp/io/basic_streambuf.html
Definition filebuf.h:17
fstream(const char *file_name, Open_Mode mode)
Definition fstream.h:34
fstream(const std::string &file_name, Open_Mode mode)
Definition fstream.h:40
ifstream(const std::string &file_name, Open_Mode mode=Open_Mode::read_existing)
Definition fstream.h:56
ifstream(const char *file_name, Open_Mode mode=Open_Mode::read_existing)
Definition fstream.h:50
ofstream(const std::string &file_name, Open_Mode mode)
Definition fstream.h:72
ofstream(const char *file_name, Open_Mode mode)
Definition fstream.h:66
Open_Mode
Definition Open_Mode.h:8
@ read_existing
fails if does not exist
JOEDB_FILE File
Definition File.h:25