Time.d.hpp (3577B)
1 #ifndef icu4x_Time_D_HPP 2 #define icu4x_Time_D_HPP 3 4 #include <stdio.h> 5 #include <stdint.h> 6 #include <stddef.h> 7 #include <stdbool.h> 8 #include <memory> 9 #include <functional> 10 #include <optional> 11 #include <cstdlib> 12 #include "../diplomat_runtime.hpp" 13 14 namespace icu4x { 15 namespace capi { struct Time; } 16 class Time; 17 class CalendarError; 18 class Rfc9557ParseError; 19 } 20 21 22 namespace icu4x { 23 namespace capi { 24 struct Time; 25 } // namespace capi 26 } // namespace 27 28 namespace icu4x { 29 /** 30 * An ICU4X Time object representing a time in terms of hour, minute, second, nanosecond 31 * 32 * See the [Rust documentation for `Time`](https://docs.rs/icu/latest/icu/time/struct.Time.html) for more information. 33 */ 34 class Time { 35 public: 36 37 /** 38 * Creates a new [`Time`] given field values 39 * 40 * See the [Rust documentation for `try_new`](https://docs.rs/icu/latest/icu/time/struct.Time.html#method.try_new) for more information. 41 */ 42 inline static diplomat::result<std::unique_ptr<icu4x::Time>, icu4x::CalendarError> create(uint8_t hour, uint8_t minute, uint8_t second, uint32_t subsecond); 43 44 /** 45 * Creates a new [`Time`] from an IXDTF string. 46 * 47 * See the [Rust documentation for `try_from_str`](https://docs.rs/icu/latest/icu/time/struct.Time.html#method.try_from_str) for more information. 48 */ 49 inline static diplomat::result<std::unique_ptr<icu4x::Time>, icu4x::Rfc9557ParseError> from_string(std::string_view v); 50 51 /** 52 * Creates a new [`Time`] representing the start of the day (00:00:00.000). 53 * 54 * See the [Rust documentation for `start_of_day`](https://docs.rs/icu/latest/icu/time/struct.Time.html#method.start_of_day) for more information. 55 */ 56 inline static diplomat::result<std::unique_ptr<icu4x::Time>, icu4x::CalendarError> start_of_day(); 57 58 /** 59 * Creates a new [`Time`] representing noon (12:00:00.000). 60 * 61 * See the [Rust documentation for `noon`](https://docs.rs/icu/latest/icu/time/struct.Time.html#method.noon) for more information. 62 */ 63 inline static diplomat::result<std::unique_ptr<icu4x::Time>, icu4x::CalendarError> noon(); 64 65 /** 66 * Returns the hour in this time 67 * 68 * See the [Rust documentation for `hour`](https://docs.rs/icu/latest/icu/time/struct.Time.html#structfield.hour) for more information. 69 */ 70 inline uint8_t hour() const; 71 72 /** 73 * Returns the minute in this time 74 * 75 * See the [Rust documentation for `minute`](https://docs.rs/icu/latest/icu/time/struct.Time.html#structfield.minute) for more information. 76 */ 77 inline uint8_t minute() const; 78 79 /** 80 * Returns the second in this time 81 * 82 * See the [Rust documentation for `second`](https://docs.rs/icu/latest/icu/time/struct.Time.html#structfield.second) for more information. 83 */ 84 inline uint8_t second() const; 85 86 /** 87 * Returns the subsecond in this time as nanoseconds 88 * 89 * See the [Rust documentation for `subsecond`](https://docs.rs/icu/latest/icu/time/struct.Time.html#structfield.subsecond) for more information. 90 */ 91 inline uint32_t subsecond() const; 92 93 inline const icu4x::capi::Time* AsFFI() const; 94 inline icu4x::capi::Time* AsFFI(); 95 inline static const icu4x::Time* FromFFI(const icu4x::capi::Time* ptr); 96 inline static icu4x::Time* FromFFI(icu4x::capi::Time* ptr); 97 inline static void operator delete(void* ptr); 98 private: 99 Time() = delete; 100 Time(const icu4x::Time&) = delete; 101 Time(icu4x::Time&&) noexcept = delete; 102 Time operator=(const icu4x::Time&) = delete; 103 Time operator=(icu4x::Time&&) noexcept = delete; 104 static void operator delete[](void*, size_t) = delete; 105 }; 106 107 } // namespace 108 #endif // icu4x_Time_D_HPP