Column-oriented GPU-accelerated Database Management System
CoGaDB
|
00001 #pragma once 00002 #include <core/global_definitions.hpp> 00003 #include <iostream> 00004 #include <fstream> 00005 #include <boost/any.hpp> 00006 00007 namespace CoGaDB{ 00008 00009 inline std::ostream& operator << (std::ostream& os, const boost::any& v) 00010 { 00011 if(v.empty()) return os; 00012 //os << 00013 if(typeid(int)==v.type()){ 00014 os << boost::any_cast<int>(v); 00015 }else if(typeid(unsigned int)==v.type()){ 00016 os << boost::any_cast<unsigned int>(v); 00017 }else if(typeid(unsigned long)==v.type()){ 00018 os << boost::any_cast<unsigned long>(v); 00019 }else if(typeid(float)==v.type()){ 00020 os << boost::any_cast<float>(v); 00021 }else if(typeid(double)==v.type()){ 00022 os << boost::any_cast<double>(v); 00023 }else if(typeid(std::string)==v.type()){ 00024 os << boost::any_cast<std::string>(v); 00025 }else if(typeid(bool)==v.type()){ 00026 os << boost::any_cast<bool>(v); 00027 }else{ 00028 std::cout << "FATAL ERROR! In std::ostream& operator << (std::ostream& os, const boost::any& v)" << std::endl; 00029 std::cout << "Unkown Type stored in boost::any, cannot print value!" << std::endl; 00030 std::cout << "In File " << __FILE__ << ":" << __LINE__ << std::endl; 00031 std::exit(-1); 00032 00033 } 00034 return os; 00035 } 00036 00037 00039 template < class T > 00040 inline std::ostream& operator << (std::ostream& os, const std::vector<T>& v) 00041 { 00042 os << "["; 00043 for (typename std::vector<T>::const_iterator ii = v.begin(); ii != v.end(); ++ii) 00044 { 00045 os << " " << *ii; 00046 } 00047 os << " ]"; 00048 return os; 00049 } 00050 00052 template <> 00053 inline std::ostream& operator << (std::ostream& os, const Tuple& v) 00054 { 00055 //ofs.write((char*)(a.array), 20*sizeof(int)); 00056 os << "Tuple: ("; 00057 for(unsigned int i=0;i<v.size();i++){ 00058 if(v[i].type()==typeid(int)){ 00059 os << boost::any_cast<int>(v[i]); 00060 }else if(v[i].type()==typeid(float)){ 00061 os << boost::any_cast<float>(v[i]); 00062 }else if(v[i].type()==typeid(std::string)){ 00063 os << boost::any_cast<std::string>(v[i]); 00064 }else if(v[i].type()==typeid(bool)){ 00065 os << boost::any_cast<bool>(v[i]); 00066 }else{ 00067 std::cout << "Found Invalid Type in Tuple: " << v[i].type().name() << std::endl; 00068 std::exit(-1); 00069 } 00070 if(i<v.size()-1) os << ","; 00071 } 00072 os << ")"; // << std::endl; 00073 return os; 00074 return os; 00075 } 00076 00077 }; //end namespace CogaDB 00078