On Tue, May 03, 2005 at 05:17:10PM -0400, Mark Merendino wrote:
> The vector form (not shown above) allows you to pass a boolean vector
> which is a time saver if you use the some pattern more than once as it
> avoids having to create the vector from the arguments each time. If a is
> a boolean vector then a[0] will hold wether to include the first
> variable a[1] the second etc... For example:
>
>
> vector<bool> a;
> a[0] = false; a[1] = false; a[2] = true; a[3] = true; a[4] =
> false;
> query << "SELECT * FROM stock WHERE " << q.equal_list(" AND ",
> a);
>
> ///////////
>
> (Note: Im passing "&a" because it wants to receive a pointer to a
> vector. Think this is a typo in the example.)
Yep. The declaration in custom.pl takes a pointer.
> However im getting and unresolved external symbol. (...Note, "SSB" is my
> class)
>
> "public: class SSB_cus_equal_list<enum mysqlpp::quote_type0> __thiscall
> SSB::equal_list<enum mysqlpp::quote_type0>(char const *, char const *,
> enum mysqlpp::quote_type0, class std::vector<bool,class
> std::allocator<bool> > *) const"
And there's only a declaration, no definition.
I'm looking inside vallist.h, and there appears to be code that handles
vector<bool> arrays, but it also requires you to mess with manipulators.
There's a factory function called equal_list() that goes like this (untested):
query << "SELECT * FROM stock WHERE " <<
equal_list(seq1, seq2, " AND ", " = ", manip, a);
Sequence 1 contains the field names, sequence 2 contains the values.
It expects the sequences to have begin() and end() iterator semantics.
The manipulator is used in the stream before each value (for escaping
or quoting).
This would be wonderful if I could do something like this:
equal_list(q.field_list(), q.value_list(),
" AND ", " = ", some_magical_manipulator, a);
But I can't find any code to support this behaviour.
I'll see if I can cook up a patch, unless someone beats me to it. :-)
- Chris