ICU 53.1  53.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Static Public Member Functions | Protected Member Functions
icu::MeasureUnit Class Reference

A unit such as length, mass, volume, currency, etc. More...

#include <measunit.h>

Inheritance diagram for icu::MeasureUnit:
icu::UObject icu::UMemory icu::CurrencyUnit icu::TimeUnit

Public Member Functions

 MeasureUnit ()
 Default constructor. More...
 
 MeasureUnit (const MeasureUnit &other)
 Copy constructor. More...
 
MeasureUnitoperator= (const MeasureUnit &other)
 Assignment operator. More...
 
virtual UObjectclone () const
 Returns a polymorphic clone of this object. More...
 
virtual ~MeasureUnit ()
 Destructor. More...
 
virtual UBool operator== (const UObject &other) const
 Equality operator. More...
 
UBool operator!= (const UObject &other) const
 Inequality operator. More...
 
const char * getType () const
 Get the type. More...
 
const char * getSubtype () const
 Get the sub type. More...
 
virtual UClassID getDynamicClassID (void) const
 Returns a unique class ID POLYMORPHICALLY. More...
 
int32_t getIndex () const
 ICU use only. More...
 
- Public Member Functions inherited from icu::UObject
virtual ~UObject ()
 Destructor. More...
 

Static Public Member Functions

static int32_t getAvailable (MeasureUnit *destArray, int32_t destCapacity, UErrorCode &errorCode)
 getAvailable gets all of the available units. More...
 
static int32_t getAvailable (const char *type, MeasureUnit *destArray, int32_t destCapacity, UErrorCode &errorCode)
 getAvailable gets all of the available units for a specific type. More...
 
static StringEnumerationgetAvailableTypes (UErrorCode &errorCode)
 getAvailableTypes gets all of the available types. More...
 
static UClassID getStaticClassID (void)
 Return the class ID for this class. More...
 
static int32_t getIndexCount ()
 ICU use only. More...
 
static MeasureUnitcreateGForce (UErrorCode &status)
 Creates a unit of acceleration: g-force. More...
 
static MeasureUnitcreateArcMinute (UErrorCode &status)
 Creates a unit of angle: arc-minute. More...
 
static MeasureUnitcreateArcSecond (UErrorCode &status)
 Creates a unit of angle: arc-second. More...
 
static MeasureUnitcreateDegree (UErrorCode &status)
 Creates a unit of angle: degree. More...
 
static MeasureUnitcreateAcre (UErrorCode &status)
 Creates a unit of area: acre. More...
 
static MeasureUnitcreateHectare (UErrorCode &status)
 Creates a unit of area: hectare. More...
 
static MeasureUnitcreateSquareFoot (UErrorCode &status)
 Creates a unit of area: square-foot. More...
 
static MeasureUnitcreateSquareKilometer (UErrorCode &status)
 Creates a unit of area: square-kilometer. More...
 
static MeasureUnitcreateSquareMeter (UErrorCode &status)
 Creates a unit of area: square-meter. More...
 
static MeasureUnitcreateSquareMile (UErrorCode &status)
 Creates a unit of area: square-mile. More...
 
static MeasureUnitcreateDay (UErrorCode &status)
 Creates a unit of duration: day. More...
 
static MeasureUnitcreateHour (UErrorCode &status)
 Creates a unit of duration: hour. More...
 
static MeasureUnitcreateMillisecond (UErrorCode &status)
 Creates a unit of duration: millisecond. More...
 
static MeasureUnitcreateMinute (UErrorCode &status)
 Creates a unit of duration: minute. More...
 
static MeasureUnitcreateMonth (UErrorCode &status)
 Creates a unit of duration: month. More...
 
static MeasureUnitcreateSecond (UErrorCode &status)
 Creates a unit of duration: second. More...
 
static MeasureUnitcreateWeek (UErrorCode &status)
 Creates a unit of duration: week. More...
 
static MeasureUnitcreateYear (UErrorCode &status)
 Creates a unit of duration: year. More...
 
static MeasureUnitcreateCentimeter (UErrorCode &status)
 Creates a unit of length: centimeter. More...
 
static MeasureUnitcreateFoot (UErrorCode &status)
 Creates a unit of length: foot. More...
 
static MeasureUnitcreateInch (UErrorCode &status)
 Creates a unit of length: inch. More...
 
static MeasureUnitcreateKilometer (UErrorCode &status)
 Creates a unit of length: kilometer. More...
 
static MeasureUnitcreateLightYear (UErrorCode &status)
 Creates a unit of length: light-year. More...
 
static MeasureUnitcreateMeter (UErrorCode &status)
 Creates a unit of length: meter. More...
 
static MeasureUnitcreateMile (UErrorCode &status)
 Creates a unit of length: mile. More...
 
static MeasureUnitcreateMillimeter (UErrorCode &status)
 Creates a unit of length: millimeter. More...
 
static MeasureUnitcreatePicometer (UErrorCode &status)
 Creates a unit of length: picometer. More...
 
static MeasureUnitcreateYard (UErrorCode &status)
 Creates a unit of length: yard. More...
 
static MeasureUnitcreateGram (UErrorCode &status)
 Creates a unit of mass: gram. More...
 
static MeasureUnitcreateKilogram (UErrorCode &status)
 Creates a unit of mass: kilogram. More...
 
static MeasureUnitcreateOunce (UErrorCode &status)
 Creates a unit of mass: ounce. More...
 
static MeasureUnitcreatePound (UErrorCode &status)
 Creates a unit of mass: pound. More...
 
static MeasureUnitcreateHorsepower (UErrorCode &status)
 Creates a unit of power: horsepower. More...
 
static MeasureUnitcreateKilowatt (UErrorCode &status)
 Creates a unit of power: kilowatt. More...
 
static MeasureUnitcreateWatt (UErrorCode &status)
 Creates a unit of power: watt. More...
 
static MeasureUnitcreateHectopascal (UErrorCode &status)
 Creates a unit of pressure: hectopascal. More...
 
static MeasureUnitcreateInchHg (UErrorCode &status)
 Creates a unit of pressure: inch-hg. More...
 
static MeasureUnitcreateMillibar (UErrorCode &status)
 Creates a unit of pressure: millibar. More...
 
static MeasureUnitcreateKilometerPerHour (UErrorCode &status)
 Creates a unit of speed: kilometer-per-hour. More...
 
static MeasureUnitcreateMeterPerSecond (UErrorCode &status)
 Creates a unit of speed: meter-per-second. More...
 
static MeasureUnitcreateMilePerHour (UErrorCode &status)
 Creates a unit of speed: mile-per-hour. More...
 
static MeasureUnitcreateCelsius (UErrorCode &status)
 Creates a unit of temperature: celsius. More...
 
static MeasureUnitcreateFahrenheit (UErrorCode &status)
 Creates a unit of temperature: fahrenheit. More...
 
static MeasureUnitcreateCubicKilometer (UErrorCode &status)
 Creates a unit of volume: cubic-kilometer. More...
 
static MeasureUnitcreateCubicMile (UErrorCode &status)
 Creates a unit of volume: cubic-mile. More...
 
static MeasureUnitcreateLiter (UErrorCode &status)
 Creates a unit of volume: liter. More...
 

Protected Member Functions

void initTime (const char *timeId)
 For ICU use only. More...
 
void initCurrency (const char *isoCurrency)
 For ICU use only. More...
 

Detailed Description

A unit such as length, mass, volume, currency, etc.

A unit is coupled with a numeric amount to produce a Measure.

Author
Alan Liu
Stable:
ICU 3.0

Definition at line 36 of file measunit.h.

Constructor & Destructor Documentation

icu::MeasureUnit::MeasureUnit ( )
inline

Default constructor.

Stable:
ICU 3.0

Definition at line 43 of file measunit.h.

icu::MeasureUnit::MeasureUnit ( const MeasureUnit other)

Copy constructor.

Draft:
This API may be changed in the future versions and was introduced in ICU 53
virtual icu::MeasureUnit::~MeasureUnit ( )
virtual

Destructor.

Stable:
ICU 3.0

Member Function Documentation

virtual UObject* icu::MeasureUnit::clone ( ) const
virtual

Returns a polymorphic clone of this object.

The result will have the same class as returned by getDynamicClassID().

Stable:
ICU 3.0

Reimplemented in icu::TimeUnit, and icu::CurrencyUnit.

static MeasureUnit* icu::MeasureUnit::createAcre ( UErrorCode status)
static

Creates a unit of area: acre.

Caller owns returned value and must free it.

Parameters
statusICU error code.
Draft:
This API may be changed in the future versions and was introduced in ICU 53
static MeasureUnit* icu::MeasureUnit::createArcMinute ( UErrorCode status)
static

Creates a unit of angle: arc-minute.

Caller owns returned value and must free it.

Parameters
statusICU error code.
Draft:
This API may be changed in the future versions and was introduced in ICU 53
static MeasureUnit* icu::MeasureUnit::createArcSecond ( UErrorCode status)
static

Creates a unit of angle: arc-second.

Caller owns returned value and must free it.

Parameters
statusICU error code.
Draft:
This API may be changed in the future versions and was introduced in ICU 53
static MeasureUnit* icu::MeasureUnit::createCelsius ( UErrorCode status)
static

Creates a unit of temperature: celsius.

Caller owns returned value and must free it.

Parameters
statusICU error code.
Draft:
This API may be changed in the future versions and was introduced in ICU 53
static MeasureUnit* icu::MeasureUnit::createCentimeter ( UErrorCode status)
static

Creates a unit of length: centimeter.

Caller owns returned value and must free it.

Parameters
statusICU error code.
Draft:
This API may be changed in the future versions and was introduced in ICU 53
static MeasureUnit* icu::MeasureUnit::createCubicKilometer ( UErrorCode status)
static

Creates a unit of volume: cubic-kilometer.

Caller owns returned value and must free it.

Parameters
statusICU error code.
Draft:
This API may be changed in the future versions and was introduced in ICU 53
static MeasureUnit* icu::MeasureUnit::createCubicMile ( UErrorCode status)
static

Creates a unit of volume: cubic-mile.

Caller owns returned value and must free it.

Parameters
statusICU error code.
Draft:
This API may be changed in the future versions and was introduced in ICU 53
static MeasureUnit* icu::MeasureUnit::createDay ( UErrorCode status)
static

Creates a unit of duration: day.

Caller owns returned value and must free it.

Parameters
statusICU error code.
Draft:
This API may be changed in the future versions and was introduced in ICU 53
static MeasureUnit* icu::MeasureUnit::createDegree ( UErrorCode status)
static

Creates a unit of angle: degree.

Caller owns returned value and must free it.

Parameters
statusICU error code.
Draft:
This API may be changed in the future versions and was introduced in ICU 53
static MeasureUnit* icu::MeasureUnit::createFahrenheit ( UErrorCode status)
static

Creates a unit of temperature: fahrenheit.

Caller owns returned value and must free it.

Parameters
statusICU error code.
Draft:
This API may be changed in the future versions and was introduced in ICU 53
static MeasureUnit* icu::MeasureUnit::createFoot ( UErrorCode status)
static

Creates a unit of length: foot.

Caller owns returned value and must free it.

Parameters
statusICU error code.
Draft:
This API may be changed in the future versions and was introduced in ICU 53
static MeasureUnit* icu::MeasureUnit::createGForce ( UErrorCode status)
static

Creates a unit of acceleration: g-force.

Caller owns returned value and must free it.

Parameters
statusICU error code.
Draft:
This API may be changed in the future versions and was introduced in ICU 53
static MeasureUnit* icu::MeasureUnit::createGram ( UErrorCode status)
static

Creates a unit of mass: gram.

Caller owns returned value and must free it.

Parameters
statusICU error code.
Draft:
This API may be changed in the future versions and was introduced in ICU 53
static MeasureUnit* icu::MeasureUnit::createHectare ( UErrorCode status)
static

Creates a unit of area: hectare.

Caller owns returned value and must free it.

Parameters
statusICU error code.
Draft:
This API may be changed in the future versions and was introduced in ICU 53
static MeasureUnit* icu::MeasureUnit::createHectopascal ( UErrorCode status)
static

Creates a unit of pressure: hectopascal.

Caller owns returned value and must free it.

