📄 streabuf.htm
字号:
<html>
<head>
<title> The basic_streambuf Class</title>
</head>
<body bgcolor="#FFFFFF">
<img src="srbufban.gif">
<pre>
<font size=5>Class Name</font> basic_streambuf
<font size=5>Header File</font> <streambuf>
<font size=5>Classification</font> Input/Output (Format Class)
</pre>
<a href="streabuf.htm#diagram">Class Relationship Diagram</a><br>
<br>
<a href="streabuf.htm#desc">Class Description</a><br>
<h1>Member Classes</h1>
<a href="locale.htm">locale</a><br>
<h1>Methods</h1>
<pre>
<a href="streabuf.htm#basicstreambuf1">basic_streambuf()</a><br>
<a href="streabuf.htm#basicstreambuf2">virtual ~basic_streambuf()</a><br>
<a href="streabuf.htm#eback">char_type* eback() const</a><br>
<a href="streabuf.htm#egptr">char_type* egptr() const</a><br>
<a href="streabuf.htm#epptr">char_type* epptr() const</a><br>
<a href="streabuf.htm#gbump">void gbump(int Num)</a><br>
<a href="iosbase.htm#getloc">locale getloc() const</a><br>
<a href="streabuf.htm#gptr">char_type* gptr() const</a><br>
<a href="streabuf.htm#imbue">virtual void imbue(const locale & Loc)</a><br>
<a href="streabuf.htm#overflow">virtual int_type overflow (int_type c = traits::eof())</a><br>
<a href="streabuf.htm#pbackfail">virtual int_type pbackfail(int_type CharValue = traits::eof())</a><br>
<a href="streabuf.htm#pbase">char_type* pbase() const</a><br>
<a href="streabuf.htm#pbump">void pbump(int Num)</a><br>
<a href="streabuf.htm#pptr">char_type* pptr() const</a><br>
<a href="streabuf.htm#pubimbue">locale pubimbue(const locale & Loc)</a><br>
<a href="streabuf.htm#pubsetbuf">basic_streambuf<char_type,traits>* pubsetbuf(char_type* Str, streamsize Num)</a><br>
<a href="streabuf.htm#pubsync">int pubsync()</a><br>
<a href="streabuf.htm#sbumpc">int_type sbumpc()</a><br>
<a href="streabuf.htm#seekoff">virtual pos_type seekoff(off_type off, ios_base::seekdir way, protected ios_base::openmode which = ios_base::in | ios_base::out)</a><br>
<a href="streabuf.htm#seekpos">virtual pos_type seekpos(pos_type Pos, ios_base::openmode Which = ios_base::in | ios_base::out)</a><br>
<a href="streabuf.htm#setbuf">virtual basic_streambuf<char_type,traits>* setbuf(char_type* s, streamsize n)</a><br>
<a href="streabuf.htm#setg">void setg(char_type* Gb, char_type* Gnext, char_type* Gend)</a><br>
<a href="streabuf.htm#setp">void setp(char_type* Pb, char_type* Pend)</a><br>
<a href="streabuf.htm#sgetc">int_type sgetc()</a><br>
<a href="streabuf.htm#sgetn">streamsize sgetn(char_type* Str, streamsize Num)</a><br>
<a href="streabuf.htm#showmanyc">virtual int showmanyc()</a><br>
<a href="streabuf.htm#snextc">int_type snextc()</a><br>
<a href="streabuf.htm#sputbackc">int_type sputbackc(char_type CharValue)</a><br>
<a href="streabuf.htm#sputc">int_type sputc(char_type CharValue)</a><br>
<a href="streabuf.htm#sputn">streamsize sputn(const char_type* Str, streamsize Num)</a><br>
<a href="streabuf.htm#sungetc">int_type sungetc()</a><br>
<a href="streabuf.htm#sync">virtual int sync()</a><br>
<a href="streabuf.htm#uflow">virtual int_type uflow()</a><br>
<a href="streabuf.htm#underflow">virtual int_type underflow()</a><br>
<a href="streabuf.htm#xsgetn">virtual streamsize xsgetn(char_type* Str, streamsize Num)</a><br>
<a href="streabuf.htm#xsputn">virtual streamsize xsputn(const char_type* s, streamsize n)</a><br>
<hr>
<a name="desc"><h2>Class Description</h2></a><br>
</pre>
<p>
The basic_streambuf class is the base class for basic_filebuf and basic_stringbuf.
The basic_streambuf class has methods that get bytes, put bytes, skip bytes, put
bytes back etc,. The basic_streambuf class has the functionality that controls what
happens with stream overflow, or stream underflow conditions. The basic_streambuf
class is contained as a data member of one of the other iostream classes. For instance,
the basic_ios class usually contains a basic_streambuf data member. Positioning is another
responsibility of the basic_streambuf class. The basic_streambuf family of classes control
the movement of a get pointer and put pointer. The get pointer points to the next byte to
read, assigned or viewed. The put pointer points to the next byte to be written, assigned,
assigned or viewed.
</p>
<p>
The class basic_streambuf can be physically described as a set of memory areas with a number
of protected methods that define the behavior of the memory areas. The areas that make up the
buffer are the reserve, put, and get areas. The reserve area is normally a fixed block of memory
used as a memory resource by the other areas. The other two areas overlap (partially or fully)
the reserve area but never meet each other. The get area could be divided into two areas:
the get and put back areas. At least two flags indicate whether the reserve area exists and
if it is owned by basic_streambuf. The get and put areas are managed by a set of pointers.
Each area is assigned three pointers. The basic_streambuf object has a typdef that allows
the user to specify a basic_streambuf class through the use of the name streambuf.
</p>
<hr>
<pre>
<a name="basicstreambuf1">Method basic_streambuf()</a>
Access Protected
Classification Constructor
Syntax basic_streambuf()
Parameters None
Return Type None
</pre>
<h3>Description</h3>
<p>
This basic_streambuf() method constructs a basic_streambuf object by setting all its pointers
to NULL and setting locale object to the global locale.
</p>
<hr>
<pre>
<a name="basicstreambuf2">Method basic_streambuf()</a>
Access Public
Classification Destructor
Syntax virtual ~basic_streambuf()
Parameters None
Return Type None
</pre>
<h3>Description</h3>
<p>
This basic_streambuf() method destructs an object of type basic_streambuf.
</p>
<hr>
<pre>
<a name="eback">Method eback()</a>
Access Protected
Classification Accessor
Syntax char_type* eback() const
Parameters None
Return This method returns a pointer to the beginning of the
input area.
</pre>
<h3>Description</h3>
<p>
The eback() method returns a pointer to the beginning of the input buffer/area.
</p>
<hr>
<pre>
<a name="egptr">Method egptr()</a>
Access Protected
Classification Accessor
Syntax char_type* egptr() const
Parameters None
Return This method returns a pointer to the end of the
input area.
</pre>
<h3>Description</h3>
<p>
The eback() method returns a pointer to the end of the input area.
</p>
<hr>
<pre>
<a name="epptr">Method epptr()</a>
Access Protected
Classification Accessor
Syntax char_type* epptr() const
Parameters None
Return This method returns a pointer to the end of the
output area.
</pre>
<h3>Description</h3>
<p>
The epptr() method returns a pointer to the end of the output buffer/area.
</p>
<hr>
<pre>
<a name="gbump">Method gbump()</a>
Access Public
Classification Modifier
Syntax void gbump(int Num);
Parameters Num is the position to advance the next pointer
Return None
</pre>
<h3>Description</h3>
<p>
The gbump() method is used to advance the pointer to the next character in the
input buffer/area by the value of Num.
</p>
<hr>
<pre>
<a name="gptr">Method gptr()</a>
Access Protected
Classification Accessor
Syntax char_type* gptr() const
Parameters None
Return This method returns the next pointer for the input area.
</pre>
<h3>Description</h3>
<p>
The gptr() method returns the next pointer for the input area/buffer.
</p>
<hr>
<pre>
<a name="imbue">Method imbue()</a>
Access Protected
Classification Modifier
Syntax virtual void imbue(const locale & Loc);
Parameters Loc is a locale object
Return None
</pre>
<h3>Description</h3>
<p>
This imbue() method is virtual and is meant to be overridden in a derived class. This imbue()
method is only a place holder.
</p>
<hr>
<pre>
<a name="overflow">Method overflow()</a>
Access Protected
Classification Modifier
Syntax virtual int_type overflow (int_type CharValue = traits::eof())
Parameters CharValue is the character that will be sent to some destination after
making room for it.
Return This method returns a value not equal to traits::eof() if it
was successful otherwise it returns traits::eof(). It may
throw an exception if unsuccessful.
</pre>
<h3>Description</h3>
<p>
The overflow() method can flush a buffer, expand a block of memory, and send characters to
some output device in attempt to output or make room for its argument. When there is no more
room in the put area for a character or sequence the overflow() method is called. The overflow() method
is designed to be overridden in a derived class.
</p>
<hr>
<pre>
<a name="pbackfail">Method pbackfail()</a>
Access Protected
Classification Modifier
Syntax virtual int_type pbackfail(int_type CharValue = traits::eof())
Parameters CharValue is the character that will be placed back into the
input buffer.
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>
If the pbackfail() method is successful the Character CharValue will have been placed
back into the input area. The effect of this method is to backup the input sequence
one character.
</p>
<hr>
<pre>
<a name="pbase">Method pbase()</a>
Access Protected
Classification Accessor
Syntax char_type* pbase() const
Parameters None
Return This method returns a pointer to the beginning of the
output buffer.
</pre>
<h3>Description</h3>
<p>
The pbase() method returns a pointer to the beginning of the output area/buff.
</p>
<hr>
<pre>
<a name="pbump">Method pbump()</a>
Access Protected
Classification Accessor
Syntax void pbump(int Num)
Parameters Num is the number that the next point is advanced
Return None
</pre>
<h3>Description</h3>
<p>
The pbump() method moves the next pointer of the output area by the value
of Num. The next pointer determines where the next output location will
be.
basic_streambuf<char_type,traits>* pubsetbuf(char_type* s, streamsize n);
The pptr() method returns the next pointer for the output buffer/area.
</p>
<hr>
<pre>
<a name="pubimbue">Method pubimbue()</a>
Access Public
Classification Modifier
Syntax locale pubimbue(const locale & Loc)
Parameters Loc is a locale object that will be assigned to the
basic_streambuf object.
Return This method returns the locale object that was in effect
prior to the assignment of Loc. If this is the first time
pubimbue() has been called for the this basic_streambuf
object then pubimbue() will return the global locale object
that is in effect.
</pre>
<h3>Description</h3>
<p>
The pubimbue() method updates the locale object of the streambuf object.
</p>
<hr>
<pre>
<a name="pubsetbuf">Method pubsetbuf()</a>
Access Public
Classification Modifier
Syntax basic_streambuf<char_type,traits>* pubsetbuf(char_type* Str, streamsize Num);
Parameters Str is a streambuf character. Num 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 pubsetbuf() 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="pubsync">Method pubsync()</a>
Access Public
Classification Accessor
Syntax int pubsync();
Parameters None
Return This method will return 0 if successful and -1 on failure.
</pre>
<h3>Description</h3>
<p>
The pubsync() method simply returns the sync() method. 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="sbumpc">Method sbumpc()</a>
Access Public
Classification Modifier
Syntax int_type sbumpc();
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>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -