List:MySQL++« Previous MessageNext Message »
From:Warren Young Date:June 19 2007 4:44am
Subject:Re: Passing functors into query
View as plain text  
Joel Fielder wrote:
> 
> I thought it would be cool to be able to do this instead:
> 
> query << "select whatever";
> query.for_each(DoSomething());

I've added this, though I all but rewrote it for style reasons.  (Yes, 
I'm aware that you copied the style from Query::storein_sequence(), but 
I didn't write that. :) )

> This functionality could be added to the library (without breaking
> ABI???) by adding the following into Query (plus appropriate versions
> mirroring the storein functions):

I also added Query::store_if(), plus an example program to demonstrate it.

The example collects rows from the sample table with prime values in the 
"num" column.  I'm open to ideas for a better example than primality 
testing.  What I'm really after here is something as simple as possible, 
so as not to clutter the example, yet not so simple that you could write 
it as a WHERE clause, thus defeating the purpose.

One could argue that there should be two versions of store_if(), one for 
sequences and one for set type containers, but I can't really see the 
need.  It won't take a very strong example to get me to change my mind, 
though, since it'd be a function naming problem down the road if we do 
need a version for associative containers.

I also wonder if we need support for template queries?
Thread
Passing functors into queryJoel Fielder13 Apr
  • Re: Passing functors into queryWarren Young19 Jun
    • RE: Passing functors into queryJoel Fielder19 Jun
      • Re: Passing functors into queryWarren Young19 Jun
        • RE: Passing functors into queryJoel Fielder19 Jun
          • Re: Passing functors into queryWarren Young20 Jun
            • RE: Passing functors into queryJoel Fielder20 Jun
              • Re: Passing functors into queryWarren Young20 Jun
                • RE: Passing functors into queryJoel Fielder21 Jun