Cross-Platform C++

ot::cvt
class CodeConverterFactory

#include "ot/cvt/CodeConverterFactory.h"

ot::ManagedObject A factory class for creating instances of a CodeConverter for a given encoding name. OpenTop is supplied with CodeConverters that can understand a broad range of different encodings. The CodeConverterFactory base class is aware of the supplied encodings, and will return an appropriate CodeConverter instance for every encoding name that it recognizes.

Applications can extend OpenTop by supplementing their own encodings. To achieve this the application must create a new factory class derived from CodeConverterFactory and set an instance of the derived class as the global CodeConverterFactory by calling SetInstance().




Method Summary
 RefPtr< CodeConverter > getConverter(const String& encoding) const
         Returns a new instance of a CodeConverter that can encode and decode the requested encoding.
 RefPtr< CodeConverter > getDefaultConverter() const
         Returns a new instance of a CodeConverter that is suitable for the target platform.
static CodeConverterFactory& GetInstance()
         Returns the global CodeConverterFactory.
static void SetInstance(CodeConverterFactory* pFactory)
         Sets the global CodeConverterFactory instance.

Methods inherited from class ot::ManagedObject
addRef, getRefCount, onFinalRelease, operator=, release

Method Detail

getConverter

RefPtr< CodeConvertergetConverter(const String& encoding) const
Returns a new instance of a CodeConverter that can encode and decode the requested encoding.

Parameters:
encoding - the name of the encoding which is used to select a matching CodeConverter without regard to case
Multi-threaded considerations:
Can safely be called from multiple concurrent threads.

getDefaultConverter

RefPtr< CodeConvertergetDefaultConverter() const
Returns a new instance of a CodeConverter that is suitable for the target platform. The returned CodeConverter is not guaranteed to perform one particular encoding.

In the current implementation a CodeConverter that encodes and decodes ISO-8859-1 (Latin1) is always returned.

Multi-threaded considerations:
Can safely be called from multiple concurrent threads.

GetInstance

static CodeConverterFactory& GetInstance()
Returns the global CodeConverterFactory. If a factory has not been registered by the application, a default CodeConverterFactory is created by the system and returned.

See also:
SetInstance()
Multi-threaded considerations:
Can safely be called from multiple concurrent threads.

SetInstance

static void SetInstance(CodeConverterFactory* pFactory)
Sets the global CodeConverterFactory instance. This global factory is used by the InputStreamReader and OutputStreamWriter classes when they require a CodeConverter for a named encoding.

Like other OpenTop global objects, CodeConverterFactory is a ManagedObject. This enables the passed object to be registered with the system's ObjectManager, thereby freeing the application from having to manage the lifetime of the factory object. In other words, the application does not need to maintain the object's reference-count once it has been registered.

A typical application may do the following:-

   CodeConverterFactory::SetInstance(new MyCodeConverterFactory);

See also:
GetInstance()
Multi-threaded considerations:
Can safely be called from multiple concurrent threads.


Cross-Platform C++

Found a bug or missing feature? Please email us at support@elcel.com

Copyright © 2000-2003 ElCel Technology   Trademark Acknowledgements