|
| basic_filebuf () |
| Constructor. More...
|
|
| ~basic_filebuf () |
| Destructor. More...
|
|
bool | is_open () const |
| Check if stream is open. More...
|
|
_Self * | open (const char *__s, std::ios_base::openmode __m) |
| Open a stream. More...
|
|
_Self * | open (const char *__s, std::ios_base::openmode __m, long __protection) |
| Open a stream. More...
|
|
_STLP_fd | fd () const |
| Obtain file descriptor. More...
|
|
_Self * | open (int __id, std::ios_base::openmode _Init_mode=m_default_openmode) |
| Attach a stream to a file descriptor. More...
|
|
_Self * | _M_open (int __id, std::ios_base::openmode _Init_mode=_Filebuf_base::m_default_openmode) |
| Attach a stream to a file descriptor. More...
|
|
_Self * | close () |
| Close the stream. More...
|
|
void | UseMemoryMappedIO (bool Value) |
| Enable/disable use of memory mapped I/O for stream. More...
|
|
bool | UseMemoryMappedIO () const |
| Obtain the memory mapped I/O status use for the stream. More...
|
|
virtual std::basic_streambuf< _CharT, _Traits > * | setbuf (char_type *, std::streamsize) |
| Set buffer limit. More...
|
|
virtual pos_type | seekoff (off_type Off, std::ios_base::seekdir Way, std::ios_base::openmode Mode=std::ios_base::in|std::ios_base::out) |
|
virtual pos_type | seekpos (pos_type Pos, std::ios_base::openmode Mode=std::ios_base::in|std::ios_base::out) |
|
bool | _M_write (char *__buf, std::ptrdiff_t __n) |
| for _Noconv_output More...
|
|
int_type | _M_do_noconv_input () |
|
| basic_filebuf () |
| Constructor. More...
|
|
| ~basic_filebuf () |
| Destructor. More...
|
|
bool | is_open () const |
| Check if stream is open. More...
|
|
_Self * | open (const char *__s, std::ios_base::openmode __m) |
| Open a stream. More...
|
|
_Self * | open (const char *__s, std::ios_base::openmode __m, long __protection) |
| Open a stream. More...
|
|
_STLP_fd | fd () const |
| Obtain file descriptor. More...
|
|
_Self * | open (int __id, std::ios_base::openmode _Init_mode=m_default_openmode) |
| Attach a stream to a file descriptor. More...
|
|
_Self * | _M_open (int __id, std::ios_base::openmode _Init_mode=_Filebuf_base::m_default_openmode) |
| Attach a stream to a file descriptor. More...
|
|
_Self * | close () |
| Close the stream. More...
|
|
void | UseMemoryMappedIO (bool Value) |
| Enable/disable use of memory mapped I/O for stream. More...
|
|
bool | UseMemoryMappedIO () const |
| Obtain the memory mapped I/O status use for the stream. More...
|
|
virtual std::basic_streambuf< _CharT, _Traits > * | setbuf (char_type *, std::streamsize) |
| Set buffer limit. More...
|
|
virtual pos_type | seekoff (off_type Off, std::ios_base::seekdir Way, std::ios_base::openmode Mode=std::ios_base::in|std::ios_base::out) |
|
virtual pos_type | seekpos (pos_type Pos, std::ios_base::openmode Mode=std::ios_base::in|std::ios_base::out) |
|
bool | _M_write (char *__buf, std::ptrdiff_t __n) |
| for _Noconv_output More...
|
|
int_type | _M_do_noconv_input () |
|
|
pos_type | seekoff_core (off_type, std::ios_base::seekdir, std::ios_base::openmode) |
|
pos_type | seekpos_core (pos_type, std::ios_base::openmode) |
|
virtual int_type | underflow_core () |
|
virtual int_type | overflow_core (int_type=traits_type::eof()) |
|
void | _M_exit_putback_mode () |
|
bool | _M_switch_to_input_mode () |
| basic_filebuf<> helper functions. More...
|
|
void | _M_exit_input_mode () |
|
bool | _M_switch_to_output_mode () |
|
int_type | _M_input_error () |
| Helper functions for input. More...
|
|
int_type | _M_underflow_aux () |
|
int_type | _M_output_error () |
| Helper functions for output. More...
|
|
bool | _M_unshift () |
|
bool | _M_allocate_buffers (_CharT *__buf, std::streamsize __n) |
| Helper functions for buffer allocation and deallocation. More...
|
|
bool | _M_allocate_buffers () |
| Abbreviation for the most common case. More...
|
|
void | _M_deallocate_buffers () |
|
pos_type | _M_seek_return (off_type __off, _State_type __state) |
|
bool | _M_seek_init (bool __do_unshift) |
| Helper functiosn for seek and imbue. More...
|
|
void | _M_setup_codecvt (const std::locale &) |
|
pos_type | current_pos (std::ios_base::openmode Mode) |
|
pos_type | seekoff_core (off_type, std::ios_base::seekdir, std::ios_base::openmode) |
|
pos_type | seekpos_core (pos_type, std::ios_base::openmode) |
|
virtual int_type | underflow_core () |
|
virtual int_type | overflow_core (int_type=traits_type::eof()) |
|
void | _M_exit_putback_mode () |
|
bool | _M_switch_to_input_mode () |
|
void | _M_exit_input_mode () |
|
bool | _M_switch_to_output_mode () |
|
int_type | _M_input_error () |
|
int_type | _M_underflow_aux () |
|
int_type | _M_output_error () |
|
bool | _M_unshift () |
|
bool | _M_allocate_buffers (_CharT *__buf, std::streamsize __n) |
|
bool | _M_allocate_buffers () |
|
void | _M_deallocate_buffers () |
|
pos_type | _M_seek_return (off_type __off, _State_type __state) |
|
bool | _M_seek_init (bool __do_unshift) |
|
void | _M_setup_codecvt (const std::locale &) |
|
pos_type | current_pos (std::ios_base::openmode Mode) |
|
template<class _CharT, class _Traits >
bool basic_filebuf< _CharT, _Traits >::_M_allocate_buffers |
( |
_CharT * |
__buf, |
|
|
std::streamsize |
__n |
|
) |
| |
|
private |
Helper functions for buffer allocation and deallocation.
This member function is called when we're initializing a filebuf's internal and external buffers. The argument is the size of the internal buffer; the external buffer is sized using the character width in the current encoding. Preconditions: the buffers are currently null. __n >= 1. __buf is either a null pointer or a pointer to an array show size is at least __n. We need __n >= 1 for two different reasons. For input, the base class always needs a buffer because of the sementics of underflow(). For output, we want to have an internal buffer that's larger by one element than the buffer that the base class knows about. (See basic_filebuf<>::overflow() for the reason.)
template<class _CharT , class _Traits >
Helper functions for input.
This member function is called if there is an error during input. It puts the filebuf in error mode, clear the get area buffer, and returns eof. returns eof. Error mode is sticky; it is cleared only by close or seek.
template<class _CharT , class _Traits >
bool basic_filebuf< _CharT, _Traits >::_M_seek_init |
( |
bool |
__do_unshift | ) |
|
|
private |
Helper functiosn for seek and imbue.
If we're in error mode, leave it.
Flush the output buffer if we're in output mode, and (conditionally) emit an unshift sequence.
Discard putback characters, if any.
template<class _CharT , class _Traits >
bool basic_filebuf< _CharT, _Traits >::_M_switch_to_output_mode |
( |
| ) |
|
|
private |
This member function is called if we're performing the first I/O operation on a filebuf, or if we're performing an output operation immediately after a seek.
In append mode, every write does an implicit seek to the end of the file. Whenever leaving output mode, the end of file get put in the initial shift state.
template<class _CharT , class _Traits >
We have the state and file position from the end of the internal buffer. This round, they become the beginning of the internal buffer.
Fill the external buffer. Start with any leftover characters that didn't get converted last time.
boris : copy_backward did not work _M_ext_buf_end = copy_backward(_M_ext_buf_converted, _M_ext_buf_end, _M_ext_buf+ (_M_ext_buf_end - _M_ext_buf_converted));
Now fill the external buffer with characters from the file. This is a loop because occasonally we don't get enough external characters to make progress.
Don't enter error mode for a failed read. Error mode is sticky, and we might succeed if we try again.
Convert the external buffer to internal characters.
Error conditions: (1) Return value of error. (2) Producing internal characters without consuming external characters. (3) In fixed-width encodings, producing an internal sequence whose length is inconsistent with that of the internal sequence. (4) Failure to produce any characters if we have enough characters in the external buffer, where "enough" means the largest possible width of a single character.
__inext - _M_int_buf != _M_width * (__enext - _M_ext_buf)) ||
We need to go around the loop again to get more external characters.
template<class _CharT , class _Traits >
This member function flushes the put area, and also outputs the character __c (unless __c is eof). Invariant: we always leave room in the internal buffer for one character more than the base class knows about. We see the internal buffer as [_M_int_buf, _M_int_buf_EOS), but the base class only sees [_M_int_buf, _M_int_buf_EOS - 1).
Switch to output mode, if necessary.
Put __c at the end of the internal buffer.
For variable-width encodings, output may take more than one pass.
For a constant-width encoding we know that the external buffer is large enough, so failure to consume the entire internal buffer or to produce the correct number of external characters, is an error. For a variable-width encoding, however, we require only that we consume at least one internal character
We successfully converted part or all of the internal buffer.
template<class _CharT , class _Traits >
Make a putback position available, if necessary, by switching to a special internal buffer used only for putback. The buffer is [_M_pback_buf, _M_pback_buf + _S_pback_buf_size), but the base class only sees a piece of it at a time. (We want to make sure that we don't try to read a character that hasn't been initialized.) The end of the putback buffer is always _M_pback_buf + _S_pback_buf_size, but the beginning is usually not _M_pback_buf.
If we aren't already in input mode, pushback is impossible.
We can use the ordinary get buffer if there's enough space, and if it's a buffer that we're allowed to write to.
Are we in the putback buffer already?
Do we have more room in the putback buffer?
We have made a putback position available. Assign to it, and return.
template<class _CharT , class _Traits >
Seek to beginning or end, regardless of whether we're in input mode.
Seek relative to current position. Complicated if we're in input mode.
__off is relative to gptr(). We need to do a bit of arithmetic to get an offset relative to the external file pointer.
if __off == 0, we do not need to exit input mode and to shift file pointer
Compensate for offset relative to gptr versus offset relative to external pointer. For a text-oriented stream, where the compensation is more than just pointer arithmetic, we may get but not set the current position.
Get position in internal buffer.
Get corresponding position in external buffer.
Sanity check (expensive): make sure __epos is the right answer.
Get the current position (at the end of the external buffer), then adjust it. Again, it might be a text-oriented stream.
template<class _CharT , class _Traits >
std::basic_streambuf< _CharT, _Traits > * basic_filebuf< _CharT, _Traits >::setbuf |
( |
char_type * |
__buf, |
|
|
std::streamsize |
__n |
|
) |
| |
|
virtual |
Set buffer limit.
This member function must be called before any I/O has been performed on the stream, otherwise it has no effect.
__buf == 0 && __n == 0 means to make ths stream unbuffered. __buf != 0 && __n > 0 means to use __buf as the stream's internal buffer, rather than the buffer that would otherwise be allocated automatically. __buf must be a pointer to an array of _CharT whose size is at least __n.
template<class _CharT, class _Traits = std::char_traits< _CharT >>
The range [_M_ext_buf, _M_ext_buf_converted) contains the external characters corresponding to the sequence in the internal buffer. The range [_M_ext_buf_converted, _M_ext_buf_end) contains characters that have been read into the external buffer but have not been converted to an internal sequence.