21 #ifndef RAPIDJSON_ENCODEDSTREAM_H_ 22 #define RAPIDJSON_ENCODEDSTREAM_H_ 28 RAPIDJSON_DIAG_OFF(effc++)
38 template <
typename Encoding,
typename InputByteStream>
45 current_ = Encoding::TakeBOM(is_);
48 Ch
Peek()
const {
return current_; }
49 Ch
Take() { Ch
c = current_; current_ = Encoding::Take(is_);
return c; }
50 size_t Tell()
const {
return is_.Tell(); }
71 template <
typename Encoding,
typename OutputByteStream>
79 Encoding::PutBOM(os_);
96 OutputByteStream& os_;
99 #define RAPIDJSON_ENCODINGS_FUNC(x) UTF8<Ch>::x, UTF16LE<Ch>::x, UTF16BE<Ch>::x, UTF32LE<Ch>::x, UTF32BE<Ch>::x 106 template <
typename CharType,
typename InputByteStream>
120 takeFunc_ = f[type_];
121 current_ = takeFunc_(*is_);
127 Ch
Peek()
const {
return current_; }
128 Ch
Take() { Ch
c = current_; current_ = takeFunc_(*is_);
return c; }
129 size_t Tell()
const {
return is_->Tell(); }
150 const unsigned char*
c = (
const unsigned char *)is_->Peek4();
154 unsigned bom = c[0] | (c[1] << 8) | (c[2] << 16) | (c[3] << 24);
156 if (bom == 0xFFFE0000) { type_ =
kUTF32BE; hasBOM_ =
true; is_->Take(); is_->Take(); is_->Take(); is_->Take(); }
157 else if (bom == 0x0000FEFF) { type_ =
kUTF32LE; hasBOM_ =
true; is_->Take(); is_->Take(); is_->Take(); is_->Take(); }
158 else if ((bom & 0xFFFF) == 0xFFFE) { type_ =
kUTF16BE; hasBOM_ =
true; is_->Take(); is_->Take(); }
159 else if ((bom & 0xFFFF) == 0xFEFF) { type_ =
kUTF16LE; hasBOM_ =
true; is_->Take(); is_->Take(); }
160 else if ((bom & 0xFFFFFF) == 0xBFBBEF) { type_ =
kUTF8; hasBOM_ =
true; is_->Take(); is_->Take(); is_->Take(); }
174 unsigned pattern = (c[0] ? 1 : 0) | (c[1] ? 2 : 0) | (c[2] ? 4 : 0) | (c[3] ? 8 : 0);
180 case 0x0F: type_ =
kUTF8;
break;
203 typedef Ch (*TakeFunc)(InputByteStream&
is);
204 InputByteStream* is_;
216 template <
typename CharType,
typename OutputByteStream>
255 void Put(Ch
c) { putFunc_(*os_, c); }
270 typedef void (*PutBOMFunc)(OutputByteStream&);
275 typedef void (*PutFunc)(OutputByteStream&,
Ch);
277 OutputByteStream* os_;
282 #undef RAPIDJSON_ENCODINGS_FUNC 290 #endif // RAPIDJSON_FILESTREAM_H_ #define RAPIDJSON_ENCODINGS_FUNC(x)
Definition: encodedstream.h:99
CharType Ch
Definition: encodedstream.h:220
UTFType
Runtime-specified UTF encoding type of a stream.
Definition: encodings.h:543
Ch Peek() const
Definition: encodedstream.h:86
int c
Definition: cpp_unittests.cpp:275
Output byte stream wrapper with statically bound encoding.
Definition: encodedstream.h:72
#define Ch(x, y, z)
Definition: sha256.c:217
UTF-32 big endian.
Definition: encodings.h:548
UTF-16 little endian.
Definition: encodings.h:545
UTF-8.
Definition: encodings.h:544
#define RAPIDJSON_STATIC_ASSERT(x)
(Internal) macro to check for conditions at compile-time
Definition: rapidjson.h:346
Ch Take()
Definition: encodedstream.h:260
size_t PutEnd(Ch *)
Definition: encodedstream.h:90
#define RAPIDJSON_NAMESPACE_BEGIN
provide custom rapidjson namespace (opening expression)
Definition: rapidjson.h:91
UTF-16 big endian.
Definition: encodings.h:546
size_t Tell() const
Definition: encodedstream.h:88
void Put(Ch c)
Definition: encodedstream.h:82
Definition: GetPutInfo.h:232
void
Definition: AVFoundationCFSoftLinking.h:81
size_t PutEnd(Ch *)
Definition: encodedstream.h:263
size_t Tell() const
Definition: encodedstream.h:261
#define RAPIDJSON_NAMESPACE_END
provide custom rapidjson namespace (closing expression)
Definition: rapidjson.h:94
Output stream wrapper with dynamically bound encoding and automatic encoding detection.
Definition: encodedstream.h:217
GLfloat f
Definition: gl2.h:417
AutoUTFOutputStream(OutputByteStream &os, UTFType type, bool putBOM)
Constructor.
Definition: encodedstream.h:228
EGLenum type
Definition: eglext.h:63
void Flush()
Definition: encodedstream.h:256
bool is(Ref< ArgType > &source)
Definition: Ref.h:220
EncodedOutputStream(OutputByteStream &os, bool putBOM=true)
Definition: encodedstream.h:77
UTFType GetType() const
Definition: encodedstream.h:253
common definitions and configuration
Ch Take()
Definition: encodedstream.h:87
#define false
Definition: float-mm.c:5
void Flush()
Definition: encodedstream.h:83
UTF-32 little endian.
Definition: encodings.h:547
Ch * PutBegin()
Definition: encodedstream.h:89
Ch * PutBegin()
Definition: encodedstream.h:262
Encoding::Ch Ch
Definition: encodedstream.h:75
#define RAPIDJSON_ASSERT(x)
Assertion.
Definition: rapidjson.h:315
void Put(Ch c)
Definition: encodedstream.h:255
Ch Peek() const
Definition: encodedstream.h:259