You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
pEpJSONServerAdapter/server/function_map.cc

77 lines
1.7 KiB
C++

#include "function_map.hh"
6 years ago
#include "c_string.hh"
FunctionMap::const_iterator FunctionMap::find(const std::string& key) const noexcept
{
return std::find_if(v.begin(), v.end(), [&key](const FunctionMap::value_type& elem){ return elem.first == key; });
}
FunctionMap::FunctionMap(std::initializer_list<FunctionMap::value_type> il)
{
v.reserve(il.size());
for(const auto& elem : il)
{
// only add if function name is not already in FunctionMap
if(elem.second->isSeparator() || this->find(elem.first)==this->end())
{
v.push_back(elem);
}else{
throw std::runtime_error("Duplicate function name \"" + elem.first + "\" in FunctionMap!");
}
}
}
FunctionMap::~FunctionMap()
{
for(auto& elem : v)
{
delete elem.second;
elem.second = nullptr;
}
}
template<>
js::Value Type2String<std::string>::get() { return "String"; }
6 years ago
template<>
js::Value Type2String<c_string>::get() { return "String"; }
template<>
js::Value Type2String<const char*>::get() { return "String"; }
template<>
js::Value Type2String<char*>::get() { return "String"; }
template<>
js::Value Type2String<int>::get() { return "Integer"; }
template<>
js::Value Type2String<long>::get() { return "Integer"; }
template<>
js::Value Type2String<long long>::get() { return "Integer"; }
template<>
js::Value Type2String<unsigned>::get() { return "Integer"; }
template<>
js::Value Type2String<unsigned long>::get() { return "Integer"; }
template<>
js::Value Type2String<unsigned long long>::get() { return "Integer"; }
template<>
js::Value Type2String<bool>::get() { return "Bool"; }
template<>
js::Value Type2String<void>::get() { return "Void"; }
template<>
js::Value Type2String<js::Array>::get() { return "Array"; }