Hyper API for C++ 0.0.20746
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>
10#include <string>
11#include <hyperapi/hyperapi.h>
12
13namespace hyperapi {
14
18class Interval final {
19 public:
23 Interval() noexcept {}
24
37 std::int32_t years,
38 std::int32_t months,
39 std::int32_t days,
40 std::int32_t hours,
41 std::int32_t minutes,
42 std::int32_t seconds,
43 std::int32_t microseconds) noexcept;
44
50 std::int32_t getYears() const noexcept;
51
57 std::int32_t getMonths() const noexcept;
58
64 std::int32_t getDays() const noexcept;
65
71 std::int32_t getHours() const noexcept;
72
78 std::int32_t getMinutes() const noexcept;
79
85 std::int32_t getSeconds() const noexcept;
86
92 std::int32_t getMicroseconds() const noexcept;
93
99 std::string toString() const;
103 friend bool operator==(const Interval& lhs, const Interval& rhs) noexcept;
107 friend bool operator>(const Interval& lhs, const Interval& rhs) noexcept;
111 friend bool operator!=(const Interval& a, const Interval& b) noexcept { return !(a == b); }
115 friend bool operator<(const Interval& a, const Interval& b) noexcept { return (b > a); }
119 friend bool operator<=(const Interval& a, const Interval& b) noexcept { return !(a > b); }
123 friend bool operator>=(const Interval& a, const Interval& b) noexcept { return !(a < b); }
124
126 friend std::ostream& operator<<(std::ostream& os, const Interval& obj) { return os << obj.toString(); }
127
128 private:
129 friend class Inserter;
130 friend class Value;
131 friend class Interval;
132 friend struct std::hash<hyperapi::Interval>;
133 friend struct internal::ValueInserter;
134
135 struct raw_t {};
136
142 explicit Interval(hyper_interval_t raw_interval, raw_t) noexcept;
143
149 hyper_interval_t getRaw() const noexcept;
150
152 int32_t getMonthPart() const noexcept;
153
155 int64_t getMicrosecondPart() const noexcept;
156
157 private:
161 hyper_interval_t representation_ = {{0, 0}};
162
166 hyper_interval_components_t interval_ = {0, 0, 0, 0, 0, 0, 0};
167};
168}
169
170#include <hyperapi/impl/Interval.impl.hpp>
171
172#endif
An inserter.
Definition Inserter.hpp:24
An interval data value.
Definition Interval.hpp:18
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:23
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:123
friend bool operator<(const Interval &a, const Interval &b) noexcept
Less than operator.
Definition Interval.hpp:115
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:119
friend std::ostream & operator<<(std::ostream &os, const Interval &obj)
Stream output operator.
Definition Interval.hpp:126
A value inside a row.
Definition Result.hpp:44
The primary namespace of the Hyper API for C++.
Definition ByteSpan.hpp:15