std::basic_filebuf::showmanyc

protected: virtual std::streamsize showmanyc() If implemented, returns the number of characters left to read from the file. Parameters (none). Return value The number of characters available for reading from the file, or -1 if the end of file was reached. Notes This function is optional. If not implemented, this function returns ​0​ (since the base class version std::basic_streambuf::showmanyc gets called). Whether implemented or not, this function is normally called by std::ba

std::basic_filebuf::setbuf

protected: virtual std::basic_streambuf<CharT, Traits>* setbuf( char_type* s, std::streamsize n ) If s is a null pointer and n is zero, the filebuf becomes unbuffered for output, meaning pbase() and pptr() are null and any output is immediately sent to file. Otherwise, a call to setbuf() replaces the internal buffer (the controlled character sequence) with the user-supplied character array whose first element is pointed to by s and allows this std::basic_filebuf object to use up t

std::basic_filebuf::seekpos

protected: virtual pos_type seekpos( pos_type sp, std::ios_base::openmode which = std::ios_base::in | std::ios_base::out ); Repositions the file pointer, if possible, to the position indicated by sp. If the associated file is not open (is_open()==false), fails immediately. If the file is open for writing, first writes the put area and any unshift sequences required by the currently imbued locale, using overflow(). Then repositions the file pointer, as if by cal

std::basic_filebuf::seekoff

protected: virtual pos_type seekoff( off_type off, std::ios_base::seekdir dir, std::ios_base::openmode which = std::ios_base::in | std::ios_base::out ); Repositions the file pointer, if possible, to the position that corresponds to exactly off characters from beginning, end, or current position of the file (depending on the value of dir. If the associated file is not open (is_open()==false, fails immediately. If the multibyte character

std::basic_filebuf::pbackfail

protected: virtual int_type pbackfail( int_type c = Traits::eof() ) This protected virtual function is called by the public functions basic_streambuf::sungetc and basic_streambuf::sputbackc (which, in turn, are called by basic_istream::unget and basic_istream::putback). 1) The caller is requesting that the get area is backed up by one character (pbackfail() is called with no arguments), in which case, this function re-reads the file starting one byte earlier and decrements basic_stream

std::basic_filebuf::overflow

protected: virtual int_type overflow ( int_type c = Traits::eof() ); Writes some data from the put area to the associated character sequence (to the file). Behaves like the base class std::basic_streambuf::overflow, except that to write the data, first uses codecvt::out() of the imbued locale to convert the characters into external (possibly multibyte) representation, stored in a temporary buffer (allocated as large as necessary), then uses file I/O to copy all fully-converted bytes int

std::basic_filebuf::open

std::basic_filebuf<CharT, Traits>* open( const char* s, std::ios_base::openmode mode ) (1) std::basic_filebuf<CharT, Traits>* open( const std::string& str, std::ios_base::openmode mode ) (2) (since C++11) Opens the file with the given name - either s or str.c_str(). The file is opened as if by calling std::fopen(s, modestring), where modestring is determined as follows: modestring openmode & ~ate Action if file already exists Action if file does not exis

std::basic_filebuf::is_open

bool is_open() const; Returns true if the most recent call to open() succeeded and there has been no call to close() since then. Parameters (none). Return value true if the associated file is open, false otherwise. Notes This function is typically called by std::basic_fstream::is_open(). Example #include <fstream> #include <iostream> int main() { std::ifstream fs("test.txt"); std::filebuf fb; fb.open("test.txt", std::ios_base::in); std::cout &

std::basic_filebuf::imbue

protected: virtual void imbue( const std::locale& loc ) Changes the associated locale so that all characters inserted or extracted after this call (and until another call to imbue()) are converted using the std::codecvt facet of loc. If the old locale's encoding is state-dependent and file is not positioned at the beginning, then the new locale must have the same std::codecvt facet as the one previously imbued. Parameters loc - the locale to imbue the stream with Return

std::basic_filebuf::close

std::basic_filebuf<CharT, Traits>* close(); If a put area exist (e.g. file was opened for writing), first calls overflow(Traits::eof()) to write all pending output to the file, including any unshift sequences. If the most recently called function, out of underflow(), overflow(), seekpos(), and seekoff(), was overflow(), then calls std::codecvt::unshift(), perhaps multiple times, to determine the unshift sequence according to the imbued locale, and writes that sequence to file with