| 1 | #pragma once |
|---|---|
| 2 | |
| 3 | #include "duckdb/common/winapi.hpp" |
| 4 | #include "duckdb/common/string.hpp" |
| 5 | #include <stdint.h> |
| 6 | |
| 7 | namespace duckdb { |
| 8 | |
| 9 | struct hugeint_t { |
| 10 | public: |
| 11 | uint64_t lower; |
| 12 | int64_t upper; |
| 13 | |
| 14 | public: |
| 15 | hugeint_t() = default; |
| 16 | DUCKDB_API hugeint_t(int64_t value); // NOLINT: Allow implicit conversion from `int64_t` |
| 17 | constexpr hugeint_t(int64_t upper, uint64_t lower) : lower(lower), upper(upper) { |
| 18 | } |
| 19 | constexpr hugeint_t(const hugeint_t &rhs) = default; |
| 20 | constexpr hugeint_t(hugeint_t &&rhs) = default; |
| 21 | hugeint_t &operator=(const hugeint_t &rhs) = default; |
| 22 | hugeint_t &operator=(hugeint_t &&rhs) = default; |
| 23 | |
| 24 | DUCKDB_API string ToString() const; |
| 25 | |
| 26 | // comparison operators |
| 27 | DUCKDB_API bool operator==(const hugeint_t &rhs) const; |
| 28 | DUCKDB_API bool operator!=(const hugeint_t &rhs) const; |
| 29 | DUCKDB_API bool operator<=(const hugeint_t &rhs) const; |
| 30 | DUCKDB_API bool operator<(const hugeint_t &rhs) const; |
| 31 | DUCKDB_API bool operator>(const hugeint_t &rhs) const; |
| 32 | DUCKDB_API bool operator>=(const hugeint_t &rhs) const; |
| 33 | |
| 34 | // arithmetic operators |
| 35 | DUCKDB_API hugeint_t operator+(const hugeint_t &rhs) const; |
| 36 | DUCKDB_API hugeint_t operator-(const hugeint_t &rhs) const; |
| 37 | DUCKDB_API hugeint_t operator*(const hugeint_t &rhs) const; |
| 38 | DUCKDB_API hugeint_t operator/(const hugeint_t &rhs) const; |
| 39 | DUCKDB_API hugeint_t operator%(const hugeint_t &rhs) const; |
| 40 | DUCKDB_API hugeint_t operator-() const; |
| 41 | |
| 42 | // bitwise operators |
| 43 | DUCKDB_API hugeint_t operator>>(const hugeint_t &rhs) const; |
| 44 | DUCKDB_API hugeint_t operator<<(const hugeint_t &rhs) const; |
| 45 | DUCKDB_API hugeint_t operator&(const hugeint_t &rhs) const; |
| 46 | DUCKDB_API hugeint_t operator|(const hugeint_t &rhs) const; |
| 47 | DUCKDB_API hugeint_t operator^(const hugeint_t &rhs) const; |
| 48 | DUCKDB_API hugeint_t operator~() const; |
| 49 | |
| 50 | // in-place operators |
| 51 | DUCKDB_API hugeint_t &operator+=(const hugeint_t &rhs); |
| 52 | DUCKDB_API hugeint_t &operator-=(const hugeint_t &rhs); |
| 53 | DUCKDB_API hugeint_t &operator*=(const hugeint_t &rhs); |
| 54 | DUCKDB_API hugeint_t &operator/=(const hugeint_t &rhs); |
| 55 | DUCKDB_API hugeint_t &operator%=(const hugeint_t &rhs); |
| 56 | DUCKDB_API hugeint_t &operator>>=(const hugeint_t &rhs); |
| 57 | DUCKDB_API hugeint_t &operator<<=(const hugeint_t &rhs); |
| 58 | DUCKDB_API hugeint_t &operator&=(const hugeint_t &rhs); |
| 59 | DUCKDB_API hugeint_t &operator|=(const hugeint_t &rhs); |
| 60 | DUCKDB_API hugeint_t &operator^=(const hugeint_t &rhs); |
| 61 | }; |
| 62 | |
| 63 | } // namespace duckdb |
| 64 |