ReactOS  0.4.14-dev-323-g6fe6a88
basic_filebuf< _CharT, _Traits > Class Template Reference

#include <_fstream.h>

Inheritance diagram for basic_filebuf< _CharT, _Traits >:
Collaboration diagram for basic_filebuf< _CharT, _Traits >:

Public Types

typedef _CharT char_type
 
typedef _Traits::int_type int_type
 
typedef _Traits::pos_type pos_type
 
typedef _Traits::off_type off_type
 
typedef _Traits traits_type
 
typedef _Traits::state_type _State_type
 
typedef basic_streambuf< _CharT, _Traits > _Base
 
typedef basic_filebuf< _CharT, _Traits > _Self
 
- Public Types inherited from basic_streambuf< _CharT, _Traits >
typedef _CharT char_type
 
typedef _Traits::int_type int_type
 
typedef _Traits::pos_type pos_type
 
typedef _Traits::off_type off_type
 
typedef _Traits traits_type
 

Public Member Functions

 basic_filebuf ()
 
 ~basic_filebuf ()
 
bool is_open () const
 
_Selfopen (const char *__s, ios_base::openmode __m)
 
_Selfopen (const char *__s, ios_base::openmode __m, long __protection)
 
_STLP_fd fd () const
 
_Selfopen (int __id, ios_base::openmode _Init_mode=ios_base::__default_mode)
 
_Self_M_open (int __id, ios_base::openmode _Init_mode=ios_base::__default_mode)
 
_Selfclose ()
 
bool _M_write (char *__buf, ptrdiff_t __n)
 
int_type _M_do_noconv_input ()
 
- Public Member Functions inherited from basic_streambuf< _CharT, _Traits >
virtual ~basic_streambuf ()
 
char_type_M_eback () const
 
char_type_M_gptr () const
 
char_type_M_egptr () const
 
void _M_gbump (int __n)
 
void _M_setg (char_type *__gbegin, char_type *__gnext, char_type *__gend)
 
basic_streambuf< _CharT, _Traits > * pubsetbuf (char_type *__s, streamsize __n)
 
pos_type pubseekoff (off_type __offset, ios_base::seekdir __way, ios_base::openmode __mod=ios_base::in|ios_base::out)
 
pos_type pubseekpos (pos_type __sp, ios_base::openmode __mod=ios_base::in|ios_base::out)
 
int pubsync ()
 
int_type sputc (char_type __c)
 
streamsize sputn (const char_type *__s, streamsize __n)
 
streamsize _M_sputnc (char_type __c, streamsize __n)
 
streamsize in_avail ()
 
int_type snextc ()
 
int_type sbumpc ()
 
int_type sgetc ()
 
streamsize sgetn (char_type *__s, streamsize __n)
 
int_type sputbackc (char_type __c)
 
int_type sungetc ()
 
locale pubimbue (const locale &)
 
locale getloc () const
 
void stossc ()
 

Protected Member Functions

virtual streamsize showmanyc ()
 
virtual int_type underflow ()
 
virtual int_type pbackfail (int_type=traits_type::eof())
 
virtual int_type overflow (int_type=traits_type::eof())
 
virtual basic_streambuf< _CharT, _Traits > * setbuf (char_type *, streamsize)
 
virtual pos_type seekoff (off_type, ios_base::seekdir, ios_base::openmode=ios_base::in|ios_base::out)
 
virtual pos_type seekpos (pos_type, ios_base::openmode=ios_base::in|ios_base::out)
 
virtual int sync ()
 
virtual void imbue (const locale &)
 
- Protected Member Functions inherited from basic_streambuf< _CharT, _Traits >
 basic_streambuf ()
 
char_typeeback () const
 
char_typegptr () const
 
char_typeegptr () const
 
void gbump (int __n)
 
void setg (char_type *__gbegin, char_type *__gnext, char_type *__gend)
 
char_typepbase () const
 
char_typepptr () const
 
char_typeepptr () const
 
void pbump (int __n)
 
void setp (char_type *__pbegin, char_type *__pend)
 
virtual streamsize xsgetn (char_type *__s, streamsize __n)
 
virtual int_type uflow ()
 
virtual streamsize xsputn (const char_type *__s, streamsize __n)
 
virtual streamsize _M_xsputnc (char_type __c, streamsize __n)
 

Private Types

enum  { _S_pback_buf_size = 8 }
 
typedef codecvt< _CharT, char, _State_type_Codecvt
 

Private Member Functions

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, 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 locale &, bool __on_imbue=true)
 

Private Attributes

_Filebuf_base _M_base
 
unsigned char _M_constant_width
 
unsigned char _M_always_noconv
 
unsigned char _M_int_buf_dynamic
 
unsigned char _M_in_input_mode
 
unsigned char _M_in_output_mode
 
unsigned char _M_in_error_mode
 
unsigned char _M_in_putback_mode
 
_CharT * _M_int_buf
 
_CharT * _M_int_buf_EOS
 
char_M_ext_buf
 
char_M_ext_buf_EOS
 
char_M_ext_buf_converted
 
char_M_ext_buf_end
 
_State_type _M_state
 
_State_type _M_end_state
 
void_M_mmap_base
 
streamoff _M_mmap_len
 
_CharT * _M_saved_eback
 
_CharT * _M_saved_gptr
 
_CharT * _M_saved_egptr
 
const _Codecvt_M_codecvt
 
int _M_width
 
int _M_max_width
 
_CharT _M_pback_buf [_S_pback_buf_size]
 

Friends

class _Underflow< _CharT, _Traits >
 

Detailed Description

template<class _CharT, class _Traits>
class basic_filebuf< _CharT, _Traits >

Definition at line 152 of file _fstream.h.

Member Typedef Documentation

◆ _Base

template<class _CharT, class _Traits>
typedef basic_streambuf<_CharT, _Traits> basic_filebuf< _CharT, _Traits >::_Base

Definition at line 161 of file _fstream.h.

◆ _Codecvt

template<class _CharT, class _Traits>
typedef codecvt<_CharT, char, _State_type> basic_filebuf< _CharT, _Traits >::_Codecvt
private

Definition at line 319 of file _fstream.h.

◆ _Self

template<class _CharT, class _Traits>
typedef basic_filebuf<_CharT, _Traits> basic_filebuf< _CharT, _Traits >::_Self

Definition at line 162 of file _fstream.h.

◆ _State_type

template<class _CharT, class _Traits>
typedef _Traits::state_type basic_filebuf< _CharT, _Traits >::_State_type

Definition at line 160 of file _fstream.h.

◆ char_type

template<class _CharT, class _Traits>
typedef _CharT basic_filebuf< _CharT, _Traits >::char_type

Definition at line 154 of file _fstream.h.

◆ int_type

template<class _CharT, class _Traits>
typedef _Traits::int_type basic_filebuf< _CharT, _Traits >::int_type

Definition at line 155 of file _fstream.h.

◆ off_type

template<class _CharT, class _Traits>
typedef _Traits::off_type basic_filebuf< _CharT, _Traits >::off_type

Definition at line 157 of file _fstream.h.

◆ pos_type

template<class _CharT, class _Traits>
typedef _Traits::pos_type basic_filebuf< _CharT, _Traits >::pos_type

Definition at line 156 of file _fstream.h.

◆ traits_type

template<class _CharT, class _Traits>
typedef _Traits basic_filebuf< _CharT, _Traits >::traits_type

Definition at line 158 of file _fstream.h.

Member Enumeration Documentation

◆ anonymous enum

template<class _CharT, class _Traits>
anonymous enum
private
Enumerator
_S_pback_buf_size 

Definition at line 326 of file _fstream.h.

Constructor & Destructor Documentation

◆ basic_filebuf()

template<class _CharT , class _Traits >
basic_filebuf< _CharT, _Traits >::basic_filebuf ( )

Definition at line 47 of file _fstream.c.

49  _M_constant_width(false), _M_always_noconv(false),
50  _M_int_buf_dynamic(false),
51  _M_in_input_mode(false), _M_in_output_mode(false),
52  _M_in_error_mode(false), _M_in_putback_mode(false),
60  _M_codecvt(0),
61  _M_width(1), _M_max_width(1)
62 {
63  this->_M_setup_codecvt(locale(), false);
64 }
char * _M_ext_buf_converted
Definition: _fstream.h:298
_Traits::state_type _State_type
Definition: _fstream.h:160
unsigned char _M_constant_width
Definition: _fstream.h:274
_CharT * _M_saved_gptr
Definition: _fstream.h:316
streamoff _M_mmap_len
Definition: _fstream.h:312
_CharT * _M_saved_egptr
Definition: _fstream.h:317
unsigned char _M_in_input_mode
Definition: _fstream.h:280
char * _M_ext_buf_end
Definition: _fstream.h:299
unsigned char _M_in_output_mode
Definition: _fstream.h:281
#define _STLP_DEFAULT_CONSTRUCTED(_TTp)
Definition: _construct.h:265
unsigned char _M_always_noconv
Definition: _fstream.h:275
_Filebuf_base _M_base
Definition: _fstream.h:270
char * _M_ext_buf
Definition: _fstream.h:290
_CharT * _M_int_buf
Definition: _fstream.h:286
unsigned char _M_int_buf_dynamic
Definition: _fstream.h:278
int _M_max_width
Definition: _fstream.h:323
_CharT * _M_int_buf_EOS
Definition: _fstream.h:287
unsigned char _M_in_putback_mode
Definition: _fstream.h:283
char * _M_ext_buf_EOS
Definition: _fstream.h:291
unsigned char _M_in_error_mode
Definition: _fstream.h:282
static const wchar_t void * locale
Definition: printf.c:79
_State_type _M_end_state
Definition: _fstream.h:308
_State_type _M_state
Definition: _fstream.h:302
void * _M_mmap_base
Definition: _fstream.h:311
void _M_setup_codecvt(const locale &, bool __on_imbue=true)
Definition: _fstream.c:735
const _Codecvt * _M_codecvt
Definition: _fstream.h:320
_CharT * _M_saved_eback
Definition: _fstream.h:315

◆ ~basic_filebuf()

template<class _CharT , class _Traits >
basic_filebuf< _CharT, _Traits >::~basic_filebuf ( )

Definition at line 67 of file _fstream.c.

67  {
68  this->close();
70 }
void _M_deallocate_buffers()
Definition: _fstream.c:685
_Self * close()
Definition: _fstream.c:81

Member Function Documentation

◆ _M_allocate_buffers() [1/2]

template<class _CharT, class _Traits >
bool basic_filebuf< _CharT, _Traits >::_M_allocate_buffers ( _CharT *  __buf,
streamsize  __n 
)
private

Definition at line 630 of file _fstream.c.

630  {
631  //The major hypothesis in the following implementation is that size_t is unsigned.
632  //We also need streamsize byte representation to be larger or equal to the int
633  //representation to correctly store the encoding information.
635  sizeof(streamsize) >= sizeof(int))
636 
637  if (__buf == 0) {
638  streamsize __bufsize = __n * sizeof(_CharT);
639  //We first check that the streamsize representation can't overflow a size_t one.
640  //If it can, we check that __bufsize is not higher than the size_t max value.
641  if ((sizeof(streamsize) > sizeof(size_t)) &&
643  return false;
644  _M_int_buf = __STATIC_CAST(_CharT*, malloc(__STATIC_CAST(size_t, __bufsize)));
645  if (!_M_int_buf)
646  return false;
647  _M_int_buf_dynamic = true;
648  }
649  else {
650  _M_int_buf = __buf;
651  _M_int_buf_dynamic = false;
652  }
653 
656 
657  _M_ext_buf = 0;
658  if ((sizeof(streamsize) < sizeof(size_t)) ||
659  ((sizeof(streamsize) == sizeof(size_t)) && numeric_limits<streamsize>::is_signed) ||
661  _M_ext_buf = __STATIC_CAST(char*, malloc(__STATIC_CAST(size_t, __ebufsiz)));
662  }
663 
664  if (!_M_ext_buf) {
666  return false;
667  }
668 
671  return true;
672 }
#define max(a, b)
Definition: svc.c:63
return __n
Definition: _algo.h:75
void _M_deallocate_buffers()
Definition: _fstream.c:685
#define __STATIC_CAST(__x, __y)
Definition: features.h:585
int max_length() const _STLP_NOTHROW
Definition: _codecvt.h:110
char * _M_ext_buf
Definition: _fstream.h:290
__kernel_size_t size_t
Definition: linux.h:237
_STLP_STATIC_ASSERT(sizeof(nl_catd_type)<=sizeof(int)) class _STLP_CLASS_DECLSPEC _Catalog_nl_catd_map
_CharT * _M_int_buf
Definition: _fstream.h:286
unsigned char _M_int_buf_dynamic
Definition: _fstream.h:278
_CharT * _M_int_buf_EOS
Definition: _fstream.h:287
char * _M_ext_buf_EOS
Definition: _fstream.h:291
__kernel_ptrdiff_t ptrdiff_t
Definition: linux.h:247
ptrdiff_t streamsize
Definition: char_traits.h:81
#define malloc
Definition: debug_ros.c:4
const _Codecvt * _M_codecvt
Definition: _fstream.h:320

◆ _M_allocate_buffers() [2/2]

template<class _CharT, class _Traits >
bool basic_filebuf< _CharT, _Traits >::_M_allocate_buffers ( )
private

Definition at line 676 of file _fstream.c.

676  {
677  // Choose a buffer that's at least 4096 characters long and that's a
678  // multiple of the page size.
679  streamsize __default_bufsiz =
681  return _M_allocate_buffers(0, __default_bufsiz);
682 }
bool _M_allocate_buffers()
Definition: _fstream.c:676
static size_t _STLP_CALL __page_size()
Definition: _fstream.h:131
_Filebuf_base _M_base
Definition: _fstream.h:270
ptrdiff_t streamsize
Definition: char_traits.h:81
#define UL
Definition: tui.h:83

◆ _M_deallocate_buffers()

template<class _CharT , class _Traits >
void basic_filebuf< _CharT, _Traits >::_M_deallocate_buffers ( )
private

Definition at line 685 of file _fstream.c.

685  {
686  if (_M_int_buf_dynamic)
687  free(_M_int_buf);
688  free(_M_ext_buf);
689  _M_int_buf = 0;
690  _M_int_buf_EOS = 0;
691  _M_ext_buf = 0;
692  _M_ext_buf_EOS = 0;
693 }
#define free
Definition: debug_ros.c:5
char * _M_ext_buf
Definition: _fstream.h:290
_CharT * _M_int_buf
Definition: _fstream.h:286
unsigned char _M_int_buf_dynamic
Definition: _fstream.h:278
_CharT * _M_int_buf_EOS
Definition: _fstream.h:287
char * _M_ext_buf_EOS
Definition: _fstream.h:291

◆ _M_do_noconv_input()

template<class _CharT, class _Traits>
int_type basic_filebuf< _CharT, _Traits >::_M_do_noconv_input ( )
inline

Definition at line 335 of file _fstream.h.

335  {
338  return traits_type::to_int_type(*_M_ext_buf);
339  }
char * _M_ext_buf_converted
Definition: _fstream.h:298
char * _M_ext_buf_end
Definition: _fstream.h:299
void setg(char_type *__gbegin, char_type *__gnext, char_type *__gend)
Definition: _streambuf.h:92
char * _M_ext_buf
Definition: _fstream.h:290
_CharT char_type
Definition: _fstream.h:154

◆ _M_exit_input_mode()

