1 // © 2017 and later: Unicode, Inc. and others. 2 // License & terms of use: http://www.unicode.org/copyright.html 3 /* 4 ******************************************************************************* 5 * Copyright (C) 2009-2017, International Business Machines Corporation, * 6 * Google, and others. All Rights Reserved. * 7 ******************************************************************************* 8 */ 9 10 #ifndef __NOUNIT_H__ 11 #define __NOUNIT_H__ 12 13 #include "unicode/utypes.h" 14 15 #if U_SHOW_CPLUSPLUS_API 16 17 #if !UCONFIG_NO_FORMATTING 18 19 #include "unicode/measunit.h" 20 21 #ifndef U_HIDE_DRAFT_API 22 23 /** 24 * \file 25 * \brief C++ API: units for percent and permille 26 */ 27 28 U_NAMESPACE_BEGIN 29 30 /** 31 * Dimensionless unit for percent and permille. 32 * Prior to ICU 68, this namespace was a class with the same name. 33 * @see NumberFormatter 34 * @draft ICU 68 35 */ 36 namespace NoUnit { 37 /** 38 * Returns an instance for the base unit (dimensionless and no scaling). 39 * 40 * Prior to ICU 68, this function returned a NoUnit by value. 41 * 42 * Since ICU 68, this function returns the same value as the default MeasureUnit constructor. 43 * 44 * @return a MeasureUnit instance 45 * @draft ICU 68 46 */ base()47 static inline MeasureUnit U_EXPORT2 base() { 48 return MeasureUnit(); 49 } 50 51 /** 52 * Returns an instance for percent, or 1/100 of a base unit. 53 * 54 * Prior to ICU 68, this function returned a NoUnit by value. 55 * 56 * Since ICU 68, this function returns the same value as MeasureUnit::getPercent(). 57 * 58 * @return a MeasureUnit instance 59 * @draft ICU 68 60 */ percent()61 static inline MeasureUnit U_EXPORT2 percent() { 62 return MeasureUnit::getPercent(); 63 } 64 65 /** 66 * Returns an instance for permille, or 1/1000 of a base unit. 67 * 68 * Prior to ICU 68, this function returned a NoUnit by value. 69 * 70 * Since ICU 68, this function returns the same value as MeasureUnit::getPermille(). 71 * 72 * @return a MeasureUnit instance 73 * @draft ICU 68 74 */ permille()75 static inline MeasureUnit U_EXPORT2 permille() { 76 return MeasureUnit::getPermille(); 77 } 78 } 79 80 U_NAMESPACE_END 81 82 #endif /* U_HIDE_DRAFT_API */ 83 #endif /* #if !UCONFIG_NO_FORMATTING */ 84 85 #endif /* U_SHOW_CPLUSPLUS_API */ 86 87 #endif // __NOUNIT_H__ 88 //eof 89 // 90