Hyper API for C++ 0.0.19691
Hyper client library for C++ applications
Loading...
Searching...
No Matches
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>
10#include <string>
11#include <hyperapi/hyperapi.h>
12
13namespace hyperapi {
14
18class Date final {
19 public:
23 struct raw_t {};
24
28 Date() noexcept {}
29
38 Date(int32_t year, std::int16_t month, std::int16_t day) noexcept;
39
45 explicit Date(hyper_date_t rawDate, raw_t) noexcept;
46
52 std::int16_t getDay() const noexcept;
53
59 std::int16_t getMonth() const noexcept;
60
66 std::int32_t getYear() const noexcept;
67
72 std::string toString() const;
78 hyper_date_t getRaw() const noexcept;
82 friend bool operator==(const Date& a, const Date& b) noexcept;
86 friend bool operator>(const Date& a, const Date& b) noexcept;
90 friend bool operator!=(const Date& a, const Date& b) noexcept { return !(a == b); }
94 friend bool operator<(const Date& a, const Date& b) noexcept { return (b > a); }
98 friend bool operator<=(const Date& a, const Date& b) noexcept { return !(a > b); }
102 friend bool operator>=(const Date& a, const Date& b) noexcept { return !(a < b); }
103
105 friend std::ostream& operator<<(std::ostream& os, const Date& obj) { return os << obj.toString(); }
106
107 private:
108 friend class Inserter;
109 friend class OffsetTimestamp;
110 friend class Timestamp;
111 friend struct std::hash<hyperapi::Date>;
112 friend class Value;
113 friend struct internal::ValueInserter;
114
118 hyper_date_t representation_ = 0;
119
121 hyper_date_components_t date_ = {0, 0, 0};
122};
123}
124
125#include <hyperapi/impl/Date.impl.hpp>
126
127#endif
A date data value.
Definition Date.hpp:18
friend bool operator>=(const Date &a, const Date &b) noexcept
Greater or equal operator.
Definition Date.hpp:102
Date() noexcept
Default constructor.
Definition Date.hpp:28
friend std::ostream & operator<<(std::ostream &os, const Date &obj)
Stream output operator.
Definition Date.hpp:105
std::int16_t getDay() const noexcept
Gets the day.
std::int16_t getMonth() const noexcept
Gets the month.
Date(int32_t year, std::int16_t month, std::int16_t day) noexcept
Creates a date value.
friend bool operator<=(const Date &a, const Date &b) noexcept
Less than or equal operator.
Definition Date.hpp:98
std::string toString() const
Gets a string representation for debugging.
hyper_date_t getRaw() const noexcept
Gets the raw date value (i.e., the Julian Day).
Date(hyper_date_t rawDate, raw_t) noexcept
Creates a date value from a raw date value (i.e., a Julian Day).
friend bool operator<(const Date &a, const Date &b) noexcept
Less than operator.
Definition Date.hpp:94
std::int32_t getYear() const noexcept
Gets the year.
Marker struct for the raw timestamp constructor.
Definition Date.hpp:23
An inserter.
Definition Inserter.hpp:24
A timestamp data value with an offset to UTC.
A timestamp data value.
Definition Timestamp.hpp:16
A value inside a row.
Definition Result.hpp:44
The primary namespace of the Hyper API for C++.
Definition ByteSpan.hpp:15