Input and output file stream buffer.
More...
#include <JFileStreamBuffer.hh>
|
int | flush () |
| Flush internal buffer.
|
|
Input and output file stream buffer.
Definition at line 235 of file JFileStreamBuffer.hh.
◆ int_type [1/2]
◆ int_type [2/2]
◆ streamsize
◆ JFileStreamBuffer()
JLANG::JFileStreamBuffer::JFileStreamBuffer |
( |
const JAbstractFile & | in, |
|
|
const JAbstractFile & | out, |
|
|
const std::size_t | size = 65536, |
|
|
const std::size_t | put_back = 8 ) |
|
inline |
Constructor.
- Parameters
-
in | input file |
out | output file |
size | size of internal buffer |
put_back | number of put back characters |
Definition at line 248 of file JFileStreamBuffer.hh.
251 :
254 {}
JFileOutputStreamBuffer(const JAbstractFile &file, const std::size_t size=65536)
Constructor.
◆ underflow()
virtual int_type JLANG::JFileInputStreamBuffer::underflow |
( |
| ) |
|
|
inlineoverridevirtualinherited |
Check underflow.
This method reads as many bytes as possible.
- Returns
- first character if OK; else EOF
Definition at line 60 of file JFileStreamBuffer.hh.
61 {
62 if (gptr() >= egptr()) {
63
64 char* __begin = this->
data();
65
66 if (eback() == __begin) {
67
68
69
71
73 }
74
75 const size_t len =
in.
read(__begin, this->size() - (__begin - this->
data()));
76
77 if (len != 0)
78 setg(this->
data(), __begin, __begin + len);
79 else
80 return traits_type::eof();
81 }
82
83 return *gptr();
84 }
virtual int read(char *buffer, const int length)
Read data from file.
◆ in_avail()
Check availability of input.
This method returns true if at least one byte can be read without blocking.
- Parameters
-
- Returns
- true if ready to read; else false
Definition at line 94 of file JFileStreamBuffer.hh.
95 {
96 return JFileDescriptorMask(
in).in_avail(timeout);
97 }
◆ overflow()
|
inlineoverridevirtualinherited |
Check overflow.
This method writes one byte if possible.
- Parameters
-
- Returns
- c if OK; else EOF
Definition at line 159 of file JFileStreamBuffer.hh.
160 {
161 if (c != traits_type::eof()) {
162
163 *pptr() = (char) c;
164
165 pbump(1);
166
167 if (
flush() == traits_type::eof()) {
168 return traits_type::eof();
169 }
170 }
171
172 return c;
173 }
int flush()
Flush internal buffer.
◆ sync()
virtual int JLANG::JFileOutputStreamBuffer::sync |
( |
| ) |
|
|
inlineoverridevirtualinherited |
Synchronise buffer.
Definition at line 179 of file JFileStreamBuffer.hh.
180 {
181 if (
flush() == traits_type::eof())
182 return -1;
183 else
184 return 0;
185 }
◆ out_avail()
Check availability of output.
This method returns true if at least one byte can be written without blocking.
- Parameters
-
- Returns
- true if ready to write; else false
Definition at line 195 of file JFileStreamBuffer.hh.
196 {
197 return JFileDescriptorMask(
out).out_avail(timeout);
198 }
◆ flush()
int JLANG::JFileOutputStreamBuffer::flush |
( |
| ) |
|
|
inlineprotectedinherited |
Flush internal buffer.
Definition at line 204 of file JFileStreamBuffer.hh.
205 {
206 const int len = pptr() - pbase();
207
208 if (len != 0) {
209
210 if (
out.
write(this->data(), len) != len) {
211 return traits_type::eof();
212 }
213
214 pbump(-len);
215 }
216
217 return len;
218 }
virtual int write(const char *buffer, const int length)
Write data to file.
◆ in
JFile JLANG::JFileInputStreamBuffer::in |
|
protectedinherited |
◆ memory
std::size_t JLANG::JFileInputStreamBuffer::memory |
|
protectedinherited |
◆ out
JFile JLANG::JFileOutputStreamBuffer::out |
|
protectedinherited |
The documentation for this class was generated from the following file: