#include "function_map.hh" #include #include // for memcpy() const Concat concat{}; namespace { char* make_c_string(const std::string& src) { char* dest = (char*)malloc(src.size() + 1); memcpy(dest, src.c_str(), src.size() + 1 ); return dest; } } template<> In::~In() { if(value) free(const_cast(value)); } template<> In::~In() { } template<> In::~In() { } template<> Out::~Out() { if(value) free(const_cast(*value)); delete value; } template<> Out::~Out() { if(value) free(*value); *value = nullptr; delete value; } template<> Out::~Out() { delete value; } template<> Out::Out(const Out& other) : value ( new bool {*other.value} ) { } template<> Out::~Out() { delete value; } template<> Out::Out(const Out& other) : value( new const char* ) { *value = *other.value ? strdup(*other.value) : nullptr; } template<> Out::Out(const Out& other) : value( new char* ) { *value = *other.value ? strdup(*other.value) : nullptr; } template<> Out::Out(const Out& other) : value( new std::size_t(*other.value)) { } template<> int from_json(const js::Value& v) { return v.get_int(); } template<> unsigned from_json(const js::Value& v) { return v.get_uint64(); } template<> std::string from_json(const js::Value& v) { return v.get_str(); } template<> char* from_json(const js::Value& v) { return make_c_string( v.get_str() ); } template<> const char* from_json(const js::Value& v) { return make_c_string( v.get_str() ); } template js::Value to_json(const T& t) { return js::Value(t); } template js::Value to_json(const bool&); template js::Value to_json(const int&); template js::Value to_json(const std::string&); template<> js::Value to_json(const unsigned& t) { return js::Value(uint64_t(t)); } template<> js::Value to_json(char* const & s) { return s ? js::Value(std::string(s)) : js::Value{}; } template<> js::Value to_json(const char* const & s) { return s ? js::Value(std::string(s)) : js::Value{}; } template<> js::Value to_json(const std::size_t& s) { return js::Value{s}; } template<> std::size_t from_json(const js::Value& v) { return v.get_uint64(); } template<> js::Value Type2String::get() { return "String"; } template<> js::Value Type2String::get() { return "String"; } template<> js::Value Type2String::get() { return "String"; } template<> js::Value Type2String::get() { return "Integer"; } template<> js::Value Type2String::get() { return "Integer"; } template<> js::Value Type2String::get() { return "Bool"; }