libstdc++
__gnu_cxx::stdio_filebuf Class Reference
Inheritance diagram for __gnu_cxx::stdio_filebuf:

List of all members.

Public Types

Public Member Functions

Protected Member Functions

Protected Attributes

Friends


Detailed Description

Provides a layer of compatibility for C/POSIX.

This GNU extension provides extensions for working with standard C FILE*'s and POSIX file descriptors. It must be instantiated by the user with the type of character used in the file stream, e.g., stdio_filebuf<char>.


Constructor & Destructor Documentation

__gnu_cxx::stdio_filebuf::stdio_filebuf ( ) [inline]

deferred initialization

Definition at line 66 of file stdio_filebuf.h.

__gnu_cxx::stdio_filebuf::stdio_filebuf ( int  __fd,
std::ios_base::openmode  __mode,
size_t  __size = static_cast<size_t>(BUFSIZ) 
)
Parameters:
fdAn open file descriptor.
modeSame meaning as in a standard filebuf.
sizeOptimal or preferred size of internal buffer, in chars.

This constructor associates a file stream buffer with an open POSIX file descriptor. The file descriptor will be automatically closed when the stdio_filebuf is closed/destroyed.

Definition at line 128 of file stdio_filebuf.h.

__gnu_cxx::stdio_filebuf::stdio_filebuf ( std::__c_file *  __f,
std::ios_base::openmode  __mode,
size_t  __size = static_cast<size_t>(BUFSIZ) 
)
Parameters:
fAn open FILE*.
modeSame meaning as in a standard filebuf.
sizeOptimal or preferred size of internal buffer, in chars. Defaults to system's BUFSIZ.

This constructor associates a file stream buffer with an open C FILE*. The FILE* will not be automatically closed when the stdio_filebuf is closed/destroyed.

Definition at line 144 of file stdio_filebuf.h.

__gnu_cxx::stdio_filebuf::~stdio_filebuf ( ) [virtual]

Closes the external data stream if the file descriptor constructor was used.

Definition at line 123 of file stdio_filebuf.h.


Member Function Documentation

void std::basic_filebuf::_M_create_pback ( ) [inline, protected, inherited]

Initializes pback buffers, and moves normal buffers to safety. Assumptions: _M_in_cur has already been moved back

Definition at line 174 of file fstream.

void std::basic_filebuf::_M_destroy_pback ( ) throw () [inline, protected, inherited]

Deactivates pback buffer contents, and restores normal buffer. Assumptions: The pback buffer has only moved forward.

Definition at line 191 of file fstream.

void std::basic_filebuf::_M_set_buffer ( streamsize  __off) [inline, protected, inherited]

This function sets the pointers of the internal buffer, both get and put areas. Typically:

__off == egptr() - eback() upon underflow/uflow (read mode); __off == 0 upon overflow (write mode); __off == -1 upon open, setbuf, seekoff/pos (uncommitted mode).

NB: epptr() - pbase() == _M_buf_size - 1, since _M_buf_size reflects the actual allocated memory and the last cell is reserved for the overflow char of a full put area.

Definition at line 392 of file fstream.

__filebuf_type* std::basic_filebuf::close ( ) [inherited]

Closes the currently associated file.

Returns:
this on success, NULL on failure

If no file is currently open, this function immediately fails.

If a put buffer area exists, overflow(eof) is called to flush all the characters. The file is then closed.

If any operations fail, this function also fails.

int __gnu_cxx::stdio_filebuf::fd ( ) [inline]
Returns:
The underlying file descriptor.

Once associated with an external data stream, this function can be used to access the underlying POSIX file descriptor. Note that there is no way for the library to track what you do with the descriptor, so be careful.

Definition at line 109 of file stdio_filebuf.h.

std::__c_file* __gnu_cxx::stdio_filebuf::file ( ) [inline]
Returns:
The underlying FILE*.

This function can be used to access the underlying "C" file pointer. Note that there is no way for the library to track what you do with the file, so be careful.

Definition at line 119 of file stdio_filebuf.h.

bool std::basic_filebuf::is_open ( ) const throw () [inline, inherited]

Returns true if the external file is open.

Definition at line 224 of file fstream.

