Standard C++ Library Copyright 1998, Rogue Wave Software, Inc. NAME basic_ios - A base class that includes the common functions required by all streams. SYNOPSIS #include <ios> template<class charT, class traits = char_traits<charT> > class basic_ios : public ios_base DESCRIPTION The class basic_ios is a base class that includes the common functions required by all streams. It maintains state infor- mation that reflects the integrity of the stream and stream buffer. It also maintains the link between the stream classes and the stream buffer classes via the rdbuf member functions. Classes derived from basic_ios specialize opera- tions for input and output. INTERFACE template<class charT, class traits = char_traits<charT> > class basic_ios : public ios_base { public: typedef basic_ios<charT, traits> ios_type; typedef basic_streambuf<charT, traits> streambuf_type; typedef basic_ostream<charT, traits> ostream_type; typedef typename traits::char_type char_type; typedef traits traits_type; typedef typename traits::int_type int_type; typedef typename traits::off_type off_type; typedef typename traits::pos_type pos_type; operator void*() const; bool operator!() const; iostate rdstate() const; void clear(iostate state = goodbit); void setstate(iostate state); bool good() const; bool eof() const; bool fail() const; bool bad() const; void exceptions(iostate except); iostate exceptions() const; explicit basic_ios(basic_streambuf<charT, traits> *sb_arg); virtual ~basic_ios(); ostream_type *tie() const; ostream_type *tie(ostream_type *tie_arg); streambuf_type *rdbuf() const; streambuf_type *rdbuf( streambuf_type *sb); ios_type& copyfmt(const ios_type& rhs); char_type fill() const; char_type fill(char_type ch); locale imbue(const locale& loc); char narrow(charT, char) const; charT widen(char) const; protected: basic_ios(); void init(basic_streambuf<charT, traits> *sb); }; TYPES char_type The type char_type is a synonym of type traits::char_type. ios The type ios is an instantiation of basic_ios on char: typedef basic_ios<char> ios; int_type The type int_type is a synonym of type traits::in_type. ios_type The type ios_type is a synonym for basic_ios<charT, traits> . off_type The type off_type is a synonym of type traits::off_type. ostream_type The type ostream_type is a synonym for basic_ostream<charT, traits> . pos_type The type pos_type is a synonym of type traits::pos_type. streambuf_type The type streambuf_type is a synonym for basic_streambuf<charT, traits> . traits_type The type traits_type is a synonym for the template param- eter traits. wios The type wios is an instantiation of basic_ios on wchar_t: typedef basic_ios<wchar_t> wios; PUBLIC CONSTRUCTORS explicit basic_ios(basic_streambuf<charT, traits>* sb); Constructs an object of class basic_ios, assigning ini- tial values to its member objects by calling init(sb). If sb is a null pointer, the stream is positioned in error state by triggering its badbit. basic_ios(); Constructs an object of class basic_ios, leaving its member objects uninitialized. The object must be initial- ized by calling the init member function before using it. PUBLIC DESTRUCTORS virtual ~basic_ios(); Destroys an object of class basic_ios. PUBLIC MEMBER FUNCTIONS bool bad() const; Returns true if badbit is set in rdstate(). void clear(iostate state = goodbit); If (state & exception()) == 0, returns. Otherwise, the function throws an object of class ios_base::failure. After the call returns state == rdstate() if rdbuf() !=0 otherwise state == state|ios_base::badbit. basic_ios& copyfmt(const basic_ios& rhs); Assigns to the member objects of *this the corresponding member objects of rhs, except the following: - rdstate() and rdbuf() are left unchanged - Calls ios_base::copyfmt - exceptions() is altered last by calling exceptions(rhs.exceptions()).RE bool eof() const; Returns true if eofbit is set in rdstate(). iostate exceptions() const; Returns a mask that determines what elements set in rdstate() cause exceptions to be thrown. void exceptions(iostate except); Sets the exception mask to except, then calls clear(rdstate()). bool fail() const; Returns true if failbit or badbit is set in rdstate(). char_type fill() const; Returns the character used to pad (fill) an output conversion to the specified field width. char_type fill(char_type fillch); Saves the field width value, then replaces it by fillch and returns the previously saved value. bool good() const; Returns rdstate() == 0. locale imbue(const locale& loc); Saves the value returned by getloc(), then assigns loc to a private variable. If rdbuf() != 0 calls rdbuf()- >pubimbue(loc) and returns the previously saved value. void init(basic_streambuf<charT,traits>* sb); Performs the following initialization: rdbuf() sb tie() 0 rdstate() goodbit if sb is not null otherwise badbit exceptions() goodbit flags() skipws | dec width() 0 precision() 6 fill() the space character getloc() a copy of the locale returned by locale::locale() char narrow(charT c, char dfault) const; Uses the stream's locale to convert the wide character c to a tiny character, and then returns it. If no conver- sion exists, it returns the character dfault. bool operator!() const; Returns fail() ? 1 : 0; streambuf_type* rdbuf() const; Returns a pointer to the stream buffer associated with the stream. streambuf_type* rdbuf(streambuf_type* sb); Associates a stream buffer with the stream. All the input and output is directed to this stream buffer. If sb is a null pointer, the stream is positioned in error state, by triggering its badbit. iostate rdstate() const; Returns the control state of the stream. void setstate(iostate state); Calls clear(rdstate() | state). ostream_type* tie() const; Returns an output sequence that is tied to (synchronized with) the sequence controlled by the stream buffer. ostream_type* tie(ostream_type* tiestr); Saves the tie() value, then replaces it by tiestr and returns the value previously saved. operator void*() const; Returns fail() ? 0 : 1; charT widen(char c) const; Uses the stream's locale to convert the tiny character c to a wide character, then returns it. SEE ALSO ios_base(3C++), basic_istream(3C++), basic_ostream(3C++), basic_streambuf(3C++), char_traits(3C++) Working Paper for Draft Proposed International Standard for Information Systems--Programming Language C++, section 27.4.5. STANDARDS CONFORMANCE ANSI X3J16/ISO WG21 Joint C++ Committee
Закладки на сайте Проследить за страницей |
Created 1996-2024 by Maxim Chirkov Добавить, Поддержать, Вебмастеру |