From 6375147d5ae76a84dd64f1996cb0d9d501839db6 Mon Sep 17 00:00:00 2001 From: Michael Shepanski Date: Tue, 4 Nov 2014 16:10:03 +1100 Subject: Implement {query,execute}_{one,value}() shortcut functions Useful in situations where the query is know to return at most one element (*_one) or exactly one element (*_value). --- odb/result.hxx | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'odb/result.hxx') diff --git a/odb/result.hxx b/odb/result.hxx index 93c0dce..5f84342 100644 --- a/odb/result.hxx +++ b/odb/result.hxx @@ -209,6 +209,23 @@ namespace odb return impl_ ? impl_->size () : 0; } + // query_one() and query_value() implementation details. + // + public: + typename object_traits::pointer_type + one (); + + bool + one (T&); + + // We cannot return by value here since result can be instantiated + // for an abstract type (polymorphic abstract base) and it seems + // the signature must be valid to the point being able to call the + // necessary constructors. + // + void + value (T&); + private: friend class result; @@ -222,6 +239,8 @@ namespace odb } } +#include + #include #endif // ODB_RESULT_HXX -- cgit v1.1