From 1381524f95514df81b0a3f7e21a743352839590f Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Sat, 9 Mar 2019 18:48:32 -0800 Subject: [PATCH] ircd::m::device: Add has(user, device_id, property) overload to interface suite. --- include/ircd/m/device.h | 1 + ircd/m.cc | 15 +++++++++++++++ modules/m_device.cc | 16 ++++++++++++++++ 3 files changed, 32 insertions(+) diff --git a/include/ircd/m/device.h b/include/ircd/m/device.h index 07dd92fc8..350b8d7c4 100644 --- a/include/ircd/m/device.h +++ b/include/ircd/m/device.h @@ -124,6 +124,7 @@ struct ircd::m::device static bool for_each(const user &, const string_view &id, const closure_bool &); // each property static bool get(std::nothrow_t, const user &, const string_view &id, const string_view &prop, const closure &); static bool get(const user &, const string_view &id, const string_view &prop, const closure &); + static bool has(const user &, const string_view &id, const string_view &prop); static bool has(const user &, const string_view &id); static bool del(const user &, const string_view &id); static bool set(const user &, const string_view &id, const string_view &prop, const string_view &val); diff --git a/ircd/m.cc b/ircd/m.cc index 43bde4dfa..8241b6108 100644 --- a/ircd/m.cc +++ b/ircd/m.cc @@ -1714,6 +1714,21 @@ ircd::m::device::has(const m::user &user, return function(user, id); } +bool +ircd::m::device::has(const m::user &user, + const string_view &id, + const string_view &prop) +{ + using prototype = bool (const m::user &, const string_view &id, const string_view &prop); + + static mods::import function + { + "m_device", "ircd::m::device::has" + }; + + return function(user, id, prop); +} + bool ircd::m::device::get(const m::user &user, const string_view &id, diff --git a/modules/m_device.cc b/modules/m_device.cc index a9058afdd..a2063cb5c 100644 --- a/modules/m_device.cc +++ b/modules/m_device.cc @@ -174,6 +174,22 @@ ircd::m::device::has(const m::user &user, return ret; } +bool +IRCD_MODULE_EXPORT +ircd::m::device::has(const m::user &user, + const string_view &id, + const string_view &prop) +{ + bool ret{false}; + get(std::nothrow, user, id, prop, [&ret] + (const string_view &value) + { + ret = !empty(value); + }); + + return ret; +} + bool IRCD_MODULE_EXPORT ircd::m::device::get(std::nothrow_t,