Hyper API for C++  0.0.15888
Hyper client library for C++ applications
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 <hyperapi/SqlType.hpp>
10 #include <string>
11 #include <hyperapi/hyperapi.h>
12 
13 namespace hyperapi {
14 
18 class Interval final {
19  public:
23  Interval() noexcept {}
24 
36  Interval(
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 m_representation = {{0, 0}};
162 
166  hyper_interval_components_t m_interval = {0, 0, 0, 0, 0, 0, 0};
167 };
168 }
169 
170 #include <hyperapi/impl/Interval.impl.hpp>
171 
172 #endif
hyperapi::Inserter
An inserter.
Definition: Inserter.hpp:24
hyperapi::Interval::Interval
Interval() noexcept
Default constructor.
Definition: Interval.hpp:23
hyperapi::Interval::getDays
std::int32_t getDays() const noexcept
Gets the number of days in the interval.
hyperapi::Interval::operator<<
friend std::ostream & operator<<(std::ostream &os, const Interval &obj)
Stream output operator.
Definition: Interval.hpp:126
hyperapi::Interval::getMonths
std::int32_t getMonths() const noexcept
Gets the number of months in the interval.
hyperapi::Interval::getMicroseconds
std::int32_t getMicroseconds() const noexcept
Gets the number of microseconds in the interval.
hyperapi::Value
A value inside a row.
Definition: Result.hpp:44
hyperapi::Interval::toString
std::string toString() const
Gets a string representation for debugging.
hyperapi::Interval::getSeconds
std::int32_t getSeconds() const noexcept
Gets the number of seconds in the interval.
hyperapi::Interval
An interval data value.
Definition: Interval.hpp:18
hyperapi::Interval::getHours
std::int32_t getHours() const noexcept
Gets the number of hours in the interval.
hyperapi::Interval::operator<
friend bool operator<(const Interval &a, const Interval &b) noexcept
Less than operator.
Definition: Interval.hpp:115
hyperapi::Interval::getYears
std::int32_t getYears() const noexcept
Gets the number of years in the interval.
SqlType.hpp
hyperapi
The primary namespace of the Hyper API for C++.
Definition: ByteSpan.hpp:15
hyperapi::Interval::operator<=
friend bool operator<=(const Interval &a, const Interval &b) noexcept
Less than or equal operator.
Definition: Interval.hpp:119
hyperapi::Interval::operator>=
friend bool operator>=(const Interval &a, const Interval &b) noexcept
Greater or equal operator.
Definition: Interval.hpp:123
hyperapi::Interval::getMinutes
std::int32_t getMinutes() const noexcept
Gets the number of minutes in the interval.