tmunit.h 2.9 KB

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