📄 filebuf.htm
字号:
<html>
<head>
<title> The basic_filebuf Class</title>
</head>
<body bgcolor="#FFFFFF">
<img src="flbufban.gif">
<pre>
<font size=5>Class Name</font> basic_filebuf
<font size=5>Header File</font> <fstream>
<font size=5>Classification</font> Input/Output (Format Class)
</pre>
<a href="filebuf.htm#diagram">Class Relationship Diagram</a><br>
<br>
<a href="filebuf.htm#desc">Class Description</a><br>
<h1>Member Classes</h1>
<i>none</i>
<h1>Methods</h1>
<pre>
<a href="filebuf.htm#basicfilebuf1">basic_filebuf()</a><br>
<a href="filebuf.htm#basicfilebuf2">virtual ~basic_filebuf()</a><br>
<a href="filebuf.htm#close">basic_filebuf<charT,traits>* close()</a><br>
<a href="filebuf.htm#is_open">bool is_open() const</a><br>
<a href="filebuf.htm#open">basic_filebuf<charT,traits>* open(const char* Str, ios_base::openmode Mode)</a><br>
<a href="filebuf.htm#overflow">virtual int_type overflow (int_type C = traits::eof())</a><br>
<a href="streabuf.htm#pbackfail">virtual int_type pbackfail(int_type C = traits::eof())</a><br>
<a href="filebuf.htm#seekoff">virtual pos_type seekoff(off_type Off, ios_base::seekdir Dir, ios_base::openmode WMode = ios_base::in | ios_base::out)</a><br>
<a href="filebuf.htm#seekpos">virtual pos_type seekpos(pos_type Sp, ios_base::openmode WMode = ios_base::in | ios_base::out)</a><br>
<a href="filebuf.htm#setbuf">virtual basic_streambuf<charT,traits>* setbuf(char_type* Str, streamsize Num)</a><br>
<a href="streabuf.htm#showmanyc">virtual int showmanyc()</a><br>
<a href="streabuf.htm#sync">virtual int sync()</a><br>
<a href="streabuf.htm#underflow">virtual int_type underflow()</a><br>
<a href="streabuf.htm#uflow">virtual int_type uflow()</a><br>
</pre>
<hr>
<a name="desc"><h3>Class Description</h3></a>
<p>
The filebuf component is a specialized <a href="streabuf.htm">basic_streambuf</a>. Through the filebuf component the
ifstream and ofstream family of classes hav access to the files, block devices and character
devices. The standard typedef for basic_filebuf is <i>filebuf</i>.
</p>
<hr>
<pre>
<a name="basicfilebuf1">Method basic_filebuf()</a>
Access Public
Classification Constructor
Syntax basic_filebuf()
Parameters None
Return None
</pre>
<h3>Description</h3>
<p>
This basic_filebuf() method constructs an object of type basic_filebuf.
</p>
<hr>
<pre>
<a name="basicfilebuf2">Method basic_filebuf()</a>
Access Public
Classification Destructor
Syntax virtual ~basic_filebuf()
Parameters None
Return None
</pre>
<h3>Description</h3>
<p>
This basic_filebuf() method destructs an object of type basic_filebuf.
</p>
<hr>
<pre>
<a name="close">Method close()</a>
Access Public
Classification Modifier
Syntax basic_filebuf<charT,traits>* close()
Parameters None
Return On success return the *this pointer for the current filebuf object.
Upon failure it returns a NULL pointer.
</pre>
<h3>Description</h3>
<p>
The close() method flushes the put buffer as necessary and closes the file associated with
the filebuf object.
</p>
<hr>
<pre>
<a name="is_open">Method is_open()</a>
Access Public
Classification Accessor
Syntax bool is_open() const
Parameters None
Return This method returns either true or false.
</pre>
<h3>Description</h3>
<p>
The is_open() method returns true if the file was opened successfully and no
call to close() has been made.
</p>
<hr>
<pre>
<a name="open">Method open()</a>
Access Public
Classification Modifier
Syntax * open(const char* Str, ios_base::openmode Mode)
Parameters Str contains the name of the file to be connected to the
filebuf object. Mode determines how the stream is
opened.
Return Upon success the method returns the *this pointer for
the filebuf object. Upon failure the method returns
a NULL pointer.
</pre>
<h3>Description</h3>
<p>
The open() method opens the file Str with attributes set to Mode. The
Valid open modes are:
<pre>
Open Modes Description
__________________________________________________
ios_base:: app open in append.
ios_base:: ate create the file.
ios_base:: binary open as a binary file.
ios_base:: in open file for input.
ios_base:: out open file for output.
ios_base:: trunc truncate file on input.
__________________________________________________
</pre>
</p>
<hr>
<pre>
<a name="overflow">Method overflow()</a>
Access Protected
Classification Modifier
Syntax virtual int_type overflow (int_type C = traits::eof())
Parameters None
Return This method returns either traits::eof() or traits::not_eof()
</pre>
<h3>Description</h3>
<p>
The overflow() method attempts to insert C into the output buffer. If successful
the method will return traits::not_eof(), otherwise the method returns traits::eof().
</p>
<hr>
<pre>
<a name="seekoff">Method seekoff()</a>
Access Protected
Classification Modifier
Syntax virtual pos_type seekoff(off_type Off, ios_base::seekdir Dir, ios_base::openmode WMode = ios_base::in | ios_base::out)</a><br>
Parameters None
Return Upon success this method returns a valid stream position. Upon failure
it returns an invalid position.
</pre>
<h3>Description</h3>
<p>
The seekoff() method positions the connected stream so that its current get/put position is
Off number of characters relative from the seek direction Dir. The valid seek directions are:
<pre>
ios_base::beg
ios_base::cur
ios_base::end
</pre>
</p>
<hr>
<pre>
<a name="seekpos">Method seekpos()</a>
Access Protected
Classification Modifier
Syntax virtual pos_type seekpos(pos_type Sp, ios_base::openmode WMode = ios_base::in | ios_base::out)
Parameters None
Return Upon success this method returns a valid stream position (Sp). Upon failure
this method returns a invalid stream position. If Sp is valid and the
operation fails the value will != Sp.
</pre>
<h3>Description</h3>
<p>
The seekpos() method positions the get/put pointer relative to the begiining of the
stream that is connected to the filebuf object.
</p>
<hr>
<pre>
<a name="setbuf">Method setbuf()</a>
Access Protected
Classification Modifier
Syntax virtual basic_streambuf<charT,traits>* setbuf(char_type* Str, streamsize Num)
Parameters Str is a pointer to a buffer that can be used as the get/put area for
the filebuf object. Num is the size of the buffer. If Str and Num
is Zero then the stream will be unbuffered.
Return Upon success this method returns the *this pointer for the filebuf
object. Upon failure this method returns a NULL pointer.
</pre>
<h3>Description</h3>
<p>
The setbuf() method sets up a specific buffer for the filebuf object. If no specific buffer
area(array) and setbuf(0,0) is called the stream is unbuffered.
</p>
<hr>
<pre>
<a name="setbuf">Method setbuf()</a>
Access Protected
Classification Modifier
Syntax virtual basic_streambuf<charT,traits>* setbuf(char_type* Str, streamsize Num)
Parameters Str is a pointer to a buffer that can be used as the get/put area for
the filebuf object. Num is the size of the buffer. If Str and Num
is Zero then the stream will be unbuffered.
Return Upon success this method returns the *this pointer for the filebuf
object. Upon failure this method returns a NULL pointer.
</pre>
<h3>Description</h3>
<p>
The setbuf() method sets up a specific buffer for the filebuf object. If no specific buffer
area(array) and setbuf(0,0) is called the stream is unbuffered.
</p>
<hr>
<p>
<a name="diagram"><h2>The Class Relationship Diagram of filebuf</h2></a>
<img src="filebuf.gif">
</p>
<hr>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -