Boost logo

Boost :

From: Arkadiy Vertleyb (vertleyb_at_[hidden])
Date: 2007-05-30 17:00:42


"Rene Rivera" <grafikrobot_at_[hidden]> wrote

> Here's part of a short
> example of what we are considering:
>
> template <typename C>
> struct Person
> : rsi::db::schema::table_def< C, Person<C> >
> {
> column id;
> column first_name;
> column last_name;
> column address;
> column mail_address;
> column phone;
>
> template <typename T>
> typename T::result_type operator()(T const & transform)
> {
> return transform(
> table("Person")
> <<= id("id")
> % integer[autoincrement]
> & not_null & primary_key
>
> <<= first_name("first_name")
> % character(50)[varying]
> & not_null
>
> <<= last_name("last_name")
> % character(50)[varying]
> & not_null
>
> <<= address("address_id")
> >> Address<C>().id
>
> <<= mail_address("mail_address_id")
> >> Address<C>().id
>
> <<= phone("phone")
> % character(20)[varying]
> & not_null
> );
> }
> };

Do I understand correctly that this code maps a database record into a C++
structure? Is it possible to enforce correct types here, instead of using
universal "column" type?

Regards,
Arkadiy


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk