15 #ifndef RAPIDJSON_ENCODEDSTREAM_H_ 16 #define RAPIDJSON_ENCODEDSTREAM_H_ 22 RAPIDJSON_DIAG_OFF(effc++)
32 template <
typename Encoding,
typename InputByteStream>
36 typedef typename Encoding::Ch
Ch;
44 size_t Tell()
const {
return is_.Tell(); }
65 template <
typename Encoding,
typename OutputByteStream>
69 typedef typename Encoding::Ch
Ch;
73 Encoding::PutBOM(os_);
76 void Put(Ch
c) { Encoding::Put(os_, c); }
90 OutputByteStream&
os_;
93 #define RAPIDJSON_ENCODINGS_FUNC(x) UTF8<Ch>::x, UTF16LE<Ch>::x, UTF16BE<Ch>::x, UTF32LE<Ch>::x, UTF32BE<Ch>::x 100 template <
typename CharType,
typename InputByteStream>
115 takeFunc_ = f[type_];
145 const unsigned char*
c = (
const unsigned char *)
is_->Peek4();
149 unsigned bom =
static_cast<unsigned>(c[0] | (c[1] << 8) | (c[2] << 16) | (c[3] << 24));
151 if (bom == 0xFFFE0000) { type_ =
kUTF32BE; hasBOM_ =
true;
is_->Take();
is_->Take();
is_->Take();
is_->Take(); }
152 else if (bom == 0x0000FEFF) { type_ =
kUTF32LE; hasBOM_ =
true;
is_->Take();
is_->Take();
is_->Take();
is_->Take(); }
153 else if ((bom & 0xFFFF) == 0xFFFE) { type_ =
kUTF16BE; hasBOM_ =
true;
is_->Take();
is_->Take(); }
154 else if ((bom & 0xFFFF) == 0xFEFF) { type_ =
kUTF16LE; hasBOM_ =
true;
is_->Take();
is_->Take(); }
155 else if ((bom & 0xFFFFFF) == 0xBFBBEF) { type_ =
kUTF8; hasBOM_ =
true;
is_->Take();
is_->Take();
is_->Take(); }
169 unsigned pattern = (c[0] ? 1 : 0) | (c[1] ? 2 : 0) | (c[2] ? 4 : 0) | (c[3] ? 8 : 0);
175 case 0x0F: type_ =
kUTF8;
break;
185 typedef Ch (*TakeFunc)(InputByteStream& is);
198 template <
typename CharType,
typename OutputByteStream>
226 void Put(Ch
c) { putFunc_(*os_, c); }
241 typedef void (*PutBOMFunc)(OutputByteStream&);
246 typedef void (*PutFunc)(OutputByteStream&,
Ch);
253 #undef RAPIDJSON_ENCODINGS_FUNC 261 #endif // RAPIDJSON_FILESTREAM_H_ #define RAPIDJSON_ENCODINGS_FUNC(x)
UTFType
Runtime-specified UTF encoding type of a stream.
Output byte stream wrapper with statically bound encoding.
GLuint GLuint GLsizei GLenum type
#define RAPIDJSON_NAMESPACE_BEGIN
provide custom rapidjson namespace (opening expression)
typedef void(GLAPIENTRY *PFNGLCOPYTEXSUBIMAGE3DPROC)(GLenum target
#define RAPIDJSON_NAMESPACE_END
provide custom rapidjson namespace (closing expression)
Output stream wrapper with dynamically bound encoding and automatic encoding detection.
AutoUTFOutputStream(OutputByteStream &os, UTFType type, bool putBOM)
Constructor.
EncodedOutputStream(OutputByteStream &os, bool putBOM=true)
common definitions and configuration
#define RAPIDJSON_ASSERT(x)
Assertion.