Hyper API for C++  0.0.15888
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;
73  friend bool operator==(const Time& lhs, const Time& rhs) noexcept;
77  friend bool operator>(const Time& lhs, const Time& rhs) noexcept;
81  friend bool operator!=(const Time& a, const Time& b) noexcept { return !(a == b); }
85  friend bool operator<(const Time& a, const Time& b) noexcept { return (b > a); }
89  friend bool operator<=(const Time& a, const Time& b) noexcept { return !(a > b); }
93  friend bool operator>=(const Time& a, const Time& b) noexcept { return !(a < b); }
94 
96  friend std::ostream& operator<<(std::ostream& os, const Time& obj) { return os << obj.toString(); }
97 
98  private:
99  friend class Inserter;
100  friend class Value;
101  friend class OffsetTimestamp;
102  friend class Timestamp;
103  friend struct std::hash<hyperapi::Time>;
104  friend struct internal::ValueInserter;
105 
106  struct raw_t {};
107 
113  explicit Time(hyper_time_t rawTime, raw_t) noexcept;
114 
120  hyper_time_t getRaw() const noexcept;
121 
125  hyper_time_t m_representation = 0;
126 
128  hyper_time_components_t m_time = {0, 0, 0, 0};
129 };
130 }
131 #include <hyperapi/impl/Time.impl.hpp>
132 
133 #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:89
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:96
hyperapi::Time::operator>=
friend bool operator>=(const Time &a, const Time &b) noexcept
Greater or equal operator.
Definition: Time.hpp:93
hyperapi::OffsetTimestamp
A timestamp data value with an offset to UTC.
Definition: OffsetTimestamp.hpp:17
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:85
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.