16#ifndef RAPIDJSON_FILEREADSTREAM_H_
17#define RAPIDJSON_FILEREADSTREAM_H_
24RAPIDJSON_DIAG_OFF(padded)
25RAPIDJSON_DIAG_OFF(unreachable-code)
26RAPIDJSON_DIAG_OFF(missing-noreturn)
45 FileReadStream(std::FILE* fp,
char* buffer,
size_t bufferSize) : fp_(fp), buffer_(buffer), bufferSize_(bufferSize), bufferLast_(0), current_(buffer_), readCount_(0),
count_(0), eof_(false) {
51 Ch Peek()
const {
return *current_; }
52 Ch Take() {
Ch c = *current_; Read();
return c; }
53 size_t Tell()
const {
return count_ +
static_cast<size_t>(current_ - buffer_); }
62 const Ch* Peek4()
const {
63 return (current_ + 4 - !eof_ <= bufferLast_) ? current_ : 0;
68 if (current_ < bufferLast_)
72 readCount_ = std::fread(buffer_, 1, bufferSize_, fp_);
73 bufferLast_ = buffer_ + readCount_ - 1;
76 if (readCount_ < bufferSize_) {
77 buffer_[readCount_] =
'\0';
File byte stream for input using fread().
size_t count_
Number of characters read.
FileReadStream(std::FILE *fp, char *buffer, size_t bufferSize)
Constructor.
char Ch
Character type (byte).
#define RAPIDJSON_ASSERT(x)
Assertion.
#define RAPIDJSON_NAMESPACE_BEGIN
provide custom rapidjson namespace (opening expression)
#define RAPIDJSON_NAMESPACE_END
provide custom rapidjson namespace (closing expression)