Hyper API for C++  0.0.15888
Hyper client library for C++ applications
Timestamp.hpp
Go to the documentation of this file.
1 
5 #ifndef TABLEAU_HYPER_TIMESTAMP_HPP
6 #define TABLEAU_HYPER_TIMESTAMP_HPP
7 
8 #include <hyperapi/Date.hpp>
9 #include <hyperapi/Time.hpp>
10 #include <string>
11 
12 namespace hyperapi {
16 class Timestamp final {
17  public:
21  Timestamp() noexcept {}
22 
29  Timestamp(Date date, Time time) noexcept;
30 
36  const Date& getDate() const noexcept;
37 
43  const Time& getTime() const noexcept;
44 
50  hyper_timestamp_t getRaw() const noexcept;
51 
57  std::string toString() const;
58 
62  friend bool operator==(const Timestamp& lhs, const Timestamp& rhs) noexcept;
66  friend bool operator>(const Timestamp& lhs, const Timestamp& rhs) noexcept;
70  friend bool operator!=(const Timestamp& a, const Timestamp& b) noexcept { return !(a == b); }
74  friend bool operator<(const Timestamp& a, const Timestamp& b) noexcept { return (b > a); }
78  friend bool operator<=(const Timestamp& a, const Timestamp& b) noexcept { return !(a > b); }
82  friend bool operator>=(const Timestamp& a, const Timestamp& b) noexcept { return !(a < b); }
83 
85  friend std::ostream& operator<<(std::ostream& os, const Timestamp& obj) { return os << obj.toString(); }
86 
87  private:
88  friend class Inserter;
89  friend class Value;
90  friend struct std::hash<hyperapi::Timestamp>;
91  friend struct internal::ValueInserter;
92 
93  struct raw_t {};
94 
98  static constexpr uint64_t microseconds_per_day = 24ull * 60 * 60 * 1000 * 1000;
99 
105  explicit Timestamp(hyper_timestamp_t rawTimestamp, raw_t) noexcept;
106 
110  hyper_timestamp_t m_representation = 0;
114  Date m_date;
118  Time m_time;
119 };
120 }
121 
122 #include <hyperapi/impl/Timestamp.impl.hpp>
123 
124 #endif
hyperapi::Inserter
An inserter.
Definition: Inserter.hpp:24
hyperapi::Timestamp::operator<
friend bool operator<(const Timestamp &a, const Timestamp &b) noexcept
Less than operator.
Definition: Timestamp.hpp:74
hyperapi::Timestamp::getDate
const Date & getDate() const noexcept
Gets the date component of the timestamp.
hyperapi::Timestamp::Timestamp
Timestamp() noexcept
Default constructor.
Definition: Timestamp.hpp:21
Date.hpp
hyperapi::Timestamp::getTime
const Time & getTime() const noexcept
Gets the time component of the timestamp.
hyperapi::Timestamp::operator>=
friend bool operator>=(const Timestamp &a, const Timestamp &b) noexcept
Greater or equal operator.
Definition: Timestamp.hpp:82
hyperapi::Timestamp::toString
std::string toString() const
Returns a string representation for debugging.
hyperapi::Value
A value inside a row.
Definition: Result.hpp:44
hyperapi::Timestamp::operator<<
friend std::ostream & operator<<(std::ostream &os, const Timestamp &obj)
Stream output operator.
Definition: Timestamp.hpp:85
hyperapi::Time
A time data value.
Definition: Time.hpp:18
hyperapi::Timestamp
A timestamp data value.
Definition: Timestamp.hpp:16
Time.hpp
hyperapi
The primary namespace of the Hyper API for C++.
Definition: ByteSpan.hpp:15
hyperapi::Timestamp::getRaw
hyper_timestamp_t getRaw() const noexcept
Gets the raw timestamp value encoded as microseconds since 1 January 4713 BC.
hyperapi::Timestamp::operator<=
friend bool operator<=(const Timestamp &a, const Timestamp &b) noexcept
Less than or equal operator.
Definition: Timestamp.hpp:78
hyperapi::Date
A date data value.
Definition: Date.hpp:18