// © 2016 and later: Unicode, Inc. and others. // License & terms of use: http://www.unicode.org/copyright.html /* ********************************************************************** * Copyright (c) 2004-2016, International Business Machines * Corporation and others. All Rights Reserved. ********************************************************************** * Author: Alan Liu * Created: April 26, 2004 * Since: ICU 3.0 ********************************************************************** */ #ifndef __MEASUREUNIT_H__ #define __MEASUREUNIT_H__ #include "unicode/utypes.h" #if U_SHOW_CPLUSPLUS_API #if !UCONFIG_NO_FORMATTING #include <utility> #include "unicode/unistr.h" #include "unicode/localpointer.h" /** * \file * \brief C++ API: A unit for measuring a quantity. */ U_NAMESPACE_BEGIN class StringEnumeration; class MeasureUnitImpl; namespace number { namespace impl { class LongNameHandler; } } // namespace number /** * Enumeration for unit complexity. There are three levels: * * - SINGLE: A single unit, optionally with a power and/or SI or binary prefix. * Examples: hectare, square-kilometer, kilojoule, per-second, mebibyte. * - COMPOUND: A unit composed of the product of multiple single units. Examples: * meter-per-second, kilowatt-hour, kilogram-meter-per-square-second. * - MIXED: A unit composed of the sum of multiple single units. Examples: foot+inch, * hour+minute+second, degree+arcminute+arcsecond. * * The complexity determines which operations are available. For example, you cannot set the power * or prefix of a compound unit. * * @stable ICU 67 */ enum UMeasureUnitComplexity { … }; /** * Enumeration for SI and binary prefixes, e.g. "kilo-", "nano-", "mebi-". * * Enum values should be treated as opaque: use umeas_getPrefixPower() and * umeas_getPrefixBase() to find their corresponding values. * * @stable ICU 69 * @see umeas_getPrefixBase * @see umeas_getPrefixPower */ UMeasurePrefix; /** * Returns the base of the factor associated with the given unit prefix: the * base is 10 for SI prefixes (kilo, micro) and 1024 for binary prefixes (kibi, * mebi). * * @stable ICU 69 */ U_CAPI int32_t U_EXPORT2 umeas_getPrefixBase(UMeasurePrefix unitPrefix); /** * Returns the exponent of the factor associated with the given unit prefix, for * example 3 for kilo, -6 for micro, 1 for kibi, 2 for mebi, 3 for gibi. * * @stable ICU 69 */ U_CAPI int32_t U_EXPORT2 umeas_getPrefixPower(UMeasurePrefix unitPrefix); /** * 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 */ class U_I18N_API MeasureUnit: public UObject { … }; // inline impl of @stable ICU 68 method inline std::pair<LocalArray<MeasureUnit>, int32_t> MeasureUnit::splitToSingleUnits(UErrorCode& status) const { … } U_NAMESPACE_END #endif // !UNCONFIG_NO_FORMATTING #endif /* U_SHOW_CPLUSPLUS_API */ #endif // __MEASUREUNIT_H__