On 17/07/2014 2:13 AM, pfultz2 wrote:
Could you clarify what you mean by "do this"? QUINCE_MAP_CLASS builds a class with exactly the data members, function members, and bases that quince requires. Boost.Fusion already provides the ability to map the classes to fusion sequences.
But that is not what QUINCE_MAP_CLASS and QUINCE_MAP_CLASS_WITH_BASES do. Those macros define mapper classes with specific data members, function members, and bases, which are required by the rest of quince. Also the members and bases are exposed to user code, so they have to be defined in exactly the way that those macros define them.
Here is a very simple example how to build an ORM using Boost.Fusion in C++14:
https://gist.github.com/pfultz2/abbea635bdc8a4971424
Of course as a simple example, it doesn't map the types to the database types(it just uses `typeid` for illustration purposes only).
Now this example just demonstrates mapping to the database with fusion. The other half is building queries in C++. This can easily be done by taking advantage that the structs are adapted as associative sequences. So we can use the keys to refer to the fields. So we could build queries something like this:
table<person> p("person"); auto query = from(p) .where(at_keyfields::age(p) > 60) .select(at_keyfields::name(p));
Of course, some additional macros would be useful to reduce the boilerplate, but an ORM in C++ should really start with Boost.Fusion.
It sounds like you are proposing a new product, rather than a change to quince. I wish you well.
I'm not actually doing tuple manipulation here. That's not to say the task couldn't be solved by a detour through tuples, but it /would/ be a detour. But it would be a 'detour' that would save you from writing mapping macros.
I still need to define my mapper *class*, with its appropriate members and bases, as described here http://quince-lib.com/mapped_data_types/user_defined_class_types.html . When I come back from the tuples detour, how will I get this class defined? I think I will be back to using Boost.Preprocessor magic. By the way, you say "mapping macros" but it's really just one. The implementations of QUINCE_MAP_CLASS and QUINCE_MAP_CLASS_WITH_BASES both invoke one macro (QUINCE_DEFINE_CLASS_MAPPER_WITH_BASES) to do all the hard work. If I were to take the tuples detour, that would be the only site where it happens. Regards, --- Michael