diff options
Diffstat (limited to 'odb/result.hxx')
-rw-r--r-- | odb/result.hxx | 40 |
1 files changed, 34 insertions, 6 deletions
diff --git a/odb/result.hxx b/odb/result.hxx index eb7f370..9f7dcb0 100644 --- a/odb/result.hxx +++ b/odb/result.hxx @@ -76,6 +76,9 @@ namespace odb virtual void cache () = 0; + virtual std::size_t + size () = 0; + protected: void current (pointer_type p) @@ -233,6 +236,29 @@ namespace odb return *this; } + void + swap (result& r) + { + // @@ add swap() to shared_ptr. + // + details::shared_ptr<result_impl<T> > p (impl_); + impl_ = r.impl_; + r.impl_ = p; + } + + public: + iterator + begin () + { + return iterator (impl_.get ()); + } + + iterator + end () + { + return iterator (); + } + // Cache the result instead of fetching the data from the database // one object at a time. This is necessary if you plan on performing // database operations while iterating over the result. @@ -246,16 +272,18 @@ namespace odb } public: - iterator - begin () + bool + empty () const { - return iterator (impl_.get ()); + return impl_ == 0 || impl_->end (); } - iterator - end () + // Size is only known in cached results. + // + size_type + size () const { - return iterator (); + return impl_ ? impl_->size () : 0; } private: |