D Programming Language 2.0

- Comments
- D
- Search
- Home

Last update Sun Jan 20 11:39:25 2008

# std.demangle

Demangle D mangled names.

string demangle(string name);
  Demangle D mangled names.
  If it is not a D mangled name, it returns its argument name.
  Example:
  This program reads standard in and writes it to standard out, pretty-printing any found D mangled names.

      import std.stdio;
      import std.ctype;
      import std.demangle;

      int main()
      {   char[] buffer;
          bool inword;
          int c;

          while ((c = fgetc(stdin)) != EOF)
          {
      	if (inword)
      	{
      	    if (c == '_' || isalnum(c))
      		buffer ~= cast(char) c;
      	    else
      	    {
      		inword = false;
      		writef(demangle(buffer), cast(char) c);
      	    }
      	}
      	else
      	{   if (c == '_' || isalpha(c))
      	    {	inword = true;
      		buffer.length = 0;
      		buffer ~= cast(char) c;
      	    }
      	    else
      		writef(cast(char) c);
      	}
          }
          if (inword)
      	writef(demangle(buffer));
          return 0;
      }

Copyright © 1999-2008 by Digital Mars, All Rights Reserved | Page generated by Ddoc.