List:MySQL++« Previous MessageNext Message »
From:Don Thompson Date:October 9 2004 1:23am
Subject:Re: compiling mysql++ examples (fwd)
View as plain text  
I'm not trying to insert the c++ class.  This code uses the template
insert function Query::insert() which uses SQLQuery::insert().  This
function uses the class functions table(), field_list() and value_list()
from the class supplied as the template class (CLdata).  See query1.hh and
sql_query1.hh which define these template classes.

<...from sql_query1.hh...>
  template <class T> SQLQuery& insert(const T &v) {
    reset();
    *this << "INSERT INTO " << v.table() << " (" << v.field_list()
          << ") VALUES (" << v.value_list() << ")";
    return *this;
  } //:
my example is not complete, in that it does not show the value_list
implementation, but this usage of insert() simply performs the db INSERT
as show above, getting table, fields and values from the classes
functions.

this template function is instantiated as:
   template <class CLdata> Query& Query::insert(const CLdata &v)

the compiler error messsage are:
/usr/local/mysql++-1.7.15/sqlplusint/sql_query1.hh: In member function `
   SQLQuery& SQLQuery::insert(const T&) [with T = CLdata]':
/usr/local/mysql++-1.7.15/sqlplusint/query1.hh:83:   instantiated from
`MysqlQuery&
MysqlQuery::insert(const CLdata&) [with T = CLdata]'
cudb.cc:21:   instantiated from here
/usr/local/mysql++-1.7.15/sqlplusint/sql_query1.hh:178: error: passing `const
   CLdata' as `this' argument of `std::string& CLdata::value_list()' discards
   qualifiers
/usr/local/mysql++-1.7.15/sqlplusint/sql_query1.hh:178: error: passing `const
   CLdata' as `this' argument of `std::string& CLdata::field_list()' discards
   qualifiers
/usr/local/mysql++-1.7.15/sqlplusint/sql_query1.hh:178: error: passing `const
   CLdata' as `this' argument of `SQLString& CLdata::table()' discards
   qualifiers
make[3]: *** [cudb.o] Error 1

Why does is it complaining about 'discards qualifiers'?



> Don Thompson wrote:
>> You're right,  the junk was test code with const qualifier, but it
>> should be removed for my example,
>> ie query.insert(*this).  Using this change, I get the complaint about
>> const:  I know we're getting
>> into c++ issues here.
>
> Wait just a minute....it seems that you're trying to insert an arbitrary
> C++ class into the database.  That cannot work.  This is not Java and,
> and MySQL is not an OODB!
>
> You need to use the SQLSS mechanism; in order to copy the data from your
> C++ class to the SQLSS structure, you will create a non-const object on
> the stack, so constness won't be a problem.  See the custom* examples.
>
> --
> MySQL++ Mailing List
> For list archives: http://lists.mysql.com/plusplus
> To unsubscribe:    http://lists.mysql.com/plusplus?unsub=1
>
>

Thread
compiling mysql++ examples (fwd)Enrique Farfan5 Oct
  • Re: compiling mysql++ examples (fwd)Warren Young5 Oct
  • Re: compiling mysql++ examples (fwd)Don Thompson8 Oct
    • Re: compiling mysql++ examples (fwd)Warren Young8 Oct
  • Re: compiling mysql++ examples (fwd)Don Thompson8 Oct
    • Re: compiling mysql++ examples (fwd)Warren Young8 Oct
      • Re: compiling mysql++ examples (fwd)Don Thompson9 Oct
        • Re: compiling mysql++ examples (fwd)Chris Frey9 Oct