mirror of
https://github.com/matrix-construct/construct
synced 2024-11-29 02:02:38 +01:00
ircd::json: Add conditioned-closure iov::add_if.
This commit is contained in:
parent
7c841e6bdb
commit
1a12b7331d
2 changed files with 14 additions and 0 deletions
|
@ -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;
|
||||
};
|
||||
|
|
13
ircd/json.cc
13
ircd/json.cc
|
@ -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
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue