OmniSciDB  a5dc49c757
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Datum.h File Reference

Definitions for core Datum union type. More...

#include "funcannotations.h"
#include <type_traits>
#include <string_view>
+ Include dependency graph for Datum.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  StringView
 
struct  VarlenDatum
 
union  Datum
 

Functions

template<typename T >
Datum make_datum (T val)
 

Detailed Description

Definitions for core Datum union type.

Definition in file Datum.h.

Function Documentation

template<typename T >
Datum make_datum ( val)

Definition at line 86 of file Datum.h.

References Datum::arrayval, Datum::bigintval, Datum::boolval, Datum::doubleval, Datum::floatval, Datum::intval, Datum::smallintval, Datum::stringval, and Datum::tinyintval.

86  {
87  static_assert(std::is_same_v<T, bool> || std::is_same_v<T, int8_t> ||
88  std::is_same_v<T, int16_t> || std::is_same_v<T, int32_t> ||
89  std::is_same_v<T, int64_t> || std::is_same_v<T, float> ||
90  std::is_same_v<T, double> || std::is_same_v<T, VarlenDatum*>
91 #ifndef __CUDACC__
92  || std::is_same_v<T, std::string*>
93 #endif
94  ,
95  "Type T must be one of the allowed types");
96  Datum d;
97  if constexpr (std::is_same_v<T, bool>) {
98  d.boolval = static_cast<int8_t>(val);
99  } else if constexpr (std::is_same_v<T, int8_t>) {
100  d.tinyintval = val;
101  } else if constexpr (std::is_same_v<T, int16_t>) {
102  d.smallintval = val;
103  } else if constexpr (std::is_same_v<T, int32_t>) {
104  d.intval = val;
105  } else if constexpr (std::is_same_v<T, int64_t>) {
106  d.bigintval = val;
107  } else if constexpr (std::is_same_v<T, float>) {
108  d.floatval = val;
109  } else if constexpr (std::is_same_v<T, double>) {
110  d.doubleval = val;
111  } else if constexpr (std::is_same_v<T, VarlenDatum*>) {
112  // deleting `arrayval` is caller's responsibility
113  d.arrayval = val;
114 #ifndef __CUDACC__
115  } else if constexpr (std::is_same_v<T, std::string*>) {
116  // deleting `stringval` is caller's responsibility
117  d.stringval = val;
118 #endif
119  }
120  return d;
121 }
int8_t tinyintval
Definition: Datum.h:73
int8_t boolval
Definition: Datum.h:72
VarlenDatum * arrayval
Definition: Datum.h:79
int32_t intval
Definition: Datum.h:75
float floatval
Definition: Datum.h:77
int64_t bigintval
Definition: Datum.h:76
int16_t smallintval
Definition: Datum.h:74
std::string * stringval
Definition: Datum.h:81
Definition: Datum.h:71
double doubleval
Definition: Datum.h:78