15 #ifndef RAPIDJSON_FILEREADSTREAM_H_
16 #define RAPIDJSON_FILEREADSTREAM_H_
23 RAPIDJSON_DIAG_OFF(padded)
24 RAPIDJSON_DIAG_OFF(unreachable-code)
25 RAPIDJSON_DIAG_OFF(missing-noreturn)
44 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) {
50 Ch Peek()
const {
return *current_; }
52 size_t Tell()
const {
return count_ +
static_cast<size_t>(current_ - buffer_); }
62 return (current_ + 4 <= bufferLast_) ? current_ : 0;
67 if (current_ < bufferLast_)
71 readCount_ = fread(buffer_, 1, bufferSize_, fp_);
72 bufferLast_ = buffer_ + readCount_ - 1;
75 if (readCount_ < bufferSize_) {
76 buffer_[readCount_] =
'\0';
99 #endif // RAPIDJSON_FILESTREAM_H_