Hyper API for C++  0.0.16638
Hyper client library for C++ applications
Time.hpp
Go to the documentation of this file.
1 
5 #ifndef TABLEAU_HYPER_TIME_HPP
6 #define TABLEAU_HYPER_TIME_HPP
7 
8 #include <cstdint>
9 #include <hyperapi/SqlType.hpp>
10 #include <string>
11 #include <hyperapi/hyperapi.h>
12 
13 namespace hyperapi {
14 
18 class Time final {
19  public:
23  Time() noexcept {}
24 
35  Time(int8_t hour, std::int8_t minute, std::int8_t second, std::int32_t microsecond = 0) noexcept;
36 
42  std::int8_t getHour() const noexcept;
43 
49  std::int8_t getMinute() const noexcept;
50 
56  std::int8_t getSecond() const noexcept;
57 
63  std::int32_t getMicrosecond() const noexcept;
64 
69  std::string toString() const;
75  hyper_time_t getRaw() const noexcept;
79  friend bool operator==(const Time& lhs, const Time& rhs) noexcept;
83  friend bool operator>(const Time& lhs, const Time& rhs) noexcept;
87  friend bool operator!=(const Time& a, const Time& b) noexcept { return !(a == b); }
91  friend bool operator<(const Time& a, const Time& b) noexcept { return (b > a); }
95  friend bool operator<=(const Time& a, const Time& b) noexcept { return !(a > b); }
99  friend bool operator>=(const Time& a, const Time& b) noexcept { return !(a < b); }
100 
102  friend std::ostream& operator<<(std::ostream& os, const Time& obj) { return os << obj.toString(); }
103 
104  private:
105  friend class Inserter;
106  friend class Value;
107  friend class OffsetTimestamp;
108  friend class Timestamp;
109  friend struct std::hash<hyperapi::Time>;
110  friend struct internal::ValueInserter;
111 
112  struct raw_t {};
113 
119  explicit Time(hyper_time_t rawTime, raw_t) noexcept;
120 
124  hyper_time_t m_representation = 0;
125 
127  hyper_time_components_t m_time = {0, 0, 0, 0};
128 };
129 }
130 #include <hyperapi/impl/Time.impl.hpp>
131 
132 #endif
hyperapi::Inserter
An inserter.
Definition: Inserter.hpp:24
hyperapi::Time::Time
Time() noexcept
Default constructor.
Definition: Time.hpp:23
hyperapi::Time::operator<=
friend bool operator<=(const Time &a, const Time &b) noexcept
Less than or equal operator.
Definition: Time.hpp:95
hyperapi::Time::toString
std::string toString() const
Gets a string representation for debugging.
hyperapi::Time::operator<<
friend std::ostream & operator<<(std::ostream &os, const Time &obj)
Stream output operator.
Definition: Time.hpp:102
hyperapi::Time::operator>=
friend bool operator>=(const Time &a, const Time &b) noexcept
Greater or equal operator.
Definition: Time.hpp:99
hyperapi::OffsetTimestamp
A timestamp data value with an offset to UTC.
Definition: OffsetTimestamp.hpp:17
hyperapi::Time::getRaw
hyper_time_t getRaw() const noexcept
Gets the raw time value encoded as microseconds since midnight.
hyperapi::Value
A value inside a row.
Definition: Result.hpp:44
hyperapi::Time::operator<
friend bool operator<(const Time &a, const Time &b) noexcept
Less than operator.
Definition: Time.hpp:91
hyperapi::Time
A time data value.
Definition: Time.hpp:18
hyperapi::Timestamp
A timestamp data value.
Definition: Timestamp.hpp:16
SqlType.hpp
hyperapi
The primary namespace of the Hyper API for C++.
Definition: ByteSpan.hpp:15
hyperapi::Time::getMinute
std::int8_t getMinute() const noexcept
Gets the minute.
hyperapi::Time::getMicrosecond
std::int32_t getMicrosecond() const noexcept
Gets the microsecond.
hyperapi::Time::getHour
std::int8_t getHour() const noexcept
Gets the hour.
hyperapi::Time::getSecond
std::int8_t getSecond() const noexcept
Gets the second.