nounit.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. #ifndef __NOUNIT_H__
  10. #define __NOUNIT_H__
  11. #include "unicode/utypes.h"
  12. #if U_SHOW_CPLUSPLUS_API
  13. #if !UCONFIG_NO_FORMATTING
  14. #include "unicode/measunit.h"
  15. /**
  16. * \file
  17. * \brief C++ API: units for percent and permille
  18. */
  19. U_NAMESPACE_BEGIN
  20. /**
  21. * Dimensionless unit for percent and permille.
  22. * Prior to ICU 68, this namespace was a class with the same name.
  23. * @see NumberFormatter
  24. * @stable ICU 68
  25. */
  26. namespace NoUnit {
  27. /**
  28. * Returns an instance for the base unit (dimensionless and no scaling).
  29. *
  30. * Prior to ICU 68, this function returned a NoUnit by value.
  31. *
  32. * Since ICU 68, this function returns the same value as the default MeasureUnit constructor.
  33. *
  34. * @return a MeasureUnit instance
  35. * @stable ICU 68
  36. */
  37. static inline MeasureUnit U_EXPORT2 base() {
  38. return {};
  39. }
  40. /**
  41. * Returns an instance for percent, or 1/100 of a base unit.
  42. *
  43. * Prior to ICU 68, this function returned a NoUnit by value.
  44. *
  45. * Since ICU 68, this function returns the same value as MeasureUnit::getPercent().
  46. *
  47. * @return a MeasureUnit instance
  48. * @stable ICU 68
  49. */
  50. static inline MeasureUnit U_EXPORT2 percent() {
  51. return MeasureUnit::getPercent();
  52. }
  53. /**
  54. * Returns an instance for permille, or 1/1000 of a base unit.
  55. *
  56. * Prior to ICU 68, this function returned a NoUnit by value.
  57. *
  58. * Since ICU 68, this function returns the same value as MeasureUnit::getPermille().
  59. *
  60. * @return a MeasureUnit instance
  61. * @stable ICU 68
  62. */
  63. static inline MeasureUnit U_EXPORT2 permille() {
  64. return MeasureUnit::getPermille();
  65. }
  66. }
  67. U_NAMESPACE_END
  68. #endif /* #if !UCONFIG_NO_FORMATTING */
  69. #endif /* U_SHOW_CPLUSPLUS_API */
  70. #endif // __NOUNIT_H__
  71. //eof
  72. //