Королев Илья wrote:
>> I proposed defining the structures in XML
>> or some other such language and create a preprocessor that translates
>> that into header files defining the structures.
> Unfortunately in closest period I'm enough
> busy, but in next months I'll try take it.
That's fine, I couldn't accept it before v3.0 anyway.
> are there any concrete ideas? Just to move in correct way.
Start with the file format. Something like this:
<?xml blah blah blah>
<ssqls class="MyStructureName" table="MyTableName">
<field type="mediumint" name="myFieldName" null="1" />
<field type="datetime" name="myOtherFieldName" />
The file name should use a unique extension (.ssqls ?) so you can write
build rules. For example, in Makefile syntax:
...takes mytables.ssqls and creates mytables.h. (Maybe creates
mytables.cpp, too, but I'm not certain about that. It might be better
if everything remained inline.)
For this to be valuable, the mechanism needs to:
1. Write clear, well-formatted C++ code
2. Create classes that are easy to subclass without problems. This
means that there should be as little public and protected methods and
data as possible.
3. Cope with different type systems. Notice above that I'm using SQL
type names. It should be smart enough to translate those into the
proper MySQL++ type names. Likewise, if I put in, say, time_t, it
should be able to figure out the right thing to do there, too.
4. Work with the Null<> template. Notice this in the first field
5. SSQLS structures should derive from a common base class. This let
you put some useful common code in the MySQL++ library itself, but more
importantly, it would let you make methods like Query::insert() into
regular methods instead of templates.