currunit.h 2.8 KB

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