Serializer class

houdoux09 via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Feb 22 10:34:26 PST 2017


Hello, i am new in D and i have a problem.
I would like to retrieve the names of the variables and their 
value.
But i can not retrieve the value of the array.

class Test
{
     public int a;
     public Test[] b;

     this()
     {
       a = 1;
       b = [new Test(), new Test()];
     }
}

//======================================================================

void Read(T)(T value)
{
    foreach(i, mm; value.tupleof)
    {
       writeln(__traits(identifier, value.tupleof[i]), " = ", mm);

       if(isArray!(typeof(mm)))
       {
           Read(mm[0]); //Error
       }
    }
}

void main(string[] args)
{
    Read(new Test());
}

Thank you for your help.


More information about the Digitalmars-d-learn mailing list