ULAPI  8.0
Public Member Functions | Static Public Member Functions | Static Protected Member Functions | List of all members
ULNumberTranslator Class Referenceabstract

The abstract parent of the classes that translate numbers in ULAPI's supported languages. More...

#include <ulnumbertranslator.h>

Public Member Functions

 ULNumberTranslator ()
 
 ULNumberTranslator (const ULNumberTranslator &other)
 
virtual ~ULNumberTranslator ()
 
virtual bool isServiceAvailable (const ULServiceDescriptor &service)=0
 
virtual void getAvailableServices (ULList< ULServiceDescriptor > &services)=0
 
virtual ULError translateNumber (const ULString &digits, ULString &result)=0
 
- Public Member Functions inherited from ULWorker
 ULWorker ()
 
virtual ~ULWorker ()
 
virtual void setCancelOperation (bool shouldCancel)
 
virtual bool shouldCancelOperation () const
 

Static Public Member Functions

static ULNumberTranslatorcreateNumberTranslator (const ULLanguage &language)
 

Static Protected Member Functions

static bool getPrimitiveNumberText (int n, const ULPrimitiveNumber *primitives, ULString &text)
 

Detailed Description

The abstract parent of the classes that translate numbers in ULAPI's supported languages.

Constructor & Destructor Documentation

ULNumberTranslator::ULNumberTranslator ( )

Default constructor.

ULNumberTranslator::ULNumberTranslator ( const ULNumberTranslator other)

Copy constructor.

ULNumberTranslator::~ULNumberTranslator ( )
virtual

Destructor.

Member Function Documentation

ULNumberTranslator * ULNumberTranslator::createNumberTranslator ( const ULLanguage language)
static

Static method that instantiates and initializes an object of the subclass appropriate for the specified language.

virtual void ULNumberTranslator::getAvailableServices ( ULList< ULServiceDescriptor > &  serviceList)
pure virtual
Parameters
[out]serviceListUsed to return a list of all the services this ULWorker can provide.

Implements ULWorker.

bool ULNumberTranslator::getPrimitiveNumberText ( int  n,
const ULPrimitiveNumber primitives,
ULString text 
)
staticprotected

Private method used to extract the text for an integer from a list of (integer, text) ordered pairs. If the specified integer is not the first component of any of the pairs in the numberNames array, then name is set to the empty string. In general, the numberNames array will consist of the primitive number words from which the number translation algorithm constructs all numbers. Your algorithm can, for example, build "forty-three" from the parts "forty" and "three", but those primitive mappings (40, "forty") and (3, "three") just have to be stored in a table. This method extracts those words from such a table.

Returns
true if the specified integer is in the list, false otherwise.
Parameters
[in]nThe integer to be converted into words.
[in]primitivesAn array of ULPrimitiveNumber objects mapping integers to text.
[out]textThe text for the specified integer, or the empty string of the integer is not found in the primitives array.
Precondition
primitives points to an array of ULPrimitiveNumber objects whose last item's integer is -1.
virtual bool ULNumberTranslator::isServiceAvailable ( const ULServiceDescriptor service)
pure virtual
Returns
true if the specified service can be performed by this ULWorker, and false otherwise.
Parameters
serviceThe desired service.

Implements ULWorker.

virtual ULError ULNumberTranslator::translateNumber ( const ULString digits,
ULString result 
)
pure virtual

Computes the textual translation of a number. For example, if the given digit string is "123" and the language supported by this ULNumberTranslator object is English, then the result will be "one hundred (and) twenty-three".

Returns
an error code.
Parameters
[in]digitsThe string of digits to be translated.
[out]resultThe translation.

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