TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
AutoUTFOutputStream< CharType, OutputByteStream > Class Template Reference

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

#include <encodedstream.h>

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.
InputByteStreamtype of output byte stream to be wrapped.

Member Typedef Documentation

template<typename CharType , typename OutputByteStream >
typedef CharType AutoUTFOutputStream< CharType, OutputByteStream >::Ch
template<typename CharType , typename OutputByteStream >
typedef void(* AutoUTFOutputStream< CharType, OutputByteStream >::PutFunc)(OutputByteStream &, Ch)
private

Constructor & Destructor Documentation

template<typename CharType , typename OutputByteStream >
AutoUTFOutputStream< CharType, OutputByteStream >::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.
210  : os_(&os), type_(type) {
211  RAPIDJSON_ASSERT(type >= kUTF8 && type <= kUTF32BE);
212 
213  // Runtime check whether the size of character type is sufficient. It only perform checks with assertion.
214  if (type_ == kUTF16LE || type_ == kUTF16BE) RAPIDJSON_ASSERT(sizeof(Ch) >= 2);
215  if (type_ == kUTF32LE || type_ == kUTF32BE) RAPIDJSON_ASSERT(sizeof(Ch) >= 4);
216 
217  static const PutFunc f[] = { RAPIDJSON_ENCODINGS_FUNC(Put) };
218  putFunc_ = f[type_];
219 
220  if (putBOM)
221  PutBOM();
222  }
#define RAPIDJSON_ENCODINGS_FUNC(x)
Definition: encodedstream.h:93
CharType Ch
Definition: encodedstream.h:202
#define RAPIDJSON_ASSERT(x)
Assertion.
Definition: rapidjson.h:344
OutputByteStream * os_
Definition: encodedstream.h:248
UTF-32 big endian.
Definition: encodings.h:543
UTF-16 little endian.
Definition: encodings.h:540
UTF-8.
Definition: encodings.h:539
UTF-16 big endian.
Definition: encodings.h:541
PutFunc putFunc_
Definition: encodedstream.h:250
UTFType type_
Definition: encodedstream.h:249
void(* PutFunc)(OutputByteStream &, Ch)
Definition: encodedstream.h:246
void Put(Ch c)
Definition: encodedstream.h:226
UTF-32 little endian.
Definition: encodings.h:542
void PutBOM()
Definition: encodedstream.h:240

+ Here is the call graph for this function:

template<typename CharType , typename OutputByteStream >
AutoUTFOutputStream< CharType, OutputByteStream >::AutoUTFOutputStream ( const AutoUTFOutputStream< CharType, OutputByteStream > &  )
private

Member Function Documentation

template<typename CharType , typename OutputByteStream >
void AutoUTFOutputStream< CharType, OutputByteStream >::Flush ( )
inline
227 { os_->Flush(); }
OutputByteStream * os_
Definition: encodedstream.h:248
template<typename CharType , typename OutputByteStream >
UTFType AutoUTFOutputStream< CharType, OutputByteStream >::GetType ( ) const
inline
224 { return type_; }
UTFType type_
Definition: encodedstream.h:249
template<typename CharType , typename OutputByteStream >
AutoUTFOutputStream& AutoUTFOutputStream< CharType, OutputByteStream >::operator= ( const AutoUTFOutputStream< CharType, OutputByteStream > &  )
private
template<typename CharType , typename OutputByteStream >
Ch AutoUTFOutputStream< CharType, OutputByteStream >::Peek ( ) const
inline
230 { RAPIDJSON_ASSERT(false); }
#define RAPIDJSON_ASSERT(x)
Assertion.
Definition: rapidjson.h:344
template<typename CharType , typename OutputByteStream >
void AutoUTFOutputStream< CharType, OutputByteStream >::Put ( Ch  c)
inline
226 { putFunc_(*os_, c); }
OutputByteStream * os_
Definition: encodedstream.h:248
PutFunc putFunc_
Definition: encodedstream.h:250

+ Here is the caller graph for this function:

template<typename CharType , typename OutputByteStream >
Ch* AutoUTFOutputStream< CharType, OutputByteStream >::PutBegin ( )
inline
233 { RAPIDJSON_ASSERT(false); return 0; }
#define RAPIDJSON_ASSERT(x)
Assertion.
Definition: rapidjson.h:344
template<typename CharType , typename OutputByteStream >
void AutoUTFOutputStream< CharType, OutputByteStream >::PutBOM ( )
inlineprivate
240  {
241  typedef void (*PutBOMFunc)(OutputByteStream&);
242  static const PutBOMFunc f[] = { RAPIDJSON_ENCODINGS_FUNC(PutBOM) };
243  f[type_](*os_);
244  }
#define RAPIDJSON_ENCODINGS_FUNC(x)
Definition: encodedstream.h:93
UTFType type_
Definition: encodedstream.h:249
void PutBOM()
Definition: encodedstream.h:240

+ Here is the caller graph for this function:

template<typename CharType , typename OutputByteStream >
size_t AutoUTFOutputStream< CharType, OutputByteStream >::PutEnd ( Ch )
inline
234 { RAPIDJSON_ASSERT(false); return 0; }
#define RAPIDJSON_ASSERT(x)
Assertion.
Definition: rapidjson.h:344
template<typename CharType , typename OutputByteStream >
AutoUTFOutputStream< CharType, OutputByteStream >::RAPIDJSON_STATIC_ASSERT ( sizeof(typename OutputByteStream::Ch)  = =1)
private
template<typename CharType , typename OutputByteStream >
Ch AutoUTFOutputStream< CharType, OutputByteStream >::Take ( )
inline
231 { RAPIDJSON_ASSERT(false); }
#define RAPIDJSON_ASSERT(x)
Assertion.
Definition: rapidjson.h:344
template<typename CharType , typename OutputByteStream >
size_t AutoUTFOutputStream< CharType, OutputByteStream >::Tell ( ) const
inline
232 { RAPIDJSON_ASSERT(false); return 0; }
#define RAPIDJSON_ASSERT(x)
Assertion.
Definition: rapidjson.h:344

Member Data Documentation

template<typename CharType , typename OutputByteStream >
OutputByteStream* AutoUTFOutputStream< CharType, OutputByteStream >::os_
private
template<typename CharType , typename OutputByteStream >
PutFunc AutoUTFOutputStream< CharType, OutputByteStream >::putFunc_
private
template<typename CharType , typename OutputByteStream >
UTFType AutoUTFOutputStream< CharType, OutputByteStream >::type_
private

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