diff options
author | Michael Shepanski <michael@codesynthesis.com> | 2014-11-04 16:10:03 +1100 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2014-11-10 16:43:00 +0200 |
commit | 6375147d5ae76a84dd64f1996cb0d9d501839db6 (patch) | |
tree | 1240e3b8c1567fde1ae11d0c93e5b38c15111506 /odb/prepared-query.hxx | |
parent | 1f217e38f7507758da1d33d46e675e801621aa38 (diff) |
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).
Diffstat (limited to 'odb/prepared-query.hxx')
-rw-r--r-- | odb/prepared-query.hxx | 23 |
1 files changed, 23 insertions, 0 deletions
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<T>::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 { |