List:MySQL++« Previous MessageNext Message »
From:Wolfram Arnold Date:May 19 2005 9:31am
Subject:[Bug?] Missing implementation for value_list(vector<bool>*...)
View as plain text  
Hi,

I'm learning about SSQL's and want to use the equal_list method with the
vector<bool>* signature.  The following example...

---------------
#include <mysql++.h>
#include <custom.h>
#include <iostream>
#include <string>
#include <vector>

using namespace std;
using namespace mysqlpp;

sql_create_2(MyTestStruct,
	     1,
	     0,
	     string, MyStringField,
	     int, MyIntField);

int main(int argc, char const*const* argv) {
  MyTestStruct testssql(argc>1 ? argv[1] : "Dummy Field Data");
  vector<bool> field_selection;
  for (int i=0; i < argc-2 && i < 2; ++i) {
    field_selection.push_back
      (argv[i+2][0]=='f' || argv[i+2][0]=='0' ? false : true);
  }
  cout << "Field list:\n" << testssql.field_list() << endl;
  cout << "Value list:\n" << testssql.value_list() << endl;
  cout << "Equal list:\n" << testssql.equal_list(&field_selection)
<<
endl;
  return 0;
}
-------------------------

compiles but linking fails with the error:

g++ -c -g -I. -I/usr/include/mysql -I/usr/local/mysql++ ssql-test.cpp
g++ -o ssql-test ssql-test.o -lmysqlpp
ssql-test.o(.gnu.linkonce.t._ZNK12MyTestStruct10equal_listEPSt6vectorIbSaIbEE+0x34): In
function `MyTestStruct::equal_list(std::vector<bool, std::allocator<bool> >*)
const':
/usr/include/c++/3.3/bits/stl_bvector.h:192: undefined reference to
`MyTestStruct_cus_equal_list<mysqlpp::quote_type0>
MyTestStruct::equal_list<mysqlpp::quote_type0>(char const*, char const*,
mysqlpp::quote_type0, std::vector<bool, std::allocator<bool> >*) const'
collect2: ld returned 1 exit status
make: *** [ssql-test] Error 1
wolfram@localhost:/usr/src/pmw$ ../mysql++-1.7.35/doc/ssqls-pretty <
ssql-test.cpp > ssql-test-expanded.cpp

Upon further inspection, it seems that the expansion of the SSQL is
missing an implementation for the function template: 

template <class Manip> inline MyTestStruct_cus_equal_list<Manip>
MyTestStruct::equal_list(cchar *d, cchar *c, Manip m, MyTestStruct_enum
i1, MyTestStruct_enum i2) const {
  return MyTestStruct_cus_equal_list<Manip> (this, d, c, m, i1, i2);
}

which is declared but not implemented.

Admittedly, there is an implementation for a similar-looking template
that takes individual bool variables instead of a vector<bool>, like so:

template <class Manip> inline MyTestStruct_cus_equal_list<Manip>
MyTestStruct::equal_list(cchar *d, cchar *c, Manip m, bool i1, bool i2)
const {
  return MyTestStruct_cus_equal_list<Manip> (this, d, c, m, i1, i2);
}

but in my application, I'm adding an additional layer of abstraction
that would not be possible if I had to enumerate the parameters
individually.

Is this interface not meant to be used like this?  If it is supposed to
be used, I want to throw out another question:  Why is the vector<bool>*
passed as non-const pointer?  I also saw that the return-value objects
(MyTestStruct_cus_equal_list, etc.) carry a bool member "del_vector"
which, if true, would provoke deletion of the vector<bool>* in the
destructor.  However, this variable is defaulted to false and nowhere
exposed in the interface.  Could the the vector<bool> simply be passed
as const reference (const vector<bool>&)?  It seems that the
implementations in vallist.h goes along these lines.

I'm happy to play with this and try to fix it, but before I launch into
this, I want to know if there is some motivation for this that I'm
missing.

Thanks,

Wolfram

-- 
Wolfram Arnold <wolfram@stripped>

Thread
[Bug?] Missing implementation for value_list(vector<bool>*...)Wolfram Arnold19 May
  • Re: [Bug?] Missing implementation for value_list(vector<bool>*...)Chris Frey19 May
    • Re: [Bug?] Missing implementation for value_list(vector<bool>*...)Wolfram Arnold21 May
      • Re: [Bug?] Missing implementation for value_list(vector<bool>*...)Warren Young23 May
Re: [Bug?] Missing implementation for value_list(vector<bool>*...)Warren Young23 May