OmniSciDB  a5dc49c757
 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:291

+ 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, shared::convert_temporal_to_iso_format(), 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()) {
107  return shared::convert_temporal_to_iso_format(ti, *boost::get<int64_t>(scalar_tv));
108  }
109  if (ti.is_decimal()) {
110  Datum datum;
111  datum.bigintval = *boost::get<int64_t>(scalar_tv);
112  if (datum.bigintval == NULL_BIGINT) {
113  return "NULL";
114  }
115  return DatumToString(datum, ti);
116  }
117  if (ti.is_boolean()) {
118  const auto bool_val = *boost::get<int64_t>(scalar_tv);
119  return bool_val == NULL_BOOLEAN ? "NULL" : (bool_val ? "true" : "false");
120  }
121  auto iptr = boost::get<int64_t>(scalar_tv);
122  if (iptr) {
123  return *iptr == inline_int_null_val(ti) ? "NULL" : std::to_string(*iptr);
124  }
125  auto fptr = boost::get<float>(scalar_tv);
126  if (fptr) {
127  return *fptr == inline_fp_null_val(ti) ? "NULL" : std::to_string(*fptr);
128  }
129  auto dptr = boost::get<double>(scalar_tv);
130  if (dptr) {
131  return *dptr == inline_fp_null_val(ti.is_decimal() ? SQLTypeInfo(kDOUBLE, false) : ti)
132  ? "NULL"
133  : std::to_string(*dptr);
134  }
135  auto sptr = boost::get<NullableString>(scalar_tv);
136  CHECK(sptr);
137  return nullable_str_to_string(*sptr);
138 }
std::string DatumToString(Datum d, const SQLTypeInfo &ti)
Definition: Datum.cpp:460
#define NULL_BIGINT
std::string convert_temporal_to_iso_format(const SQLTypeInfo &type_info, int64_t unix_time)
Definition: misc.cpp:111
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:579
std::string to_string(char const *&&v)
std::string nullable_str_to_string(const NullableString &str)
int64_t bigintval
Definition: Datum.h:76
bool is_boolean() const
Definition: sqltypes.h:582
#define NULL_BOOLEAN
#define CHECK(condition)
Definition: Logger.h:291
int64_t inline_int_null_val(const SQL_TYPE_INFO &ti)
Definition: Datum.h:71
SQLTypeInfo get_elem_type() const
Definition: sqltypes.h:977
bool is_decimal() const
Definition: sqltypes.h:570
bool is_array() const
Definition: sqltypes.h:585

+ Here is the call graph for this function:

+ Here is the caller graph for this function: