5#ifndef TABLEAU_HYPER_SQLTYPE_HPP
6#define TABLEAU_HYPER_SQLTYPE_HPP
8#include <hyperapi/impl/infra.hpp>
10#include <hyperapi/hyperapi.h>
15static CONSTEXPR_OPTIONAL optional<internal::AnyType> null = {};
19 Unsupported = HYPER_UNSUPPORTED,
21 BigInt = HYPER_BIG_INT,
22 SmallInt = HYPER_SMALL_INT,
26 Double = HYPER_DOUBLE,
30 Varchar = HYPER_VARCHAR,
37 TimestampTZ = HYPER_TIMESTAMP_TZ,
38 Geography = HYPER_GEOGRAPHY
47 SqlType(
TypeTag tag, uint32_t
oid, hyper_type_modifier_t modifier = HYPER_UNUSED_MODIFIER) noexcept
48 : tag_(tag), internalOid_(
oid), modifier_(modifier) {
96 static
SqlType boolean() noexcept {
return {TypeTag::Bool, HYPER_OID_BOOL}; }
101 static SqlType bigInt() noexcept {
return {TypeTag::BigInt, HYPER_OID_BIG_INT}; }
106 static SqlType smallInt() noexcept {
return {TypeTag::SmallInt, HYPER_OID_SMALL_INT}; }
118 static SqlType numeric(uint16_t precision, uint16_t scale)
noexcept {
return {TypeTag::Numeric, HYPER_OID_NUMERIC, hyper_encode_numeric_modifier(precision, scale)}; }
123 static SqlType real() noexcept {
return {TypeTag::Float, HYPER_OID_FLOAT}; }
133 static SqlType oid() noexcept {
return {TypeTag::Oid, HYPER_OID_OID}; }
138 static SqlType bytes() noexcept {
return {TypeTag::Bytes, HYPER_OID_BYTE_A}; }
143 static SqlType text() noexcept {
return {TypeTag::Text, HYPER_OID_TEXT}; }
149 static SqlType varchar(uint32_t maxLength)
noexcept {
return {TypeTag::Varchar, HYPER_OID_VARCHAR, hyper_encode_string_modifier(maxLength)}; }
155 static SqlType character(uint32_t maxLength)
noexcept {
return {TypeTag::Char,
static_cast<uint32_t
>((maxLength == 1) ? HYPER_OID_CHAR1 : HYPER_OID_CHAR), hyper_encode_string_modifier(maxLength)}; }
160 static SqlType json() noexcept {
return {TypeTag::Json, HYPER_OID_JSON}; }
165 static SqlType date() noexcept {
return {TypeTag::Date, HYPER_OID_DATE}; }
170 static SqlType interval() noexcept {
return {TypeTag::Interval, HYPER_OID_INTERVAL}; }
175 static SqlType time() noexcept {
return {TypeTag::Time, HYPER_OID_TIME}; }
225 uint32_t internalOid_;
227 hyper_type_modifier_t modifier_;
229 friend class internal::HyperTableDefinition;
244#include <hyperapi/impl/SqlType.impl.hpp>
A fixed-point numeric data value with scale fraction digits and precision digits overall.
uint32_t getInternalOid() const noexcept
Returns the internal oid.
static SqlType smallInt() noexcept
Returns the SMALL INTEGER SQL type.
static SqlType geography() noexcept
Returns the GEOGRAPHY SQL type.
static SqlType character(uint32_t maxLength) noexcept
Returns the CHARACTER SQL type.
static SqlType real() noexcept
Returns the REAL SQL type.
static SqlType numeric(uint16_t precision, uint16_t scale) noexcept
Returns the NUMERIC SQL type.
friend bool operator==(const SqlType &a, const SqlType &b) noexcept
Equality operator.
friend std::ostream & operator<<(std::ostream &os, const SqlType &obj)
Stream output operator.
SqlType(TypeTag tag, uint32_t oid, hyper_type_modifier_t modifier=HYPER_UNUSED_MODIFIER) noexcept
Constructor.
TypeTag getTag() const noexcept
Returns the type tag.
static SqlType timestampTZ() noexcept
Returns the TIMESTAMPTZ SQL type.
uint32_t getScale() const noexcept
Returns the scale parameter of the type if the type supports it, HYPER_UNUSED_MODIFIER otherwise.
uint32_t getMaxLength() const noexcept
Returns the maximum length parameter of the type if the type supports it, HYPER_UNUSED_MODIFIER other...
uint32_t getInternalTypeModifier() const noexcept
Returns the internal type modifier.
static SqlType json() noexcept
Returns the JSON SQL type.
static SqlType bytes() noexcept
Returns the BYTEA SQL type.
static SqlType oid() noexcept
Returns the OID SQL type.
static SqlType bigInt() noexcept
Returns the BIG INTEGER SQL type.
friend bool operator<=(const SqlType &a, const SqlType &b) noexcept
Smaller or equal operator.
static SqlType text() noexcept
Returns the TEXT SQL type.
static SqlType interval() noexcept
Returns the INTERVAL SQL type.
friend bool operator>=(const SqlType &a, const SqlType &b) noexcept
Greater or equal operator.
static SqlType date() noexcept
Returns the DATE SQL type.
static SqlType integer() noexcept
Returns the INTEGER SQL type.
static SqlType varchar(uint32_t maxLength) noexcept
Returns the VARCHAR SQL type.
static SqlType time() noexcept
Returns the TIME SQL type.
friend bool operator>(const SqlType &a, const SqlType &b) noexcept
Greater operator.
uint32_t getPrecision() const noexcept
Returns the maximum precision parameter of the type if the type supports it, HYPER_UNUSED_MODIFIER ot...
static SqlType doublePrecision() noexcept
Returns the DOUBLE PRECISION SQL type.
friend bool operator<(const SqlType &a, const SqlType &b) noexcept
Smaller operator.
std::string toString() const
Returns a string representation for debugging.
static SqlType timestamp() noexcept
Returns the TIMESTAMP SQL type.
friend bool operator!=(const SqlType &a, const SqlType &b) noexcept
Not equal operator.
The primary namespace of the Hyper API for C++.
size_t operator()(const hyperapi::SqlType &type) const noexcept
Calculates the hash value of the given SQL type.