Hyper API for C++  0.0.16638
Hyper client library for C++ applications
Date.hpp
Go to the documentation of this file.
1 
5 #ifndef TABLEAU_HYPER_DATE_HPP
6 #define TABLEAU_HYPER_DATE_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 Date final {
19  public:
23  Date() noexcept {}
24 
33  Date(int32_t year, std::int16_t month, std::int16_t day) noexcept;
34 
40  std::int16_t getDay() const noexcept;
41 
47  std::int16_t getMonth() const noexcept;
48 
54  std::int32_t getYear() const noexcept;
55 
60  std::string toString() const;
66  hyper_date_t getRaw() const noexcept;
70  friend bool operator==(const Date& a, const Date& b) noexcept;
74  friend bool operator>(const Date& a, const Date& b) noexcept;
78  friend bool operator!=(const Date& a, const Date& b) noexcept { return !(a == b); }
82  friend bool operator<(const Date& a, const Date& b) noexcept { return (b > a); }
86  friend bool operator<=(const Date& a, const Date& b) noexcept { return !(a > b); }
90  friend bool operator>=(const Date& a, const Date& b) noexcept { return !(a < b); }
91 
93  friend std::ostream& operator<<(std::ostream& os, const Date& obj) { return os << obj.toString(); }
94 
95  private:
96  friend class Inserter;
97  friend class OffsetTimestamp;
98  friend class Timestamp;
99  friend struct std::hash<hyperapi::Date>;
100  friend class Value;
101  friend struct internal::ValueInserter;
102 
103  struct raw_t {};
104 
110  explicit Date(hyper_date_t rawDate, raw_t) noexcept;
111 
115  hyper_date_t m_representation = 0;
116 
118  hyper_date_components_t m_date = {0, 0, 0};
119 };
120 }
121 
122 #include <hyperapi/impl/Date.impl.hpp>
123 
124 #endif
hyperapi::Inserter
An inserter.
Definition: Inserter.hpp:24
hyperapi::Date::getDay
std::int16_t getDay() const noexcept
Gets the day.
hyperapi::Date::toString
std::string toString() const
Gets a string representation for debugging.
hyperapi::OffsetTimestamp
A timestamp data value with an offset to UTC.
Definition: OffsetTimestamp.hpp:17
hyperapi::Date::getRaw
hyper_date_t getRaw() const noexcept
Gets the raw date value (i.e., the Julian Day).
hyperapi::Date::operator<
friend bool operator<(const Date &a, const Date &b) noexcept
Less than operator.
Definition: Date.hpp:82
hyperapi::Value
A value inside a row.
Definition: Result.hpp:44
hyperapi::Date::getMonth
std::int16_t getMonth() const noexcept
Gets the month.
hyperapi::Date::operator<=
friend bool operator<=(const Date &a, const Date &b) noexcept
Less than or equal operator.
Definition: Date.hpp:86
hyperapi::Timestamp
A timestamp data value.
Definition: Timestamp.hpp:16
hyperapi::Date::operator<<
friend std::ostream & operator<<(std::ostream &os, const Date &obj)
Stream output operator.
Definition: Date.hpp:93
hyperapi::Date::getYear
std::int32_t getYear() const noexcept
Gets the year.
SqlType.hpp
hyperapi
The primary namespace of the Hyper API for C++.
Definition: ByteSpan.hpp:15
hyperapi::Date::Date
Date() noexcept
Default constructor.
Definition: Date.hpp:23
hyperapi::Date
A date data value.
Definition: Date.hpp:18
hyperapi::Date::operator>=
friend bool operator>=(const Date &a, const Date &b) noexcept
Greater or equal operator.
Definition: Date.hpp:90