OmniSciDB  6686921089
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
import_export::anonymous_namespace{QueryExporterCSV.cpp} Namespace Reference

Functions

std::string nullable_str_to_string (const NullableString &str)
 
std::string target_value_to_string (const TargetValue &tv, const SQLTypeInfo &ti, const std::string &delim)
 

Function Documentation

std::string import_export::anonymous_namespace{QueryExporterCSV.cpp}::nullable_str_to_string ( const NullableString str)

Definition at line 76 of file QueryExporterCSV.cpp.

References CHECK.

Referenced by target_value_to_string().

76  {
77  auto nptr = boost::get<void*>(&str);
78  if (nptr) {
79  CHECK(!*nptr);
80  return "NULL";
81  }
82  auto sptr = boost::get<std::string>(&str);
83  CHECK(sptr);
84  return *sptr;
85 }
#define CHECK(condition)
Definition: Logger.h:209

+ Here is the caller graph for this function:

std::string import_export::anonymous_namespace{QueryExporterCSV.cpp}::target_value_to_string ( const TargetValue tv,
const SQLTypeInfo ti,
const std::string &  delim 
)

Definition at line 87 of file QueryExporterCSV.cpp.

References Datum::bigintval, CHECK, DatumToString(), SQLTypeInfo::get_elem_type(), inline_fp_null_val(), inline_int_null_val(), SQLTypeInfo::is_array(), SQLTypeInfo::is_boolean(), SQLTypeInfo::is_decimal(), SQLTypeInfo::is_time(), join(), kDOUBLE, NULL_BIGINT, NULL_BOOLEAN, nullable_str_to_string(), and to_string().

Referenced by import_export::QueryExporterCSV::exportResults().

89  {
90  if (ti.is_array()) {
91  const auto array_tv = boost::get<ArrayTargetValue>(&tv);
92  CHECK(array_tv);
93  if (array_tv->is_initialized()) {
94  const auto& vec = array_tv->get();
95  std::vector<std::string> elem_strs;
96  elem_strs.reserve(vec.size());
97  const auto& elem_ti = ti.get_elem_type();
98  for (const auto& elem_tv : vec) {
99  elem_strs.push_back(target_value_to_string(elem_tv, elem_ti, delim));
100  }
101  return "{" + boost::algorithm::join(elem_strs, delim) + "}";
102  }
103  return "NULL";
104  }
105  const auto scalar_tv = boost::get<ScalarTargetValue>(&tv);
106  if (ti.is_time() || ti.is_decimal()) {
107  Datum datum;
108  datum.bigintval = *boost::get<int64_t>(scalar_tv);
109  if (datum.bigintval == NULL_BIGINT) {
110  return "NULL";
111  }
112  return DatumToString(datum, ti);
113  }
114  if (ti.is_boolean()) {
115  const auto bool_val = *boost::get<int64_t>(scalar_tv);
116  return bool_val == NULL_BOOLEAN ? "NULL" : (bool_val ? "true" : "false");
117  }
118  auto iptr = boost::get<int64_t>(scalar_tv);
119  if (iptr) {
120  return *iptr == inline_int_null_val(ti) ? "NULL" : std::to_string(*iptr);
121  }
122  auto fptr = boost::get<float>(scalar_tv);
123  if (fptr) {
124  return *fptr == inline_fp_null_val(ti) ? "NULL" : std::to_string(*fptr);
125  }
126  auto dptr = boost::get<double>(scalar_tv);
127  if (dptr) {
128  return *dptr == inline_fp_null_val(ti.is_decimal() ? SQLTypeInfo(kDOUBLE, false) : ti)
129  ? "NULL"
130  : std::to_string(*dptr);
131  }
132  auto sptr = boost::get<NullableString>(scalar_tv);
133  CHECK(sptr);
134  return nullable_str_to_string(*sptr);
135 }
std::string DatumToString(Datum d, const SQLTypeInfo &ti)
Definition: Datum.cpp:392
#define NULL_BIGINT
std::string join(T const &container, std::string const &delim)
std::string target_value_to_string(const TargetValue &tv, const SQLTypeInfo &ti, const std::string &delim)
double inline_fp_null_val(const SQL_TYPE_INFO &ti)
bool is_time() const
Definition: sqltypes.h:515
std::string to_string(char const *&&v)
std::string nullable_str_to_string(const NullableString &str)
int64_t bigintval
Definition: sqltypes.h:215
bool is_boolean() const
Definition: sqltypes.h:516
#define NULL_BOOLEAN
#define CHECK(condition)
Definition: Logger.h:209
int64_t inline_int_null_val(const SQL_TYPE_INFO &ti)
SQLTypeInfo get_elem_type() const
Definition: sqltypes.h:850
bool is_decimal() const
Definition: sqltypes.h:512
bool is_array() const
Definition: sqltypes.h:517

+ Here is the call graph for this function:

+ Here is the caller graph for this function: