This function takes an ANSI string as the file name including the path and the file extension, therefore, use of the Unicode version of this function, OpenStreamOnFileW, is recommended. The member function exchanges the contents of this object for the contents of right.Allocates and initializes an OLE IStream object to access the contents of a file. void swap(basic_ifstream& right) Ī reference to another stream buffer. basic_ifstream::swapĮxchanges the contents of two basic_ifstream objects. See basic_filebuf::close for an example that uses rdbuf. basic_filebuf *rdbuf() constĪ pointer to a basic_filebuf object representing the stored stream buffer. Returns the address of the stored stream buffer. For more information, see Lvalues and Rvalues. The member operator replaces the contents of the object by using the contents of right, treated as an rvalue reference. basic_ifstream& operator=(basic_ifstream& right) Īn rvalue reference to a basic_ifstream object. This is a move assignment involving an rvalue that doesn't leave a copy behind. basic_ifstream::operator=Īssigns the content of this stream object. See basic_filebuf::open for an example that uses open. If open fails, the function calls setstate(failbit), which may throw an ios_base::failure exception. For more information, see rdbuf and basic_filebuf::open. The member function calls rdbuf->open(_Filename, _Mode | ios_base::in). See basic_filebuf::is_open for an example that uses is_open. The member function returns rdbuf -> is_open. True if the file is open, false otherwise. basic_ifstream::is_openĭetermines if a file is open. See basic_filebuf::close for an example that uses close. To create the file, see the example for basic_ofstream::basic_ofstream. The following example shows how to read in text from a file. The fourth constructor initializes the object with the contents of right, treated as an rvalue reference.įor more information, see basic_istream, basic_filebuf, setstate, and open. If the latter function returns a null pointer, the constructor calls setstate(failbit). It also initializes sb by calling basic_filebuf, then sb.open(_Filename, _Mode | ios_base::in). The second and third constructors initialize the base class by calling basic_istream(sb). It also initializes sb by calling basic_filebuf. The first constructor initializes the base class by calling basic_istream(sb), where sb is the stored object of class basic_filebuf. The default file opening protection, equivalent to the shflag parameter in _fsopen, _wfsopen. One of the enumerations in ios_base::openmode. Namespace: std basic_ifstream::basic_ifstreamĬonstructs an object of type basic_ifstream. Dump the contents of the file to cout. Ifstream ifs("basic_ifstream_class.txt") The object stores an object of class basic_filebuf. The traits of the basic element of the file buffer (usually char_traits). Syntax template >Ĭlass basic_ifstream : public basic_istream Describes an object that controls extraction of elements and encoded objects from a stream buffer of class basic_filebuf, with elements of type Elem, whose character traits are determined by the class Tr.įor more information, see basic_filebuf.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |