ICU 57.1 57.1
measure.h
Go to the documentation of this file.
1/*
2**********************************************************************
3* Copyright (c) 2004-2015, International Business Machines
4* Corporation and others. All Rights Reserved.
5**********************************************************************
6* Author: Alan Liu
7* Created: April 26, 2004
8* Since: ICU 3.0
9**********************************************************************
10*/
11#ifndef __MEASURE_H__
12#define __MEASURE_H__
13
14#include "unicode/utypes.h"
15
21#if !UCONFIG_NO_FORMATTING
22
23#include "unicode/fmtable.h"
24
26
27class MeasureUnit;
28
41class U_I18N_API Measure: public UObject {
42 public:
53 Measure(const Formattable& number, MeasureUnit* adoptedUnit,
54 UErrorCode& ec);
55
60 Measure(const Measure& other);
61
66 Measure& operator=(const Measure& other);
67
73 virtual UObject* clone() const;
74
79 virtual ~Measure();
80
86 UBool operator==(const UObject& other) const;
87
94 inline const Formattable& getNumber() const;
95
100 inline const MeasureUnit& getUnit() const;
101
113 static UClassID U_EXPORT2 getStaticClassID(void);
114
126 virtual UClassID getDynamicClassID(void) const;
127
128 protected:
134
135 private:
139 Formattable number;
140
145 MeasureUnit* unit;
146};
147
148inline const Formattable& Measure::getNumber() const {
149 return number;
150}
151
152inline const MeasureUnit& Measure::getUnit() const {
153 return *unit;
154}
155
157
158#endif // !UCONFIG_NO_FORMATTING
159#endif // __MEASURE_H__
Formattable objects can be passed to the Format class or its subclasses for formatting.
Definition: fmtable.h:66
A unit such as length, mass, volume, currency, etc.
Definition: measunit.h:36
An amount of a specified unit, consisting of a number and a Unit.
Definition: measure.h:41
UBool operator==(const UObject &other) const
Equality operator.
virtual UObject * clone() const
Return a polymorphic clone of this object.
Measure & operator=(const Measure &other)
Assignment operator.
const MeasureUnit & getUnit() const
Return a reference to the unit of this object.
Definition: measure.h:152
Measure(const Formattable &number, MeasureUnit *adoptedUnit, UErrorCode &ec)
Construct an object with the given numeric amount and the given unit.
Measure(const Measure &other)
Copy constructor.
virtual ~Measure()
Destructor.
static UClassID getStaticClassID(void)
Return the class ID for this class.
virtual UClassID getDynamicClassID(void) const
Returns a unique class ID POLYMORPHICALLY.
const Formattable & getNumber() const
Return a reference to the numeric value of this object.
Definition: measure.h:148
Measure()
Default constructor.
UObject is the common ICU "boilerplate" class.
Definition: uobject.h:221
C++ API: Formattable is a thin wrapper for primitive types used for formatting and parsing.
int8_t UBool
The ICU boolean type.
Definition: umachine.h:234
void * UClassID
UClassID is used to identify classes without using the compiler's RTTI.
Definition: uobject.h:91
Basic definitions for ICU, for both C and C++ APIs.
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers,...
Definition: utypes.h:476
#define U_I18N_API
Set to export library symbols from inside the i18n library, and to import them from outside.
Definition: utypes.h:358
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition: uversion.h:130
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition: uversion.h:129