From cfb80085a8e4b37d2ad0e8a3b41f19a0d9998c33 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Tue, 3 Apr 2018 11:05:03 -0700 Subject: [PATCH] ircd::db: Support map-based property retrieval. --- include/ircd/db/column.h | 1 + include/ircd/db/database/database.h | 1 + ircd/db.cc | 12 ++++++++++++ 3 files changed, 14 insertions(+) diff --git a/include/ircd/db/column.h b/include/ircd/db/column.h index 5db6d3e06..f28b1184a 100644 --- a/include/ircd/db/column.h +++ b/include/ircd/db/column.h @@ -29,6 +29,7 @@ namespace ircd::db template 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 & = {}); diff --git a/include/ircd/db/database/database.h b/include/ircd/db/database/database.h index 611783187..54172640a 100644 --- a/include/ircd/db/database/database.h +++ b/include/ircd/db/database/database.h @@ -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; template R property(const database &, const string_view &name); template<> prop_int property(const database &, const string_view &name); diff --git a/ircd/db.cc b/ircd/db.cc index 412942a46..1ac19ad7e 100644 --- a/ircd/db.cc +++ b/ircd/db.cc @@ -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 ret; + database::column &c(const_cast(column)); + database &d(const_cast(column)); + d.d->GetMapProperty(c, slice(name), &ret); + return ret; +} + size_t ircd::db::bytes(const column &column) {