📄 streabuf.htm
字号:
<p>
It returns the current character in the input stream or traits::eof(). If the call
to this method is successful it moves the get pointer forward by one value.
</p>
<hr>
<pre>
<a name="seekoff">Method seekoff()</a>
Access Protected
Classification Modifier
Syntax virtual pos_type seekoff(off_type Off, ios_base::seekdir Way, protected ios_base::openmode which = ios_base::in | ios_base::out)
Parameters Way is can be
ios_base::beg
ios_base::cur
ios_base::end
Off is the number of positions to move relative to Way
Which is the open mode of the streambuf object.
Return This method returns an invalid stream position for the streambuf object.
</pre>
<h3>Description</h3>
<p>
The seekoff() method moves to a new position in the stream relative to Way by a value of Off.
This virtual method is designed to be overridden in a derived class. The seekoff() method
usually returns an invalid stream position for the streambuf object.
</p>
<hr>
<pre>
<a name="seekpos">Method seekpos()</a>
Access Protected
Classification Modifier
Syntax virtual pos_type seekpos(pos_type Pos, ios_base::openmode Which = ios_base::in | ios_base::out)
Parameters Pos is the new position in the stream. Which is the open mode of the
stream.
Return This method returns an invalid stream position for the streambuf object.
</pre>
<h3>Description</h3>
<p>
The seekpos() method moves to a new position in the stream.
This virtual method is designed to be overridden in a derived class. The seekpos() method
usually returns an invalid stream position for the streambuf object.
</p>
<hr>
<pre>
<a name="setbuf">Method setbuf()</a>
Access Public
Classification Modifier
Syntax virtual basic_streambuf<char_type,traits>* setbuf(char_type* S, streamsize N)
Parameters S is a streambuf character. N is a value used to effect the update of
the associated buffer object.
Return This method returns a pointer to this basic_streambuf object.
</pre>
<h3>Description</h3>
<p>
This virtual setbuf() is designed to be overridden in a derived class such as basic_filebuf,
or stringbuf. It serves only as a place holder in the basic_streambuf class.
</p>
<hr>
<pre>
<a name="setg">Method setg()</a>
Access Protected
Classification Modifier
Syntax void setg(char_type* Gb, char_type* Gnext, char_type* Gend)
Parameters Gb will be used to update the beginning input area pointer. Gnext
will be used to update the next pointer for the input area. Gend
will be used to update the pointer that is pointing to the end
of the input area.
Return None
</pre>
<h3>Description</h3>
<p>
The setg() method updates the pointers to the input buffer. The beginning pointer
is set to Gb. The next pointer is set to Gnext and the end pointer is set to Gend.
</p>
<hr>
<pre>
<a name="setp">Method setp()</a>
Access Protected
Classification Modifier
Syntax void setp(char_type* Pb, char_type* Pend);
Parameters Pb will be used to update the beginning output area pointer. Pend
will be used to update the pointer that is pointing to the end
of the output area.
Return None
</pre>
<h3>Description</h3>
<p>
The setp() method updates the pointers to the output buffer. The beginning pointer
is set to Pb. The end pointer is set to Pend.
</p>
<hr>
<pre>
<a name="sgetc">Method sgetc()</a>
Access Public
Classification Accessor
Syntax int_type sgetc();
Parameters None
Return This method returns a value not equal to traits::eof() if it
was successful otherwise it returns traits::eof().
</pre>
<h3>Description</h3>
<p>
The sgetc() method returns the next character in the input stream(if there is one)
otherwise it returns traits::eof().
</p>
<hr>
<pre>
<a name="sgetn">Method sgetn()</a>
Access Public
Classification Modifier
Syntax streamsize sgetn(char_type* Str, streamsize Num)
Parameters Str is the starting location for a sequence of characters that will
be assigned to the streambuf object. Num is the number of characters
that will be assigned to the streambuf object.
Return This method returns the number of characters inserted into the
buffer.
</pre>
<h3>Description</h3>
<p>
The sgetn() method does its work by calling xsgetn(). The xsgetn() method inserts Num characters
into the buffer area beginning at the location pointed to by Str. It will continue to insert
characters until Num characters have been exhausted or until traits::eof() has been reached.
</p>
<hr>
<pre>
<a name="showmanyc">Method showmanyc()</a>
Access Protected
Classification Accessor
Syntax virtual int showmanyc();
Parameters None
Return This method will return -1 if there are no characters to extract or
an estimation of the least number of characters that can be extracted.
</pre>
<h3>Description</h3>
<p>
The showmanyc() method returns an estimate of the number of characters in the input area
that can be extracted. However, this method is a virtual method as is designed to be
overridden in a derived class. The default behavior for this class is for showmanyc() to
return 0.
</p>
<hr>
<pre>
<a name="snextc">Method snextc()</a>
Access Public
Classification Modifier
Syntax int_type snextc();
Parameters None
Return This method returns a value not equal to traits::eof() if it
was successful otherwise it returns traits::eof().
</pre>
<h3>Description</h3>
<p>
It returns the current character in the input stream or traits::eof(). If the call
to this method is successful it moves the get pointer forward by one value.
</p>
<hr>
<pre>
<a name="sputbackc">Method sputbackc()</a>
Access Public
Classification Modifier
Syntax int_type sputbackc(char_type CharValue);
Parameters CharValue is the character to put back into the input
stream.
Return This method returns pbackfail()
</pre>
<h3>Description</h3>
<p>
The sputbackc() method() attempts to place CharValue back into the input stream.
Upon success this method will return gptr() upon failure it returns pbackfail().
</p>
<hr>
<pre>
<a name="sputc">Method sputc()</a>
Access Public
Classification Modifier
Syntax int_type sputc(char_type CharValue);
Parameters CharValue is the character to put into the output
stream.
Return This method returns xsputn()
</pre>
<h3>Description</h3>
<p>
The sputc() method inserts CharValue into the output stream.
</p>
<hr>
<pre>
<a name="sputn">Method sputn()</a>
Access Public
Classification Modifier
Syntax streamsize sputn(const char_type* Str, streamsize Num)
Parameters Str is the beginning of the sequence of elements to be inserted into
the output stream. Num is the number of elements to be inserted into
the output stream.
Return This method returns xsputn()
</pre>
<h3>Description</h3>
<p>
The sputn() method inserts up to Num elements into the output stream.
</p>
<hr>
<pre>
<a name="sungetc">Method sungetc()</a>
Access Public
Classification Modifier
Syntax int_type sungetc();
Parameters None
Return This method returns either a pointer to the current element or
pbackfail()
</pre>
<h3>Description</h3>
<p>
The sungetc() method decrements the next pointer for the input buffer if possible.
</p>
<hr>
<pre>
<a name="sync">Method sync()</a>
Access Protected
Classification Accessor
Syntax virtual int sync()
Parameters None
Return This method will return 0 if successful and -1 on failure.
</pre>
<h3>Description</h3>
<p>
The sync() method synchronizes the controlled sequences with the internal arrays or streams.
In many cases the behavior is to flush the buffer area to the connected output device.
</p>
<hr>
<pre>
<a name="uflow">Method uflow()</a>
Access Protected
Classification Modifier
Syntax virtual int_type uflow()
Parameters None
Return
</pre>
<h3>Description</h3>
<p>
calls <a = href="streabuf.htm#underflow">underflow()</a>
</p>
<hr>
<pre>
<a name="underflow">Method underflow()</a>
Access Protected
Classification Modifier
Syntax virtual int_type underflow()
Parameters None
Return This method returns the current element of the input stream on success
otherwise traits::eof()
</pre>
<h3>Description</h3>
<p>
The underflow() method attempts to get more characters from the source or input stream. This
method is virtual and is designed to be overridden in a derived class. It will be have
differently based on the type of input stream it is connected to. The default behavior
of this method is to return traits::eof().
</p>
<hr>
<pre>
<a name="xsgetn">Method xsgetn()</a>
Access Protected
Classification Modifier
Syntax virtual streamsize xsgetn(char_type* Str, streamsize Num)
Parameters Str is the starting location for a sequence of characters that will
be assigned to the streambuf object. Num is the number of characters
that will be assigned to the streambuf object.
Return This method returns the number of characters inserted into the
buffer.
</pre>
<h3>Description</h3>
<p>
The xsgetn() method inserts Num characters into the buffer area beginning at the location
pointed to by Str. It will continue to insert characters until Num characters have
been exhausted or until traits::eof() has been reached.
</p>
<hr>
<pre>
<a name="xsputn">Method xsputn()</a>
Access Protected
Classification Modifier
Syntax virtual streamsize xsgetn(char_type* Str, streamsize Num)
Parameters Str is the beginning of the sequence of elements to be inserted into
the output stream. Num is the number of elements to be inserted into
the output stream.
Return This method returns the number of characters inserted into the
output stream.
</pre>
<h3>Description</h3>
<p>
The Xsputn() method inserts up to Num elements into the output stream.
</p>
<hr>
<p>
<a name="diagram"><h2>The Class Relationship Diagram of streambuf</h2></a>
<img src="streambf.gif">
</p>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -