Hyper API for C++ 0.0.20027
Hyper client library for C++ applications
Loading...
Searching...
No Matches
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
12namespace hyperapi {
16class Timestamp final {
17 public:
21 struct raw_t {};
22
26 Timestamp() noexcept {}
27
34 Timestamp(Date date, Time time) noexcept;
35
41 explicit Timestamp(hyper_timestamp_t rawTimestamp, raw_t) noexcept;
42
48 const Date& getDate() const noexcept;
49
55 const Time& getTime() const noexcept;
56
62 hyper_timestamp_t getRaw() const noexcept;
63
69 std::string toString() const;
70
74 friend bool operator==(const Timestamp& lhs, const Timestamp& rhs) noexcept;
78 friend bool operator>(const Timestamp& lhs, const Timestamp& rhs) noexcept;
82 friend bool operator!=(const Timestamp& a, const Timestamp& b) noexcept { return !(a == b); }
86 friend bool operator<(const Timestamp& a, const Timestamp& b) noexcept { return (b > a); }
90 friend bool operator<=(const Timestamp& a, const Timestamp& b) noexcept { return !(a > b); }
94 friend bool operator>=(const Timestamp& a, const Timestamp& b) noexcept { return !(a < b); }
95
97 friend std::ostream& operator<<(std::ostream& os, const Timestamp& obj) { return os << obj.toString(); }
98
99 private:
100 friend class Inserter;
101 friend class Value;
102 friend struct std::hash<hyperapi::Timestamp>;
103 friend struct internal::ValueInserter;
104
108 static constexpr uint64_t microseconds_per_day = 24ull * 60 * 60 * 1000 * 1000;
109
113 hyper_timestamp_t representation_ = 0;
117 Date date_;
121 Time time_;
122};
123}
124
125#include <hyperapi/impl/Timestamp.impl.hpp>
126
127#endif
A date data value.
Definition Date.hpp:18
An inserter.
Definition Inserter.hpp:24
A time data value.
Definition Time.hpp:18
A timestamp data value.
Definition Timestamp.hpp:16
Timestamp(hyper_timestamp_t rawTimestamp, raw_t) noexcept
Creates a timestamp from a raw timestamp value encoded as microseconds since 1 January 4713 BC.
hyper_timestamp_t getRaw() const noexcept
Gets the raw timestamp value encoded as microseconds since 1 January 4713 BC.
Timestamp(Date date, Time time) noexcept
Creates a timestamp value with a date and a time component.
Timestamp() noexcept
Default constructor.
Definition Timestamp.hpp:26
friend std::ostream & operator<<(std::ostream &os, const Timestamp &obj)
Stream output operator.
Definition Timestamp.hpp:97
friend bool operator<(const Timestamp &a, const Timestamp &b) noexcept
Less than operator.
Definition Timestamp.hpp:86
const Time & getTime() const noexcept
Gets the time component of the timestamp.
friend bool operator<=(const Timestamp &a, const Timestamp &b) noexcept
Less than or equal operator.
Definition Timestamp.hpp:90
std::string toString() const
Returns a string representation for debugging.
const Date & getDate() const noexcept
Gets the date component of the timestamp.
friend bool operator>=(const Timestamp &a, const Timestamp &b) noexcept
Greater or equal operator.
Definition Timestamp.hpp:94
Marker struct for the raw timestamp constructor.
Definition Timestamp.hpp:21
A value inside a row.
Definition Result.hpp:44
The primary namespace of the Hyper API for C++.
Definition ByteSpan.hpp:15