te::common::CharEncodingConv Class Reference

This class deals with character encoding/decoding. More...

#include <CharEncodingConv.h>

Public Member Functions

 CharEncodingConv (const CharEncoding &fromCode, const CharEncoding &toCode)
 It prepare sthe conversion from a charset code to another one. More...
 
std::string conv (const std::string &src)
 It converts the source string to a target charset. More...
 
 ~CharEncodingConv ()
 Destructor. More...
 

Static Public Member Functions

static std::string convert (const std::string &src, const CharEncoding &fromCode, const CharEncoding &toCode)
 An static method that converts the source string to a target charset. More...
 
static std::string getCharEncodingName (const CharEncoding &code)
 It returns the name of the given charset. More...
 
static CharEncoding getCharEncodingType (const std::string &name)
 It returns the charset type of the given charset name. More...
 
static void initialize ()
 It initializes the CharEncoding Converter. More...
 

Private Member Functions

 CharEncodingConv (const CharEncodingConv &rhs)
 Copy constructor not allowed! More...
 
CharEncodingConvoperator= (const CharEncodingConv &rhs)
 Assignment operator not allowed! More...
 

Private Attributes

iconv_t m_cd
 The iconv state machine used to convert string from one character to another one. More...
 
const CharEncoding m_fromCode
 The origin charset. More...
 
const CharEncoding m_toCode
 The target charset. More...
 

Static Private Attributes

static std::map< CharEncoding, std::string > sm_encodingNames
 Static map with the encoding names. More...
 

Detailed Description

This class deals with character encoding/decoding.

Definition at line 80 of file CharEncodingConv.h.

Constructor & Destructor Documentation

te::common::CharEncodingConv::CharEncodingConv ( const CharEncoding fromCode,
const CharEncoding toCode 
)

It prepare sthe conversion from a charset code to another one.

The name of the origen charset of the string to be converted to destiny charset. The name of the destiny charset of the string to be converted.

te::common::CharEncodingConv::~CharEncodingConv ( )

Destructor.

te::common::CharEncodingConv::CharEncodingConv ( const CharEncodingConv rhs)
private

Copy constructor not allowed!

Member Function Documentation

std::string te::common::CharEncodingConv::conv ( const std::string &  src)

It converts the source string to a target charset.

Parameters
srcThe string in a source charset.
Returns
The string converted to the destiny charset.
Exceptions
ExceptionIt throws an exception if the conversion can not be done.
Note
This method tries to cache the internal encoder/decoder machine.
Once an exception is thrown the converter object can not be used anymore because it can be in an state that can not be used to convert text anymore.
static std::string te::common::CharEncodingConv::convert ( const std::string &  src,
const CharEncoding fromCode,
const CharEncoding toCode 
)
static

An static method that converts the source string to a target charset.

Parameters
srcThe string in a source charset.
fromCodeThe name of the origen charset of the string to be converted to destiny charset.
toCodeThe name of the destiny charset of the string to be converted.
Returns
The string converted to the destiny charset.
Exceptions
ExceptionIt throws an exception if the conversion can not be done.
Note
This method doesn't cache the internal encoder/decoder machine.
static std::string te::common::CharEncodingConv::getCharEncodingName ( const CharEncoding code)
static

It returns the name of the given charset.

Parameters
codeThe charset code.
Returns
The name of the given charset.
static CharEncoding te::common::CharEncodingConv::getCharEncodingType ( const std::string &  name)
static

It returns the charset type of the given charset name.

Parameters
nameThe charset name.
Returns
The type of the given charset.
static void te::common::CharEncodingConv::initialize ( )
static

It initializes the CharEncoding Converter.

CharEncodingConv& te::common::CharEncodingConv::operator= ( const CharEncodingConv rhs)
private

Assignment operator not allowed!

Member Data Documentation

iconv_t te::common::CharEncodingConv::m_cd
private

The iconv state machine used to convert string from one character to another one.

Definition at line 158 of file CharEncodingConv.h.

const CharEncoding te::common::CharEncodingConv::m_fromCode
private

The origin charset.

Definition at line 156 of file CharEncodingConv.h.

const CharEncoding te::common::CharEncodingConv::m_toCode
private

The target charset.

Definition at line 157 of file CharEncodingConv.h.

std::map<CharEncoding, std::string> te::common::CharEncodingConv::sm_encodingNames
staticprivate

Static map with the encoding names.

Definition at line 160 of file CharEncodingConv.h.


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