[ create a new paste ] login | about

Project: ncu
Link: http://ncu.codepad.org/7VQmQv2f    [ raw code | fork ]

GiM - D, pasted on Sep 2:
template RetriveFields(T, char[] name, int u)
{
        static if (is(T == struct) || is(T == class))
        {   
            static if (u < T.tupleof.length)
            {   
                static if (is(typeof(T.tupleof[u]) == struct)) {
                    const char[] RetriveFields = RetriveFields!(typeof(T.tupleof[u]),
                            (name~ (T.tupleof[u].stringof[T.stringof.length+2 .. $])), 0)
                        ~ RetriveFields!(T, name, u+1);
                } else static if (isArray!(typeof(T.tupleof[u]))) {
                    const char[] RetriveFields = RetriveFields!(typeof(T.tupleof[u]),
                            (name~ (T.tupleof[u].stringof[T.stringof.length+2 .. $])), 0)
                        ~ RetriveFields!(T, name, u+1);
                } else static if (T.tupleof[u].stringof[T.stringof.length+2 .. $] == ".this") {
                    const char[] RetriveFields = RetriveFields!(T, name, u+1);
                } else {
                    const char[] RetriveFields =  "(" ~ name ~ T.tupleof[u].stringof[T.stringof.length+2 .. $] ~ ") " ~ RetriveFields!(T, name, u+1);
                }
            } else
                const char[] RetriveFields = "";
        } else static if (isArray!(T)) {
            static if (u < T.length) {
                static if (is(typeof(T[0]) == struct)) {
                    const char[] RetriveFields = RetriveFields!(typeof(T[0]), name~"[0x"~tohex(u)~"]", 0) ~ RetriveFields!(T, name, u+1);
                } else static if (isArray!(T)) {
                    const char[] RetriveFields = RetriveFields!(typeof(T[0]), name~"[0x"~tohex(u)~"]", 0) ~ RetriveFields!(T, name, u+1);
                } else {
                    const char[] RetriveFields = name~"[0x" ~ tohex(u) ~ "]" ~ RetriveFields!(T, name, u+1);
                }
            } else {
                const char[] RetriveFields = "";
            }
        } else {
                    const char[] RetriveFields = "(" ~ name ~ ")";
        }
}


Create a new paste based on this one


Comments: