currunit.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. // Copyright (C) 2016 and later: Unicode, Inc. and others.
  2. // License & terms of use: http://www.unicode.org/copyright.html
  3. /*
  4. **********************************************************************
  5. * Copyright (c) 2004-2014, 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 __CURRENCYUNIT_H__
  14. #define __CURRENCYUNIT_H__
  15. #include "unicode/utypes.h"
  16. #if !UCONFIG_NO_FORMATTING
  17. #include "unicode/measunit.h"
  18. /**
  19. * \file
  20. * \brief C++ API: Currency Unit Information.
  21. */
  22. U_NAMESPACE_BEGIN
  23. /**
  24. * A unit of currency, such as USD (U.S. dollars) or JPY (Japanese
  25. * yen). This class is a thin wrapper over a UChar string that
  26. * subclasses MeasureUnit, for use with Measure and MeasureFormat.
  27. *
  28. * @author Alan Liu
  29. * @stable ICU 3.0
  30. */
  31. class U_I18N_API CurrencyUnit: public MeasureUnit {
  32. public:
  33. /**
  34. * Construct an object with the given ISO currency code.
  35. * @param isoCode the 3-letter ISO 4217 currency code; must not be
  36. * NULL and must have length 3
  37. * @param ec input-output error code. If the isoCode is invalid,
  38. * then this will be set to a failing value.
  39. * @stable ICU 3.0
  40. */
  41. CurrencyUnit(const UChar* isoCode, UErrorCode &ec);
  42. /**
  43. * Copy constructor
  44. * @stable ICU 3.0
  45. */
  46. CurrencyUnit(const CurrencyUnit& other);
  47. /**
  48. * Assignment operator
  49. * @stable ICU 3.0
  50. */
  51. CurrencyUnit& operator=(const CurrencyUnit& other);
  52. /**
  53. * Return a polymorphic clone of this object. The result will
  54. * have the same class as returned by getDynamicClassID().
  55. * @stable ICU 3.0
  56. */
  57. virtual UObject* clone() const;
  58. /**
  59. * Destructor
  60. * @stable ICU 3.0
  61. */
  62. virtual ~CurrencyUnit();
  63. /**
  64. * Returns a unique class ID for this object POLYMORPHICALLY.
  65. * This method implements a simple form of RTTI used by ICU.
  66. * @return The class ID for this object. All objects of a given
  67. * class have the same class ID. Objects of other classes have
  68. * different class IDs.
  69. * @stable ICU 3.0
  70. */
  71. virtual UClassID getDynamicClassID() const;
  72. /**
  73. * Returns the class ID for this class. This is used to compare to
  74. * the return value of getDynamicClassID().
  75. * @return The class ID for all objects of this class.
  76. * @stable ICU 3.0
  77. */
  78. static UClassID U_EXPORT2 getStaticClassID();
  79. /**
  80. * Return the ISO currency code of this object.
  81. * @stable ICU 3.0
  82. */
  83. inline const UChar* getISOCurrency() const;
  84. private:
  85. /**
  86. * The ISO 4217 code of this object.
  87. */
  88. UChar isoCode[4];
  89. };
  90. inline const UChar* CurrencyUnit::getISOCurrency() const {
  91. return isoCode;
  92. }
  93. U_NAMESPACE_END
  94. #endif // !UCONFIG_NO_FORMATTING
  95. #endif // __CURRENCYUNIT_H__