ICU 76.1 76.1
Loading...
Searching...
No Matches
measure.h
Go to the documentation of this file.
1// © 2016 and later: Unicode, Inc. and others.
2// License & terms of use: http://www.unicode.org/copyright.html
3/*
4**********************************************************************
5* Copyright (c) 2004-2015, International Business Machines
6* Corporation and others. All Rights Reserved.
7**********************************************************************
8* Author: Alan Liu
9* Created: April 26, 2004
10* Since: ICU 3.0
11**********************************************************************
12*/
13#ifndef __MEASURE_H__
14#define __MEASURE_H__
15
16#include "unicode/utypes.h"
17
18#if U_SHOW_CPLUSPLUS_API
19
25#if !UCONFIG_NO_FORMATTING
26
27#include "unicode/fmtable.h"
28
29U_NAMESPACE_BEGIN
30
31class MeasureUnit;
32
45class U_I18N_API Measure: public UObject {
46 public:
58 UErrorCode& ec);
59
65
71
77 virtual Measure* clone() const;
78
83 virtual ~Measure();
84
90 bool operator==(const UObject& other) const;
91
98 inline bool operator!=(const UObject& other) const { return !operator==(other); }
99
106 inline const Formattable& getNumber() const;
107
112 inline const MeasureUnit& getUnit() const;
113
126
138 virtual UClassID getDynamicClassID() const override;
139
140 protected:
146
147 private:
151 Formattable number;
152
157 MeasureUnit* unit;
158};
159
160inline const Formattable& Measure::getNumber() const {
161 return number;
162}
163
164inline const MeasureUnit& Measure::getUnit() const {
165 return *unit;
166}
167
169
170#endif // !UCONFIG_NO_FORMATTING
171
172#endif /* U_SHOW_CPLUSPLUS_API */
173
174#endif // __MEASURE_H__
Formattable objects can be passed to the Format class or its subclasses for formatting.
Definition fmtable.h:63
"Smart pointer" base class; do not use directly: use LocalPointer etc.
A unit such as length, mass, volume, currency, etc.
Definition measunit.h:409
An amount of a specified unit, consisting of a number and a Unit.
Definition measure.h:45
virtual Measure * clone() const
Return a polymorphic clone of this object.
static UClassID getStaticClassID()
Return the class ID for this class.
Measure(const Formattable &number, MeasureUnit *adoptedUnit, UErrorCode &ec)
Construct an object with the given numeric amount and the given unit.
bool operator!=(const UObject &other) const
Inequality operator.
Definition measure.h:98
virtual ~Measure()
Destructor.
Measure()
Default constructor.
Measure & operator=(const Measure &other)
Assignment operator.
Measure(const Measure &other)
Copy constructor.
bool operator==(const UObject &other) const
Equality operator.
virtual UClassID getDynamicClassID() const override
Returns a unique class ID POLYMORPHICALLY.
UObject is the common ICU "boilerplate" class.
Definition uobject.h:223
C++ API: Formattable is a thin wrapper for primitive types used for formatting and parsing.
U_EXPORT UBool operator==(const StringPiece &x, const StringPiece &y)
Global operator == for StringPiece.
void * UClassID
UClassID is used to identify classes without using the compiler's RTTI.
Definition uobject.h:96
Basic definitions for ICU, for both C and C++ APIs.
UErrorCode
Standard ICU4C error code type, a substitute for exceptions.
Definition utypes.h:430
#define U_I18N_API
Set to export library symbols from inside the i18n library, and to import them from outside.
Definition utypes.h:316