OmniSciDB  8fa3bf436f
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
toString.h File Reference
#include <cxxabi.h>
#include <chrono>
#include <iostream>
#include <set>
#include <sstream>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <vector>
+ Include dependency graph for toString.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  anonymous_namespace{toString.h}::has_toString< T, typename >
 
struct  anonymous_namespace{toString.h}::has_toString< T, decltype(std::declval< T >().toString(), void())>
 
struct  anonymous_namespace{toString.h}::get_has_toString< T, typename >
 

Namespaces

 anonymous_namespace{toString.h}
 

Macros

#define HAVE_TOSTRING
 
#define __FILENAME__   (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
 
#define PRINT(EXPR)
 

Functions

template<typename T >
std::string typeName (const T *v)
 
template<typename T >
struct get_has_toString< T,
decltype(std::declval< T >
().get() -> 
anonymous_namespace{toString.h}::toString ()
 
template<typename T >
std::string toString (const T &v)
 
template<typename T1 , typename T2 >
std::string toString (const std::pair< T1, T2 > &v)
 
template<typename T >
std::string toString (const std::vector< T > &v)
 
template<typename T1 , typename T2 >
std::string toString (const std::unordered_map< T1, T2 > &v)
 
template<typename T >
std::string toString (const std::list< T > &v)
 
template<typename T >
std::string toString (const std::unordered_set< T > &v)
 
template<typename T >
std::string toString (const std::set< T > &v)
 
template<typename T >
std::string toString (const std::tuple< T, T > &v)
 

Variables

template<class T >
constexpr bool anonymous_namespace{toString.h}::has_toString_v = has_toString<T>::value
 
template<class T >
struct get_has_toString< T,
decltype(std::declval< T >
().get() -> void())> constexpr
bool 
anonymous_namespace{toString.h}::get_has_toString_v = get_has_toString<T>::value
 

Macro Definition Documentation

#define __FILENAME__   (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)

Definition at line 76 of file toString.h.

#define HAVE_TOSTRING

Definition at line 39 of file toString.h.

#define PRINT (   EXPR)
Value:
std::cout << "[" << __FILENAME__ << ":" << __func__ << "#" << __LINE__ \
<< "]: " #EXPR "=" << ::toString(EXPR) << std::endl;
std::string toString(const ExtArgumentType &sig_type)
#define __FILENAME__
Definition: toString.h:76

Definition at line 77 of file toString.h.

Function Documentation

template<typename T >
std::string toString ( const T &  v)

Definition at line 135 of file toString.h.

References omnisci.dtypes::T, to_string(), toString(), and typeName().

135  {
136  if constexpr (std::is_same_v<T, std::string>) {
137  return "\"" + v + "\"";
138 #ifdef ENABLE_TOSTRING_RAPIDJSON
139  } else if constexpr (std::is_same_v<T, rapidjson::Value>) {
140  rapidjson::StringBuffer buffer;
141  rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
142  v.Accept(writer);
143  return buffer.GetString();
144 #endif
145 #ifdef ENABLE_TOSTRING_LLVM
146  } else if constexpr (std::is_same_v<T, llvm::Module>) {
147  std::string type_str;
148  llvm::raw_string_ostream rso(type_str);
149  v.print(rso, nullptr);
150  return "(" + rso.str() + ")";
151  } else if constexpr (std::is_same_v<T, llvm::Function>) {
152  std::string type_str;
153  llvm::raw_string_ostream rso(type_str);
154  v.print(rso, nullptr);
155  return "(" + rso.str() + ")";
156  } else if constexpr (std::is_same_v<T, llvm::Value>) {
157  std::string type_str;
158  llvm::raw_string_ostream rso(type_str);
159  v.print(rso);
160  return "(" + rso.str() + ")";
161  } else if constexpr (std::is_same_v<T, llvm::Type>) {
162  std::string type_str;
163  llvm::raw_string_ostream rso(type_str);
164  v.print(rso);
165  return "(" + rso.str() + ")";
166  } else if constexpr (std::is_same_v<T, llvm::Triple>) {
167  return v.str();
168 #endif
169  } else if constexpr (std::is_same_v<T, bool>) {
170  return v ? "True" : "False";
171  } else if constexpr (std::is_arithmetic_v<T>) {
172  return std::to_string(v);
173 #ifdef ENABLE_TOSTRING_str
174  } else if constexpr (has_str_v<T>) {
175  return v.str();
176 #endif
177 #ifdef ENABLE_TOSTRING_to_string
178  } else if constexpr (has_to_string_v<T>) {
179  return v.to_string();
180 #endif
181  } else if constexpr (has_toString_v<T>) {
182  return v.toString();
183  } else if constexpr (get_has_toString_v<T>) {
184  auto ptr = v.get();
185  return (ptr == NULL ? "NULL" : "&" + ptr->toString());
186  } else if constexpr (std::is_same_v<T, void*>) {
187  std::ostringstream ss;
188  ss << std::hex << (uintptr_t)v;
189  return "0x" + ss.str();
190  } else if constexpr (std::is_same_v<
191  T,
192  std::chrono::time_point<std::chrono::system_clock>>) {
193  std::string s(30, '\0');
194  auto converted_v = (std::chrono::time_point<std::chrono::system_clock>)v;
195  std::time_t ts = std::chrono::system_clock::to_time_t(v);
196  std::strftime(&s[0], s.size(), "%Y-%m-%d %H:%M:%S", std::localtime(&ts));
197  return s + "." +
198  std::to_string((converted_v.time_since_epoch().count() / 1000) % 1000000);
199  } else if constexpr (std::is_pointer_v<T>) {
200  return (v == NULL ? "NULL" : "&" + toString(*v));
201  } else {
202  return typeName(&v);
203  }
204 }
std::string toString(const ExtArgumentType &sig_type)
std::string to_string(char const *&&v)
std::string typeName(const T *v)
Definition: toString.h:82

+ Here is the call graph for this function:

template<typename T1 , typename T2 >
std::string toString ( const std::pair< T1, T2 > &  v)

Definition at line 207 of file toString.h.

References toString().

207  {
208  return "(" + toString(v.first) + ", " + toString(v.second) + ")";
209 }
std::string toString(const ExtArgumentType &sig_type)

+ Here is the call graph for this function:

template<typename T >
std::string toString ( const std::vector< T > &  v)

Definition at line 212 of file toString.h.

References i, run_benchmark_import::result, and toString().

212  {
213  auto result = std::string("[");
214  for (size_t i = 0; i < v.size(); ++i) {
215  if (i) {
216  result += ", ";
217  }
218  result += toString(v[i]);
219  }
220  result += "]";
221  return result;
222 }
std::string toString(const ExtArgumentType &sig_type)

+ Here is the call graph for this function:

template<typename T1 , typename T2 >
std::string toString ( const std::unordered_map< T1, T2 > &  v)

Definition at line 225 of file toString.h.

References i, run_benchmark_import::result, and toString().

225  {
226  auto result = std::string("{");
227  size_t i = 0;
228  for (const auto& p : v) {
229  if (i) {
230  result += ", ";
231  }
232  result += toString(p);
233  i++;
234  }
235  result += "}";
236  return result;
237 }
std::string toString(const ExtArgumentType &sig_type)

+ Here is the call graph for this function:

template<typename T >
std::string toString ( const std::list< T > &  v)

Definition at line 240 of file toString.h.

References i, run_benchmark_import::result, and toString().

240  {
241  auto result = std::string("[");
242  size_t i = 0;
243  for (const auto& p : v) {
244  if (i) {
245  result += ", ";
246  }
247  result += toString(p);
248  i++;
249  }
250  result += "]";
251  return result;
252 }
std::string toString(const ExtArgumentType &sig_type)

+ Here is the call graph for this function:

template<typename T >
std::string toString ( const std::unordered_set< T > &  v)

Definition at line 255 of file toString.h.

References i, run_benchmark_import::result, and toString().

255  {
256  auto result = std::string("{");
257  size_t i = 0;
258  for (const auto& p : v) {
259  if (i) {
260  result += ", ";
261  }
262  result += toString(p);
263  i++;
264  }
265  result += "}";
266  return result;
267 }
std::string toString(const ExtArgumentType &sig_type)

+ Here is the call graph for this function:

template<typename T >
std::string toString ( const std::set< T > &  v)

Definition at line 270 of file toString.h.

References i, run_benchmark_import::result, and toString().

270  {
271  auto result = std::string("{");
272  size_t i = 0;
273  for (const auto& p : v) {
274  if (i) {
275  result += ", ";
276  }
277  result += toString(p);
278  i++;
279  }
280  result += "}";
281  return result;
282 }
std::string toString(const ExtArgumentType &sig_type)

+ Here is the call graph for this function:

template<typename T >
std::string toString ( const std::tuple< T, T > &  v)

Definition at line 285 of file toString.h.

References omnisci.dtypes::T, and toString().

285  {
286  T left, right;
287  std::tie(left, right) = v;
288  return std::string("(") + toString(left) + ", " + toString(right) + ")";
289 }
std::string toString(const ExtArgumentType &sig_type)

+ Here is the call graph for this function:

template<typename T >
std::string typeName ( const T *  v)

Definition at line 82 of file toString.h.

References setup::name, and omnisci.dtypes::T.

Referenced by com.omnisci.jdbc.OmniSciConnection::createArrayOf(), com.mapd.calcite.parser.MapDTypeSystem::getMaxPrecision(), com.mapd.parser.extension.ddl.omnisci.OmniSciTypeNameSpec::OmniSciTypeNameSpec(), ColumnList< T >::operator()(), InputDescriptor::toString(), ColumnDescriptor::toString(), RexAbstractInput::toString(), ExecutionResult::toString(), InputColDescriptor::toString(), TableFunctionExecutionUnit::toString(), Chunk_NS::Chunk::toString(), toString(), RexLiteral::toString(), ResultSet::toString(), RexOperator::toString(), RexSubQuery::toString(), RexInput::toString(), RexCase::toString(), RexFunctionOperator::toString(), SortField::toString(), RexWindowFunctionOperator::toString(), RexRef::toString(), RexAgg::toString(), RelScan::toString(), RelProject::toString(), RelAggregate::toString(), RelJoin::toString(), RelFilter::toString(), RelCompound::toString(), RelSort::toString(), RelModify::toString(), RelTableFunction::toString(), RelLogicalValues::toString(), and RelLogicalUnion::toString().

82  {
83  std::stringstream stream;
84  int status;
85 #ifdef _WIN32
86  stream << std::string(typeid(T).name());
87 #else
88  char* demangled = abi::__cxa_demangle(typeid(T).name(), 0, 0, &status);
89  stream << std::string(demangled);
90  free(demangled);
91 #endif
92  return stream.str();
93 }
string name
Definition: setup.in.py:72

+ Here is the caller graph for this function: