15 #ifndef RAPIDJSON_FILEWRITESTREAM_H_
16 #define RAPIDJSON_FILEWRITESTREAM_H_
23 RAPIDJSON_DIAG_OFF(unreachable-code)
36 FileWriteStream(std::FILE* fp,
char* buffer,
size_t bufferSize) : fp_(fp), buffer_(buffer), bufferEnd_(buffer + bufferSize), current_(buffer_) {
41 if (current_ >= bufferEnd_)
47 void PutN(
char c,
size_t n) {
48 size_t avail =
static_cast<size_t>(bufferEnd_ - current_);
50 std::memset(current_, c, avail);
54 avail =
static_cast<size_t>(bufferEnd_ - current_);
58 std::memset(current_, c, n);
64 if (current_ != buffer_) {
65 size_t result = fwrite(buffer_, 1,
static_cast<size_t>(current_ - buffer_), fp_);
66 if (result <
static_cast<size_t>(current_ - buffer_)) {
Wrapper of C file stream for input using fread().
Definition: filewritestream.h:32
char Ch
Character type. Only support char.
Definition: filewritestream.h:34
#define RAPIDJSON_ASSERT(x)
Assertion.
Definition: rapidjson.h:402
#define RAPIDJSON_NAMESPACE_BEGIN
provide custom rapidjson namespace (opening expression)
Definition: rapidjson.h:116
#define RAPIDJSON_NAMESPACE_END
provide custom rapidjson namespace (closing expression)
Definition: rapidjson.h:119