CARVIEW |
Select Language
HTTP/1.1 301 Moved Permanently
Server: nginx
Date: Sun, 27 Jul 2025 22:24:24 GMT
Content-Type: text/html; charset=UTF-8
Transfer-Encoding: chunked
Connection: keep-alive
Location: /reference/fstream/filebuf/
HTTP/1.1 200 OK
Server: nginx
Date: Sun, 27 Jul 2025 22:24:25 GMT
Content-Type: text/html; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
ETag: W/"8fed-vvaipvNOm4p/Q4dI9EA1Ulew/88"
Content-Encoding: gzip
Stream buffer to read from and write to files.
Constructed without association, these objects are associated to a file by calling member open. Once open, all input/output operations performed on the object are reflected in the associated file.
Objects of this class may internally maintain an intermediate input buffer and/or an intermediate output buffer, where individual characters are read or written by i/o operations. These buffers are synchronized with the contents of the file once filled up, when explicitly requested to do so (sync), or when the object is closed.
Objects of this class may be explicitly made unbuffered by calling member pubsetbuf with both arguments set to zero (see member setbuf): Unbuffered file stream buffers perform the i/o operations directly on the file, without an intermediate buffer.
Access to the associated sequence of characters (i.e., the file) is given to streams by means of the interface offered by the virtual members inherited from streambuf that are overriden in this class.
This is an instantiation of basic_filebuf with the following template parameters:
The class also inherits other protected members that are non-virtual or not overridden. See base class streambuf for more details.
Reference
C library:
- <cassert> (assert.h)
- <cctype> (ctype.h)
- <cerrno> (errno.h)
-
<cfenv> (fenv.h)C++11
- <cfloat> (float.h)
-
<cinttypes> (inttypes.h)C++11
- <ciso646> (iso646.h)
- <climits> (limits.h)
- <clocale> (locale.h)
- <cmath> (math.h)
- <csetjmp> (setjmp.h)
- <csignal> (signal.h)
- <cstdarg> (stdarg.h)
-
<cstdbool> (stdbool.h)C++11
- <cstddef> (stddef.h)
-
<cstdint> (stdint.h)C++11
- <cstdio> (stdio.h)
- <cstdlib> (stdlib.h)
- <cstring> (string.h)
-
<ctgmath> (tgmath.h)C++11
- <ctime> (time.h)
-
<cuchar> (uchar.h)C++11
- <cwchar> (wchar.h)
- <cwctype> (wctype.h)
Containers:
-
<array>C++11
- <deque>
-
<forward_list>C++11
- <list>
- <map>
- <queue>
- <set>
- <stack>
-
<unordered_map>C++11
-
<unordered_set>C++11
- <vector>
-
Input/Output:
Multi-threading:
-
<atomic>C++11
-
<condition_variable>C++11
-
<future>C++11
-
<mutex>C++11
-
<thread>C++11
-
Other:
- <algorithm>
- <bitset>
-
<chrono>C++11
-
<codecvt>C++11
- <complex>
- <exception>
- <functional>
-
<initializer_list>C++11
- <iterator>
- <limits>
- <locale>
- <memory>
- <new>
- <numeric>
-
<random>C++11
-
<ratio>C++11
-
<regex>C++11
- <stdexcept>
- <string>
-
<system_error>C++11
-
<tuple>C++11
-
<type_traits>C++11
-
<typeindex>C++11
- <typeinfo>
- <utility>
- <valarray>
<fstream>
class templates
classes
filebuf
- filebuf::~filebuf
- filebuf::filebuf
public members
protected virtual members
non-member overloads
-
swap (filebuf)C++11
-
class
<fstream>
std::filebuf
typedef basic_filebuf<char> filebuf;
File stream buffer
- streambuf
- filebuf
Stream buffer to read from and write to files.
Constructed without association, these objects are associated to a file by calling member open. Once open, all input/output operations performed on the object are reflected in the associated file.
Objects of this class may internally maintain an intermediate input buffer and/or an intermediate output buffer, where individual characters are read or written by i/o operations. These buffers are synchronized with the contents of the file once filled up, when explicitly requested to do so (sync), or when the object is closed.
Objects of this class may be explicitly made unbuffered by calling member pubsetbuf with both arguments set to zero (see member setbuf): Unbuffered file stream buffers perform the i/o operations directly on the file, without an intermediate buffer.
Access to the associated sequence of characters (i.e., the file) is given to streams by means of the interface offered by the virtual members inherited from streambuf that are overriden in this class.
This is an instantiation of basic_filebuf with the following template parameters:
template parameter | definition | comments |
---|---|---|
charT | char | Aliased as member char_type |
traits | char_traits<char> | Aliased as member traits_type |
Member types
member type | definition |
---|---|
char_type | char |
traits_type | char_traits<char> |
int_type | int |
pos_type | streampos |
off_type | streamoff |
Public member functions
- (constructor)
- Construct object (public member function)
- (destructor)
- Destruct object (public member function)
- operator=
- Move-assignment (public member function)
- swap
- Swap file buffers (public member function)
File association
- open
- Open file (public member function)
- is_open
- Check if a file is open (public member function)
- close
- Close file (public member function)
Public member functions inherited from streambuf
Locales:- pubimbue
- Imbue locale (public member function)
- getloc
- Get current locale (public member function)
- pubsetbuf
- Set buffer array (public member function)
- pubseekoff
- Set internal position pointer to relative position (public member function)
- pubseekpos
- Set internal position pointer to absolute position (public member function)
- pubsync
- Synchronize stream buffer (public member function)
- in_avail
- Get number of characters available to read (public member function)
- snextc
- Advance to next position and get character (public member function)
- sbumpc
- Get current character and advance to next position (public member function)
- sgetc
- Get current character (public member function)
- sgetn
- Get sequence of characters (public member function)
- sputbackc
- Put character back (public member function)
- sungetc
- Decrease current position (public member function)
- sputc
- Store character at current put position and increase put pointer (public member function)
- sputn
- Put sequence of characters (public member function)
Protected virtual function overrides
- showmanyc
- Get number of characters available (protected virtual member function)
- underflow
- Get character on underflow (protected virtual member function)
- uflow
- Get character on overflow and advance position (protected virtual member function)
- pbackfail
- Put character back on backup underflow (protected virtual member function)
- overflow
- Put character on overflow (protected virtual member function)
- setbuf
- Set buffer (protected virtual member function)
- seekoff
- Set internal position to relative position (protected virtual member function)
- seekpos
- Set position pointer to absolute position (protected virtual member function)
- sync
- Synchronize buffer (protected virtual member function)
- imbue
- Imbue locale (protected virtual member function)
The class also inherits other protected members that are non-virtual or not overridden. See base class streambuf for more details.
Non-member function overloads
- swap
- Swap file buffers (function)
Home page | Privacy policy
© cplusplus.com, 2000-2025 - All rights reserved - v3.3.4s
Spotted an error? contact us
© cplusplus.com, 2000-2025 - All rights reserved - v3.3.4s
Spotted an error? contact us