Hi,
I know how disliked asking questions without research is and let me first
assure you that I tried and failed.
Let me start with general description of the problem and add details later:
I'm trying to write type_convertion struct for my custom class City. I
believe I did everything by the documentation:
http://soci.sourceforge.net/doc/exchange.html#object_relational
Here's the code:
#ifndef _CITY_H
> #define _CITY_H
> #include <string>
> #include <soci/soci.h>
>
> class City{
> public:
> int Nr;
> std::string Name;
>
double Population;
>
double Latitude;
> double Longitude;
> std::string Owner;
> City();
> City(const City& orig);
> virtual ~City();
> private:
> };
>
> namespace soci {
> template<>
> struct type_conversion<City> {
> typedef values base_type;
>
> static void from_base(values const &v, indicator, City & c) {
> c.Nr = v.get<int>("Nr");
> c.Name = v.get<std::string>("Name");
> c.Population = v.get<double>("Population");
> c.Latitude = v.get<double>("Latitude");
> c.Longitude = v.get<double>("Longitude");
> c.Owner = v.get<std::string>("Owner");
> }
>
> static void to_base(const City &c, values& v, indicator ind) {
> v.set("Nr", c.Nr);
> v.set("Name", c.Name);
> v.set("Population", c.Population);
> v.set("Latitude", c.Latitude);
> v.set("Longitude", c.Longitude);
> v.set("Owner", c.Owner);
> ind = i_ok;
> }
> };
> }
>
main.cpp has:
#include <stdlib.h>
> #include "City.h"
> #include <soci/soci-sqlite3.h>
> #include <soci/soci.h>
>
> using soci::into;
> using soci::use;
>
> int main(int argc, char** argv) {
> soci::session db(soci::sqlite3, "database.db");
> City c;
> c.Nr = 2;
> c.Name = "Warsaw";
> c.Population = 1;
> c.Latitude = 1;
> c.Longitude = 1;
> c.Owner = "PL";
> // db << "insert into cities values(null, :nr, :name, :pop, :lat, :long,
> :owner)" << use(c);
> db.close();
> return (EXIT_SUCCESS);
> }
>
Project compiles and runs fine until I uncomment the line with use(c).
That's when I get this unreadable build output: http://www.nopaste.pl/fi9.
("Pokaz jako czysty tekst" will make it plain text if you don't like the
colours. My guess is that important part goes up from line 11. Later on
compiler tries to use basic << operator associated with iostream.
All things happen at Ubuntu 8.04 and Netbeans 6.7 with C++ plugin. Code is a
fresh download from repository using git clone. I was unable to compile
sources with make, make install routine (I got some errors, but I've got no
experience with that, that's why I use IDE), but succeeded with make -f
Makefile.basic in core directory + sqlite3 backend directory (didn't do
tests). Then I copied *.a files to /usr/local/lib and header files from both
directories to /usr/include.
The project has libraries libsoci-core.a, libsoci-sqlite3.a and libsqlite3
added to linker.
Thanks in advance for reading that far. I would appreciate any clues that
may lead me to understand what I'm doing wrong.
Best regards,
Daniel
------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
Soci-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/soci-users