template<class _CharT , class _Traits >
void basic_filebuf< _CharT, _Traits >::_M_exit_input_mode ( )
private

Definition at line 118 of file _fstream.c.

118  {
119  if (_M_mmap_base != 0) {
121  _M_mmap_base = 0;
122  _M_mmap_len = 0;
123  }
124  _M_in_input_mode = false;
125 }
streamoff _M_mmap_len
Definition: _fstream.h:312
unsigned char _M_in_input_mode
Definition: _fstream.h:280
void _M_unmap(void *__mmap_base, streamoff __len)
_Filebuf_base _M_base
Definition: _fstream.h:270
void * _M_mmap_base
Definition: _fstream.h:311

Referenced by basic_filebuf< char, char_traits< char > >::_M_seek_return().

◆ _M_exit_putback_mode()

template<class _CharT, class _Traits>
void basic_filebuf< _CharT, _Traits >::_M_exit_putback_mode ( )
inlineprivate

Definition at line 228 of file _fstream.h.

228  {
230  _M_in_putback_mode = false;
231  }
_CharT * _M_saved_gptr
Definition: _fstream.h:316
_CharT * _M_saved_egptr
Definition: _fstream.h:317
void setg(char_type *__gbegin, char_type *__gnext, char_type *__gend)
Definition: _streambuf.h:92
unsigned char _M_in_putback_mode
Definition: _fstream.h:283
_CharT * _M_saved_eback
Definition: _fstream.h:315

Referenced by _Underflow< _CharT, _Traits >::_M_doit().

◆ _M_input_error()

template<class _CharT , class _Traits >
__BF_int_type__ basic_filebuf< _CharT, _Traits >::_M_input_error ( )
private

Definition at line 485 of file _fstream.c.

485  {
486  this->_M_exit_input_mode();
487  _M_in_output_mode = false;
488  _M_in_error_mode = true;
489  this->setg(0, 0, 0);
490  return traits_type::eof();
491 }
void setg(char_type *__gbegin, char_type *__gnext, char_type *__gend)
Definition: _streambuf.h:92
unsigned char _M_in_output_mode
Definition: _fstream.h:281
unsigned char _M_in_error_mode
Definition: _fstream.h:282
void _M_exit_input_mode()
Definition: _fstream.c:118
_Check_return_ _CRTIMP int __cdecl __cdecl eof(_In_ int _FileHandle)

◆ _M_open()

template<class _CharT, class _Traits>
_Self* basic_filebuf< _CharT, _Traits >::_M_open ( int  __id,
ios_base::openmode  _Init_mode = ios_base::__default_mode 
)
inline

Definition at line 202 of file _fstream.h.

202  {
203  return _M_base._M_open(__id, _Init_mode) ? this : 0;
204  }
_Filebuf_base _M_base
Definition: _fstream.h:270
bool _M_open(const char *, ios_base::openmode, long __protection)

Referenced by basic_filebuf< char, char_traits< char > >::open().

◆ _M_output_error()

template<class _CharT , class _Traits >
__BF_int_type__ basic_filebuf< _CharT, _Traits >::_M_output_error ( )
private

Definition at line 579 of file _fstream.c.

579  {
580  _M_in_output_mode = false;
581  _M_in_input_mode = false;
582  _M_in_error_mode = true;
583  this->setp(0, 0);
584  return traits_type::eof();
585 }
unsigned char _M_in_input_mode
Definition: _fstream.h:280
void setp(char_type *__pbegin, char_type *__pend)
Definition: _streambuf.h:116
unsigned char _M_in_output_mode
Definition: _fstream.h:281
unsigned char _M_in_error_mode
Definition: _fstream.h:282
_Check_return_ _CRTIMP int __cdecl __cdecl eof(_In_ int _FileHandle)

◆ _M_seek_init()

template<class _CharT , class _Traits >
bool basic_filebuf< _CharT, _Traits >::_M_seek_init ( bool  __do_unshift)
private

Definition at line 700 of file _fstream.c.

700  {
701  // If we're in error mode, leave it.
702  _M_in_error_mode = false;
703 
704  // Flush the output buffer if we're in output mode, and (conditionally)
705  // emit an unshift sequence.
706  if (_M_in_output_mode) {
707  bool __ok = !traits_type::eq_int_type(this->overflow(traits_type::eof()),
708  traits_type::eof());
709  if (__do_unshift)
710  __ok = __ok && this->_M_unshift();
711  if (!__ok) {
712  _M_in_output_mode = false;
713  _M_in_error_mode = true;
714  this->setp(0, 0);
715  return false;
716  }
717  }
718 
719  // Discard putback characters, if any.
722 
723  return true;
724 }
unsigned char _M_in_input_mode
Definition: _fstream.h:280
virtual int_type overflow(int_type=traits_type::eof())
Definition: _fstream.c:208
void setp(char_type *__pbegin, char_type *__pend)
Definition: _streambuf.h:116
unsigned char _M_in_output_mode
Definition: _fstream.h:281
unsigned char _M_in_putback_mode
Definition: _fstream.h:283
unsigned char _M_in_error_mode
Definition: _fstream.h:282
_Check_return_ _CRTIMP int __cdecl __cdecl eof(_In_ int _FileHandle)
bool _M_unshift()
Definition: _fstream.c:593
void _M_exit_putback_mode()
Definition: _fstream.h:228

◆ _M_seek_return()

template<class _CharT, class _Traits>
pos_type basic_filebuf< _CharT, _Traits >::_M_seek_return ( off_type  __off,
_State_type  __state 
)
inlineprivate

Definition at line 247 of file _fstream.h.

247  {
248  if (__off != -1) {
249  if (_M_in_input_mode)
251  _M_in_input_mode = false;
252  _M_in_output_mode = false;
253  _M_in_putback_mode = false;
254  _M_in_error_mode = false;
255  this->setg(0, 0, 0);
256  this->setp(0, 0);
257  }
258 
259  pos_type __result(__off);
260  __result.state(__state);
261  return __result;
262  }
unsigned char _M_in_input_mode
Definition: _fstream.h:280
void setp(char_type *__pbegin, char_type *__pend)
Definition: _streambuf.h:116
void setg(char_type *__gbegin, char_type *__gnext, char_type *__gend)
Definition: _streambuf.h:92
_Traits::pos_type pos_type
Definition: _fstream.h:156
unsigned char _M_in_output_mode
Definition: _fstream.h:281
unsigned char _M_in_putback_mode
Definition: _fstream.h:283
unsigned char _M_in_error_mode
Definition: _fstream.h:282
void _M_exit_input_mode()
Definition: _fstream.c:118

◆ _M_setup_codecvt()

template<class _CharT , class _Traits >
void basic_filebuf< _CharT, _Traits >::_M_setup_codecvt ( const locale __loc,
bool  __on_imbue = true 
)
private

Definition at line 735 of file _fstream.c.

735  {
736  if (has_facet<_Codecvt>(__loc)) {
737  _M_codecvt = &use_facet<_Codecvt>(__loc) ;
738  int __encoding = _M_codecvt->encoding();
739 
740  _M_width = (max)(__encoding, 1);
742  _M_constant_width = __encoding > 0;
744  }
745  else {
746  _M_codecvt = 0;
747  _M_width = _M_max_width = 1;
749  if (__on_imbue) {
750  //This call will generate an exception reporting the problem.
751  use_facet<_Codecvt>(__loc);
752  }
753  }
754 }
#define max(a, b)
Definition: svc.c:63
unsigned char _M_constant_width
Definition: _fstream.h:274
int encoding() const _STLP_NOTHROW
Definition: _codecvt.h:98
unsigned char _M_always_noconv
Definition: _fstream.h:275
int max_length() const _STLP_NOTHROW
Definition: _codecvt.h:110
bool always_noconv() const _STLP_NOTHROW
Definition: _codecvt.h:100
int _M_max_width
Definition: _fstream.h:323
const _Codecvt * _M_codecvt
Definition: _fstream.h:320

