add specialized request id constructors

This commit is contained in:
badaix 2017-01-13 07:59:12 +01:00
parent 0a879301c9
commit 027cb8ed50
2 changed files with 12 additions and 4 deletions

View file

@ -36,11 +36,19 @@ struct req_id
integer
};
req_id() : type(value_t::null)
req_id() : type(value_t::null), int_id(0), string_id("")
{
}
req_id(Json json_id) : type(value_t::null)
req_id(int id) : type(value_t::integer), int_id(id), string_id("")
{
}
req_id(const std::string& id) : type(value_t::string), int_id(0), string_id(id)
{
}
explicit req_id(Json json_id) : type(value_t::null)
{
if (json_id.is_null())
{
@ -77,8 +85,8 @@ struct req_id
}
value_t type;
std::string string_id;
int int_id;
std::string string_id;
};

View file

@ -24,7 +24,7 @@ using namespace std;
JsonRequest::JsonRequest() : id(-1), method("")
JsonRequest::JsonRequest() : id(), method("")
{
}