Christof Petig schrieb:

Vinzenz 'evilissimo' Feenstra schrieb:
Hi,

I've attached the class query_args which can be used as VA_ARGS
replacement for the methods database::execute and database::fetch

a possible signature of database::execute
  void database::execute( query_args & args );

Thinkable usage will be something like this:    ( db is a object of
database )
db.execute( db.query("INSERT INTO TEST VALUES( ? , ? , ? , ? )") %
value1 % value2 % value 3 % value 4);
Let me know what you're thinking about it.

I prefer your (or boosts) % syntax over my std::vector variant.
IIRC this relates to the sqlite3.binary branch, doesn't it?

   Christof
Sorry I don't know which branch it is related too. I've just done what Nathaniel has asked me for.

We talked about it this night and decided not to give up the va_args. Instead we're using a struct now which helps us to identify the value. So we can now use SQLITE_STATIC as argument for sqlite3_bind_text and sqlite3_bind_blob and can figure out in the methode database::fetch what kind of parameter was given.

The usage for now is:
std::string query_ = "SELECT foo FROM bar where id = ?";
execute(query(query_), text(id) );

or
execute( "SELECT foo FROM bar where id = ?", text(id) );

There are to functions text() and blob()

text does take either char const* or std::string const &
blob does take either void const* and size in bytes, or char const* and size in bytes.

I'm sending the PATCH for it soon.


BR Vinzenz




_______________________________________________
Monotone-devel mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/monotone-devel

Reply via email to