Referenced by basic_filebuf< char, char_traits< char > >::basic_filebuf().

◆ _M_switch_to_input_mode()

template<class _CharT , class _Traits >
bool basic_filebuf< _CharT, _Traits >::_M_switch_to_input_mode ( )
private

Definition at line 429 of file _fstream.c.

429  {
430  if (this->is_open() && (((int)_M_base.__o_mode() & (int)ios_base::in) !=0)
431  && (_M_in_output_mode == 0) && (_M_in_error_mode == 0)) {
432  if (!_M_int_buf && !_M_allocate_buffers())
433  return false;
434 
437 
439 
440  _M_in_input_mode = true;
441  return true;
442  }
443 
444  return false;
445 }
bool _M_allocate_buffers()
Definition: _fstream.c:676
char * _M_ext_buf_converted
Definition: _fstream.h:298
unsigned char _M_in_input_mode
Definition: _fstream.h:280
char * _M_ext_buf_end
Definition: _fstream.h:299
unsigned char _M_in_output_mode
Definition: _fstream.h:281
_Filebuf_base _M_base
Definition: _fstream.h:270
char * _M_ext_buf
Definition: _fstream.h:290
int __o_mode() const
Definition: _fstream.h:132
_CharT * _M_int_buf
Definition: _fstream.h:286
unsigned char _M_in_error_mode
Definition: _fstream.h:282
_State_type _M_end_state
Definition: _fstream.h:308
GLuint in
Definition: glext.h:9616
_State_type _M_state
Definition: _fstream.h:302
bool is_open() const
Definition: _fstream.h:169
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31

Referenced by _Underflow< _CharT, _Traits >::_M_doit().

◆ _M_switch_to_output_mode()

template<class _CharT , class _Traits >
bool basic_filebuf< _CharT, _Traits >::_M_switch_to_output_mode ( )
private

Definition at line 452 of file _fstream.c.

452  {
453  if (this->is_open() && (_M_base.__o_mode() & (int)ios_base::out) &&
454  _M_in_input_mode == 0 && _M_in_error_mode == 0) {
455 
456  if (!_M_int_buf && !_M_allocate_buffers())
457  return false;
458 
459  // In append mode, every write does an implicit seek to the end
460  // of the file. Whenever leaving output mode, the end of file
461  // get put in the initial shift state.
462  if (_M_base.__o_mode() & ios_base::app)
463  _M_state = _State_type();
464 
465  this->setp(_M_int_buf, _M_int_buf_EOS - 1);
466  _M_in_output_mode = true;
467  return true;
468  }
469 
470  return false;
471 }
bool _M_allocate_buffers()
Definition: _fstream.c:676
_Traits::state_type _State_type
Definition: _fstream.h:160
unsigned char _M_in_input_mode
Definition: _fstream.h:280
void setp(char_type *__pbegin, char_type *__pend)
Definition: _streambuf.h:116
unsigned char _M_in_output_mode
Definition: _fstream.h:281
_Filebuf_base _M_base
Definition: _fstream.h:270
int __o_mode() const
Definition: _fstream.h:132
_CharT * _M_int_buf
Definition: _fstream.h:286
static FILE * out
Definition: regtests2xml.c:44
_CharT * _M_int_buf_EOS
Definition: _fstream.h:287
unsigned char _M_in_error_mode
Definition: _fstream.h:282
_State_type _M_state
Definition: _fstream.h:302
bool is_open() const
Definition: _fstream.h:169
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31

◆ _M_underflow_aux()

template<class _CharT , class _Traits >
__BF_int_type__ basic_filebuf< _CharT, _Traits >::_M_underflow_aux ( )
private

Definition at line 495 of file _fstream.c.

495  {
496  // We have the state and file position from the end of the internal
497  // buffer. This round, they become the beginning of the internal buffer.
499 
500  // Fill the external buffer. Start with any leftover characters that
501  // didn't get converted last time.
503 
505  // boris : copy_backward did not work
506  //_M_ext_buf_end = copy_backward(_M_ext_buf_converted, _M_ext_buf_end,
507  //_M_ext_buf+ (_M_ext_buf_end - _M_ext_buf_converted));
508  else
510 
511  // Now fill the external buffer with characters from the file. This is
512  // a loop because occasionally we don't get enough external characters
513  // to make progress.
514  for (;;) {
516  if (__n < 0) {
517  // Read failed, maybe we should set err bit on associated stream...
518  this->setg(0, 0, 0);
519  return traits_type::eof();
520  }
521 
522  _M_ext_buf_end += __n;
523 
524  // If external buffer is empty there is nothing to do.
525  if (_M_ext_buf == _M_ext_buf_end) {
526  this->setg(0, 0, 0);
527  return traits_type::eof();
528  }
529 
530  // Convert the external buffer to internal characters.
531  const char* __enext;
532  _CharT* __inext;
533 
534  typename _Codecvt::result __status
536  _M_ext_buf, _M_ext_buf_end, __enext,
537  _M_int_buf, _M_int_buf_EOS, __inext);
538 
539  /* Error conditions:
540  * (1) Return value of error.
541  * (2) Producing internal characters without consuming external characters.
542  * (3) In fixed-width encodings, producing an internal sequence whose length
543  * is inconsistent with that of the internal sequence.
544  * (4) Failure to produce any characters if we have enough characters in
545  * the external buffer, where "enough" means the largest possible width
546  * of a single character. */
547  if (__status == _Codecvt::noconv)
548  return _Noconv_input<_Traits>::_M_doit(this);
549  else if (__status == _Codecvt::error ||
550  (__inext != _M_int_buf && __enext == _M_ext_buf) ||
551  (_M_constant_width && (__inext - _M_int_buf) * _M_width != (__enext - _M_ext_buf)) ||
552  (__inext == _M_int_buf && __enext - _M_ext_buf >= _M_max_width))
553  return _M_input_error();
554  else if (__inext != _M_int_buf) {
556  this->setg(_M_int_buf, _M_int_buf, __inext);
557  return traits_type::to_int_type(*_M_int_buf);
558  }
559  /* We need to go around the loop again to get more external characters.
560  * But if the previous read failed then don't try again for now.
561  * Don't enter error mode for a failed read. Error mode is sticky,
562  * and we might succeed if we try again. */
563  if (__n <= 0) {
564  this->setg(0, 0, 0);
565  return traits_type::eof();
566  }
567  }
568 }
char * _M_ext_buf_converted
Definition: _fstream.h:298
return __n
Definition: _algo.h:75
unsigned char _M_constant_width
Definition: _fstream.h:274
ptrdiff_t _M_read(char *__buf, ptrdiff_t __n)
char * _M_ext_buf_end
Definition: _fstream.h:299
void setg(char_type *__gbegin, char_type *__gnext, char_type *__gend)
Definition: _streambuf.h:92
static int_type _STLP_CALL _M_doit(basic_filebuf< char_type, _Traits > *)
Definition: _fstream.h:391
_Filebuf_base _M_base
Definition: _fstream.h:270
char * _M_ext_buf
Definition: _fstream.h:290
_CharT * _M_int_buf
Definition: _fstream.h:286
int_type _M_input_error()
Definition: _fstream.c:485
int _M_max_width
Definition: _fstream.h:323
_CharT * _M_int_buf_EOS
Definition: _fstream.h:287
char * _M_ext_buf_EOS
Definition: _fstream.h:291
_Check_return_ _CRTIMP int __cdecl __cdecl eof(_In_ int _FileHandle)
_State_type _M_end_state
Definition: _fstream.h:308
_State_type _M_state
Definition: _fstream.h:302
INT copy(TCHAR source[MAX_PATH], TCHAR dest[MAX_PATH], INT append, DWORD lpdwFlags, BOOL bTouch)
Definition: copy.c:51
result in(state_type &__state, const extern_type *__from, const extern_type *__from_end, const extern_type *&__from_next, intern_type *__to, intern_type *__to_limit, intern_type *&__to_next) const
Definition: _codecvt.h:84
__kernel_ptrdiff_t ptrdiff_t
Definition: linux.h:247
const _Codecvt * _M_codecvt
Definition: _fstream.h:320

