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>
145 const unsigned char* c = (
const unsigned char *)
is_->Peek4();
149 unsigned bom = c[0] | (c[1] << 8) | (c[2] << 16) | (c[3] << 24);
169 unsigned pattern = (c[0] ? 1 : 0) | (c[1] ? 2 : 0) | (c[2] ? 4 : 0) | (c[3] ? 8 : 0);
198 template <
typename CharType,
typename OutputByteStream>
241 typedef void (*PutBOMFunc)(OutputByteStream&);
253 #undef RAPIDJSON_ENCODINGS_FUNC
261 #endif // RAPIDJSON_FILESTREAM_H_
#define RAPIDJSON_ENCODINGS_FUNC(x)
Definition: encodedstream.h:93
CharType Ch
Definition: encodedstream.h:202
UTFType
Runtime-specified UTF encoding type of a stream.
Definition: encodings.h:538
#define RAPIDJSON_ASSERT(x)
Assertion.
Definition: rapidjson.h:344
Ch * PutBegin()
Definition: encodedstream.h:83
#define RAPIDJSON_NAMESPACE_END
provide custom rapidjson namespace (closing expression)
Definition: rapidjson.h:119
void Flush()
Definition: encodedstream.h:77
OutputByteStream * os_
Definition: encodedstream.h:248
UTF-32 big endian.
Definition: encodings.h:543
Ch Take()
Definition: encodedstream.h:81
UTFType GetType() const
Definition: encodedstream.h:224
UTF-16 little endian.
Definition: encodings.h:540
void Put(Ch c)
Definition: encodedstream.h:76
Output byte stream wrapper with statically bound encoding.
Definition: encodedstream.h:66
UTF-8.
Definition: encodings.h:539
AutoUTFOutputStream(OutputByteStream &os, UTFType type, bool putBOM)
Constructor.
Definition: encodedstream.h:210
#define false
Definition: CascPort.h:18
size_t PutEnd(Ch *)
Definition: encodedstream.h:234
UTF-16 big endian.
Definition: encodings.h:541
EncodedOutputStream(OutputByteStream &os, bool putBOM=true)
Definition: encodedstream.h:71
Ch Peek() const
Definition: encodedstream.h:80
PutFunc putFunc_
Definition: encodedstream.h:250
EncodedOutputStream & operator=(const EncodedOutputStream &)
size_t Tell() const
Definition: encodedstream.h:82
Output stream wrapper with dynamically bound encoding and automatic encoding detection.
Definition: encodedstream.h:199
#define RAPIDJSON_NAMESPACE_BEGIN
provide custom rapidjson namespace (opening expression)
Definition: rapidjson.h:116
AutoUTFOutputStream & operator=(const AutoUTFOutputStream &)
Ch Peek() const
Definition: encodedstream.h:230
UTFType type_
Definition: encodedstream.h:249
size_t Tell() const
Definition: encodedstream.h:232
void(* PutFunc)(OutputByteStream &, Ch)
Definition: encodedstream.h:246
const uint8_t bom[]
The library API - functions intended to be called by the users.
Definition: core.h:285
Encoding::Ch Ch
Definition: encodedstream.h:69
Ch * PutBegin()
Definition: encodedstream.h:233
void Flush()
Definition: encodedstream.h:227
common definitions and configuration
void Put(Ch c)
Definition: encodedstream.h:226
RAPIDJSON_STATIC_ASSERT(sizeof(typename OutputByteStream::Ch)==1)
UTF-32 little endian.
Definition: encodings.h:542
OutputByteStream & os_
Definition: encodedstream.h:90
void PutBOM()
Definition: encodedstream.h:240
size_t PutEnd(Ch *)
Definition: encodedstream.h:84
RAPIDJSON_STATIC_ASSERT(sizeof(typename OutputByteStream::Ch)==1)
Ch Take()
Definition: encodedstream.h:231