📄 istream_.gml
字号:
:CLFNM.istream
:CMT.========================================================================
:LIBF fmt='hdr'.istream
:HFILE.iostream.h
:DVFML.
:DVFM.ios
:eDVFML.
:DVBYL.
:DVBY.iostream
:DVBY.ifstream
:DVBY.istrstream
:eDVBYL.
:CLSS.
The &cls. supports reading characters from a class derived from
:MONO.streambuf
:CONT., and provides formatted conversion of characters into other types
(such as integers and floating-point numbers). The
:MONO.streambuf
class provides the methods for communicating with the external device
(keyboard, disk), while the &cls. provides the interpretation of the
resulting characters.
:P.
Generally, an &obj. won't be explicitly created by a program, since
there is no mechanism at this level to open a device. The only default
&obj. in a program is &cin., which reads from standard input (usually
the keyboard).
:P.
The &cls. supports two basic concepts of input: formatted and unformatted.
The overloaded
:MONO.operator~b>>
member functions are called
:ITALICS.extractors
:I1.extractor
and they provide the support for formatted input. The rest of the member
functions deal with unformatted input, managing the state of the
:MONO.ios
object and providing a friendlier interface to the associated
:MONO.streambuf
object.
:HDG.Protected Member Functions
The following protected member functions are declared:
:MFNL.
:MFCD cd_idx='c' .istream();
:MFN index='eatwhite'.eatwhite();
:eMFNL.
:HDG.Public Member Functions
The following public member functions are declared:
:MFNL.
:MFCD cd_idx='c'.istream( istream const & );
:MFCD cd_idx='c'.istream( streambuf * );
:MFCD cd_idx='d' .virtual ~~istream();
:MFN index='ipfx' .int ipfx( int = 0 );
:MFN index='isfx' .void isfx();
:MFN index='get' .int get();
:MFN index='get' .istream &.get( char *, int, char = '\n' );
:MFN index='get' .istream &.get( signed char *, int, char = '\n' );
:MFN index='get' .istream &.get( unsigned char *, int, char = '\n' );
:MFN index='get' .istream &.get( char & );
:MFN index='get' .istream &.get( signed char & );
:MFN index='get' .istream &.get( unsigned char & );
:MFN index='get' .istream &.get( streambuf &, char = '\n' );
:MFN index='getline' .istream &.getline( char *, int, char = '\n' );
:MFN index='getline' .istream &.getline( signed char *, int, char = '\n' );
:MFN index='getline' .istream &.getline( unsigned char *, int, char = '\n' );
:MFN index='ignore' .istream &.ignore( int = 1, int = EOF );
:MFN index='read' .istream &.read( char *, int );
:MFN index='read' .istream &.read( signed char *, int );
:MFN index='read' .istream &.read( unsigned char *, int );
:MFN index='seekg' .istream &.seekg( streampos );
:MFN index='seekg' .istream &.seekg( streamoff, ios::seekdir );
:MFN index='putback' .istream &.putback( char );
:MFN index='tellg' .streampos tellg();
:MFN index='gcount' .int gcount() const;
:MFN index='peek' .int peek();
:MFN index='sync' .int sync();
:eMFNL.
:HDG.Public Member Operators
The following public member operators are declared:
:MFNL.
:MFN index='operator =' .istream &.operator =( streambuf * );
:MFN index='operator =' .istream &.operator =( istream const & );
:MFN index='operator >>'.istream &.operator >>( char * );
:MFN index='operator >>'.istream &.operator >>( signed char * );
:MFN index='operator >>'.istream &.operator >>( unsigned char * );
:MFN index='operator >>'.istream &.operator >>( char & );
:MFN index='operator >>'.istream &.operator >>( signed char & );
:MFN index='operator >>'.istream &.operator >>( unsigned char & );
:MFN index='operator >>'.istream &.operator >>( signed short & );
:MFN index='operator >>'.istream &.operator >>( unsigned short & );
:MFN index='operator >>'.istream &.operator >>( signed int & );
:MFN index='operator >>'.istream &.operator >>( unsigned int & );
:MFN index='operator >>'.istream &.operator >>( signed long & );
:MFN index='operator >>'.istream &.operator >>( unsigned long & );
:MFN index='operator >>'.istream &.operator >>( float & );
:MFN index='operator >>'.istream &.operator >>( double & );
:MFN index='operator >>'.istream &.operator >>( long double & );
:MFN index='operator >>'.istream &.operator >>( streambuf & );
:MFN index='operator >>'.istream &.operator >>( istream &(*)( istream & ) );
:MFN index='operator >>'.istream &.operator >>( ios &(*)( ios & ) );
:eMFNL.
:eCLSS.
:SALSO.
:SAL typ='cls'.ios
:SAL typ='cls'.iostream
:SAL typ='cls'.ostream
:eSALSO.
:eLIBF.
:CMT.========================================================================
:LIBF fmt='mfun' prot='protected'.eatwhite
:SNPL.
:SNPFLF .#include <iostream.h>
:SNPFLF .protected:
:SNPF index='eatwhite'.void istream::eatwhite();
:eSNPL.
:SMTICS.
The &fn. extracts and discards whitespace characters from the &obj.,
until a non-whitespace character is found. The non-whitespace character
is not extracted.
:RSLTS.
The &fn. sets &eofbit. in the &errstate. if end-of-file
is encountered as the first character while extracting whitespace characters.
:SALSO.
:SAL typ='mfun'.ignore
:SAL typ='omtyp' ocls='ios'.fmtflags
:eSALSO.
:eLIBF.
:CMT.========================================================================
:LIBF fmt='mfun' prot='public'.gcount
:SNPL.
:SNPFLF .#include <iostream.h>
:SNPFLF .public:
:SNPF index='gcount'.int istream::gcount() const;
:eSNPL.
:SMTICS.
The &fn. determines the number of characters extracted by the last unformatted
input member function.
:RSLTS.
The &fn. returns the number of characters extracted by the last unformatted
input member function.
:SALSO.
:SAL typ='mfun'.get
:SAL typ='mfun'.getline
:SAL typ='mfun'.read
:eSALSO.
:eLIBF.
:CMT.========================================================================
:LIBF fmt='mfun' prot='public'.get
:SNPL.
:SNPFLF .#include <iostream.h>
:SNPFLF .public:
:SNPF index='get'.int istream::get();
:eSNPL.
:SMTICS.
This form of the &fn. performs an unformatted read of a single character from
the &obj.:PERIOD.
:RSLTS.
This form of the &fn. returns the character read from the &obj.:PERIOD.
If the &obj. is positioned at end-of-file before the read, &eof. is returned
and &eofbit. bit is set in the &errstate.:PERIOD.
&failbit. bit is not
set by this form of the &fn.:PERIOD.
:SALSO.
:SAL typ='mfun'.putback
:eSALSO.
:eLIBF.
:CMT.========================================================================
:LIBF fmt='mfun' prot='public'.get
:SNPL.
:SNPFLF .#include <iostream.h>
:SNPFLF .public:
:SNPF index='get'.istream &.istream::get( char &.ch );
:SNPF index='get'.istream &.istream::get( signed char &.ch );
:SNPF index='get'.istream &.istream::get( unsigned char &.ch );
:eSNPL.
:SMTICS.
These forms of the &fn. perform an unformatted read of a single character
from the &obj. and store the character in the
:ARG.ch
parameter.
:RSLTS.
These forms of the &fn. return a reference to the &obj.:PERIOD.
&eofbit. is set in the &errstate. if the &obj. is positioned at
end-of-file before the attempt to read the character.
&failbit. is set in the &errstate. if no character is read.
:SALSO.
:SAL typ='mfun'.read
:SAL typ='mfun'.operator~b>>
:eSALSO.
:eLIBF.
:CMT.========================================================================
:LIBF fmt='mfun' prot='public'.get
:SNPL.
:SNPFLF .#include <iostream.h>
:SNPFLF .public:
:SNPF index='get'.istream &.istream::get( char *buf, int len,
:SNPFLF . char delim = '\n' );
:SNPF index='get'.istream &.istream::get( signed char *buf, int len,
:SNPFLF . char delim = '\n' );
:SNPF index='get'.istream &.istream::get( unsigned char *buf, int len,
:SNPFLF . char delim = '\n' );
:eSNPL.
:SMTICS.
These forms of the &fn. perform an unformatted read of at most
:ARG.len
-1 characters from the &obj. and store them starting at the memory
location specified by the
:ARG.buf
parameter. If the character specified by the
:ARG.delim
parameter is encountered in the &obj. before
:ARG.len
-1 characters have been read, the read terminates without
extracting the delimiting character.
:P.
After the read terminates, whether or not an error occurred, a null
character is stored in
:ARG.buf
following the last character read from the &obj.:PERIOD.
:P.
If the
:ARG.delim
parameter is not specified, the new-line character is assumed.
:RSLTS.
These forms of the &fn. return a reference to the &obj.:PERIOD.
If end-of-file is encountered as the first character, &eofbit. is set in
the &errstate.:PERIOD.
If no characters are stored into
:ARG.buf,
&failbit. is set in the &errstate.:PERIOD.
:SALSO.
:SAL typ='mfun'.getline
:SAL typ='mfun'.read
:SAL typ='mfun'.operator~b>>
:eSALSO.
:eLIBF.
:CMT.========================================================================
:LIBF fmt='mfun' prot='public'.get
:SNPL.
:SNPFLF .#include <iostream.h>
:SNPFLF .public:
:SNPF index='get'.istream &.istream::get( streambuf &.sb, char delim = '\n' );
:eSNPL.
:SMTICS.
This form of the &fn. performs an unformatted read of
characters from the &obj. and transfers them to the
:MONO.streambuf
object specified in the
:ARG.sb
parameter. The transfer stops if end-of-file is encountered, the
delimiting character specified in the
:ARG.delim
parameter is found, or if the store into the
:ARG.sb
parameter fails. If the
:ARG.delim
character is found, it is not extracted from the &obj. and is not transferred
to the
:ARG.sb
object.
:P.
If the
:ARG.delim
parameter is not specified, the new-line character is assumed.
:RSLTS.
The &fn. returns a reference to the &obj.:PERIOD.
&failbit. is set in the &errstate. if the store into the
:MONO.streambuf
object fails.
:SALSO.
:SAL typ='mfun'.getline
:SAL typ='mfun'.read
:SAL typ='mfun'.operator~b>>
:eSALSO.
:eLIBF.
:CMT.========================================================================
:LIBF fmt='mfun' prot='public'.getline
:SNPL.
:SNPFLF .#include <iostream.h>
:SNPFLF .public:
:SNPF index='getline'.istream &.istream::getline( char *buf, int len,
:SNPFLF . char delim = '\n' );
:SNPF index='getline'.istream &.istream::getline( signed char *buf, int len,
:SNPFLF . char delim = '\n' );
:SNPF index='getline'.istream &.istream::getline( unsigned char *buf, int len,
:SNPFLF . char delim = '\n' );
:eSNPL.
:SMTICS.
The &fn. performs an unformatted read of at most
:ARG.len
-1 characters from the &obj. and stores them starting at the memory
location specified by the
:ARG.buf
parameter. If the delimiting character, specified by the
:ARG.delim
parameter, is encountered in the &obj. before
:ARG.len
-1 characters have been read, the read terminates after
extracting the
:ARG.delim
character.
:P.
If
:ARG.len
-1 characters have been read and the next character is the
:ARG.delim
character, it is not extracted.
:P.
After the read terminates, whether or not an error occurred, a null
character is stored in the buffer following the last character
read from the &obj.:PERIOD.
:P.
If the
:ARG.delim
parameter is not specified, the new-line character is assumed.
:RSLTS.
The &fn. returns a reference to the &obj.:PERIOD.
If end-of-file is encountered as the first character, &eofbit. is set in
the &errstate.:PERIOD.
If end-of-file is encountered before
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -