19 #ifndef RAPIDJSON_ENCODEDSTREAM_H_ 20 #define RAPIDJSON_ENCODEDSTREAM_H_ 27 RAPIDJSON_DIAG_OFF(effc++)
32 RAPIDJSON_DIAG_OFF(padded)
43 template <
typename Encoding,
typename InputByteStream>
48 typedef typename Encoding::Ch
Ch;
60 size_t Tell()
const {
return is_.Tell(); }
89 if (static_cast<unsigned char>(
is_.Peek()) == 0xEFu)
is_.Take();
90 if (static_cast<unsigned char>(
is_.Peek()) == 0xBBu)
is_.Take();
91 if (static_cast<unsigned char>(
is_.Peek()) == 0xBFu)
is_.Take();
95 size_t Tell()
const {
return is_.Tell(); }
116 template <
typename Encoding,
typename OutputByteStream>
121 typedef typename Encoding::Ch
Ch;
124 if (putBOM) Encoding::PutBOM(os_);
127 void Put(Ch c) { Encoding::Put(os_, c); }
159 #define RAPIDJSON_ENCODINGS_FUNC(x) \ 160 UTF8<Ch>::x, UTF16LE<Ch>::x, UTF16BE<Ch>::x, UTF32LE<Ch>::x, UTF32BE<Ch>::x 168 template <
typename CharType,
typename InputByteStream>
181 :
is_(&is), type_(type), hasBOM_(false) {
185 takeFunc_ = f[type_];
225 const unsigned char *c =
226 reinterpret_cast<const unsigned char *
>(
is_->Peek4());
230 static_cast<unsigned>(c[0] | (c[1] << 8) | (c[2] << 16) | (c[3] << 24));
232 if (bom == 0xFFFE0000) {
239 }
else if (bom == 0x0000FEFF) {
246 }
else if ((bom & 0xFFFF) == 0xFFFE) {
251 }
else if ((bom & 0xFFFF) == 0xFEFF) {
256 }
else if ((bom & 0xFFFFFF) == 0xBFBBEF) {
277 (c[0] ? 1 : 0) | (c[1] ? 2 : 0) | (c[2] ? 4 : 0) | (c[3] ? 8 : 0);
307 typedef Ch (*TakeFunc)(InputByteStream &is);
321 template <
typename CharType,
typename OutputByteStream>
335 : os_(&os), type_(type) {
348 if (putBOM) PutBOM();
353 void Put(Ch c) { putFunc_(*os_, c); }
383 typedef void (*PutBOMFunc)(OutputByteStream &);
388 typedef void (*PutFunc)(OutputByteStream &,
Ch);
395 #undef RAPIDJSON_ENCODINGS_FUNC 407 #endif // RAPIDJSON_FILESTREAM_H_ #define RAPIDJSON_ENCODINGS_FUNC(x)
UTFType
Runtime-specified UTF encoding type of a stream.
Represents an in-memory input byte stream.
#define RAPIDJSON_ASSERT(x)
Assertion.
#define RAPIDJSON_NAMESPACE_END
provide custom rapidjson namespace (closing expression)
Output byte stream wrapper with statically bound encoding.
AutoUTFOutputStream(OutputByteStream &os, UTFType type, bool putBOM)
Constructor.
EncodedOutputStream(OutputByteStream &os, bool putBOM=true)
#define RAPIDJSON_NAMESPACE_BEGIN
provide custom rapidjson namespace (opening expression)