tmunit.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. // © 2016 and later: Unicode, Inc. and others.
  2. // License & terms of use: http://www.unicode.org/copyright.html
  3. /*
  4. *******************************************************************************
  5. * Copyright (C) 2009-2016, International Business Machines Corporation, *
  6. * Google, and others. All Rights Reserved. *
  7. *******************************************************************************
  8. */
  9. #ifndef __TMUNIT_H__
  10. #define __TMUNIT_H__
  11. /**
  12. * \file
  13. * \brief C++ API: time unit object
  14. */
  15. #include "unicode/utypes.h"
  16. #if U_SHOW_CPLUSPLUS_API
  17. #include "unicode/measunit.h"
  18. #if !UCONFIG_NO_FORMATTING
  19. U_NAMESPACE_BEGIN
  20. /**
  21. * Measurement unit for time units.
  22. * @see TimeUnitAmount
  23. * @see TimeUnit
  24. * @stable ICU 4.2
  25. */
  26. class U_I18N_API TimeUnit: public MeasureUnit {
  27. public:
  28. /**
  29. * Constants for all the time units we supported.
  30. * @stable ICU 4.2
  31. */
  32. enum UTimeUnitFields {
  33. UTIMEUNIT_YEAR,
  34. UTIMEUNIT_MONTH,
  35. UTIMEUNIT_DAY,
  36. UTIMEUNIT_WEEK,
  37. UTIMEUNIT_HOUR,
  38. UTIMEUNIT_MINUTE,
  39. UTIMEUNIT_SECOND,
  40. #ifndef U_HIDE_DEPRECATED_API
  41. /**
  42. * One more than the highest normal UTimeUnitFields value.
  43. * @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420.
  44. */
  45. UTIMEUNIT_FIELD_COUNT
  46. #endif // U_HIDE_DEPRECATED_API
  47. };
  48. /**
  49. * Create Instance.
  50. * @param timeUnitField time unit field based on which the instance
  51. * is created.
  52. * @param status input-output error code.
  53. * If the timeUnitField is invalid,
  54. * then this will be set to U_ILLEGAL_ARGUMENT_ERROR.
  55. * @return a TimeUnit instance
  56. * @stable ICU 4.2
  57. */
  58. static TimeUnit* U_EXPORT2 createInstance(UTimeUnitFields timeUnitField,
  59. UErrorCode& status);
  60. /**
  61. * Override clone.
  62. * @stable ICU 4.2
  63. */
  64. virtual TimeUnit* clone() const override;
  65. /**
  66. * Copy operator.
  67. * @stable ICU 4.2
  68. */
  69. TimeUnit(const TimeUnit& other);
  70. /**
  71. * Assignment operator.
  72. * @stable ICU 4.2
  73. */
  74. TimeUnit& operator=(const TimeUnit& other);
  75. /**
  76. * Returns a unique class ID for this object POLYMORPHICALLY.
  77. * This method implements a simple form of RTTI used by ICU.
  78. * @return The class ID for this object. All objects of a given
  79. * class have the same class ID. Objects of other classes have
  80. * different class IDs.
  81. * @stable ICU 4.2
  82. */
  83. virtual UClassID getDynamicClassID() const override;
  84. /**
  85. * Returns the class ID for this class. This is used to compare to
  86. * the return value of getDynamicClassID().
  87. * @return The class ID for all objects of this class.
  88. * @stable ICU 4.2
  89. */
  90. static UClassID U_EXPORT2 getStaticClassID();
  91. /**
  92. * Get time unit field.
  93. * @return time unit field.
  94. * @stable ICU 4.2
  95. */
  96. UTimeUnitFields getTimeUnitField() const;
  97. /**
  98. * Destructor.
  99. * @stable ICU 4.2
  100. */
  101. virtual ~TimeUnit();
  102. private:
  103. UTimeUnitFields fTimeUnitField;
  104. /**
  105. * Constructor
  106. * @internal (private)
  107. */
  108. TimeUnit(UTimeUnitFields timeUnitField);
  109. };
  110. U_NAMESPACE_END
  111. #endif /* #if !UCONFIG_NO_FORMATTING */
  112. #endif /* U_SHOW_CPLUSPLUS_API */
  113. #endif // __TMUNIT_H__
  114. //eof
  115. //