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/prepared-query.hxx | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'odb/prepared-query.hxx') diff --git a/odb/prepared-query.hxx b/odb/prepared-query.hxx index b321564..5fc4783 100644 --- a/odb/prepared-query.hxx +++ b/odb/prepared-query.hxx @@ -86,6 +86,29 @@ namespace odb return r; } + typename object_traits::pointer_type + execute_one () + { + return execute (false).one (); + } + + bool + execute_one (T& object) + { + return execute (false).one (object); + } + + T + execute_value () + { + // Compiler error pointing here? The object must be default- + // constructible in order to use the return-by-value API. + // + T o; + execute (false).value (o); + return o; + } + const char* name () const { -- cgit v1.1