curramt.h 3.6 KB

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