#include <fdstream.h>
Public Member Functions | |
| fdinbuf (int _fd) | |
Protected Member Functions | |
| virtual int | underflow () |
Protected Attributes | |
| int | fd |
| char | buffer [bufSize+pbSize] |
Static Protected Attributes | |
| const int | pbSize = 4 |
| const int | bufSize = 1024 |
|
|
Definition at line 123 of file fdstream.h. 00123 : fd(_fd) { 00124 setg (buffer+pbSize, // beginning of putback area 00125 buffer+pbSize, // read position 00126 buffer+pbSize); // end position 00127 }
|
|
|
Definition at line 131 of file fdstream.h. 00131 {
00132 #ifndef _MSC_VER
00133 using std::memmove;
00134 #endif
00135
00136 // is read position before end of buffer?
00137 if (gptr() < egptr()) {
00138 return *gptr();
00139 }
00140
00141 /* process size of putback area
00142 * - use number of characters read
00143 * - but at most size of putback area
00144 */
00145 int numPutback;
00146 numPutback = gptr() - eback();
00147 if (numPutback > pbSize) {
00148 numPutback = pbSize;
00149 }
00150
00151 /* copy up to pbSize characters previously read into
00152 * the putback area
00153 */
00154 memmove (buffer+(pbSize-numPutback), gptr()-numPutback,
00155 numPutback);
00156
00157 // read at most bufSize new characters
00158 int num;
00159 num = read (fd, buffer+pbSize, bufSize);
00160 if (num <= 0) {
00161 // ERROR or EOF
00162 return EOF;
00163 }
00164
00165 // reset buffer pointers
00166 setg (buffer+(pbSize-numPutback), // beginning of putback area
00167 buffer+pbSize, // read position
00168 buffer+pbSize+num); // end of buffer
00169
00170 // return next character
00171 return *gptr();
00172 }
|
|
|
Definition at line 114 of file fdstream.h. |
|
|
Definition at line 113 of file fdstream.h. |
|
|
Definition at line 106 of file fdstream.h. |
|
|
Definition at line 112 of file fdstream.h. |
1.3.9.1