Im­prove this page Quickly fork, edit on­line, and sub­mit a pull re­quest for this page. Re­quires a signed-in GitHub ac­count. This works well for small changes. If you'd like to make larger changes you may want to con­sider using local clone. Page wiki View or edit the com­mu­nity-main­tained wiki page as­so­ci­ated with this page.

std.​demangle

Jump to: demangle

De­man­gle D man­gled names.

Li­cense:
Boost Li­cense 1.0.

Au­thors:
Wal­ter Bright, Thomas Kuehne, Frits van Bom­mel

Source:
std/de­man­gle.d

string de­man­gle(string name);
De­man­gle D man­gled names.

If it is not a D man­gled name, it re­turns its ar­gu­ment name.

Ex­am­ple:
This pro­gram reads stan­dard in and writes it to stan­dard out, pretty-print­ing any found D man­gled names.
import core.stdc.stdio : stdin;
import std.stdio;
import std.ascii;
import std.demangle;

void test(int x, float y) { }

int main()
{
    string buffer;
    bool inword;
    int c;

    writefln("Try typing in: %s", test.mangleof);
    while ((c = fgetc(stdin)) != EOF)
    {
        if (inword)
        {
            if (c == '_' || isAlphaNum(c))
                buffer ~= cast(char) c;
            else
            {
                inword = false;
                write(demangle(buffer), cast(char) c);
            }
        }
        else
        {   if (c == '_' || isAlpha(c))
            {
                inword = true;
                buffer.length = 0;
                buffer ~= cast(char) c;
            }
            else
                write(cast(char) c);
        }
    }
    if (inword)
        write(demangle(buffer));
    return 0;
}