|
Boost Users : |
Subject: [Boost-users] [Q] opinion on basic C++ reflection implementation
From: Hajo Kirchhoff (mailinglists_at_[hidden])
Date: 2009-03-01 14:40:17
Hello all,
> Hello to be make it easy to read a table from a database
> and save the result with boost serialization (and to write back back to
> the database)
I have such as system working, including an odbc c++ wrapper. I've been
developing this since 2004, unfortunately have not had much time to do
some proper "marketing".
I've just restarted public development.
Here are some relevant links:
Entry point for the whole endevour:
http://www.litwindow.com/Library/index.html
This is a description of the 'reflection' mechanism.
http://www.litwindow.com/Library/Articles/dataabstractionlayer.htm
Basically my code looks like this:
struct Foo
{
SomeClass m_myaggregate;
int m_basic_datatype;
vector<SomeOtherClass> m_myvector;
};
The reflection definition requires this:
LWL_BEGIN_AGGREGATE(Foo)
PROP(m_myaggregate)
PROP(m_basic_datatype)
PROP(m_myvector)
LWL_END_AGGREGATE()
and currently you will also need a
LWL_IMPLEMENT_CONTAINER(vector<SomeOtherClass>)
Once you've written this, you can then
Foo myFoo;
litwindow::aggregate ag=make_aggregate(myFoo);
litwindow::aggregate::iterator i;
for (i=ag.begin(); i!=ag.end(); ++i) {
if (i->is_container()==false) {
printf("Member %s=%s", i->name(), i->to_string());
} else {
// print contents of a container
}
}
IOW use an iterator to iterate over the members of an aggregate.
The ODBC library allows
Foo myFoo;
odbc::table t("MyTable", m_odbc_connection);
t.bind(myFoo); // bind all members to columns of the same name in the
table "MyTable"
and then deal with the table.
This is the sourceforge project:
http://sourceforge.net/projects/litwindow
I am interested in boostifying this more than it currently is and
perhaps, if there is enough interest and perhaps some help from the
community in crossplatforming this, fixing the documentation enough so
that it might actually be reviewed at one time.
BTW, the current version in sourceforge also includes a C++ library
wrapper for ODBC, which is not yet mentioned in the documentation. The
build system is using boost.build now, although the code has only been
tested on Windows platform using Visual Studio compilers.
Best regards
Hajo
-- Hajo Kirchhoff Kirchhoff IT-Consulting Hilpertstr 13 91052 Erlangen Germany http://www.litwindow.com Phone: ++49 9131 209272
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net