__filebuf_type* std::basic_filebuf::open ( const char *  __s,
ios_base::openmode  __mode 
) [inherited]

Opens an external file.

Parameters:
sThe name of the file.
modeThe open mode flags.
Returns:
this on success, NULL on failure

If a file is already open, this function immediately fails. Otherwise it tries to open the file named s using the flags given in mode.

Table 92, adapted here, gives the relation between openmode combinations and the equivalent fopen() flags. (NB: lines app, in|out|app, in|app, binary|app, binary|in|out|app, and binary|in|app per DR 596) +---------------------------------------------------------+ | ios_base Flag combination stdio equivalent | |binary in out trunc app | +---------------------------------------------------------+ | + w | | + + a | | + a | | + + w | | + r | | + + r+ | | + + + w+ | | + + + a+ | | + + a+ | +---------------------------------------------------------+ | + + wb | | + + + ab | | + + ab | | + + + wb | | + + rb | | + + + r+b | | + + + + w+b | | + + + + a+b | | + + + a+b | +---------------------------------------------------------+

__filebuf_type* std::basic_filebuf::open ( const std::string __s,
ios_base::openmode  __mode 
) [inline, inherited]

Opens an external file.

Parameters:
sThe name of the file.
modeThe open mode flags.
Returns:
this on success, NULL on failure

Definition at line 277 of file fstream.

virtual __streambuf_type* std::basic_filebuf::setbuf ( char_type __s,
streamsize  __n 
) [protected, virtual, inherited]

Manipulates the buffer.

Parameters:
sPointer to a buffer area.
nSize of s.
Returns:
this

If no file has been opened, and both s and n are zero, then the stream becomes unbuffered. Otherwise, s is used as a buffer; see http://gcc.gnu.org/onlinedocs/libstdc++/manual/bk01pt11ch25s02.html for more.


Member Data Documentation

char_type* std::basic_filebuf::_M_buf [protected, inherited]

Pointer to the beginning of internal buffer.

Definition at line 111 of file fstream.

size_t std::basic_filebuf::_M_buf_size [protected, inherited]

Actual size of internal buffer. This number is equal to the size of the put area + 1 position, reserved for the overflow char of a full area.

Definition at line 118 of file fstream.

char* std::basic_filebuf::_M_ext_buf [protected, inherited]

Buffer for external characters. Used for input when codecvt::always_noconv() == false. When valid, this corresponds to eback().

Definition at line 153 of file fstream.

streamsize std::basic_filebuf::_M_ext_buf_size [protected, inherited]

Size of buffer held by _M_ext_buf.

Definition at line 158 of file fstream.

const char* std::basic_filebuf::_M_ext_next [protected, inherited]

Pointers into the buffer held by _M_ext_buf that delimit a subsequence of bytes that have been read but not yet converted. When valid, _M_ext_next corresponds to egptr().

Definition at line 165 of file fstream.

ios_base::openmode std::basic_filebuf::_M_mode [protected, inherited]

Place to stash in || out || in | out settings for current filebuf.

Definition at line 96 of file fstream.

char_type std::basic_filebuf::_M_pback [protected, inherited]

Necessary bits for putback buffer management.

Note:
pbacks of over one character are not currently supported.

Definition at line 139 of file fstream.

char_type* std::basic_filebuf::_M_pback_cur_save [protected, inherited]

Necessary bits for putback buffer management.

Note:
pbacks of over one character are not currently supported.

Definition at line 140 of file fstream.

char_type* std::basic_filebuf::_M_pback_end_save [protected, inherited]

Necessary bits for putback buffer management.

Note:
pbacks of over one character are not currently supported.

Definition at line 141 of file fstream.

bool std::basic_filebuf::_M_pback_init [protected, inherited]

Necessary bits for putback buffer management.

Note:
pbacks of over one character are not currently supported.

Definition at line 142 of file fstream.

bool std::basic_filebuf::_M_reading [protected, inherited]

_M_reading == false && _M_writing == false for uncommitted mode; _M_reading == true for read mode; _M_writing == true for write mode;

NB: _M_reading == true && _M_writing == true is unused.

Definition at line 130 of file fstream.


The documentation for this class was generated from the following file: