IN2OSM  1.0.1
AutoUTFOutputStream< CharType, OutputByteStream >

Output stream wrapper with dynamically bound encoding and automatic encoding detection. More...

#include <encodedstream.h>

Collaboration diagram for AutoUTFOutputStream< CharType, OutputByteStream >:
Collaboration graph

Public Types

typedef CharType Ch
 

Public Member Functions

 AutoUTFOutputStream (OutputByteStream &os, UTFType type, bool putBOM)
 Constructor. More...
 
UTFType GetType () const
 
void Put (Ch c)
 
void Flush ()
 
Ch Peek () const
 
Ch Take ()
 
size_t Tell () const
 
ChPutBegin ()
 
size_t PutEnd (Ch *)
 

Private Types

typedef void(* PutFunc) (OutputByteStream &, Ch)
 

Private Member Functions

 RAPIDJSON_STATIC_ASSERT (sizeof(typename OutputByteStream::Ch)==1)
 
 AutoUTFOutputStream (const AutoUTFOutputStream &)
 
AutoUTFOutputStreamoperator= (const AutoUTFOutputStream &)
 
void PutBOM ()
 

Private Attributes

OutputByteStream * os_
 
UTFType type_
 
PutFunc putFunc_
 

Detailed Description

template<typename CharType, typename OutputByteStream>
class AutoUTFOutputStream< CharType, OutputByteStream >

Output stream wrapper with dynamically bound encoding and automatic encoding detection.

Template Parameters
CharTypeType of character for writing.
OutputByteStreamtype of output byte stream to be wrapped.

Definition at line 233 of file encodedstream.h.

Member Typedef Documentation

◆ Ch

typedef CharType Ch

Definition at line 236 of file encodedstream.h.

◆ PutFunc

typedef void(* PutFunc) (OutputByteStream &, Ch)
private

Definition at line 280 of file encodedstream.h.

Constructor & Destructor Documentation

◆ AutoUTFOutputStream() [1/2]

AutoUTFOutputStream ( OutputByteStream &  os,
UTFType  type,
bool  putBOM 
)
inline

Constructor.

Parameters
osoutput stream to be wrapped.
typeUTF encoding type.
putBOMWhether to write BOM at the beginning of the stream.

Definition at line 244 of file encodedstream.h.

244  : os_(&os), type_(type) {
245  RAPIDJSON_ASSERT(type >= kUTF8 && type <= kUTF32BE);
246 
247  // Runtime check whether the size of character type is sufficient. It only perform checks with assertion.
248  if (type_ == kUTF16LE || type_ == kUTF16BE) RAPIDJSON_ASSERT(sizeof(Ch) >= 2);
249  if (type_ == kUTF32LE || type_ == kUTF32BE) RAPIDJSON_ASSERT(sizeof(Ch) >= 4);
250 
251  static const PutFunc f[] = { RAPIDJSON_ENCODINGS_FUNC(Put) };
252  putFunc_ = f[type_];
253 
254  if (putBOM)
255  PutBOM();
256  }
#define RAPIDJSON_ENCODINGS_FUNC(x)
void(* PutFunc)(OutputByteStream &, Ch)
UTF-32 big endian.
Definition: encodings.h:608
UTF-16 little endian.
Definition: encodings.h:605
UTF-8.
Definition: encodings.h:604
UTF-16 big endian.
Definition: encodings.h:606
OutputByteStream * os_
UTF-32 little endian.
Definition: encodings.h:607
#define RAPIDJSON_ASSERT(x)
Assertion.
Definition: rapidjson.h:406
Here is the call graph for this function:

◆ AutoUTFOutputStream() [2/2]

AutoUTFOutputStream ( const AutoUTFOutputStream< CharType, OutputByteStream > &  )
private

Member Function Documentation

◆ Flush()

void Flush ( )
inline

Definition at line 261 of file encodedstream.h.

261 { os_->Flush(); }
OutputByteStream * os_

◆ GetType()

UTFType GetType ( ) const
inline

Definition at line 258 of file encodedstream.h.

258 { return type_; }

◆ operator=()

AutoUTFOutputStream& operator= ( const AutoUTFOutputStream< CharType, OutputByteStream > &  )
private

◆ Peek()

Ch Peek ( ) const
inline

Definition at line 264 of file encodedstream.h.

264 { RAPIDJSON_ASSERT(false); return 0;}
#define RAPIDJSON_ASSERT(x)
Assertion.
Definition: rapidjson.h:406

◆ Put()

void Put ( Ch  c)
inline

Definition at line 260 of file encodedstream.h.

260 { putFunc_(*os_, c); }
OutputByteStream * os_

◆ PutBegin()

Ch* PutBegin ( )
inline

Definition at line 267 of file encodedstream.h.

267 { RAPIDJSON_ASSERT(false); return 0; }
#define RAPIDJSON_ASSERT(x)
Assertion.
Definition: rapidjson.h:406

◆ PutBOM()

void PutBOM ( )
inlineprivate

Definition at line 274 of file encodedstream.h.

274  {
275  typedef void (*PutBOMFunc)(OutputByteStream&);
276  static const PutBOMFunc f[] = { RAPIDJSON_ENCODINGS_FUNC(PutBOM) };
277  f[type_](*os_);
278  }
#define RAPIDJSON_ENCODINGS_FUNC(x)

◆ PutEnd()

size_t PutEnd ( Ch )
inline

Definition at line 268 of file encodedstream.h.

268 { RAPIDJSON_ASSERT(false); return 0; }
#define RAPIDJSON_ASSERT(x)
Assertion.
Definition: rapidjson.h:406
Here is the call graph for this function:

◆ RAPIDJSON_STATIC_ASSERT()

RAPIDJSON_STATIC_ASSERT ( sizeof(typename OutputByteStream::Ch)  = =1)
private

◆ Take()

Ch Take ( )
inline

Definition at line 265 of file encodedstream.h.

265 { RAPIDJSON_ASSERT(false); return 0;}
#define RAPIDJSON_ASSERT(x)
Assertion.
Definition: rapidjson.h:406

◆ Tell()

size_t Tell ( ) const
inline

Definition at line 266 of file encodedstream.h.

266 { RAPIDJSON_ASSERT(false); return 0; }
#define RAPIDJSON_ASSERT(x)
Assertion.
Definition: rapidjson.h:406

Member Data Documentation

◆ os_

OutputByteStream* os_
private

Definition at line 282 of file encodedstream.h.

◆ putFunc_

PutFunc putFunc_
private

Definition at line 284 of file encodedstream.h.

◆ type_

UTFType type_
private

Definition at line 283 of file encodedstream.h.


The documentation for this class was generated from the following file: