15 #ifndef RAPIDJSON_ENCODEDSTREAM_H_ 16 #define RAPIDJSON_ENCODEDSTREAM_H_ 23 RAPIDJSON_DIAG_OFF(effc++)
28 RAPIDJSON_DIAG_OFF(padded)
38 template <
typename Encoding,
typename InputByteStream>
42 typedef typename Encoding::Ch
Ch;
50 size_t Tell()
const {
return is_.Tell(); }
73 if (static_cast<unsigned char>(
is_.Peek()) == 0xEFu)
is_.Take();
74 if (static_cast<unsigned char>(
is_.Peek()) == 0xBBu)
is_.Take();
75 if (static_cast<unsigned char>(
is_.Peek()) == 0xBFu)
is_.Take();
79 size_t Tell()
const {
return is_.Tell(); }
99 template <
typename Encoding,
typename OutputByteStream>
103 typedef typename Encoding::Ch
Ch;
107 Encoding::PutBOM(
os_);
127 #define RAPIDJSON_ENCODINGS_FUNC(x) UTF8<Ch>::x, UTF16LE<Ch>::x, UTF16BE<Ch>::x, UTF32LE<Ch>::x, UTF32BE<Ch>::x 134 template <
typename CharType,
typename InputByteStream>
179 const unsigned char*
c =
reinterpret_cast<const unsigned char *
>(
is_->Peek4());
183 unsigned bom =
static_cast<unsigned>(
c[0] | (
c[1] << 8) | (
c[2] << 16) | (
c[3] << 24));
203 unsigned pattern = (
c[0] ? 1 : 0) | (
c[1] ? 2 : 0) | (
c[2] ? 4 : 0) | (
c[3] ? 8 : 0);
232 template <
typename CharType,
typename OutputByteStream>
275 typedef void (*PutBOMFunc)(OutputByteStream&);
287 #undef RAPIDJSON_ENCODINGS_FUNC 299 #endif // RAPIDJSON_FILESTREAM_H_ Output stream wrapper with dynamically bound encoding and automatic encoding detection.
Definition: encodedstream.h:233
void Flush()
Definition: encodedstream.h:83
Ch * PutBegin()
Definition: encodedstream.h:163
CharType Ch
Definition: encodedstream.h:236
AutoUTFOutputStream(OutputByteStream &os, UTFType type, bool putBOM)
Constructor.
Definition: encodedstream.h:244
size_t PutEnd(Ch *)
Definition: encodedstream.h:164
UTFType type_
Definition: encodedstream.h:221
void DetectType()
Definition: encodedstream.h:171
OutputByteStream & os_
Definition: encodedstream.h:124
Ch Peek() const
Definition: encodedstream.h:114
UTFType GetType() const
Definition: encodedstream.h:153
Ch * PutBegin()
Definition: encodedstream.h:267
RAPIDJSON_STATIC_ASSERT(sizeof(typename InputByteStream::Ch)==1)
EncodedInputStream(MemoryStream &is)
Definition: encodedstream.h:72
UTFType type_
Definition: encodedstream.h:283
Ch Take()
Definition: encodedstream.h:157
Ch Peek() const
Definition: encodedstream.h:77
MemoryStream & is_
Definition: encodedstream.h:87
Represents an in-memory input byte stream.
Definition: memorystream.h:40
void Put(Ch c)
Definition: encodedstream.h:110
UTF-32 big endian.
Definition: encodings.h:608
GLfloat f
Definition: glext.h:8207
Ch current_
Definition: encodedstream.h:63
void Put(Ch c)
Definition: encodedstream.h:260
typedef void(__stdcall *PFN_DESTRUCTION_CALLBACK)(void *pData)
Ch Peek() const
Definition: encodedstream.h:156
size_t PutEnd(Ch *)
Definition: encodedstream.h:268
EncodedOutputStream(OutputByteStream &os, bool putBOM=true)
Definition: encodedstream.h:105
UTF-16 little endian.
Definition: encodings.h:605
EncodedOutputStream & operator=(const EncodedOutputStream &)
#define RAPIDJSON_NAMESPACE_END
provide custom rapidjson namespace (closing expression)
Definition: rapidjson.h:119
UTF-32 little endian.
Definition: encodings.h:607
Ch * PutBegin()
Definition: encodedstream.h:84
size_t Tell() const
Definition: encodedstream.h:266
size_t Tell() const
Definition: encodedstream.h:79
void Flush()
Definition: encodedstream.h:261
const GLubyte * c
Definition: glext.h:9812
size_t PutEnd(Ch *)
Definition: encodedstream.h:85
CharType Ch
Definition: encodedstream.h:138
size_t PutEnd(Ch *)
Definition: encodedstream.h:118
void(* PutFunc)(OutputByteStream &, Ch)
Definition: encodedstream.h:280
UTF8 ::Ch Ch
Definition: encodedstream.h:70
AutoUTFOutputStream & operator=(const AutoUTFOutputStream &)
size_t PutEnd(Ch *)
Definition: encodedstream.h:56
void Put(Ch)
Definition: encodedstream.h:161
TakeFunc takeFunc_
Definition: encodedstream.h:223
InputByteStream * is_
Definition: encodedstream.h:220
GLenum type
Definition: glext.h:6233
Ch(* TakeFunc)(InputByteStream &is)
Definition: encodedstream.h:219
EncodedInputStream & operator=(const EncodedInputStream &)
Ch * PutBegin()
Definition: encodedstream.h:117
size_t Tell() const
Definition: encodedstream.h:116
void Flush()
Definition: encodedstream.h:162
Ch Take()
Definition: encodedstream.h:115
UTFType GetType() const
Definition: encodedstream.h:258
#define RAPIDJSON_ASSERT(x)
Assertion.
Definition: rapidjson.h:402
Ch Take()
Definition: encodedstream.h:78
Input stream wrapper with dynamically bound encoding and automatic encoding detection.
Definition: encodedstream.h:135
Ch current_
Definition: encodedstream.h:222
OutputByteStream * os_
Definition: encodedstream.h:282
Encoding::Ch Ch
Definition: encodedstream.h:42
void Flush()
Definition: encodedstream.h:111
void Put(Ch)
Definition: encodedstream.h:53
void Flush()
Definition: encodedstream.h:54
PutFunc putFunc_
Definition: encodedstream.h:284
UTFType
Runtime-specified UTF encoding type of a stream.
Definition: encodings.h:603
#define RAPIDJSON_NAMESPACE_BEGIN
provide custom rapidjson namespace (opening expression)
Definition: rapidjson.h:116
RAPIDJSON_STATIC_ASSERT(sizeof(typename OutputByteStream::Ch)==1)
Ch Peek() const
Definition: encodedstream.h:48
UTF-8.
Definition: encodings.h:604
Encoding::Ch Ch
Definition: encodedstream.h:103
InputByteStream & is_
Definition: encodedstream.h:62
RAPIDJSON_STATIC_ASSERT(sizeof(typename OutputByteStream::Ch)==1)
bool hasBOM_
Definition: encodedstream.h:224
AutoUTFInputStream & operator=(const AutoUTFInputStream &)
Ch Take()
Definition: encodedstream.h:49
Input byte stream wrapper with a statically bound encoding.
Definition: encodedstream.h:39
EncodedInputStream(InputByteStream &is)
Definition: encodedstream.h:44
size_t Tell() const
Definition: encodedstream.h:50
AutoUTFInputStream(InputByteStream &is, UTFType type=kUTF8)
Constructor.
Definition: encodedstream.h:145
bool HasBOM() const
Definition: encodedstream.h:154
Ch * PutBegin()
Definition: encodedstream.h:55
void PutBOM()
Definition: encodedstream.h:274
UTF-16 big endian.
Definition: encodings.h:606
#define false
Definition: ordinals.h:83
UTF-8 encoding.
Definition: encodings.h:96
Output byte stream wrapper with statically bound encoding.
Definition: encodedstream.h:100
#define RAPIDJSON_ENCODINGS_FUNC(x)
Definition: encodedstream.h:127
void Put(Ch)
Definition: encodedstream.h:82
Ch Peek() const
Definition: encodedstream.h:264
Ch Take()
Definition: encodedstream.h:265
size_t Tell() const
Definition: encodedstream.h:158
RAPIDJSON_STATIC_ASSERT(sizeof(typename InputByteStream::Ch)==1)