Referenced by _Underflow< _CharT, _Traits >::_M_doit().

◆ _M_unshift()

template<class _CharT , class _Traits >
bool basic_filebuf< _CharT, _Traits >::_M_unshift ( )
private

Definition at line 593 of file _fstream.c.

593  {
595  typename _Codecvt::result __status;
596  do {
597  char* __enext = _M_ext_buf;
598  __status = _M_codecvt->unshift(_M_state,
599  _M_ext_buf, _M_ext_buf_EOS, __enext);
600  if (__status == _Codecvt::noconv ||
601  (__enext == _M_ext_buf && __status == _Codecvt::ok))
602  return true;
603  else if (__status == _Codecvt::error)
604  return false;
605  else if (!_M_write(_M_ext_buf, __enext - _M_ext_buf))
606  return false;
607  } while (__status == _Codecvt::partial);
608  }
609 
610  return true;
611 }
unsigned char _M_constant_width
Definition: _fstream.h:274
result unshift(state_type &__state, extern_type *__to, extern_type *__to_limit, extern_type *&__to_next) const
Definition: _codecvt.h:76
unsigned char _M_in_output_mode
Definition: _fstream.h:281
char * _M_ext_buf
Definition: _fstream.h:290
char * _M_ext_buf_EOS
Definition: _fstream.h:291
_State_type _M_state
Definition: _fstream.h:302
const _Codecvt * _M_codecvt
Definition: _fstream.h:320
bool _M_write(char *__buf, ptrdiff_t __n)
Definition: _fstream.h:331

◆ _M_write()

template<class _CharT, class _Traits>
bool basic_filebuf< _CharT, _Traits >::_M_write ( char __buf,
ptrdiff_t  __n 
)
inline

Definition at line 331 of file _fstream.h.

331 {return _M_base._M_write(__buf, __n); }
return __n
Definition: _algo.h:75
_Filebuf_base _M_base
Definition: _fstream.h:270
bool _M_write(char *__buf, ptrdiff_t __n)

◆ close()

template<class _CharT , class _Traits >
basic_filebuf< _CharT, _Traits > * basic_filebuf< _CharT, _Traits >::close ( void  )

Definition at line 81 of file _fstream.c.

81  {
82  bool __ok = this->is_open();
83 
84  if (_M_in_output_mode) {
85  __ok = __ok && !_Traits::eq_int_type(this->overflow(traits_type::eof()),
87  __ok = __ok && this->_M_unshift();
88  }
89  else if (_M_in_input_mode)
90  this->_M_exit_input_mode();
91 
92  // Note order of arguments. We close the file even if __ok is false.
93  __ok = _M_base._M_close() && __ok;
94 
95  // Restore the initial state, except that we don't deallocate the buffer
96  // or mess with the cached codecvt information.
99 
100  _M_mmap_base = 0;
101  _M_mmap_len = 0;
102 
103  this->setg(0, 0, 0);
104  this->setp(0, 0);
105 
107 
109  = false;
110 
111  return __ok ? this : 0;
112 }
char * _M_ext_buf_converted
Definition: _fstream.h:298
_Traits::state_type _State_type
Definition: _fstream.h:160
_CharT * _M_saved_gptr
Definition: _fstream.h:316
streamoff _M_mmap_len
Definition: _fstream.h:312
_CharT * _M_saved_egptr
Definition: _fstream.h:317
unsigned char _M_in_input_mode
Definition: _fstream.h:280
char * _M_ext_buf_end
Definition: _fstream.h:299
virtual int_type overflow(int_type=traits_type::eof())
Definition: _fstream.c:208
void setp(char_type *__pbegin, char_type *__pend)
Definition: _streambuf.h:116
void setg(char_type *__gbegin, char_type *__gnext, char_type *__gend)
Definition: _streambuf.h:92
unsigned char _M_in_output_mode
Definition: _fstream.h:281
_Filebuf_base _M_base
Definition: _fstream.h:270
unsigned char _M_in_putback_mode
Definition: _fstream.h:283
unsigned char _M_in_error_mode
Definition: _fstream.h:282
void _M_exit_input_mode()
Definition: _fstream.c:118
_Check_return_ _CRTIMP int __cdecl __cdecl eof(_In_ int _FileHandle)
bool _M_unshift()
Definition: _fstream.c:593
_State_type _M_end_state
Definition: _fstream.h:308
_State_type _M_state
Definition: _fstream.h:302
void * _M_mmap_base
Definition: _fstream.h:311
bool is_open() const
Definition: _fstream.h:169
_CharT * _M_saved_eback
Definition: _fstream.h:315

◆ fd()

template<class _CharT, class _Traits>
_STLP_fd basic_filebuf< _CharT, _Traits >::fd ( ) const
inline

Definition at line 182 of file _fstream.h.

182 { return _M_base.__get_fd(); }
_Filebuf_base _M_base
Definition: _fstream.h:270
_STLP_fd __get_fd() const
Definition: _fstream.h:136

◆ imbue()

template<class _CharT , class _Traits >
void basic_filebuf< _CharT, _Traits >::imbue ( const locale __loc)
protectedvirtual

Reimplemented from basic_streambuf< _CharT, _Traits >.

Definition at line 413 of file _fstream.c.

413  {
415  this->_M_setup_codecvt(__loc);
416  }
417 }
unsigned char _M_in_input_mode
Definition: _fstream.h:280
unsigned char _M_in_output_mode
Definition: _fstream.h:281
unsigned char _M_in_error_mode
Definition: _fstream.h:282
void _M_setup_codecvt(const locale &, bool __on_imbue=true)
Definition: _fstream.c:735

◆ is_open()

template<class _CharT, class _Traits>
bool basic_filebuf< _CharT, _Traits >::is_open ( ) const
inline

Definition at line 169 of file _fstream.h.

169 { return _M_base.__is_open(); }
bool __is_open() const
Definition: _fstream.h:133
_Filebuf_base _M_base
Definition: _fstream.h:270

◆ open() [1/3]

template<class _CharT, class _Traits>
_Self* basic_filebuf< _CharT, _Traits >::open ( const char __s,
ios_base::openmode  __m 
)
inline

Definition at line 171 of file _fstream.h.

171  {
172  return _M_base._M_open(__s, __m) ? this : 0;
173  }
_Filebuf_base _M_base
Definition: _fstream.h:270
bool _M_open(const char *, ios_base::openmode, long __protection)

◆ open() [2/3]

template<class _CharT, class _Traits>
_Self* basic_filebuf< _CharT, _Traits >::open ( const char __s,
ios_base::openmode  __m,
long  __protection 
)
inline

Definition at line 177 of file _fstream.h.

178  {
179  return _M_base._M_open(__s, __m, __protection) ? this : 0;
180  }
_Filebuf_base _M_base
Definition: _fstream.h:270
bool _M_open(const char *, ios_base::openmode, long __protection)

◆ open() [3/3]

template<class _CharT, class _Traits>
_Self* basic_filebuf< _CharT, _Traits >::open ( int  __id,
ios_base::openmode  _Init_mode = ios_base::__default_mode 
)
inline

Definition at line 184 of file _fstream.h.

184  {
185  return this->_M_open(__id, _Init_mode);
186  }
_Self * _M_open(int __id, ios_base::openmode _Init_mode=ios_base::__default_mode)
Definition: _fstream.h:202

◆ overflow()

template<class _CharT , class _Traits >
__BF_int_type__ basic_filebuf< _CharT, _Traits >::overflow ( int_type  __c = traits_type::eof())
protectedvirtual

