📄 iosbase.htm
字号:
<html>
<head>
<title> The ios_base Class</title>
</head>
<body bgcolor="#FFFFFF">
<img src="iosbasn.gif">
<pre>
<font size=5>Class Name</font> ios_base
<font size=5>Header File</font> <ios>
<font size=5>Classification</font> Input/Output (Format Class)
</pre>
<a href="iosbase.htm#diagram">Class Relationship Diagram</a><br>
<br>
<a href="iosbase.htm#desc">Class Description</a><br>
<h1>Member Classes</h1>
<a href="iosbase.htm#initclass">init</a><br>
<a href="iosbase.htm#failure">failure</a><br>
<h1>Methods</h1>
<pre>
<a href="iosbase.htm#flags1">fmtflags flags() const;</a><br>
<a href="iosbase.htm#flags2">fmtflags flags(fmtflags fmtfl);</a><br>
<a href="iosbase.htm#getloc">locale getloc() const;</a><br>
<a href="iosbase.htm#imbue">locale imbue(const locale& loc);</a><br>
<a href="iosbase.htm#iosbase">~ios_base();</a><br>
<a href="iosbase.htm#iword">long& iword(int index);</a><br>
<a href="iosbase.htm#precision1">streamsize precision() const;</a><br>
<a href="iosbase.htm#precision2">streamsize precision(streamsize prec);</a><br>
<a href="iosbase.htm#pword">void*& pword(int index);</a><br>
<a href="iosbase.htm#register">void register_callback(event_call_back fn, int index);</a><br>
<a href="iosbase.htm#setf1">fmtflags setf(fmtflags fmtfl);</a><br>
<a href="iosbase.htm#setf2">fmtflags setf(fmtflags fmtfl, fmtflags mask);</a><br>
<a href="iosbase.htm#sync">static bool sync_with_stdio(bool sync = true);</a><br>
<a href="iosbase.htm#unsetf">void unsetf(fmtflags mask);</a><br>
<a href="iosbase.htm#width1">streamsize width(streamsize wide);</a><br>
<a href="iosbase.htm#width2">streamsize width(void);</a><br>
<a href="iosbase.htm#xalloc">static int xalloc();</a><br>
</pre>
<a href="iosbase.htm#example"><h2>Example</h2></a><br>
<hr>
<h2><a name="desc"> Class Description</a></h2>
<p>
The ios_base class is the ultimate base class of the entire iostream family of classes. Every major class in the iostream class hierarchy except for basic_streambuf family has a ios component. This class encapsulates the format state of the stream classes; istream, ofstream, istringstream, ostringstream, ifstream and ofstream. The ios_base class defines most of the state methods as well as the manipulators for the iostream classes.
</p>
<hr>
<p>
<a name="failure"><h3>failure</h3></a> The failure class is derived from the exception
class and is used to encapsulate the exceptions that will be
thrown by iostream classes.
</p>
<hr>
<p>
<a name="initclass"><h3>Init</h3></a> The Init class is used during the construction of
ios component to enforce the preconditions and the prefix conditions
</p>
<hr>
<pre>
<a name="flags1">Method flags()</a>
Access Public
Classification Accessor
Syntax fmtflags flags() const;
Parameters None
Return Type fmtflags
</pre>
<h3>Description</h3>
<p>
This flags() method returns the format flags for the ios component.
</p>
<hr>
<pre>
<a name="flags2"><b>Method</b> flags(fmtflags FlagArg)</a>
Classification Modifier
Access Public
Syntax fmtflags flags(fmtflags FlagArg)
Parameters None
Return Type fmtflags
</pre>
<h3>Description</h3>
<p>
This flags() method changes the format state of the ios component.
This effects the state of the stream connected to the ios component.
The format state determines what type of conversion takes place when
objects are inserted into the stream or when objects are extracted
from the stream. The format state describes whether objects are left
justified or right justified as they are inserted into a stream.
The format state describes how integers are represented as they are
inserted or extracted to or from a stream. The base of the integers
can be decimal, hexadecimal, or octal. The floats and doubles can be
formatted as fixed floating point or in scientific notation. The format
state describes the fill character that will be used for padding during
stream operations. Table ios1-1 shows the format states that the flags()
methods can be used to set.
</p>
<hr>
<pre>
<a name="getloc">Method getloc()</a>
Access Public
Classification Accessor
Syntax locale getloc() const;
Parameters None
Return Type locale
</pre>
<h3>Description</h3>
The getloc() method returns a copy of the locale object that is contained in ios_base
<hr>
<pre>
<a name="imbue">Method imbue()</a>
Classification Modifier
Access Public
Syntax locale imbue(const locale& Lc);
Parameters Lc
Return Type locale
</pre>
<h3>Description</h3>
<p>
The imbue() method sets the locale object of ios_base to Lc. The imbue() function returns
a copy of the previous locale object. If the ios_base object has a call back function
i.e. a function registered with the register_callback() function, then a call to imbue()
will also cause the registered function to be called
</p>
<hr>
<pre>
<a name="iosbase">Method ios_base()</a>
Classification Destructor
Access Public
Syntax ~ios_base();
Parameters None
Return Type None
</pre>
<h3>Description</h3>
<p>
The ios_base() method is the destructor for the ios_base class.
If the ios_base object has a call back function i.e. a function registered
with the register_callback() function, then when the destructor for ios_base is invoked,
the registered function will also be called.
</p>
<hr>
<pre>
<a name="iword">Method iword()</a>
Access Modifier
Classification Accessor
Syntax long& iword(int Ndx);
Parameters Ndx is the index into an array that is used
to store the user defined format flags.
Return Type long
</pre>
<h3>Description</h3>
<p>
The iword() method gives access to any user defined format flags that
were allocated with the xalloc() method.
</p>
<hr>
<pre>
<a name="precision1">Method precision()</a>
Access Public
Classification Accessor
Syntax streamsize precision() const;
Parameters none
Return Type streamsize
</pre>
<h3>Description</h3>
<p>
This precision() method returns the current precision settings for the ios_base
component. The precision setting determines the number of digits displayed
after the decimal point during output functions or formatting functions.
The default precision is 6. The precision affects both the e-notation(scientific)
and fixed formats for real numbers.
</p>
<hr>
<pre>
<a name="precision2">Method precision()</a>
Classification Modifier
Access Public
Syntax streamsize precision(streamsize P);
Parameters The current precision will be assigned
the value stored in P.
Return Type streamsize
</pre>
<h3>Description</h3>
<p>
This precision() method changes the current precision settings for the ios_base component the
value stored in P. It returns the previous precision setting. The precision setting
determines the number of digits displayed after the decimal point during output functions or
formatting functions. The default precision is 6. The precision affects both the e-notation(scientific) and fixed formats for real numbers. The effects of this method are not persistent. The precision will
have to be set for each input/output operation unless the default value is desired.
</p>
<hr>
<pre>
<a name="pword">Method pword()</a>
Access Public
Classification Modifier
Syntax void* &pword(int Ndx);
Parameters Ndx is position in the array that is
maintained for user defined format flags.
Return Type void*
</pre>
<h3>Description</h3>
<p>
The pword() method returns a reference to a memory object
that can be used for user defined format flags. This method
will dynamically allocate memory for the format flags when
necessary and if possible. If the function fails for
some reason badbit will be set and a exception may be
thrown.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -