Author: wyoung
Date: Tue Jun 19 13:24:57 2007
New Revision: 1571
URL: http://svn.gna.org/viewcvs/mysqlpp?rev=1571&view=rev
Log:
Overloaded Query::for_each() and Query::store_in() with versions that
don't take a query string. They use the query string held by the object
already, such as one built using the stream interface.
Modified:
trunk/lib/query.h
Modified: trunk/lib/query.h
URL:
http://svn.gna.org/viewcvs/mysqlpp/trunk/lib/query.h?rev=1571&r1=1570&r2=1571&view=diff
==============================================================================
--- trunk/lib/query.h (original)
+++ trunk/lib/query.h Tue Jun 19 13:24:57 2007
@@ -394,6 +394,27 @@
return fn;
}
+ /// \brief Execute the query, and call a functor for each returned row
+ ///
+ /// Just like for_each(const SQLString&, Function), but it uses
+ /// the query string held by the Query object already
+ ///
+ /// \param fn the functor called for each row
+ /// \return a copy of the passed functor
+ template <typename Function>
+ Function for_each(Function fn)
+ {
+ mysqlpp::ResUse res = use();
+ if (res) {
+ mysqlpp::NoExceptions ne(res);
+ while (mysqlpp::Row row = res.fetch_row()) {
+ fn(row);
+ }
+ }
+
+ return fn;
+ }
+
/// \brief Execute a query, conditionally storing each row in a
/// container
///
@@ -429,6 +450,31 @@
return fn;
}
+ /// \brief Execute the query, conditionally storing each row in a
+ /// container
+ ///
+ /// Just like store_if(Sequence&, const SQLString&, Function), but
+ /// it uses the query string held by the Query object already
+ ///
+ /// \param seq the destination container; needs a push_back() method
+ /// \param fn the functor called for each row
+ /// \return a copy of the passed functor
+ template <class Sequence, typename Function>
+ Function store_if(Sequence& seq, Function fn)
+ {
+ mysqlpp::ResUse res = use();
+ if (res) {
+ mysqlpp::NoExceptions ne(res);
+ while (mysqlpp::Row row = res.fetch_row()) {
+ if (fn(row)) {
+ seq.push_back(row);
+ }
+ }
+ }
+
+ return fn;
+ }
+
/// \brief Return next result set, when processing a multi-query
///
/// There are two cases where you'd use this function instead of
_______________________________________________
Mysqlpp-commits mailing list
[email protected]
https://mail.gna.org/listinfo/mysqlpp-commits