Introspection/Reflection/etc on Linux

J Arrizza cppgent0 at gmail.com
Thu Nov 3 22:52:29 PDT 2011


Here's my changes to it:

   //Convert a string representation of a type, produced by typeinfo into a
.stringof representation
    string typeinfo2stringof(string id){
        auto rid = retro(id);
        auto r1  = find(rid, '.');
        auto rb  = find(rid, '!');
        auto r1len = r1.source.length;

        if(!rb.empty) {
            auto r1a = r1;
                 r1a.popFront;
                  rb.popFront;
            auto r2  = find(r1a,'.');
            auto r1alen = r1a.source.length;
            auto r2len = r2.source.length;
            auto rblen = rb.source.length;
            assert(id[r2len..rblen]==id[r1len..r1len+ (rblen-r2len)],
"Internal error in std.Variant regarding converting toString to stringof.");
            if(r1len+(rblen-r2len) >= id.length ) {
                id = id[r2len..r1alen];
            } else {
                id = id[r2len..r1alen]~id[r1len +(rblen-r2len)..$];
            }
        } else {
            id = id[r1len..$];
        }
        return id;
    }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20111103/b7640025/attachment.html>


More information about the Digitalmars-d mailing list