0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-26 08:42:34 +01:00

ircd:Ⓜ️:event: Add std::string overloads to event get() suite.

This commit is contained in:
Jason Volk 2019-02-12 10:03:20 -08:00
parent df8cee0b47
commit c204ece49a
2 changed files with 66 additions and 5 deletions

View file

@ -13,21 +13,24 @@
namespace ircd::m namespace ircd::m
{ {
// Fetch the value for a single property of an event into the closure // Fetch the value for a single property of an event into the closure.
bool get(std::nothrow_t, const event::idx &, const string_view &key, const event::fetch::view_closure &); bool get(std::nothrow_t, const event::idx &, const string_view &key, const event::fetch::view_closure &);
bool get(std::nothrow_t, const event::id &, const string_view &key, const event::fetch::view_closure &); bool get(std::nothrow_t, const event::id &, const string_view &key, const event::fetch::view_closure &);
// Throws if event or property in that event not found
void get(const event::idx &, const string_view &key, const event::fetch::view_closure &); void get(const event::idx &, const string_view &key, const event::fetch::view_closure &);
void get(const event::id &, const string_view &key, const event::fetch::view_closure &); void get(const event::id &, const string_view &key, const event::fetch::view_closure &);
// Copies value into buffer returning view (empty for not found) // Copies value into buffer returning view.
const_buffer get(std::nothrow_t, const event::idx &, const string_view &key, const mutable_buffer &out); const_buffer get(std::nothrow_t, const event::idx &, const string_view &key, const mutable_buffer &out);
const_buffer get(std::nothrow_t, const event::id &, const string_view &key, const mutable_buffer &out); const_buffer get(std::nothrow_t, const event::id &, const string_view &key, const mutable_buffer &out);
const_buffer get(const event::idx &, const string_view &key, const mutable_buffer &out); const_buffer get(const event::idx &, const string_view &key, const mutable_buffer &out);
const_buffer get(const event::id &, const string_view &key, const mutable_buffer &out); const_buffer get(const event::id &, const string_view &key, const mutable_buffer &out);
// Allocates and copies into string.
std::string get(std::nothrow_t, const event::idx &, const string_view &key);
std::string get(std::nothrow_t, const event::id &, const string_view &key);
std::string get(const event::idx &, const string_view &key);
std::string get(const event::id &, const string_view &key);
template<class T> template<class T>
typename std::enable_if<std::is_integral<T>::value, bool>::type typename std::enable_if<std::is_integral<T>::value, bool>::type
get(const event::idx &, const string_view &key, T &ret); get(const event::idx &, const string_view &key, T &ret);

View file

@ -521,6 +521,64 @@ ircd::m::cached(const event::idx &event_idx,
// event/get.h // event/get.h
// //
std::string
ircd::m::get(const event::id &event_id,
const string_view &key)
{
std::string ret;
get(event_id, key, [&ret]
(const string_view &value)
{
ret = value;
});
return ret;
}
std::string
ircd::m::get(const event::idx &event_idx,
const string_view &key)
{
std::string ret;
get(event_idx, key, [&ret]
(const string_view &value)
{
ret = value;
});
return ret;
}
std::string
ircd::m::get(std::nothrow_t,
const event::id &event_id,
const string_view &key)
{
std::string ret;
get(std::nothrow, event_id, key, [&ret]
(const string_view &value)
{
ret = value;
});
return ret;
}
std::string
ircd::m::get(std::nothrow_t,
const event::idx &event_idx,
const string_view &key)
{
std::string ret;
get(std::nothrow, event_idx, key, [&ret]
(const string_view &value)
{
ret = value;
});
return ret;
}
ircd::const_buffer ircd::const_buffer
ircd::m::get(const event::id &event_id, ircd::m::get(const event::id &event_id,
const string_view &key, const string_view &key,