ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> boost
boost
Re: [boost] Interest in an ODBC library?
by Brock Peabody other posts by this author
Aug 3 2005 1:09PM messages near this date
Re: [boost] Interest in an ODBC library? | Re: [boost] Interest in an ODBC library?
SOURCE Sorry for the late reply, my filter threw this message in the trash bin.

>  -----Original Message-----
>  From: boost-bounces@[...].org
[mailto:boost-bounces@[...].org]
>  On Behalf Of Caleb Epstein
>  
>  On 7/28/05, Brock Peabody <brock.peabody@[...].com> wrote:
>  
>  >    table("customer") [
>  >       *field("id")     = &customer::id,
>  >       field("name")    = &customer::name,
>  >       field("number")  = &customer::number,
>  >
>  >       table("tax_exempt")[
>  >          -field("customer"),
>  >          field("state_id")   = &tax_exempt_data::state_id
>  >       ]
>  >       = &customer::tax_exempt
>  >    ];
>  
>  I assume 'customer' is a class with data members id, name, number?

Exactly.  I tried to keep the example as short as I could.  You can
assign the above expression to a serializer:

   serializer<customer>  s = table(....

      //loads all customers named Bob
   std::vector<customer>  customers =
      s.load<std::vector<customer>  >(database, "name = 'Bob'");

      //throws if more than one 
   boost::optional<customer>  c =
      s.load<boost::optional<customer>  >(database, "id = 5");

Usually in a case like this customer wouldn't have an id field, it would
be the key to a map:

   typedef std::map<int,customer>  customer_map;

   typedef std::pair<int,customer>  pair_type;

   serializer<pair_type>  s =
      table("customer") [

         *field("id")  = &pair_type::first
         field("name") = &customer::name,
      
         ...
      ];

   customer_map m = s.load<customer_map> (db, "id < 50");
   
>  
>  [...]
>  
>  > If any of that sounds useful I'd love to help out.
>  
>  It sounds very useful!  Are you planning on sharing the code you've
>  written, or would this be a start-from-scratch approach?

Thanks!

I'll share all I've learned but it might be better to start from
scratch.  I've made too many assumptions that are true in my world but
not in general and we can probably come up with a better syntax than
what I've got.

Where do you think would be a good place to start?  I could put together
and post an abstract database interface with a postgresql implementation
for starters.

Brock

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Thread:
Brian Braatz
Brock Peabody
Caleb Epstein
Brock Peabody
Caleb Epstein
Brock Peabody
Jonathan Wakely
Daryle Walker
Jonathan Wakely
Brock Peabody
Jonathan Wakely
Jonathan Wakely
Brock Peabody
Caleb Epstein
Caleb Epstein
Brock Peabody
Jonathan Wakely
Brock Peabody

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved