Hyper API for C++ 0.0.24081
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>
9#include <string>
10#include <hyperapi/hyperapi.h>
11
12namespace hyperapi {
13namespace internal {
14struct ValueInserter;
15}
16
20class Date final {
21 public:
25 struct raw_t {};
26
30 Date() noexcept {}
31
40 Date(int32_t year, std::int16_t month, std::int16_t day) noexcept;
41
47 explicit Date(hyper_date_t rawDate, raw_t) noexcept;
48
54 std::int16_t getDay() const noexcept;
55
61 std::int16_t getMonth() const noexcept;
62
68 std::int32_t getYear() const noexcept;
69
74 std::string toString() const;
80 hyper_date_t getRaw() const noexcept;
84 friend bool operator==(const Date& a, const Date& b) noexcept;
88 friend bool operator>(const Date& a, const Date& b) noexcept;
92 friend bool operator!=(const Date& a, const Date& b) noexcept { return !(a == b); }
96 friend bool operator<(const Date& a, const Date& b) noexcept { return (b > a); }
100 friend bool operator<=(const Date& a, const Date& b) noexcept { return !(a > b); }
104 friend bool operator>=(const Date& a, const Date& b) noexcept { return !(a < b); }
105
107 friend std::ostream& operator<<(std::ostream& os, const Date& obj) { return os << obj.toString(); }
108
109 private:
110 friend class Inserter;
111 friend class OffsetTimestamp;
112 friend class Timestamp;
113 friend struct std::hash<hyperapi::Date>;
114 friend class Value;
115 friend struct internal::ValueInserter;
116
120 hyper_date_t representation_ = 0;
121
123 hyper_date_components_t date_ = {0, 0, 0};
124};
125}
126
127#include <hyperapi/impl/Date.impl.hpp>
128
129#endif
A date data value.
Definition Date.hpp:20
friend bool operator>=(const Date &a, const Date &b) noexcept
Greater or equal operator.
Definition Date.hpp:104
Date() noexcept
Default constructor.
Definition Date.hpp:30
friend std::ostream & operator<<(std::ostream &os, const Date &obj)
Stream output operator.
Definition Date.hpp:107
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:100
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:96
std::int32_t getYear() const noexcept
Gets the year.
Marker struct for the raw timestamp constructor.
Definition Date.hpp:25
An inserter.
Definition Inserter.hpp:23
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:37
The primary namespace of the Hyper API for C++.
Definition ByteSpan.hpp:14