Poco::Data

class Transcoder

Library: Data
Package: DataCore
Header: Poco/Data/Transcoder.h

Description

Utility class used to convert string data encoding.

The purpose of this class is to help with deciding whether conversion is actually required, and to keep the encodings lifetimes aligned with the converter lifetime.

Member Summary

Member Functions: create, fromEncoding, reverseTranscode, toEncoding, transcode

Types Aliases

ConverterPtr

using ConverterPtr = std::unique_ptr < Poco::TextConverter >;

Ptr

using Ptr = std::unique_ptr < Transcoder >;

Constructors

Destructor

~Transcoder virtual

virtual ~Transcoder();

Destroys the Transcoder.

Member Functions

create static

static Ptr create(
    Poco::TextEncoding::Ptr pFromEncoding = nullptr,
    Poco::TextEncoding::Ptr pToEncoding = nullptr
);

Returns a unique pointer to Transcode instance; if there is no need for transcoding, null pointer is returned.

fromEncoding inline

std::string fromEncoding() const;

Returns "from" encoding canonical name.

reverseTranscode

void reverseTranscode(
    const std::string & from,
    std::string & to
);

Performs the reverse conversion. Any prior content of the destination string is cleared.

toEncoding inline

std::string toEncoding() const;

Returns "from" encoding canonical name.

transcode

void transcode(
    const std::string & from,
    std::string & to
);

Performs the conversion. Any prior content of the destination string is cleared.