Parameters
statusICU error code.
Draft:
This API may be changed in the future versions and was introduced in ICU 53
static MeasureUnit* icu::MeasureUnit::createHorsepower ( UErrorCode status)
static

Creates a unit of power: horsepower.

Caller owns returned value and must free it.

Parameters
statusICU error code.
Draft:
This API may be changed in the future versions and was introduced in ICU 53
static MeasureUnit* icu::MeasureUnit::createHour ( UErrorCode status)
static

Creates a unit of duration: hour.

Caller owns returned value and must free it.

Parameters
statusICU error code.
Draft:
This API may be changed in the future versions and was introduced in ICU 53
static MeasureUnit* icu::MeasureUnit::createInch ( UErrorCode status)
static

Creates a unit of length: inch.

Caller owns returned value and must free it.

Parameters
statusICU error code.
Draft:
This API may be changed in the future versions and was introduced in ICU 53
static MeasureUnit* icu::MeasureUnit::createInchHg ( UErrorCode status)
static

Creates a unit of pressure: inch-hg.

Caller owns returned value and must free it.

Parameters
statusICU error code.
Draft:
This API may be changed in the future versions and was introduced in ICU 53
static MeasureUnit* icu::MeasureUnit::createKilogram ( UErrorCode status)
static

Creates a unit of mass: kilogram.

Caller owns returned value and must free it.

Parameters
statusICU error code.
Draft:
This API may be changed in the future versions and was introduced in ICU 53
static MeasureUnit* icu::MeasureUnit::createKilometer ( UErrorCode status)
static

Creates a unit of length: kilometer.

Caller owns returned value and must free it.

Parameters
statusICU error code.
Draft:
This API may be changed in the future versions and was introduced in ICU 53
static MeasureUnit* icu::MeasureUnit::createKilometerPerHour ( UErrorCode status)
static

Creates a unit of speed: kilometer-per-hour.

Caller owns returned value and must free it.

Parameters
statusICU error code.
Draft:
This API may be changed in the future versions and was introduced in ICU 53
static MeasureUnit* icu::MeasureUnit::createKilowatt ( UErrorCode status)
static

Creates a unit of power: kilowatt.

Caller owns returned value and must free it.

Parameters
statusICU error code.
Draft:
This API may be changed in the future versions and was introduced in ICU 53
static MeasureUnit* icu::MeasureUnit::createLightYear ( UErrorCode status)
static

Creates a unit of length: light-year.

Caller owns returned value and must free it.

Parameters
statusICU error code.
Draft:
This API may be changed in the future versions and was introduced in ICU 53
static MeasureUnit* icu::MeasureUnit::createLiter ( UErrorCode status)
static

Creates a unit of volume: liter.

Caller owns returned value and must free it.

Parameters
statusICU error code.
Draft:
This API may be changed in the future versions and was introduced in ICU 53
static MeasureUnit* icu::MeasureUnit::createMeter ( UErrorCode status)
static

Creates a unit of length: meter.

Caller owns returned value and must free it.

Parameters
statusICU error code.
Draft:
This API may be changed in the future versions and was introduced in ICU 53
static MeasureUnit* icu::MeasureUnit::createMeterPerSecond ( UErrorCode status)
static

Creates a unit of speed: meter-per-second.

Caller owns returned value and must free it.

Parameters
statusICU error code.
Draft:
This API may be changed in the future versions and was introduced in ICU 53
static MeasureUnit* icu::MeasureUnit::createMile ( UErrorCode status)
static

Creates a unit of length: mile.

Caller owns returned value and must free it.

Parameters
statusICU error code.
Draft:
This API may be changed in the future versions and was introduced in ICU 53
static MeasureUnit* icu::MeasureUnit::createMilePerHour ( UErrorCode status)
static

Creates a unit of speed: mile-per-hour.

Caller owns returned value and must free it.

Parameters
statusICU error code.
Draft:
This API may be changed in the future versions and was introduced in ICU 53
static MeasureUnit* icu::MeasureUnit::createMillibar ( UErrorCode status)
static

Creates a unit of pressure: millibar.

Caller owns returned value and must free it.

Parameters
statusICU error code.
Draft:
This API may be changed in the future versions and was introduced in ICU 53
static MeasureUnit* icu::MeasureUnit::createMillimeter ( UErrorCode status)
static

Creates a unit of length: millimeter.

Caller owns returned value and must free it.

Parameters
statusICU error code.
Draft:
This API may be changed in the future versions and was introduced in ICU 53
static MeasureUnit* icu::MeasureUnit::createMillisecond ( UErrorCode status)
static

Creates a unit of duration: millisecond.

Caller owns returned value and must free it.

Parameters
statusICU error code.
Draft:
This API may be changed in the future versions and was introduced in ICU 53
static MeasureUnit* icu::MeasureUnit::createMinute ( UErrorCode status)
static

Creates a unit of duration: minute.

Caller owns returned value and must free it.

Parameters
statusICU error code.
Draft:
This API may be changed in the future versions and was introduced in ICU 53
static MeasureUnit* icu::MeasureUnit::createMonth ( UErrorCode status)
static

Creates a unit of duration: month.

Caller owns returned value and must free it.

Parameters
statusICU error code.
Draft:
This API may be changed in the future versions and was introduced in ICU 53
static MeasureUnit* icu::MeasureUnit::createOunce ( UErrorCode status)
static

Creates a unit of mass: ounce.

Caller owns returned value and must free it.

Parameters
statusICU error code.
Draft:
This API may be changed in the future versions and was introduced in ICU 53
static MeasureUnit* icu::MeasureUnit::createPicometer ( UErrorCode status)
static

Creates a unit of length: picometer.

Caller owns returned value and must free it.

Parameters
statusICU error code.
Draft:
This API may be changed in the future versions and was introduced in ICU 53
static MeasureUnit* icu::MeasureUnit::createPound ( UErrorCode status)
static

Creates a unit of mass: pound.

Caller owns returned value and must free it.

Parameters
statusICU error code.
Draft:
This API may be changed in the future versions and was introduced in ICU 53
static MeasureUnit* icu::MeasureUnit::createSecond ( UErrorCode status)
static

Creates a unit of duration: second.

Caller owns returned value and must free it.

Parameters
statusICU error code.
Draft:
This API may be changed in the future versions and was introduced in ICU 53
static MeasureUnit* icu::MeasureUnit::createSquareFoot ( UErrorCode status)
static

Creates a unit of area: square-foot.

Caller owns returned value and must free it.

Parameters
statusICU error code.
Draft:
This API may be changed in the future versions and was introduced in ICU 53
static MeasureUnit* icu::MeasureUnit::createSquareKilometer ( UErrorCode status)
static

Creates a unit of area: square-kilometer.

Caller owns returned value and must free it.

Parameters
statusICU error code.
Draft:
This API may be changed in the future versions and was introduced in ICU 53
static MeasureUnit* icu::MeasureUnit::createSquareMeter ( UErrorCode status)
static

Creates a unit of area: square-meter.

Caller owns returned value and must free it.

Parameters
statusICU error code.
Draft:
This API may be changed in the future versions and was introduced in ICU 53
static MeasureUnit* icu::MeasureUnit::createSquareMile ( UErrorCode status)
static

Creates a unit of area: square-mile.

Caller owns returned value and must free it.

Parameters
statusICU error code.
Draft:
This API may be changed in the future versions and was introduced in ICU 53
static MeasureUnit* icu::MeasureUnit::createWatt ( UErrorCode status)
static

Creates a unit of power: watt.

Caller owns returned value and must free it.

Parameters
statusICU error code.
Draft:
This API may be changed in the future versions and was introduced in ICU 53
static MeasureUnit* icu::MeasureUnit::createWeek ( UErrorCode status)
static

Creates a unit of duration: week.

Caller owns returned value and must free it.

Parameters
statusICU error code.
Draft:
This API may be changed in the future versions and was introduced in ICU 53
static MeasureUnit* icu::MeasureUnit::createYard ( UErrorCode status)
static

Creates a unit of length: yard.

Caller owns returned value and must free it.

Parameters
statusICU error code.
Draft:
This API may be changed in the future versions and was introduced in ICU 53
static MeasureUnit* icu::MeasureUnit::createYear ( UErrorCode status)
static

Creates a unit of duration: year.

Caller owns returned value and must free it.

Parameters
statusICU error code.
Draft:
This API may be changed in the future versions and was introduced in ICU 53
static int32_t icu::MeasureUnit::getAvailable ( MeasureUnit destArray,
int32_t  destCapacity,
UErrorCode errorCode 
)
static

getAvailable gets all of the available units.

If there are too many units to fit into destCapacity then the error code is set to U_BUFFER_OVERFLOW_ERROR.

Parameters
destArraydestination buffer.
destCapacitynumber of MeasureUnit instances available at dest.
errorCodeICU error code.
Returns
number of available units.
Draft:
This API may be changed in the future versions and was introduced in ICU 53
static int32_t icu::MeasureUnit::getAvailable ( const char *  type,
MeasureUnit destArray,
int32_t  destCapacity,
UErrorCode errorCode 
)
static

getAvailable gets all of the available units for a specific type.

If there are too many units to fit into destCapacity then the error code is set to U_BUFFER_OVERFLOW_ERROR.

Parameters
typethe type
destArraydestination buffer.
destCapacitynumber of MeasureUnit instances available at dest.
errorCodeICU error code.
Returns
number of available units for type.
Draft:
This API may be changed in the future versions and was introduced in ICU 53
static StringEnumeration* icu::MeasureUnit::getAvailableTypes ( UErrorCode errorCode)
static

getAvailableTypes gets all of the available types.

Caller owns the returned StringEnumeration and must delete it when finished using it.

Parameters
errorCodeICU error code.
Returns
the types.
Draft:
This API may be changed in the future versions and was introduced in ICU 53
virtual UClassID icu::MeasureUnit::getDynamicClassID ( void  ) const
virtual

Returns a unique class ID POLYMORPHICALLY.

Pure virtual override. This method is to implement a simple version of RTTI, since not all C++ compilers support genuine RTTI. Polymorphic operator==() and clone() methods call this method.

Returns
The class ID for this object. All objects of a given class have the same class ID. Objects of other classes have different class IDs.
Draft:
This API may be changed in the future versions and was introduced in ICU 53

Reimplemented from icu::UObject.

Reimplemented in icu::TimeUnit, and icu::CurrencyUnit.

int32_t icu::MeasureUnit::getIndex ( ) const

ICU use only.

Returns associated array index for this measure unit. Only valid for non-currency measure units.

Internal:
Do not use. This API is for internal use only.
static int32_t icu::MeasureUnit::getIndexCount ( )
static

ICU use only.

Returns maximum value from getIndex plus 1.

Internal:
Do not use. This API is for internal use only.
static UClassID icu::MeasureUnit::getStaticClassID ( void  )
static

Return the class ID for this class.

This is useful only for comparing to a return value from getDynamicClassID(). For example:

.   Base* polymorphic_pointer = createPolymorphicObject();
.   if (polymorphic_pointer->getDynamicClassID() ==
.       erived::getStaticClassID()) ...
Returns
The class ID for all objects of this class.
Draft:
This API may be changed in the future versions and was introduced in ICU 53
const char* icu::MeasureUnit::getSubtype ( ) const

Get the sub type.

Draft:
This API may be changed in the future versions and was introduced in ICU 53
const char* icu::MeasureUnit::getType ( ) const

Get the type.

Draft:
This API may be changed in the future versions and was introduced in ICU 53
void icu::MeasureUnit::initCurrency ( const char *  isoCurrency)
protected

For ICU use only.

Internal:
Do not use. This API is for internal use only.
void icu::MeasureUnit::initTime ( const char *  timeId)
protected

For ICU use only.

Internal:
Do not use. This API is for internal use only.
UBool icu::MeasureUnit::operator!= ( const UObject other) const
inline

Inequality operator.

Return true if this object is not equal to the given object.

Draft:
This API may be changed in the future versions and was introduced in ICU 53

Definition at line 85 of file measunit.h.

MeasureUnit& icu::MeasureUnit::operator= ( const MeasureUnit other)

Assignment operator.

Draft:
This API may be changed in the future versions and was introduced in ICU 53
virtual UBool icu::MeasureUnit::operator== ( const UObject other) const
virtual

Equality operator.

Return true if this object is equal to the given object.

Stable:
ICU 3.0

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