www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.announce - Another SQLite3 wrapper

reply Alexey Khmara <alex.khmara gmail.com> writes:
Hello!

I tried to find any module to work with SQLite3 in D2, and failed. I
found either just bindings to old SQLite versions or D1 modules with
"craft-SQL-on-the-fly" interface, all abandoned.
So I want to add just another D2 SQLite3 bindings and OO-wrapper and
uploaded to GitHub: https://github.com/bayun/SQLite3-D
It seems that no-one wants to support bindings for current SQLite
version.. Well, I'll try to do this. But I currently use very small
subset of it's features, so it's mostly mechanical translation without
further testing.
My tiny OO interface supports prepare/bind style of statements, and
seems to work good :-) But I'm new to D, and will be grateful to
somebody who can check, if my code is correct and don't have subtle
bugs.
Also I cannot figure if this code can be writen simpler:

void getRow(T...)(ref T args) {
	foreach(i, arg; args) {
		args[i] = mixin("getValue!" ~ typeof(arg).stringof ~ "(i)");
	}

}

I want there to call appropriate overloaded function for each item of
args tuple, but I was not able to do this without mixin - compiler
gives syntax errors when I try to write something like "args[i] =
getValue!T[i](i);"

Also if I try to assign to arg, and not args[i], changes are not
propagated to variables given as function arguments, even if I have
foreach(ref... syntax. Is it a bug or I just don't understand
something?

--
WBR,
Alexey Khmara
Nov 15 2010
parent reply Jesse Phillips <jessekphillips+D gmail.com> writes:
While it might be better to update existing projects, here are some answers.

Alexey Khmara Wrote:

 I want there to call appropriate overloaded function for each item of
 args tuple, but I was not able to do this without mixin - compiler
 gives syntax errors when I try to write something like "args[i] =
 getValue!T[i](i);"
Try using: getValue!(T[i])(i), the !() shortcut doesn't work with arrays. Might be a bug, but I don't think it necessarily should.
 Also if I try to assign to arg, and not args[i], changes are not
 propagated to variables given as function arguments, even if I have
 foreach(ref... syntax. Is it a bug or I just don't understand
 something?
Not sure what your ref syntax looks like, but it should be like below. foreach(i, ref arg; args) {
Nov 15 2010
parent Alexey Khmara <alex.khmara gmail.com> writes:
2010/11/16 Jesse Phillips <jessekphillips+D gmail.com>:
 While it might be better to update existing projects, here are some answers.

 Alexey Khmara Wrote:

 I want there to call appropriate overloaded function for each item of
 args tuple, but I was not able to do this without mixin - compiler
 gives syntax errors when I try to write something like "args[i] =
 getValue!T[i](i);"
Try using: getValue!(T[i])(i), the !() shortcut doesn't work with arrays. Might be a bug, but I don't think it necessarily should.
 Also if I try to assign to arg, and not args[i], changes are not
 propagated to variables given as function arguments, even if I have
 foreach(ref... syntax. Is it a bug or I just don't understand
 something?
Not sure what your ref syntax looks like, but it should be like below. foreach(i, ref arg; args) {
I tried to use this: foreach(ref i, arg; args) { I was stupid - don't realized that ref affects only one argument, not all of them :-) Thanks, for suggestions, all works good now :-) But strangely, assign not to arg, but to args works also, this line: args = getValue!(T[i])(i); gets compiled and gives correct results... Not a bad, but I cannot understand why - seems like assigning one value to tuple... -- WBR, Alexey Khmara
Nov 15 2010