0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-09-30 04:38:52 +02:00

ircd::db: Support map-based property retrieval.

This commit is contained in:
Jason Volk 2018-04-03 11:05:03 -07:00
parent 0bf6742ac9
commit cfb80085a8
3 changed files with 14 additions and 0 deletions

View file

@ -29,6 +29,7 @@ namespace ircd::db
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_int property(const column &, const string_view &name);
template<> prop_map property(const column &, const string_view &name);
// [GET] Tests if key exists
bool has(column &, const string_view &key, const gopts & = {});

View file

@ -22,6 +22,7 @@ namespace ircd::db
// Property information interface
using prop_int = uint64_t;
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<> prop_int property(const database &, const string_view &name);

View file

@ -3613,6 +3613,18 @@ ircd::db::property(const column &column,
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
ircd::db::bytes(const column &column)
{