0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-29 10:12:39 +01:00

ircd::json: Add conditioned-closure iov::add_if.

This commit is contained in:
Jason Volk 2018-06-04 23:17:29 -07:00
parent 7c841e6bdb
commit 1a12b7331d
2 changed files with 14 additions and 0 deletions

View file

@ -90,6 +90,7 @@ struct ircd::json::iov::add
struct ircd::json::iov::add_if
:protected ircd::json::iov::node
{
add_if(iov &, const bool &, const string_view &, const std::function<json::value ()> &);
add_if(iov &, const bool &, member);
add_if() = default;
};

View file

@ -1069,6 +1069,19 @@ ircd::json::iov::add_if::add_if(iov &iov,
iov.pop_front();
}
ircd::json::iov::add_if::add_if(iov &iov,
const bool &b,
const string_view &key,
const std::function<json::value ()> &val)
:node
{
iov, b? member{key, val()} : member{}
}
{
if(!b)
iov.pop_front();
}
ircd::json::iov::set::set(iov &iov, member member)
:node
{