Reimplemented from basic_streambuf< _CharT, _Traits >.

Definition at line 208 of file _fstream.c.

208  {
209  // Switch to output mode, if necessary.
210  if (!_M_in_output_mode)
212  return traits_type::eof();
213 
214  _CharT* __ibegin = this->_M_int_buf;
215  _CharT* __iend = this->pptr();
216  this->setp(_M_int_buf, _M_int_buf_EOS - 1);
217 
218  // Put __c at the end of the internal buffer.
219  if (!traits_type::eq_int_type(__c, traits_type::eof()))
220  *__iend++ = _Traits::to_char_type(__c);
221 
222  // For variable-width encodings, output may take more than one pass.
223  while (__ibegin != __iend) {
224  const _CharT* __inext = __ibegin;
225  char* __enext = _M_ext_buf;
226  typename _Codecvt::result __status
227  = _M_codecvt->out(_M_state, __ibegin, __iend, __inext,
228  _M_ext_buf, _M_ext_buf_EOS, __enext);
229  if (__status == _Codecvt::noconv) {
230  return _Noconv_output<_Traits>::_M_doit(this, __ibegin, __iend)
231  ? traits_type::not_eof(__c)
232  : _M_output_error();
233  }
234 
235  // For a constant-width encoding we know that the external buffer
236  // is large enough, so failure to consume the entire internal buffer
237  // or to produce the correct number of external characters, is an error.
238  // For a variable-width encoding, however, we require only that we
239  // consume at least one internal character
240  else if (__status != _Codecvt::error &&
241  (((__inext == __iend) &&
242  (__enext - _M_ext_buf == _M_width * (__iend - __ibegin))) ||
243  (!_M_constant_width && __inext != __ibegin))) {
244  // We successfully converted part or all of the internal buffer.
245  ptrdiff_t __n = __enext - _M_ext_buf;
246  if (_M_write(_M_ext_buf, __n))
247  __ibegin += __inext - __ibegin;
248  else
249  return _M_output_error();
250  }
251  else
252  return _M_output_error();
253  }
254 
255  return traits_type::not_eof(__c);
256 }
return __n
Definition: _algo.h:75
unsigned char _M_constant_width
Definition: _fstream.h:274
int_type _M_output_error()
Definition: _fstream.c:579
void setp(char_type *__pbegin, char_type *__pend)
Definition: _streambuf.h:116
bool _M_switch_to_output_mode()
Definition: _fstream.c:452
char_type * pptr() const
Definition: _streambuf.h:112
#define __c
Definition: schilyio.h:209
static bool _STLP_CALL _M_doit(basic_filebuf< char_type, _Traits > *, char_type *, char_type *)
Definition: _fstream.h:357
unsigned char _M_in_output_mode
Definition: _fstream.h:281
char * _M_ext_buf
Definition: _fstream.h:290
_CharT * _M_int_buf
Definition: _fstream.h:286
_CharT * _M_int_buf_EOS
Definition: _fstream.h:287
result out(state_type &__state, const intern_type *__from, const intern_type *__from_end, const intern_type *&__from_next, extern_type *__to, extern_type *__to_limit, extern_type *&__to_next) const
Definition: _codecvt.h:62
char * _M_ext_buf_EOS
Definition: _fstream.h:291
_Check_return_ _CRTIMP int __cdecl __cdecl eof(_In_ int _FileHandle)
_State_type _M_state
Definition: _fstream.h:302
__kernel_ptrdiff_t ptrdiff_t
Definition: linux.h:247
const _Codecvt * _M_codecvt
Definition: _fstream.h:320
bool _M_write(char *__buf, ptrdiff_t __n)
Definition: _fstream.h:331

◆ pbackfail()

template<class _CharT , class _Traits >
__BF_int_type__ basic_filebuf< _CharT, _Traits >::pbackfail ( int_type  __c = traits_type::eof())
protectedvirtual

Reimplemented from basic_streambuf< _CharT, _Traits >.

Definition at line 157 of file _fstream.c.

157  {
158  const int_type __eof = traits_type::eof();
159 
160  // If we aren't already in input mode, pushback is impossible.
161  if (!_M_in_input_mode)
162  return __eof;
163 
164  // We can use the ordinary get buffer if there's enough space, and
165  // if it's a buffer that we're allowed to write to.
166  if (this->gptr() != this->eback() &&
167  (traits_type::eq_int_type(__c, __eof) ||
168  traits_type::eq(traits_type::to_char_type(__c), this->gptr()[-1]) ||
169  !_M_mmap_base)) {
170  this->gbump(-1);
171  if (traits_type::eq_int_type(__c, __eof) ||
172  traits_type::eq(traits_type::to_char_type(__c), *this->gptr()))
173  return traits_type::to_int_type(*this->gptr());
174  }
175  else if (!traits_type::eq_int_type(__c, __eof)) {
176  // Are we in the putback buffer already?
177  _CharT* __pback_end = _M_pback_buf + __STATIC_CAST(int,_S_pback_buf_size);
178  if (_M_in_putback_mode) {
179  // Do we have more room in the putback buffer?
180  if (this->eback() != _M_pback_buf)
181  this->setg(this->egptr() - 1, this->egptr() - 1, __pback_end);
182  else
183  return __eof; // No more room in the buffer, so fail.
184  }
185  else { // We're not yet in the putback buffer.
186  _M_saved_eback = this->eback();
187  _M_saved_gptr = this->gptr();
188  _M_saved_egptr = this->egptr();
189  this->setg(__pback_end - 1, __pback_end - 1, __pback_end);
190  _M_in_putback_mode = true;
191  }
192  }
193  else
194  return __eof;
195 
196  // We have made a putback position available. Assign to it, and return.
197  *this->gptr() = traits_type::to_char_type(__c);
198  return __c;
199 }
char_type * eback() const
Definition: _streambuf.h:87
void gbump(int __n)
Definition: _streambuf.h:91
char_type * egptr() const
Definition: _streambuf.h:89
_CharT * _M_saved_gptr
Definition: _fstream.h:316
#define __STATIC_CAST(__x, __y)
Definition: features.h:585
_CharT * _M_saved_egptr
Definition: _fstream.h:317
unsigned char _M_in_input_mode
Definition: _fstream.h:280
#define eq(received, expected, label, type)
Definition: locale.c:144
void setg(char_type *__gbegin, char_type *__gnext, char_type *__gend)
Definition: _streambuf.h:92
#define __c
Definition: schilyio.h:209
unsigned char _M_in_putback_mode
Definition: _fstream.h:283
char_type * gptr() const
Definition: _streambuf.h:88
_CharT _M_pback_buf[_S_pback_buf_size]
Definition: _fstream.h:327
_Check_return_ _CRTIMP int __cdecl __cdecl eof(_In_ int _FileHandle)
_Traits::int_type int_type
Definition: _fstream.h:155
void * _M_mmap_base
Definition: _fstream.h:311
_CharT * _M_saved_eback
Definition: _fstream.h:315

◆ seekoff()

template<class _CharT , class _Traits >
__BF_pos_type__ basic_filebuf< _CharT, _Traits >::seekoff ( off_type  __off,
ios_base::seekdir  __whence,
ios_base::openmode  = ios_base::in | ios_base::out 
)
protectedvirtual

Reimplemented from basic_streambuf< _CharT, _Traits >.

Definition at line 291 of file _fstream.c.

