mirror of
https://github.com/matrix-construct/construct
synced 2024-11-18 07:50:57 +01:00
ircd::db: Support map-based property retrieval.
This commit is contained in:
parent
0bf6742ac9
commit
cfb80085a8
3 changed files with 14 additions and 0 deletions
|
@ -29,6 +29,7 @@ namespace ircd::db
|
||||||
template<class R = prop_str> R property(const column &, const string_view &name);
|
template<class R = prop_str> R property(const column &, const string_view &name);
|
||||||
template<> prop_str property(const column &, const string_view &name);
|
template<> prop_str property(const column &, const string_view &name);
|
||||||
template<> prop_int property(const column &, const string_view &name);
|
template<> prop_int property(const column &, const string_view &name);
|
||||||
|
template<> prop_map property(const column &, const string_view &name);
|
||||||
|
|
||||||
// [GET] Tests if key exists
|
// [GET] Tests if key exists
|
||||||
bool has(column &, const string_view &key, const gopts & = {});
|
bool has(column &, const string_view &key, const gopts & = {});
|
||||||
|
|
|
@ -22,6 +22,7 @@ namespace ircd::db
|
||||||
// Property information interface
|
// Property information interface
|
||||||
using prop_int = uint64_t;
|
using prop_int = uint64_t;
|
||||||
using prop_str = std::string;
|
using prop_str = std::string;
|
||||||
|
using prop_map = std::map<std::string, double>;
|
||||||
template<class R = prop_int> R property(const database &, const string_view &name);
|
template<class R = prop_int> R property(const database &, const string_view &name);
|
||||||
template<> prop_int property(const database &, const string_view &name);
|
template<> prop_int property(const database &, const string_view &name);
|
||||||
|
|
||||||
|
|
12
ircd/db.cc
12
ircd/db.cc
|
@ -3613,6 +3613,18 @@ ircd::db::property(const column &column,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<>
|
||||||
|
ircd::db::prop_map
|
||||||
|
ircd::db::property(const column &column,
|
||||||
|
const string_view &name)
|
||||||
|
{
|
||||||
|
std::map<std::string, double> ret;
|
||||||
|
database::column &c(const_cast<db::column &>(column));
|
||||||
|
database &d(const_cast<db::column &>(column));
|
||||||
|
d.d->GetMapProperty(c, slice(name), &ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
size_t
|
size_t
|
||||||
ircd::db::bytes(const column &column)
|
ircd::db::bytes(const column &column)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue