curramt.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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-2006, 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 __CURRENCYAMOUNT_H__
  14. #define __CURRENCYAMOUNT_H__
  15. #include "unicode/utypes.h"
  16. #if U_SHOW_CPLUSPLUS_API
  17. #if !UCONFIG_NO_FORMATTING
  18. #include "unicode/measure.h"
  19. #include "unicode/currunit.h"
  20. /**
  21. * \file
  22. * \brief C++ API: Currency Amount Object.
  23. */
  24. U_NAMESPACE_BEGIN
  25. /**
  26. *
  27. * A currency together with a numeric amount, such as 200 USD.
  28. *
  29. * @author Alan Liu
  30. * @stable ICU 3.0
  31. */
  32. class U_I18N_API CurrencyAmount: public Measure {
  33. public:
  34. /**
  35. * Construct an object with the given numeric amount and the given
  36. * ISO currency code.
  37. * @param amount a numeric object; amount.isNumeric() must be true
  38. * @param isoCode the 3-letter ISO 4217 currency code; must not be
  39. * nullptr and must have length 3
  40. * @param ec input-output error code. If the amount or the isoCode
  41. * is invalid, then this will be set to a failing value.
  42. * @stable ICU 3.0
  43. */
  44. CurrencyAmount(const Formattable& amount, ConstChar16Ptr isoCode,
  45. UErrorCode &ec);
  46. /**
  47. * Construct an object with the given numeric amount and the given
  48. * ISO currency code.
  49. * @param amount the amount of the given currency
  50. * @param isoCode the 3-letter ISO 4217 currency code; must not be
  51. * nullptr and must have length 3
  52. * @param ec input-output error code. If the isoCode is invalid,
  53. * then this will be set to a failing value.
  54. * @stable ICU 3.0
  55. */
  56. CurrencyAmount(double amount, ConstChar16Ptr isoCode,
  57. UErrorCode &ec);
  58. /**
  59. * Copy constructor
  60. * @stable ICU 3.0
  61. */
  62. CurrencyAmount(const CurrencyAmount& other);
  63. /**
  64. * Assignment operator
  65. * @stable ICU 3.0
  66. */
  67. CurrencyAmount& operator=(const CurrencyAmount& other);
  68. /**
  69. * Return a polymorphic clone of this object. The result will
  70. * have the same class as returned by getDynamicClassID().
  71. * @stable ICU 3.0
  72. */
  73. virtual CurrencyAmount* clone() const override;
  74. /**
  75. * Destructor
  76. * @stable ICU 3.0
  77. */
  78. virtual ~CurrencyAmount();
  79. /**
  80. * Returns a unique class ID for this object POLYMORPHICALLY.
  81. * This method implements a simple form of RTTI used by ICU.
  82. * @return The class ID for this object. All objects of a given
  83. * class have the same class ID. Objects of other classes have
  84. * different class IDs.
  85. * @stable ICU 3.0
  86. */
  87. virtual UClassID getDynamicClassID() const override;
  88. /**
  89. * Returns the class ID for this class. This is used to compare to
  90. * the return value of getDynamicClassID().
  91. * @return The class ID for all objects of this class.
  92. * @stable ICU 3.0
  93. */
  94. static UClassID U_EXPORT2 getStaticClassID();
  95. /**
  96. * Return the currency unit object of this object.
  97. * @stable ICU 3.0
  98. */
  99. const CurrencyUnit& getCurrency() const;
  100. /**
  101. * Return the ISO currency code of this object.
  102. * @stable ICU 3.0
  103. */
  104. inline const char16_t* getISOCurrency() const;
  105. };
  106. inline const char16_t* CurrencyAmount::getISOCurrency() const {
  107. return getCurrency().getISOCurrency();
  108. }
  109. U_NAMESPACE_END
  110. #endif // !UCONFIG_NO_FORMATTING
  111. #endif /* U_SHOW_CPLUSPLUS_API */
  112. #endif // __CURRENCYAMOUNT_H__