293  {
294  if (!this->is_open())
295  return pos_type(-1);
296 
297  if (!_M_constant_width && __off != 0)
298  return pos_type(-1);
299 
300  if (!_M_seek_init(__off != 0 || __whence != ios_base::cur))
301  return pos_type(-1);
302 
303  // Seek to beginning or end, regardless of whether we're in input mode.
304  if (__whence == ios_base::beg || __whence == ios_base::end)
305  return _M_seek_return(_M_base._M_seek(_M_width * __off, __whence),
306  _State_type());
307 
308  // Seek relative to current position. Complicated if we're in input mode.
309  _STLP_ASSERT(__whence == ios_base::cur)
310  if (!_M_in_input_mode)
311  return _M_seek_return(_M_base._M_seek(_M_width * __off, __whence),
312  _State_type());
313 
314  if (_M_mmap_base != 0) {
315  // __off is relative to gptr(). We need to do a bit of arithmetic
316  // to get an offset relative to the external file pointer.
317  streamoff __adjust = _M_mmap_len - (this->gptr() - (_CharT*) _M_mmap_base);
318 
319  // if __off == 0, we do not need to exit input mode and to shift file pointer
320  return __off == 0 ? pos_type(_M_base._M_seek(0, ios_base::cur) - __adjust)
321  : _M_seek_return(_M_base._M_seek(__off - __adjust, ios_base::cur), _State_type());
322  }
323 
324  if (_M_constant_width) { // Get or set the position.
325  streamoff __iadj = _M_width * (this->gptr() - this->eback());
326 
327  // Compensate for offset relative to gptr versus offset relative
328  // to external pointer. For a text-oriented stream, where the
329  // compensation is more than just pointer arithmetic, we may get
330  // but not set the current position.
331 
332  if (__iadj <= _M_ext_buf_end - _M_ext_buf) {
334 
335  return __off == 0 ? pos_type(_M_base._M_seek(0, ios_base::cur) - __eadj)
336  : _M_seek_return(_M_base._M_seek(__off - __eadj, ios_base::cur), _State_type());
337  }
338  }
339  else { // Get the position. Encoding is var width.
340  // Get position in internal buffer.
341  ptrdiff_t __ipos = this->gptr() - this->eback();
342 
343  // Get corresponding position in external buffer.
344  _State_type __state = _M_state;
345  int __epos = _M_codecvt->length(__state, _M_ext_buf, _M_ext_buf_converted,
346  __ipos);
347 #if defined (_STLP_ASSERTIONS)
348  // Sanity check (expensive): make sure __epos is the right answer.
349  _STLP_ASSERT(__epos >= 0)
350  _State_type __tmp_state = _M_state;
351  _Filebuf_Tmp_Buf<_CharT> __buf(__ipos);
352  _CharT* __ibegin = __buf._M_ptr;
353  _CharT* __inext = __ibegin;
354  const char* __dummy;
355  typename _Codecvt::result __status
356  = _M_codecvt->in(__tmp_state,
357  _M_ext_buf, _M_ext_buf + __epos, __dummy,
358  __ibegin, __ibegin + __ipos, __inext);
359  // The result code is necessarily ok because:
360  // - noconv: impossible for a variable encoding
361  // - error: length method is supposed to count until it reach max value or find an error so we cannot have
362  // an error again when decoding an external buffer up to length return value.
363  // - partial: idem error, it is also a reason for length to stop counting.
364  _STLP_ASSERT(__status == _Codecvt::ok)
365  _STLP_ASSERT(__inext == __ibegin + __ipos)
366  _STLP_ASSERT(equal(this->eback(), this->gptr(), __ibegin, _STLP_PRIV _Eq_traits<traits_type>()))
367 #endif
368  // Get the current position (at the end of the external buffer),
369  // then adjust it. Again, it might be a text-oriented stream.
370  streamoff __cur = _M_base._M_seek(0, ios_base::cur);
373  if (__cur != -1 && __cur + __adj >= 0)
374  return __off == 0 ? pos_type(__cur + __adj)
375  : _M_seek_return(__cur + __adj, __state);
376  }
377 
378  return pos_type(-1);
379 }
off_t streamoff
Definition: char_traits.h:74
char_type * eback() const
Definition: _streambuf.h:87
char * _M_ext_buf_converted
Definition: _fstream.h:298
_Traits::state_type _State_type
Definition: _fstream.h:160
unsigned char _M_constant_width
Definition: _fstream.h:274
char typename[32]
Definition: main.c:84
streamoff _M_mmap_len
Definition: _fstream.h:312
#define __STATIC_CAST(__x, __y)
Definition: features.h:585
bool _M_seek_init(bool __do_unshift)
Definition: _fstream.c:700
#define equal(x, y)
Definition: reader.cc:56
unsigned char _M_in_input_mode
Definition: _fstream.h:280
GLuint GLuint end
Definition: gl.h:1545
char * _M_ext_buf_end
Definition: _fstream.h:299
codecvt< _CharT, char, _State_type > _Codecvt
Definition: _fstream.h:319
_Traits::pos_type pos_type
Definition: _fstream.h:156
_Filebuf_base _M_base
Definition: _fstream.h:270
char * _M_ext_buf
Definition: _fstream.h:290
_Traits traits_type
Definition: _fstream.h:158
streamoff _M_seek(streamoff __offset, ios_base::seekdir __dir)
#define _STLP_PRIV
Definition: _dm.h:70
char_type * gptr() const
Definition: _streambuf.h:88
GLuint in
Definition: glext.h:9616
_State_type _M_state
Definition: _fstream.h:302
streamoff _M_get_offset(char *__first, char *__last)
Definition: _fstream.h:88
#define ok(value,...)
Definition: atltest.h:57
void * _M_mmap_base
Definition: _fstream.h:311
__kernel_ptrdiff_t ptrdiff_t
Definition: linux.h:247
#define _STLP_ASSERT(expr)
Definition: _debug.h:165
int length(state_type &__state, const extern_type *__from, const extern_type *__from_end, size_t __max) const
Definition: _codecvt.h:102
#define const
Definition: zconf.h:230
bool is_open() const
Definition: _fstream.h:169
GLuint64EXT * result
Definition: glext.h:11304
const _Codecvt * _M_codecvt
Definition: _fstream.h:320
pos_type _M_seek_return(off_type __off, _State_type __state)
Definition: _fstream.h:247

◆ seekpos()

template<class _CharT , class _Traits >
__BF_pos_type__ basic_filebuf< _CharT, _Traits >::seekpos ( pos_type  __pos,
ios_base::openmode  = ios_base::in | ios_base::out 
)
protectedvirtual

Reimplemented from basic_streambuf< _CharT, _Traits >.

Definition at line 384 of file _fstream.c.

385  {
386  if (this->is_open()) {
387  if (!_M_seek_init(true))
388  return pos_type(-1);
389 
390  streamoff __off = off_type(__pos);
391  if (__off != -1 && _M_base._M_seek(__off, ios_base::beg) != -1) {
392  _M_state = __pos.state();
393  return _M_seek_return(__off, __pos.state());
394  }
395  }
396 
397  return pos_type(-1);
398 }
off_t streamoff
Definition: char_traits.h:74
bool _M_seek_init(bool __do_unshift)
Definition: _fstream.c:700
_Traits::pos_type pos_type
Definition: _fstream.h:156
_Traits::off_type off_type
Definition: _fstream.h:157
_Filebuf_base _M_base
Definition: _fstream.h:270
streamoff _M_seek(streamoff __offset, ios_base::seekdir __dir)
_State_type _M_state
Definition: _fstream.h:302
bool is_open() const
Definition: _fstream.h:169
pos_type _M_seek_return(off_type __off, _State_type __state)
Definition: _fstream.h:247

◆ setbuf()

template<class _CharT , class _Traits >
basic_streambuf< _CharT, _Traits > * basic_filebuf< _CharT, _Traits >::setbuf ( char_type __buf,
streamsize  __n 
)
protectedvirtual

Reimplemented from basic_streambuf< _CharT, _Traits >.

Definition at line 268 of file _fstream.c.

