How to write a class proxy ?

2019-03-20 Thread boolangery via Digitalmars-d-learn
Hi, What is the best way to write a class proxy ? I need to intercept attribute access. Example: The user write a PODO: class User { string name; } Then he use my library: auto user = mylib.get!User(); // return a proxy here writeln(user.name); // intercept user.name access (how to do

Re: Compile-time associative array

2019-03-20 Thread boolangery via Digitalmars-d-learn
On Tuesday, 19 March 2019 at 23:41:58 UTC, Steven Schveighoffer wrote: On 3/19/19 7:22 PM, Bastiaan Veelo wrote: Beware that a CT AA stores its elements in a different order than a RT AA, which you would notice in a foreach, for example. Yes, this is the issue -- the runtime AA depends on

Compile-time associative array

2019-03-19 Thread boolangery via Digitalmars-d-learn
Hi, I want to use a constant associative array in a ctfe-able function. Example: string ctfeableFunction() { return Foo["foo"]; } Then I force ctfe with: enum res = ctfeableFunction(); When I use an enum like: enum Foo = ["foo" : "bar"]; It works fine. D-Scanner keep saying to me:

automapper v1.0.0

2019-01-21 Thread boolangery via Digitalmars-d-learn
Hi, AutoMapper is an object-object mapper. It use compile-time generated mapper to try to avoid any overhead. I'm posting in this section, because I'm not a D expert and any feedback will be appreciated :) Have a look: https://github.com/boolangery/d-automapper

Compile time code generation

2018-11-16 Thread boolangery via Digitalmars-d-learn
Hi, Is something like this is doable ? --- // all compile time MapperGen.Create!(A, B) .Map!("p1", "p2") .Map!("myprop", "otherprop") .Gen(); // The code above must generate something like // // class Mapper { // B

Deserialize json on runtime type with vibed

2018-05-12 Thread boolangery via Digitalmars-d-learn
Hi, I want to do something like that: The user first register some type associated to a string and a callback registerHandler!Foo("foo", (res) { info("message received"); }); I want the callback to be called when a json packet containing the string "foo" arrives on a transport layer.