Debian Codegraph @

headers/fstream

raw
1 /* Copyright (C) 2015 Povilas Kanapickas <[email protected]>
2
3 This file is part of cppreference-doc
4
5 This work is licensed under the Creative Commons Attribution-ShareAlike 3.0
6 Unported License. To view a copy of this license, visit
7 http://creativecommons.org/licenses/by-sa/3.0/ or send a letter to Creative
8 Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA.
9
10 Permission is granted to copy, distribute and/or modify this document
11 under the terms of the GNU Free Documentation License, Version 1.3 or
12 any later version published by the Free Software Foundation; with no
13 Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
14 */
15
16 #ifndef CPPREFERENCE_FSTREAM_H
17 #define CPPREFERENCE_FSTREAM_H
18
19 namespace std {
20
21 template <
22 class CharT,
23 class Traits = std::char_traits<CharT>
24 > class basic_filebuf : public std::basic_streambuf<CharT, Traits> {
25 public:
26 basic_filebuf();
27 #if CPPREFERENCE_STDVER>= 2011
28 basic_filebuf(const std::basic_filebuf& rhs) = delete;
29 basic_filebuf(std::basic_filebuf&& rhs);
30 std::basic_filebuf& operator=(std::basic_filebuf&& rhs);
31 std::basic_filebuf& operator=(const std::basic_filebuf& rhs) = delete;
32 void swap(std::basic_filebuf& rhs);
33 #endif
34
35 virtual ~basic_filebuf();
36
37 bool is_open() const;
38 basic_filebuf* open(const char* s, ios_base::openmode mode);
39 basic_filebuf* open(const string& str, ios_base::openmode mode);
40 basic_filebuf* close();
41
42 protected:
43 virtual streamsize showmanyc();
44 virtual int_type underflow();
45 virtual int_type uflow();
46 virtual int_type pbackfail(int_type c = Traits_type::eof());
47 virtual int_type overflow(int_type c = Traits_type::eof());
48 virtual basic_streambuf<CharT, Traits>* setbuf(char_type* s, streamsize n);
49 virtual pos_type seekoff(off_type off, ios_base::seekdir dir,
50 ios_base::openmode which = ios_base::in | ios_base::out);
51 virtual pos_type seekpos(pos_type pos,
52 ios_base::openmode which = ios_base::in | ios_base::out);
53 virtual int sync();
54 virtual void imbue(const locale& loc);
55 };
56
57 typedef basic_filebuf<char> filebuf;
58 typedef basic_filebuf<wchar_t> wfilebuf;
59
60 template <
61 class CharT,
62 class Traits = std::char_traits<CharT>
63 > class basic_fstream : public std::basic_iostream<CharT, Traits> {
64 public:
65 basic_fstream();
66 explicit basic_fstream(const char* filename,
67 ios_base::openmode mode = ios_base::in | ios_base::out);
68 #if CPPREFERENCE_STDVER>= 2011
69 explicit basic_fstream(const string& filename,
70 ios_base::openmode mode = ios_base::in | ios_base::out);
71 basic_fstream(basic_fstream&& other);
72 basic_fstream(const basic_fstream& rhs) = delete;
73 basic_fstream& operator=(basic_fstream&& other);
74
75 void swap(basic_fstream& other);
76 std::basic_filebuf<CharT, Traits>* rdbuf() const;
77 #endif
78
79 #if CPPREFERENCE_STDVER <2011
80 bool is_open();
81 #else
82 bool is_open() const;
83 #endif
84
85 void open(const char* filename,
86 ios_base::openmode mode = ios_base::in | ios_base::out);
87
88 #if CPPREFERENCE_STDVER>= 2011
89 void open(const std::string& filename,
90 ios_base::openmode mode = ios_base::in | ios_base::out);
91 #endif
92 void close();
93
94 template<class T>
95 void swap(basic_fstream<T>& lhs, basic_fstream<T>& rhs);
96 };
97
98 typedef basic_fstream<char> fstream;
99 typedef basic_fstream<wchar_t> wfstream;
100
101 template <
102 class CharT,
103 class Traits = std::char_traits<CharT>
104 > class basic_ifstream : public std::basic_ostream<CharT, Traits> {
105 public:
106 basic_ifstream();
107 explicit basic_ifstream(const char* filename,
108 ios_base::openmode mode = ios_base::in);
109 #if CPPREFERENCE_STDVER>= 2011
110 explicit basic_ifstream(const string& filename,
111 ios_base::openmode mode = ios_base::in);
112 basic_ifstream(basic_ifstream&& other);
113 basic_ifstream(const basic_ifstream& rhs) = delete;
114 basic_ifstream& operator=(basic_ifstream&& other);
115
116 void swap(basic_ifstream& other);
117 std::basic_filebuf<CharT, Traits>* rdbuf() const;
118 #endif
119
120 #if CPPREFERENCE_STDVER <2011
121 bool is_open();
122 #else
123 bool is_open() const;
124 #endif
125
126 void open(const char* filename,
127 ios_base::openmode mode = ios_base::in);
128
129 #if CPPREFERENCE_STDVER>= 2011
130 void open(const std::string& filename,
131 ios_base::openmode mode = ios_base::in);
132 #endif
133 void close();
134
135 template<class T>
136 void swap(basic_ifstream<T>& lhs, basic_ifstream<T>& rhs);
137 };
138
139 typedef basic_ifstream<char> ifstream;
140 typedef basic_ifstream<wchar_t> wifstream;
141
142 template <
143 class CharT,
144 class Traits = std::char_traits<CharT>
145 > class basic_ofstream : public std::basic_ostream<CharT, Traits> {
146 public:
147 basic_ofstream();
148 explicit basic_ofstream(const char* filename,
149 ios_base::openmode mode = ios_base::out);
150 #if CPPREFERENCE_STDVER>= 2011
151 explicit basic_ofstream(const string& filename,
152 ios_base::openmode mode = ios_base::out);
153 basic_ofstream(basic_ofstream&& other);
154 basic_ofstream(const basic_ofstream& rhs) = delete;
155 basic_ofstream& operator=(basic_ofstream&& other);
156
157 void swap(basic_ofstream& other);
158 std::basic_filebuf<CharT, Traits>* rdbuf() const;
159 #endif
160
161 #if CPPREFERENCE_STDVER <2011
162 bool is_open();
163 #else
164 bool is_open() const;
165 #endif
166
167 void open(const char* filename,
168 ios_base::openmode mode = ios_base::out);
169
170 #if CPPREFERENCE_STDVER>= 2011
171 void open(const std::string& filename,
172 ios_base::openmode mode = ios_base::out);
173 #endif
174 void close();
175
176 template<class T>
177 void swap(basic_ofstream<T>& lhs, basic_ofstream<T>& rhs);
178 };
179
180 typedef basic_ofstream<char> ofstream;
181 typedef basic_ofstream<wchar_t> wofstream;
182
183 } // namespace std
184
185 #endif // CPPREFERENCE_FSTREAM_H