📄 ios_.gml
字号:
:CLFNM.ios
:CMT.========================================================================
:LIBF fmt='hdr'.ios
:HFILE.iostream.h
:DVBYL.
:DVBY.istream
:DVBY.ostream
:eDVBYL.
:CLSS.
The &cls. is used to group together common functionality needed for
other derived stream classes. It is not intended that objects of type
:MONO.ios
be created.
:P.
This class maintains state information about the stream. (the
:MONO.ios
name can be thought of as a short-form for I/O State).
Error flags, formatting flags, and values and the connection to the
buffers used for the input and output are all maintained by the &cls.:PERIOD.
No information about the buffer itself is stored in an &obj., merely the
pointer to the buffer information.
:HDG.Protected Member Functions
The following member functions are declared in the protected interface:
:MFNL.
:MFCD cd_idx='c' .ios();
:MFN index='init' .void init( streambuf * );
:MFN index='setstate' .void setstate( ios::iostate );
:eMFNL.
:HDG.Public Enumerations
The following enumeration typedefs are declared in the public interface:
:MTYPL.
:MTYP index='iostate' .typedef int iostate;
:MTYP index='fmtflags'.typedef long fmtflags;
:MTYP index='openmode'.typedef int openmode;
:MTYP index='seekdir' .typedef int seekdir;
:eMTYPL.
:HDG.Public Member Functions
The following member functions are declared in the public interface:
:MFNL.
:MFCD cd_idx='c'.ios( streambuf * );
:MFCD cd_idx='d' .virtual ~~ios();
:MFN index='tie' .ostream *tie() const;
:MFN index='tie' .ostream *tie( ostream * );
:MFN index='rdbuf' .streambuf *rdbuf() const;
:MFN index='rdstate' .ios::iostate rdstate() const;
:MFN index='clear' .ios::iostate clear( ios::iostate = 0 );
:MFN index='good' .int good() const;
:MFN index='bad' .int bad() const;
:MFN index='fail' .int fail() const;
:MFN index='eof' .int eof() const;
:MFN index='exceptions' .ios::iostate exceptions( ios::iostate );
:MFN index='exceptions' .ios::iostate exceptions() const;
:MFN index='setf' .ios::fmtflags setf( ios::fmtflags, ios::fmtflags );
:MFN index='setf' .ios::fmtflags setf( ios::fmtflags );
:MFN index='unsetf' .ios::fmtflags unsetf( ios::fmtflags );
:MFN index='flags' .ios::fmtflags flags( ios::fmtflags );
:MFN index='flags' .ios::fmtflags flags() const;
:MFN index='fill' .char fill( char );
:MFN index='fill' .char fill() const;
:MFN index='precision' .int precision( int );
:MFN index='precision' .int precision() const;
:MFN index='width' .int width( int );
:MFN index='width' .int width() const;
:MFN index='iword' .long &.iword( int );
:MFN index='pword' .void *&.pword( int );
:MFN index='sync_with_stdio'.static void sync_with_stdio();
:MFN index='bitalloc' .static ios::fmtflags bitalloc();
:MFN index='xalloc' .static int xalloc();
:eMFNL.
:HDG.Public Member Operators
The following member operators are declared in the public interface:
:MFNL.
:MFN index='operator void *'.operator void *() const;
:MFN index='operator !' .int operator !() const;
:eMFNL.
:eCLSS.
:SALSO.
:SAL typ='cls'.iostream
:SAL typ='cls'.istream
:SAL typ='cls'.ostream
:SAL typ='cls'.streambuf
:eSALSO.
:eLIBF.
:CMT.========================================================================
:LIBF fmt='mfun' prot='public'.bad
:SNPL.
:SNPFLF .#include <iostream.h>
:SNPFLF .public:
:SNPF index='bad'.int ios::bad() const;
:eSNPL.
:SMTICS.
The &fn. queries the state of the &obj.:PERIOD.
:RSLTS.
The &fn. returns a non-zero value if &badbit. is set in the &errstate.,
otherwise zero is returned.
:SALSO.
:SAL typ='mfun'.clear
:SAL typ='mfun'.eof
:SAL typ='mfun'.fail
:SAL typ='mfun'.good
:SAL typ='mtyp'.iostate
:SAL typ='mfun'.operator~b!
:SAL typ='mfun'.operator~bvoid~b*
:SAL typ='mfun'.rdstate
:SAL typ='mfun'.setstate
:eSALSO.
:eLIBF.
:CMT.========================================================================
:LIBF fmt='mfun' prot='public static'.bitalloc
:SNPL.
:SNPFLF .#include <iostream.h>
:SNPFLF .public:
:SNPF index='bitalloc'.static ios::fmtflags ios::bitalloc();
:eSNPL.
:SMTICS.
The &fn. is used to allocate a new &fmtflags. bit for use by
user derived classes.
:INCLUDE file='ios_stat'.
:P.
The bit value allocated may be used with the member functions that query
and affect &fmtflags.:PERIOD.
In particular, the bit can be set with the
:MONO.setf
or
:MONO.flags
member functions
or the
:MONO.setiosflags
manipulator, and reset with the
:MONO.unsetf
or
:MONO.flags
member functions or the
:MONO.resetiosflags
manipulator.
:P.
There are two constants defined in
:MONO.<iostream.h>
which indicate the number of bits available when a program starts.
:MONO._LAST_FORMAT_FLAG
indicates the last bit used by the built-in format flags described by
&fmtflags.:PERIOD.
:MONO._LAST_FLAG_BIT
indicates the last bit that is available for the &fn. to allocate.
The difference between the bit positions indicates how many bits are
available.
:RSLTS.
The &fn. returns the next available &fmtflags. bit for use by user
derived classes. If no more bits are available, zero is returned.
:SALSO.
:SAL typ='mtyp'.fmtflags
:eSALSO.
:eLIBF.
:CMT.========================================================================
:LIBF fmt='mfun' prot='public'.clear
:SNPL.
:SNPFLF .#include <iostream.h>
:SNPFLF .public:
:SNPF index='clear'.iostate ios::clear( ios::iostate flags = 0 );
:eSNPL.
:SMTICS.
The &fn. is used to change the current value of &iostate. in the
&obj.:PERIOD.
&iostate. is cleared, all bits specified in
:ARG.flags
are set.
:RSLTS.
The &fn. returns the previous value of &iostate.:PERIOD.
:SALSO.
:SAL typ='mfun'.bad
:SAL typ='mfun'.eof
:SAL typ='mfun'.fail
:SAL typ='mfun'.good
:SAL typ='mtyp'.iostate
:SAL typ='mfun'.operator~b!
:SAL typ='mfun'.operator~bvoid~b*
:SAL typ='mfun'.rdstate
:SAL typ='mfun'.setstate
:eSALSO.
:eLIBF.
:CMT.========================================================================
:LIBF fmt='mfun' prot='public'.eof
:SNPL.
:SNPFLF .#include <iostream.h>
:SNPFLF .public:
:SNPF index='eof'.int ios::eof() const;
:eSNPL.
:SMTICS.
The &fn. queries the state of the &obj.:PERIOD.
:RSLTS.
The &fn. returns a non-zero value if &eofbit. is set in the &errstate.,
otherwise zero is returned.
:SALSO.
:SAL typ='mfun'.bad
:SAL typ='mfun'.clear
:SAL typ='mfun'.fail
:SAL typ='mfun'.good
:SAL typ='mtyp'.iostate
:SAL typ='mfun'.rdstate
:SAL typ='mfun'.setstate
:eSALSO.
:eLIBF.
:CMT.========================================================================
:LIBF fmt='mfun' prot='public'.exceptions
:SNPL.
:SNPFLF .#include <iostream.h>
:SNPFLF .public:
:SNPF index='exceptions'.ios::iostate ios::exceptions() const;
:SNPF index='exceptions'.ios::iostate ios::exceptions( int enable );
:eSNPL.
:SMTICS.
The &fn. queries and/or sets the bits that control which exceptions
are enabled. &iostate. within the &obj. is used to enable
and disable exceptions.
:P.
When a condition arises that sets a bit in &iostate., a check is made
to see if the same bit is also set in the exception bits.
If so, an exception is thrown. Otherwise, no exception is thrown.
:P.
The first form of the &fn. looks up the current setting of the exception bits.
The bit values are those described by &iostate.:PERIOD.
:P.
The second form of the &fn. sets the exceptions bits to those specified in the
:ARG.enable
parameter, and returns the current settings.
:P.
:RSLTS.
The &fn. returns the previous setting of the exception bits.
:SALSO.
:SAL typ='mfun'.clear
:SAL typ='mtyp'.iostate
:SAL typ='mfun'.rdstate
:SAL typ='mfun'.setstate
:eSALSO.
:eLIBF.
:CMT.========================================================================
:LIBF fmt='mfun' prot='public'.fail
:SNPL.
:SNPFLF .#include <iostream.h>
:SNPFLF .public:
:SNPF index='fail'.int ios::fail() const;
:eSNPL.
:SMTICS.
The &fn. queries the state of the &obj.:PERIOD.
:RSLTS.
The &fn. returns a non-zero value if &failbit. or &badbit. is set
in the &errstate., otherwise zero is returned.
:SALSO.
:SAL typ='mfun'.bad
:SAL typ='mfun'.clear
:SAL typ='mfun'.eof
:SAL typ='mfun'.good
:SAL typ='mtyp'.iostate
:SAL typ='mfun'.operator~b!
:SAL typ='mfun'.operator~bvoid~b*
:SAL typ='mfun'.rdstate
:SAL typ='mfun'.setstate
:eSALSO.
:eLIBF.
:CMT.========================================================================
:LIBF fmt='mfun' prot='public'.fill
:SNPL.
:SNPFLF .#include <iostream.h>
:SNPFLF .public:
:SNPF index='fill'.char ios::fill() const;
:SNPF index='fill'.char ios::fill( char fillchar );
:eSNPL.
:SMTICS.
The &fn. queries and/or sets the &fillchar. used when the size of a
:I1.fill character
formatted object is smaller than the &fmtwidth. specified.
:P.
The first form of the &fn. looks up the current value of the &fillchar.:PERIOD.
:P.
The second form of the &fn. sets the &fillchar. to
:ARG.fillchar
:PERIOD.
:P.
By default, the &fillchar. is a space.
:RSLTS.
The &fn. returns the previous value of the &fillchar.:PERIOD.
:SALSO.
:SAL typ='mtyp'.fmtflags
:SAL typ='mnp'.setfill
:eSALSO.
:eLIBF.
:CMT.========================================================================
:LIBF fmt='mfun' prot='public'.flags
:SNPL.
:SNPFLF .#include <iostream.h>
:SNPFLF .public:
:SNPF index='flags'.ios::fmtflags ios::flags() const;
:SNPF index='flags'.ios::fmtflags ios::flags( ios::fmtflags setbits );
:eSNPL.
:SMTICS.
The &fn. is used to query and/or set the value of &fmtflags.
in the &obj.:PERIOD.
:P.
The first form of the &fn. looks up the current &fmtflags. value.
:P.
The second form of the &fn. sets &fmtflags. to the value specified in the
:ARG.setbits
parameter.
:P.
Note that the
:MONO.setf
public member function only turns bits on, while the &fn.
turns some bits on and some bits off.
:RSLTS.
The &fn. returns the previous &fmtflags. value.
:SALSO.
:SAL typ='mtyp'.fmtflags
:SAL typ='mfun'.setf
:SAL typ='mfun'.unsetf
:SAL typ='mnp'.dec
:SAL typ='mnp'.hex
:SAL typ='mnp'.oct
:SAL typ='mnp'.resetiosflags
:SAL typ='mnp'.setbase
:SAL typ='mnp'.setiosflags
:eSALSO.
:eLIBF.
:CMT.========================================================================
:LIBF fmt='mtyp' prot='public'.fmtflags
:SNPL.
:SNPFLF .#include <iostream.h>
:SNPFLF .public:
:SNPFLF .enum fmt_flags {
:SNPT index='skipws' . skipws = 0x0001, // skip whitespace
:SNPT index='left' . left = 0x0002, // align field to left edge
:SNPT index='right' . right = 0x0004, // align field to right edge
:SNPT index='internal' . internal = 0x0008, // sign at left, value at right
:SNPT index='dec' . dec = 0x0010, // decimal conversion for integers
:SNPT index='oct' . oct = 0x0020, // octal conversion for integers
:SNPT index='hex' . hex = 0x0040, // hexadecimal conversion for integers
:SNPT index='showbase' . showbase = 0x0080, // show dec/octal/hex base on output
:SNPT index='showpoint' . showpoint = 0x0100, // show decimal and digits on output
:SNPT index='uppercase' . uppercase = 0x0200, // use uppercase for format characters
:SNPT index='showpos' . showpos = 0x0400, // use + for output positive numbers
:SNPT index='scientific' . scientific = 0x0800, // use scientific notation for output
:SNPT index='fixed' . fixed = 0x1000, // use floating notation for output
:SNPT index='unitbuf' . unitbuf = 0x2000, // flush stream after output
:SNPT index='stdio' . stdio = 0x4000, // flush stdout/stderr after output
:BLANKLINE.
:SNPT index='basefield' . basefield = dec | oct | hex,
:SNPT index='adjustfield'. adjustfield= left | right | internal,
:SNPT index='floatfield' . floatfield = scientific | fixed
:SNPFLF .};
:SNPT index='fmtflags' .typedef long fmtflags;
:eSNPL.
:SMTICS.
The type
:MONO.ios::fmt_flags
is a set of bits representing methods of formatting objects written to
the stream and interpreting objects read from the stream. The &fn.
represents the same set of bits, but uses a
:MONO.long
to represent the values, thereby avoiding problems made possible by the
compiler's ability to use smaller types for enumerations. All uses of
these bits should use the &fn.:PERIOD.
:P.
The bit values defined by the &fn. are set and read by the member functions
:MONO.setf
:CONT.,
:MONO.unsetf
and
:MONO.flags
:CONT., as well as the
manipulators
:MONO.setiosflags
and
:MONO.resetiosflags
:PERIOD.
:P.
Because one field is used to store all of these bits, there are three special
values used to mask various groups of bits. These values are named
:MONO.ios::basefield
:CONT.,
:MONO.ios::adjustfield
and
:MONO.ios::floatfield
:CONT.,
and are discussed with the bits that they are used to mask.
:P.
:MONO.ios::skipws
controls whether or not whitespace
characters are automatically skipped when using an
:MONO.operator~b>>
extractor.
If
:MONO.ios::skipws
is on, any use of the
:MONO.operator~b>>
extractor skips whitespace characters
before inputting the next item. Otherwise, skipping of whitespace characters
must be handled by the program.
:P.
:MONO.ios::left
:CONT.,
:MONO.ios::right
and
:MONO.ios::internal
control the alignment of items written using an
:MONO.operator~b<<
inserter.
These bits are usually used in conjunction with the &fmtwidth. and &fillchar.:PERIOD.
:P.
:MONO.ios::adjustfield
can be used to mask the alignment bits returned by the
:MONO.setf
:CONT.,
:MONO.unsetf
and
:MONO.flags
member functions, and for setting new values to ensure that no other bits
are accidentally affected.
:P.
When the item to be written is smaller than the &fmtwidth. specified,
&fillchar.s are written to occupy the additional space. If
:MONO.ios::left
is in effect, the item is written in the left portion of the available
space, and &fillchar.s are written in the right portion. If
:MONO.ios::right
is in effect, the item is written in the right portion of the available
space, and &fillchar.s are written in the left portion. If
:MONO.ios::internal
is in effect, any sign character or base indicator is written in the
left portion, the digits are written in the right portion, and
&fillchar.s are written in between.
:P.
If no alignment is specified,
:MONO.ios::right
is assumed.
:P.
If the item to be written is as big as or bigger than the &fmtwidth. specified,
no &fillchar.s are written and the alignment is ignored.
:P.
:MONO.ios::dec
:CONT.,
:MONO.ios::oct
and
:MONO.ios::hex
control the base used to format integers being written to the stream, and
also control the interpretation of integers being read from the stream.
:P.
:MONO.ios::basefield
can be used to mask the base bits returned by the member functions
:MONO.setf
:CONT.,
:MONO.unsetf
and
:MONO.flags
:CONT., and for setting new values to ensure that no other bits are
accidentally affected.
:P.
When an integer is being read from the stream, these bits control the base
used for the interpretation of the digits. If none of these bits is set,
a number that starts with
:MONO.0x
or
:MONO.0X
is interpreted as hexadecimal (digits
:MONO.0123456789
:CONT., plus the letters
:MONO.abcdef
or
:MONO.ABCDEF
:CONT.), a number that starts with
:MONO.0
(zero) is interpreted as octal (digits
:MONO.01234567
:CONT.), otherwise the number is interpreted as decimal (digits
:MONO.0123456789
:CONT.).
If one of the bits is set, then the prefix is not necessary and the number
is interpreted according to the bit.
:P.
When any one of the integer types is being written to the stream, it can be
written in decimal, octal or hexadecimal. If none of these bits is set,
:MONO.ios::dec
is assumed.
:P.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -