Hyper API for C++  0.0.15888
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;
64  friend bool operator==(const Date& a, const Date& b) noexcept;
68  friend bool operator>(const Date& a, const Date& b) noexcept;
72  friend bool operator!=(const Date& a, const Date& b) noexcept { return !(a == b); }
76  friend bool operator<(const Date& a, const Date& b) noexcept { return (b > a); }
80  friend bool operator<=(const Date& a, const Date& b) noexcept { return !(a > b); }
84  friend bool operator>=(const Date& a, const Date& b) noexcept { return !(a < b); }
85 
87  friend std::ostream& operator<<(std::ostream& os, const Date& obj) { return os << obj.toString(); }
88 
89  private:
90  friend class Inserter;
91  friend class OffsetTimestamp;
92  friend class Timestamp;
93  friend struct std::hash<hyperapi::Date>;
94  friend class Value;
95  friend struct internal::ValueInserter;
96 
97  struct raw_t {};
98 
104  explicit Date(hyper_date_t rawDate, raw_t) noexcept;
105 
111  hyper_date_t getRaw() const noexcept;
112 
116  hyper_date_t m_representation = 0;
117 
119  hyper_date_components_t m_date = {0, 0, 0};
120 };
121 }
122 
123 #include <hyperapi/impl/Date.impl.hpp>
124 
125 #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::operator<
friend bool operator<(const Date &a, const Date &b) noexcept
Less than operator.
Definition: Date.hpp:76
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:80
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:87
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:84