cxxtools::IConverter Class Reference

IConverter is a simple wrapper around cxxtools::iconvstream. More...

#include <cxxtools/iconverter.h>

Public Member Functions

 IConverter ()
 IConverter (const std::string &tocode_, const std::string &fromcode_)
void setToCode (const std::string &tocode_)
void setFromCode (const std::string &fromcode_)
const std::string & getToCode () const
const std::string & getFromCode () const
template<typename objT >
std::string convert (objT s) const
std::string convert (const char *data, unsigned size) const
template<typename iteratorT >
std::string convertRange (iteratorT begin, iteratorT end) const
template<typename objT >
std::string operator() (objT s) const
std::string operator() (const char *data, unsigned size) const

Detailed Description

IConverter is a simple wrapper around cxxtools::iconvstream.

Often the result of a character-conversion is needed as a std::string. This can be achived to let iconvstream to a ostringstream and get the string from the ostringstream. IConverter simplify this.

example: convert a UTF8-encoded string to ISO8859-1:

cxxtools::IConverter conv("ISO8859-1", "UTF8");
std::string utf8string = getUtf8String();
std::string iso8895_1 = conv.convert(utf8string);
// or functor-style:
std::string iso8895_1 = conv(utf8string);

Constructor & Destructor Documentation

cxxtools::IConverter::IConverter ( )
inline
cxxtools::IConverter::IConverter ( const std::string &  tocode_,
const std::string &  fromcode_ 
)
inline

Member Function Documentation

template<typename objT >
std::string cxxtools::IConverter::convert ( objT  s) const
inline
std::string cxxtools::IConverter::convert ( const char *  data,
unsigned  size 
) const
inline
template<typename iteratorT >
std::string cxxtools::IConverter::convertRange ( iteratorT  begin,
iteratorT  end 
) const
inline
const std::string& cxxtools::IConverter::getFromCode ( ) const
inline
const std::string& cxxtools::IConverter::getToCode ( ) const
inline
template<typename objT >
std::string cxxtools::IConverter::operator() ( objT  s) const
inline
std::string cxxtools::IConverter::operator() ( const char *  data,
unsigned  size 
) const
inline
void cxxtools::IConverter::setFromCode ( const std::string &  fromcode_)
inline
void cxxtools::IConverter::setToCode ( const std::string &  tocode_)
inline

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