diff --git a/include/ircd/db/row.h b/include/ircd/db/row.h index 8136e9cc2..559aefcd2 100644 --- a/include/ircd/db/row.h +++ b/include/ircd/db/row.h @@ -39,7 +39,9 @@ struct ircd::db::row public: bool valid() const; // true on any cell valid; false on empty + bool valid_all() const; // true on all cell valid; false_ on empty bool valid(const string_view &) const; // true on any cell valid equal; false on empty + bool valid_all(const string_view &) const; // true on all cell valid equal; false on empty bool cached() const; // true on all cell cached bool cached(const string_view &) const; // true on all columns cached key diff --git a/ircd/db.cc b/ircd/db.cc index 476ae5f8b..41477766f 100644 --- a/ircd/db.cc +++ b/ircd/db.cc @@ -5351,13 +5351,13 @@ const } bool -ircd::db::row::valid() +ircd::db::row::valid_all(const string_view &s) const { - return std::any_of(std::begin(*this), std::end(*this), [] + return !empty() && std::all_of(std::begin(*this), std::end(*this), [&s] (const auto &cell) { - return cell.valid(); + return cell.valid(s); }); } @@ -5372,6 +5372,28 @@ const }); } +bool +ircd::db::row::valid_all() +const +{ + return !empty() && std::all_of(std::begin(*this), std::end(*this), [] + (const auto &cell) + { + return cell.valid(); + }); +} + +bool +ircd::db::row::valid() +const +{ + return std::any_of(std::begin(*this), std::end(*this), [] + (const auto &cell) + { + return cell.valid(); + }); +} + /////////////////////////////////////////////////////////////////////////////// // // db/cell.h