16#ifndef RAPIDJSON_ISTREAMWRAPPER_H_
17#define RAPIDJSON_ISTREAMWRAPPER_H_
25RAPIDJSON_DIAG_OFF(padded)
26#elif defined(_MSC_VER)
28RAPIDJSON_DIAG_OFF(4351)
49template <
typename StreamType>
52 typedef typename StreamType::char_type Ch;
58 BasicIStreamWrapper(StreamType &stream) : stream_(stream), buffer_(peekBuffer_), bufferSize_(4), bufferLast_(0), current_(buffer_), readCount_(0),
count_(0), eof_(false) {
68 BasicIStreamWrapper(StreamType &stream,
char* buffer,
size_t bufferSize) : stream_(stream), buffer_(buffer), bufferSize_(bufferSize), bufferLast_(0), current_(buffer_), readCount_(0),
count_(0), eof_(false) {
73 Ch Peek()
const {
return *current_; }
74 Ch Take() { Ch c = *current_; Read();
return c; }
75 size_t Tell()
const {
return count_ +
static_cast<size_t>(current_ - buffer_); }
84 const Ch* Peek4()
const {
85 return (current_ + 4 - !eof_ <= bufferLast_) ? current_ : 0;
94 if (current_ < bufferLast_)
98 readCount_ = bufferSize_;
99 bufferLast_ = buffer_ + readCount_ - 1;
102 if (!stream_.read(buffer_,
static_cast<std::streamsize
>(bufferSize_))) {
103 readCount_ =
static_cast<size_t>(stream_.gcount());
104 *(bufferLast_ = buffer_ + readCount_) =
'\0';
111 Ch peekBuffer_[4], *buffer_;
123#if defined(__clang__) || defined(_MSC_VER)
Wrapper of std::basic_istream into RapidJSON's Stream concept.
BasicIStreamWrapper(StreamType &stream)
Constructor.
BasicIStreamWrapper(StreamType &stream, char *buffer, size_t bufferSize)
Constructor.
size_t count_
Number of characters read.
#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)