ReactOS 0.4.15-dev-8207-gd73a838
_Underflow< char, char_traits< char > > Class Reference

#include <_fstream.h>

Public Types

typedef char_traits< char >::int_type int_type
 
typedef char_traits< chartraits_type
 

Static Public Member Functions

static int_type _STLP_CALL _M_doit (basic_filebuf< char, traits_type > *__this)
 

Detailed Description

Definition at line 436 of file _fstream.h.

Member Typedef Documentation

◆ int_type

typedef char_traits<char>::int_type _Underflow< char, char_traits< char > >::int_type

Definition at line 439 of file _fstream.h.

◆ traits_type

typedef char_traits<char> _Underflow< char, char_traits< char > >::traits_type

Definition at line 440 of file _fstream.h.

Member Function Documentation

◆ _M_doit()

Definition at line 37 of file fstream.cpp.

38{
41
42 if (!__this->_M_in_input_mode) {
43 if (!__this->_M_switch_to_input_mode())
44 return traits_type::eof();
45 }
46 else if (__this->_M_in_putback_mode) {
47 __this->_M_exit_putback_mode();
48 if (__this->gptr() != __this->egptr()) {
50 return __c;
51 }
52 }
53
54 // If it's a disk file, and if the internal and external character
55 // sequences are guaranteed to be identical, then try to use memory
56 // mapped I/O. Otherwise, revert to ordinary read.
57 if (__this->_M_base.__regular_file()
58 && __this->_M_always_noconv
59 && __this->_M_base._M_in_binary_mode()) {
60 // If we've mmapped part of the file already, then unmap it.
61 if (__this->_M_mmap_base)
62 __this->_M_base._M_unmap(__this->_M_mmap_base, __this->_M_mmap_len);
63
64 // Determine the position where we start mapping. It has to be
65 // a multiple of the page size.
66 streamoff __cur = __this->_M_base._M_seek(0, ios_base::cur);
67 streamoff __size = __this->_M_base._M_file_size();
68 if (__size > 0 && __cur >= 0 && __cur < __size) {
69 streamoff __offset = (__cur / __this->_M_base.__page_size()) * __this->_M_base.__page_size();
70 streamoff __remainder = __cur - __offset;
71
72 __this->_M_mmap_len = __size - __offset;
73
74 if (__this->_M_mmap_len > MMAP_CHUNK)
75 __this->_M_mmap_len = MMAP_CHUNK;
76
77 if ((__this->_M_mmap_base = __this->_M_base._M_mmap(__offset, __this->_M_mmap_len)) != 0) {
78 __this->setg(__STATIC_CAST(char*, __this->_M_mmap_base),
79 __STATIC_CAST(char*, __this->_M_mmap_base) + __STATIC_CAST(ptrdiff_t, __remainder),
81 return traits_type::to_int_type(*__this->gptr());
82 }
83 else
84 __this->_M_mmap_len = 0;
85 }
86 else {
87 __this->_M_mmap_base = 0;
88 __this->_M_mmap_len = 0;
89 }
90 }
91
92 return __this->_M_underflow_aux();
93}
off_t streamoff
Definition: char_traits.h:74
streamoff _M_file_size()
bool __regular_file() const
Definition: _fstream.h:135
void _M_unmap(void *__mmap_base, streamoff __len)
void * _M_mmap(streamoff __offset, streamoff __len)
streamoff _M_seek(streamoff __offset, ios_base::seekdir __dir)
static size_t _STLP_CALL __page_size()
Definition: _fstream.h:131
bool _M_in_binary_mode() const
Definition: _fstream.h:100
char_traits< char >::int_type int_type
Definition: _fstream.h:439
static int_type _STLP_CALL eof()
Definition: char_traits.h:193
void * _M_mmap_base
Definition: _fstream.h:311
bool _M_switch_to_input_mode()
Definition: _fstream.c:429
int_type _M_underflow_aux()
Definition: _fstream.c:495
streamoff _M_mmap_len
Definition: _fstream.h:312
unsigned char _M_always_noconv
Definition: _fstream.h:275
_Filebuf_base _M_base
Definition: _fstream.h:270
void _M_exit_putback_mode()
Definition: _fstream.h:228
unsigned char _M_in_putback_mode
Definition: _fstream.h:283
unsigned char _M_in_input_mode
Definition: _fstream.h:280
char_type * egptr() const
Definition: _streambuf.h:89
char_type * gptr() const
Definition: _streambuf.h:88
void setg(char_type *__gbegin, char_type *__gnext, char_type *__gend)
Definition: _streambuf.h:92
static int _STLP_CALL to_int_type(const char &__c)
Definition: char_traits.h:222
__kernel_ptrdiff_t ptrdiff_t
Definition: linux.h:247
#define __STATIC_CAST(__x, __y)
Definition: features.h:585
#define MMAP_CHUNK
Definition: fstream.cpp:34
#define __c
Definition: schilyio.h:209

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