1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
std::string element::getJson() const{
static std::vector<std::function<void (const element&,std::ostream&)> > funcs = {
[](const element& dt,std::ostream& ss){ss << "";},
[](const element& dt,std::ostream& ss){ss << dt.value;},
[](const element& dt,std::ostream& ss){ss << (*((int*)(&dt.ulval)));},
[](const element& dt,std::ostream& ss){ss << (*((double*)(&dt.ulval)));},
[](const element& dt,std::ostream& ss){ss << (*((long*)(&dt.ulval)));},
[](const element& dt,std::ostream& ss){ss << (*((long long*)(&dt.ulval)));},
[](const element& dt,std::ostream& ss){ss << (*((short*)(&dt.ulval)));},
[](const element& dt,std::ostream& ss){ss << (*((char*)(&dt.ulval)));},
[](const element& dt,std::ostream& ss){ss << (*((bool*)(&dt.ulval)));},
[](const element& dt,std::ostream& ss){ss << (*((ui8*)(&dt.ulval)));},
[](const element& dt,std::ostream& ss){ss << (*((ui16*)(&dt.ulval)));},
[](const element& dt,std::ostream& ss){ss << (*((ui32*)(&dt.ulval)));},
[](const element& dt,std::ostream& ss){ss << (*((unsigned long*)(&dt.ulval)));},
[](const element& dt,std::ostream& ss){ss << (*((ui64*)(&dt.ulval)));}
};
std::stringstream ss;
funcs[this->valtype](*this,ss);
return ss.str();
}
|