class tool_map
{
public:
static bool try_get_value(sio::message::ptr& out_data,
const char* key, sio::message::ptr const& data)
{
auto map=data->get_map()[key];
if(map && sio::message::flag_object == map->get_flag())
{
out_data = map;
return true;
}
return false;
}
static bool try_get_value(int64_t& out_data, const char* key, sio::message::ptr const& data)
{
auto map=data->get_map()[key];
if(map && sio::message::flag_integer == map->get_flag())
{
out_data = map->get_int();
return true;
}
return false;
}
static bool try_get_value(uint32_t& out_data, const char* key, sio::message::ptr const& data)
{
auto map=data->get_map()[key];
if(map && sio::message::flag_integer == map->get_flag())
{
out_data = static_cast<uint32_t>(map->get_int());
return true;
}
return false;
}
static bool try_get_value(int& out_data, const char* key, sio::message::ptr const& data)
{
auto map=data->get_map()[key];
if(map && sio::message::flag_integer == map->get_flag())
{
out_data = static_cast<int>(map->get_int());
return true;
}
return false;
}
static bool try_get_value(std::string& out_data, const char* key, sio::message::ptr const& data)
{
auto map=data->get_map()[key];
if(map && sio::message::flag_string == map->get_flag())
{
out_data = map->get_string();
return true;
}
return false;
}
static bool try_get_value(double& out_data, const char* key, sio::message::ptr const& data)
{
auto map=data->get_map()[key];
if(map && sio::message::flag_double == map->get_flag())
{
out_data = map->get_double();
return true;
}
return false;
}
static bool try_get_value(std::vector<sio::message::ptr>& out_data,
const char* key, sio::message::ptr const& data)
{
auto map=data->get_map()[key];
if(map && sio::message::flag_array == map->get_flag())
{
out_data = map->get_vector();
return true;
}
return false;
}
};