17 #ifndef RAPIDJSON_STREAM_H_
18 #define RAPIDJSON_STREAM_H_
20 #include "encodings.h"
22 RAPIDJSON_NAMESPACE_BEGIN
61 size_t PutEnd(Ch* begin);
72 template<
typename Stream>
79 enum { copyOptimization = 0 };
83 template<
typename Stream>
90 template<
typename Stream>
96 template<
typename Stream,
typename Ch>
99 for (
size_t i = 0; i < n; i++)
109 template <
typename Encoding>
110 struct GenericStringStream {
111 typedef typename Encoding::Ch Ch;
113 GenericStringStream(
const Ch *src) : src_(src), head_(src) {}
115 Ch Peek()
const {
return *src_; }
116 Ch Take() {
return *src_++; }
117 size_t Tell()
const {
return static_cast<size_t>(src_ - head_); }
128 template <
typename Encoding>
130 enum { copyOptimization = 1 };
143 template <
typename Encoding>
145 typedef typename Encoding::Ch Ch;
150 Ch Peek() {
return *src_; }
151 Ch Take() {
return *src_++; }
152 size_t Tell() {
return static_cast<size_t>(src_ - head_); }
157 Ch* PutBegin() {
return dst_ = src_; }
158 size_t PutEnd(Ch* begin) {
return static_cast<size_t>(dst_ - begin); }
161 Ch* Push(
size_t count) { Ch* begin = dst_; dst_ += count;
return begin; }
162 void Pop(
size_t count) { dst_ -= count; }
169 template <
typename Encoding>
171 enum { copyOptimization = 1 };
177 RAPIDJSON_NAMESPACE_END
179 #endif // RAPIDJSON_STREAM_H_
Concept for reading and writing characters.
A read-write string stream.
Definition: fwd.h:52
common definitions and configuration
Provides additional information for stream.
Definition: stream.h:73
Read-only string stream.
Definition: fwd.h:47
#define RAPIDJSON_ASSERT(x)
Assertion.
Definition: rapidjson.h:402
void PutUnsafe(Stream &stream, typename Stream::Ch c)
Write character to a stream, presuming buffer is reserved.
Definition: stream.h:91
void PutReserve(Stream &stream, size_t count)
Reserve n characters for writing to a stream.
Definition: stream.h:84
const Ch * head_
Original head of the string.
Definition: stream.h:125
Concept for encoding of Unicode characters.
void PutN(FileWriteStream &stream, char c, size_t n)
Implement specialized version of PutN() with memset() for better performance.
Definition: filewritestream.h:94
const Ch * src_
Current read position.
Definition: stream.h:124