DustMite updated
Chad J
chadjoan at __spam.is.bad__gmail.com
Sun Mar 4 10:43:39 PST 2012
On 03/04/2012 12:04 PM, Andrej Mitrovic wrote:
> On 3/4/12, Vladimir Panteleev<vladimir at thecybershadow.net> wrote:
>> I pushed out another large update today.
>
> I can't believe I'm saying this, but I can't wait for my next ICE to
> try it out. :p
Here's one for DMD 2.057. Knock yourself out ;)
(As I mentioned in my other post, I can't build DustMite right now, or
I'd do it myself. But if you want one...)
----------------------------------------------
chad at Hugin ~/dprojects/database $ dmd ice.d
entity.(fld)
Internal error: e2ir.c 683
----------------------------------------------
import std.stdio;
scope class Query(string queryText)
{
static class Entity
{
private static size_t bufSize = 0;
private static size_t[string] offsets;
private static size_t registerField(T)(string varName)
{
auto offset = bufSize;
offsets[varName] = offset;
bufSize += T.sizeof;
return offset;
}
private void[] buf;
class fld(T,string varName)
{
T opCall()
{
auto i1 = offsets[varName];
return cast(T)buf[i1 .. i1 + T.sizeof];
}
static this()
{
registerField!T(varName);
}
}
this()
{
buf = new void[bufSize];
writefln("offsets = %s\n", offsets);
}
~this()
{
delete buf;
}
}
Entity e;
this()
{
e = new Entity();
}
}
void main()
{
scope query = new Query!(
"SELECT ONLY_NEEDED_COLUMNS"
"FROM contacts c"
"WHERE c.country = 'US'"
"AND c.sales > 10000;")();
auto entity = query.e;
//foreach(entity; query)
//{
auto email_addy = entity.fld!(char[],"email")();
auto full_name = entity.fld!(char[],"name")();
//Email.spam(email_addy, full_name, "We have this great new offer for
you!");
//}
}
More information about the Digitalmars-d
mailing list