15 #include "rapidjson.h" 17 #ifndef RAPIDJSON_STREAM_H_ 18 #define RAPIDJSON_STREAM_H_ 20 #include "encodings.h" 72 template<
typename Stream>
79 enum { copyOptimization = 0 };
83 template<
typename Stream>
84 inline void PutReserve(Stream& stream,
size_t count) {
90 template<
typename Stream>
91 inline void PutUnsafe(Stream& stream,
typename Stream::Ch c) {
96 template<
typename Stream,
typename Ch>
97 inline void PutN(Stream& stream, Ch c,
size_t n) {
98 PutReserve(stream, n);
99 for (
size_t i = 0; i < n; i++)
100 PutUnsafe(stream, c);
112 #if defined(_MSC_VER) && _MSC_VER <= 1800 114 RAPIDJSON_DIAG_OFF(4702)
115 RAPIDJSON_DIAG_OFF(4512)
118 template <
typename InputStream,
typename Encoding = UTF8<> >
121 typedef typename Encoding::Ch Ch;
124 Ch Peek()
const {
return is_.Peek(); }
125 Ch Take() {
return is_.Take(); }
126 size_t Tell() {
return is_.Tell(); }
127 Ch* PutBegin() {
return is_.PutBegin(); }
128 void Put(Ch ch) { is_.Put(ch); }
129 void Flush() { is_.Flush(); }
130 size_t PutEnd(Ch* ch) {
return is_.PutEnd(ch); }
133 const Ch* Peek4()
const {
return is_.Peek4(); }
136 UTFType GetType()
const {
return is_.GetType(); }
137 bool HasBOM()
const {
return is_.HasBOM(); }
143 #if defined(_MSC_VER) && _MSC_VER <= 1800 153 template <
typename Encoding>
155 typedef typename Encoding::Ch Ch;
159 Ch Peek()
const {
return *src_; }
160 Ch Take() {
return *src_++; }
161 size_t Tell()
const {
return static_cast<size_t>(src_ - head_); }
172 template <
typename Encoding>
174 enum { copyOptimization = 1 };
187 template <
typename Encoding>
189 typedef typename Encoding::Ch Ch;
194 Ch Peek() {
return *src_; }
195 Ch Take() {
return *src_++; }
196 size_t Tell() {
return static_cast<size_t>(src_ - head_); }
201 Ch* PutBegin() {
return dst_ = src_; }
202 size_t PutEnd(Ch* begin) {
return static_cast<size_t>(dst_ - begin); }
205 Ch* Push(
size_t count) { Ch* begin = dst_; dst_ += count;
return begin; }
206 void Pop(
size_t count) { dst_ -= count; }
213 template <
typename Encoding>
215 enum { copyOptimization = 1 };
223 #endif // RAPIDJSON_STREAM_H_ A Stream Wrapper.
Definition: stream.h:119
#define RAPIDJSON_NAMESPACE_BEGIN
provide custom rapidjson namespace (opening expression)
Definition: rapidjson.h:121
Provides additional information for stream.
Definition: stream.h:73
const Ch * src_
Current read position.
Definition: stream.h:168
Read-only string stream.
Definition: fwd.h:47
#define RAPIDJSON_NAMESPACE_END
provide custom rapidjson namespace (closing expression)
Definition: rapidjson.h:124
const Ch * head_
Original head of the string.
Definition: stream.h:169
A read-write string stream.
Definition: fwd.h:52
#define RAPIDJSON_ASSERT(x)
Assertion.
Definition: rapidjson.h:437