From e9e25a08d4438f8a983cd2af7b17ecd906881c3c Mon Sep 17 00:00:00 2001 From: "Adam D. Ruppe" Date: Wed, 6 Nov 2013 15:08:20 -0500 Subject: [PATCH] replacing the old opDispatch now that some dmd bugs are fixed --- database.d | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/database.d b/database.d index eeabe0c..71ed709 100644 --- a/database.d +++ b/database.d @@ -667,7 +667,33 @@ class DataObject { string[string][string] multiTableKeys; // note this is not set internally tight now // but it can be set manually to do multi table mappings for automatic update + + string opDispatch(string field, string file = __FILE__, size_t line = __LINE__)() + if((field.length < 8 || field[0..8] != "id_from_") && field != "popFront") + { + if(field !in fields) + throw new Exception("no such field " ~ field, file, line); + + return fields[field]; + } + + string opDispatch(string field, T)(T t) + if((field.length < 8 || field[0..8] != "id_from_") && field != "popFront") + { + static if(__traits(compiles, t is null)) { + if(t is null) + setImpl(field, null); + else + setImpl(field, to!string(t)); + } else + setImpl(field, to!string(t)); + + return fields[field]; + } + + // vararg hack so property assignment works right, even with null + version(none) string opDispatch(string field, string file = __FILE__, size_t line = __LINE__)(...) if((field.length < 8 || field[0..8] != "id_from_") && field != "popFront") {