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...
 
MeasureUnit & operator= (const MeasureUnit &other)
 Assignment operator. More...
 
virtual UObject * clone () 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 StringEnumeration * getAvailableTypes (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 MeasureUnit * createGForce (UErrorCode &status)
 Creates a unit of acceleration: g-force. More...
 
static MeasureUnit * createArcMinute (UErrorCode &status)
 Creates a unit of angle: arc-minute. More...
 
static MeasureUnit * createArcSecond (UErrorCode &status)
 Creates a unit of angle: arc-second. More...
 
static MeasureUnit * createDegree (UErrorCode &status)
 Creates a unit of angle: degree. More...
 
static MeasureUnit * createAcre (UErrorCode &status)
 Creates a unit of area: acre. More...
 
static MeasureUnit * createHectare (UErrorCode &status)
 Creates a unit of area: hectare. More...
 
static MeasureUnit * createSquareFoot (UErrorCode &status)
 Creates a unit of area: square-foot. More...
 
static MeasureUnit * createSquareKilometer (UErrorCode &status)
 Creates a unit of area: square-kilometer. More...
 
static MeasureUnit * createSquareMeter (UErrorCode &status)
 Creates a unit of area: square-meter. More...
 
static MeasureUnit * createSquareMile (UErrorCode &status)
 Creates a unit of area: square-mile. More...
 
static MeasureUnit * createDay (UErrorCode &status)
 Creates a unit of duration: day. More...
 
static MeasureUnit * createHour (UErrorCode &status)
 Creates a unit of duration: hour. More...
 
static MeasureUnit * createMillisecond (UErrorCode &status)
 Creates a unit of duration: millisecond. More...
 
static MeasureUnit * createMinute (UErrorCode &status)
 Creates a unit of duration: minute. More...
 
static MeasureUnit * createMonth (UErrorCode &status)
 Creates a unit of duration: month. More...
 
static MeasureUnit * createSecond (UErrorCode &status)
 Creates a unit of duration: second. More...
 
static MeasureUnit * createWeek (UErrorCode &status)
 Creates a unit of duration: week. More...
 
static MeasureUnit * createYear (UErrorCode &status)
 Creates a unit of duration: year. More...
 
static MeasureUnit * createCentimeter (UErrorCode &status)
 Creates a unit of length: centimeter. More...
 
static MeasureUnit * createFoot (UErrorCode &status)
 Creates a unit of length: foot. More...
 
static MeasureUnit * createInch (UErrorCode &status)
 Creates a unit of length: inch. More...
 
static MeasureUnit * createKilometer (UErrorCode &status)
 Creates a unit of length: kilometer. More...
 
static MeasureUnit * createLightYear (UErrorCode &status)
 Creates a unit of length: light-year. More...
 
static MeasureUnit * createMeter (UErrorCode &status)
 Creates a unit of length: meter. More...
 
static MeasureUnit * createMile (UErrorCode &status)
 Creates a unit of length: mile. More...
 
static MeasureUnit * createMillimeter (UErrorCode &status)
 Creates a unit of length: millimeter. More...
 
static MeasureUnit * createPicometer (UErrorCode &status)
 Creates a unit of length: picometer. More...
 
static MeasureUnit * createYard (UErrorCode &status)
 Creates a unit of length: yard. More...
 
static MeasureUnit * createGram (UErrorCode &status)
 Creates a unit of mass: gram. More...
 
static MeasureUnit * createKilogram (UErrorCode &status)
 Creates a unit of mass: kilogram. More...
 
static MeasureUnit * createOunce (UErrorCode &status)
 Creates a unit of mass: ounce. More...
 
static MeasureUnit * createPound (UErrorCode &status)
 Creates a unit of mass: pound. More...
 
static MeasureUnit * createHorsepower (UErrorCode &status)
 Creates a unit of power: horsepower. More...
 
static MeasureUnit * createKilowatt (UErrorCode &status)
 Creates a unit of power: kilowatt. More...
 
static MeasureUnit * createWatt (UErrorCode &status)
 Creates a unit of power: watt. More...
 
static MeasureUnit * createHectopascal (UErrorCode &status)
 Creates a unit of pressure: hectopascal. More...
 
static MeasureUnit * createInchHg (UErrorCode &status)
 Creates a unit of pressure: inch-hg. More...
 
static MeasureUnit * createMillibar (UErrorCode &status)
 Creates a unit of pressure: millibar. More...
 
static MeasureUnit * createKilometerPerHour (UErrorCode &status)
 Creates a unit of speed: kilometer-per-hour. More...
 
static MeasureUnit * createMeterPerSecond (UErrorCode &status)
 Creates a unit of speed: meter-per-second. More...
 
static MeasureUnit * createMilePerHour (UErrorCode &status)
 Creates a unit of speed: mile-per-hour. More...
 
static MeasureUnit * createCelsius (UErrorCode &status)
 Creates a unit of temperature: celsius. More...
 
static MeasureUnit * createFahrenheit (UErrorCode &status)
 Creates a unit of temperature: fahrenheit. More...
 
static MeasureUnit * createCubicKilometer (UErrorCode &status)
 Creates a unit of volume: cubic-kilometer. More...
 
static MeasureUnit * createCubicMile (UErrorCode &status)
 Creates a unit of volume: cubic-mile. More...
 
static MeasureUnit * createLiter (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: