Christian Henning wrote:
Hi there,
I like and use SOCI, as well. Although, today I found out about litesql and I like their approach of generating c++ code from xml based table definitions. So, I think a cross of both would be nice.
Interesting, but this seems fairly limited to a very specific mapping. What if I need to change the mapping names or key associations? And, I have come out of the closet -- I hate xml as a primary 'input language'. If you're going to all the trouble of writing a generator, why not write one with simplified data specification language? Off the top of my head -- imagine something like more like this: schema example { type Mother; //forward declare type Father; type Office; type Role {}; type Employee : Role { //1 to many bi-directional, required Office office <-> employees[0..*]; } type Office { Employee employees[0..*] <-> office; //needs to match Employee } type Student : Role { } type School { string name; } //alternative way to specify a relation outside the type //Student will have an optional relation to school //School will have 0 to many students relation StudentSchool { Student.school[0..1] <-> School.students[0..*]; } enum Sex { Male=0, Female=1 }; //The obvious mapping Table = Person type Person { string name; //mapped to column name in table Person Sex sex; integer age = 0; //automatically generates Table PersonRoles Role roles[0..*]; //unidirectional 0..m relation //Generates a field for mother id Person mother; //unidirectional required relation Person father; //automatically generates a join table PersonSiblings Person siblings[0..*] <-> siblings[0..*];//bidirectional m-m }; } database Exampledb uses schema example;
I did my own code generator on top of SOCI but not with all the bang that litesql have. The good thing about generators is that you would deal with sql statements a lot less, since they can be generated by the code generator. The C++ on SOCI generator might be a nice project for SoC.
Possibly, but to accept such a project we would be over the edge of *not boost* since SOCI isn't part of Boost. Yes, the intention is there, but there's literally hundreds of other proposals where the intention was there. Getting SOCI Boostified has a direct relation to Boost. All that said, we did accept a couple projects last year that were more related to 'C++' in general than Boost, so it might be possible we would be willing to do one of these.
This reminds me: I always wanted to ask if there is something similar to Javaspaces ( http://en.wikipedia.org/wiki/JavaSpace ) out there for C++.
The OMG has a specification call Data Local Reconstruction Layer which provides this sort of functionality in a cross-language/platform manner. Unfortunately, there's no open source implementation of it and it's incredibly complex to create one. It's a good idea though... http://www.omg.org/cgi-bin/doc?formal/07-01-01 Jeff