268  {
270  _M_int_buf == 0) {
271  if (__buf == 0 && __n == 0)
272  _M_allocate_buffers(0, 1);
273  else if (__buf != 0 && __n > 0)
274  _M_allocate_buffers(__buf, __n);
275  }
276  return this;
277 }
bool _M_allocate_buffers()
Definition: _fstream.c:676
return __n
Definition: _algo.h:75
unsigned char _M_in_input_mode
Definition: _fstream.h:280
unsigned char _M_in_output_mode
Definition: _fstream.h:281
_CharT * _M_int_buf
Definition: _fstream.h:286
unsigned char _M_in_error_mode
Definition: _fstream.h:282

◆ showmanyc()

template<class _CharT , class _Traits >
streamsize basic_filebuf< _CharT, _Traits >::showmanyc ( )
protectedvirtual

Reimplemented from basic_streambuf< _CharT, _Traits >.

Definition at line 132 of file _fstream.c.

132  {
133  // Is there any possibility that reads can succeed?
134  if (!this->is_open() || _M_in_output_mode || _M_in_error_mode)
135  return -1;
136  else if (_M_in_putback_mode)
137  return this->egptr() - this->gptr();
138  else if (_M_constant_width) {
139  streamoff __pos = _M_base._M_seek(0, ios_base::cur);
140  streamoff __size = _M_base._M_file_size();
141  return __pos >= 0 && __size > __pos ? __size - __pos : 0;
142  }
143  else
144  return 0;
145 }
off_t streamoff
Definition: char_traits.h:74
char_type * egptr() const
Definition: _streambuf.h:89
unsigned char _M_constant_width
Definition: _fstream.h:274
unsigned char _M_in_output_mode
Definition: _fstream.h:281
streamoff _M_file_size()
_Filebuf_base _M_base
Definition: _fstream.h:270
streamoff _M_seek(streamoff __offset, ios_base::seekdir __dir)
unsigned char _M_in_putback_mode
Definition: _fstream.h:283
char_type * gptr() const
Definition: _streambuf.h:88
unsigned char _M_in_error_mode
Definition: _fstream.h:282
bool is_open() const
Definition: _fstream.h:169

◆ sync()

template<class _CharT , class _Traits >
int basic_filebuf< _CharT, _Traits >::sync ( )
protectedvirtual

Reimplemented from basic_streambuf< _CharT, _Traits >.

Definition at line 402 of file _fstream.c.

402  {
403  if (_M_in_output_mode)
404  return traits_type::eq_int_type(this->overflow(traits_type::eof()),
405  traits_type::eof()) ? -1 : 0;
406  return 0;
407 }
virtual int_type overflow(int_type=traits_type::eof())
Definition: _fstream.c:208
unsigned char _M_in_output_mode
Definition: _fstream.h:281
_Check_return_ _CRTIMP int __cdecl __cdecl eof(_In_ int _FileHandle)

◆ underflow()

template<class _CharT , class _Traits >
_STLP_TYPENAME_ON_RETURN_TYPE basic_filebuf< _CharT, _Traits >::int_type basic_filebuf< _CharT, _Traits >::underflow ( )
protectedvirtual

Reimplemented from basic_streambuf< _CharT, _Traits >.

Definition at line 75 of file _fstream.c.

75  {
77 }
static int_type _STLP_CALL _M_doit(basic_filebuf< _CharT, _Traits > *__this)
Definition: _fstream.h:416

Friends And Related Function Documentation

◆ _Underflow< _CharT, _Traits >

template<class _CharT, class _Traits>
friend class _Underflow< _CharT, _Traits >
friend

Definition at line 238 of file _fstream.h.

Member Data Documentation

◆ _M_always_noconv

template<class _CharT, class _Traits>
unsigned char basic_filebuf< _CharT, _Traits >::_M_always_noconv
private

Definition at line 275 of file _fstream.h.

◆ _M_base

◆ _M_codecvt

template<class _CharT, class _Traits>
const _Codecvt* basic_filebuf< _CharT, _Traits >::_M_codecvt
private

Definition at line 320 of file _fstream.h.

◆ _M_constant_width

template<class _CharT, class _Traits>
unsigned char basic_filebuf< _CharT, _Traits >::_M_constant_width
private

Definition at line 274 of file _fstream.h.

◆ _M_end_state

template<class _CharT, class _Traits>
_State_type basic_filebuf< _CharT, _Traits >::_M_end_state
private

Definition at line 308 of file _fstream.h.

◆ _M_ext_buf

template<class _CharT, class _Traits>
char* basic_filebuf< _CharT, _Traits >::_M_ext_buf
private

◆ _M_ext_buf_converted

template<class _CharT, class _Traits>
char* basic_filebuf< _CharT, _Traits >::_M_ext_buf_converted
private

◆ _M_ext_buf_end

template<class _CharT, class _Traits>
char* basic_filebuf< _CharT, _Traits >::_M_ext_buf_end
private

◆ _M_ext_buf_EOS

template<class _CharT, class _Traits>
char* basic_filebuf< _CharT, _Traits >::_M_ext_buf_EOS
private

Definition at line 291 of file _fstream.h.

◆ _M_in_error_mode

template<class _CharT, class _Traits>
unsigned char basic_filebuf< _CharT, _Traits >::_M_in_error_mode
private

◆ _M_in_input_mode

template<class _CharT, class _Traits>
unsigned char basic_filebuf< _CharT, _Traits >::_M_in_input_mode
private

◆ _M_in_output_mode

template<class _CharT, class _Traits>
unsigned char basic_filebuf< _CharT, _Traits >::_M_in_output_mode
private

◆ _M_in_putback_mode

template<class _CharT, class _Traits>
unsigned char basic_filebuf< _CharT, _Traits >::_M_in_putback_mode
private

◆ _M_int_buf

template<class _CharT, class _Traits>
_CharT* basic_filebuf< _CharT, _Traits >::_M_int_buf
private

Definition at line 286 of file _fstream.h.

◆ _M_int_buf_dynamic

template<class _CharT, class _Traits>
unsigned char basic_filebuf< _CharT, _Traits >::_M_int_buf_dynamic
private

Definition at line 278 of file _fstream.h.

◆ _M_int_buf_EOS

template<class _CharT, class _Traits>
_CharT* basic_filebuf< _CharT, _Traits >::_M_int_buf_EOS
private

Definition at line 287 of file _fstream.h.

◆ _M_max_width

template<class _CharT, class _Traits>
int basic_filebuf< _CharT, _Traits >::_M_max_width
private

Definition at line 323 of file _fstream.h.

◆ _M_mmap_base

template<class _CharT, class _Traits>
void* basic_filebuf< _CharT, _Traits >::_M_mmap_base
private

Definition at line 311 of file _fstream.h.

◆ _M_mmap_len

template<class _CharT, class _Traits>
streamoff basic_filebuf< _CharT, _Traits >::_M_mmap_len
private

Definition at line 312 of file _fstream.h.

◆ _M_pback_buf

template<class _CharT, class _Traits>
_CharT basic_filebuf< _CharT, _Traits >::_M_pback_buf[_S_pback_buf_size]
private

Definition at line 327 of file _fstream.h.

◆ _M_saved_eback

template<class _CharT, class _Traits>
_CharT* basic_filebuf< _CharT, _Traits >::_M_saved_eback
private

◆ _M_saved_egptr

template<class _CharT, class _Traits>
_CharT* basic_filebuf< _CharT, _Traits >::_M_saved_egptr
private

◆ _M_saved_gptr

template<class _CharT, class _Traits>
_CharT* basic_filebuf< _CharT, _Traits >::_M_saved_gptr
private

◆ _M_state

template<class _CharT, class _Traits>
_State_type basic_filebuf< _CharT, _Traits >::_M_state
private

Definition at line 302 of file _fstream.h.

◆ _M_width

template<class _CharT, class _Traits>
int basic_filebuf< _CharT, _Traits >::_M_width
private

Definition at line 322 of file _fstream.h.


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