Wrapper of C file stream for output using fwrite().
More...
#include <filewritestream.h>
|
typedef char | Ch |
| Character type. Only support char.
|
|
- Note
- implements Stream concept
Definition at line 32 of file filewritestream.h.
◆ Ch
◆ FileWriteStream()
FileWriteStream::FileWriteStream |
( |
std::FILE * | fp, |
|
|
char * | buffer, |
|
|
size_t | bufferSize ) |
|
inline |
Definition at line 36 of file filewritestream.h.
36 : fp_(fp), buffer_(buffer), bufferEnd_(buffer + bufferSize), current_(buffer_) {
38 }
#define RAPIDJSON_ASSERT(x)
Assertion.
◆ Flush()
void FileWriteStream::Flush |
( |
| ) |
|
|
inline |
Definition at line 63 of file filewritestream.h.
63 {
64 if (current_ != buffer_) {
65 size_t result = std::fwrite(buffer_, 1, static_cast<size_t>(current_ - buffer_), fp_);
66 if (result < static_cast<size_t>(current_ - buffer_)) {
67
68
69 }
70 current_ = buffer_;
71 }
72 }
◆ Peek()
char FileWriteStream::Peek |
( |
| ) |
const |
|
inline |
◆ Put()
void FileWriteStream::Put |
( |
char | c | ) |
|
|
inline |
Definition at line 40 of file filewritestream.h.
40 {
41 if (current_ >= bufferEnd_)
43
44 *current_++ = c;
45 }
◆ PutBegin()
char * FileWriteStream::PutBegin |
( |
| ) |
|
|
inline |
◆ PutEnd()
size_t FileWriteStream::PutEnd |
( |
char * | | ) |
|
|
inline |
◆ PutN()
void FileWriteStream::PutN |
( |
char | c, |
|
|
size_t | n ) |
|
inline |
Definition at line 47 of file filewritestream.h.
47 {
48 size_t avail = static_cast<size_t>(bufferEnd_ - current_);
49 while (n > avail) {
50 std::memset(current_, c, avail);
51 current_ += avail;
53 n -= avail;
54 avail = static_cast<size_t>(bufferEnd_ - current_);
55 }
56
57 if (n > 0) {
58 std::memset(current_, c, n);
59 current_ += n;
60 }
61 }
◆ Take()
char FileWriteStream::Take |
( |
| ) |
|
|
inline |
◆ Tell()
size_t FileWriteStream::Tell |
( |
| ) |
const |
|
inline |
The documentation for this class was generated from the following file: