Hyper API for C++ 0.0.24081
Hyper client library for C++ applications
Loading...
Searching...
No Matches
Interval.hpp
Go to the documentation of this file.
1
5#ifndef TABLEAU_HYPER_INTERVAL_HPP
6#define TABLEAU_HYPER_INTERVAL_HPP
7
8#include <cstdint>
9#include <string>
10#include <hyperapi/hyperapi.h>
11
12namespace hyperapi {
13namespace internal {
14struct ValueInserter;
15}
16
20class Interval final {
21 public:
25 Interval() noexcept {}
26
39 std::int32_t years,
40 std::int32_t months,
41 std::int32_t days,
42 std::int32_t hours,
43 std::int32_t minutes,
44 std::int32_t seconds,
45 std::int32_t microseconds) noexcept;
46
52 std::int32_t getYears() const noexcept;
53
59 std::int32_t getMonths() const noexcept;
60
66 std::int32_t getDays() const noexcept;
67
73 std::int32_t getHours() const noexcept;
74
80 std::int32_t getMinutes() const noexcept;
81
87 std::int32_t getSeconds() const noexcept;
88
94 std::int32_t getMicroseconds() const noexcept;
95
101 std::string toString() const;
105 friend bool operator==(const Interval& lhs, const Interval& rhs) noexcept;
109 friend bool operator>(const Interval& lhs, const Interval& rhs) noexcept;
113 friend bool operator!=(const Interval& a, const Interval& b) noexcept { return !(a == b); }
117 friend bool operator<(const Interval& a, const Interval& b) noexcept { return (b > a); }
121 friend bool operator<=(const Interval& a, const Interval& b) noexcept { return !(a > b); }
125 friend bool operator>=(const Interval& a, const Interval& b) noexcept { return !(a < b); }
126
128 friend std::ostream& operator<<(std::ostream& os, const Interval& obj) { return os << obj.toString(); }
129
130 private:
131 friend class Inserter;
132 friend class Value;
133 friend class Interval;
134 friend struct std::hash<hyperapi::Interval>;
135 friend struct internal::ValueInserter;
136
137 struct raw_t {};
138
144 explicit Interval(hyper_interval_t raw_interval, raw_t) noexcept;
145
151 hyper_interval_t getRaw() const noexcept;
152
154 int32_t getMonthPart() const noexcept;
155
157 int64_t getMicrosecondPart() const noexcept;
158
159 private:
163 hyper_interval_t representation_ = {{0, 0}};
164
168 hyper_interval_components_t interval_ = {0, 0, 0, 0, 0, 0, 0};
169};
170}
171
172#include <hyperapi/impl/Interval.impl.hpp> // IWYU pragma: export
173
174#endif
An inserter.
Definition Inserter.hpp:23
An interval data value.
Definition Interval.hpp:20
Interval(std::int32_t years, std::int32_t months, std::int32_t days, std::int32_t hours, std::int32_t minutes, std::int32_t seconds, std::int32_t microseconds) noexcept
Creates an interval value from a number of years, months, days, hours, minutes, seconds,...
std::string toString() const
Gets a string representation for debugging.
Interval() noexcept
Default constructor.
Definition Interval.hpp:25
std::int32_t getHours() const noexcept
Gets the number of hours in the interval.
std::int32_t getDays() const noexcept
Gets the number of days in the interval.
std::int32_t getMonths() const noexcept
Gets the number of months in the interval.
std::int32_t getMicroseconds() const noexcept
Gets the number of microseconds in the interval.
std::int32_t getYears() const noexcept
Gets the number of years in the interval.
std::int32_t getMinutes() const noexcept
Gets the number of minutes in the interval.
friend bool operator>=(const Interval &a, const Interval &b) noexcept
Greater or equal operator.
Definition Interval.hpp:125
friend bool operator<(const Interval &a, const Interval &b) noexcept
Less than operator.
Definition Interval.hpp:117
std::int32_t getSeconds() const noexcept
Gets the number of seconds in the interval.
friend bool operator<=(const Interval &a, const Interval &b) noexcept
Less than or equal operator.
Definition Interval.hpp:121
friend std::ostream & operator<<(std::ostream &os, const Interval &obj)
Stream output operator.
Definition Interval.hpp:128
A value inside a row.
Definition Result.hpp:37
The primary namespace of the Hyper API for C++.
Definition ByteSpan.hpp:14