DumpEnumValues.refscript

This page describes the DumpEnumValues RefactorScript shipped with VisualGDB.

Overview

This script generates a function for translating an enum value to a string.
In order to run this script, first select an enum in Code Explorer -> Outline.

Script

[Main]
generator GenerateEnumDump(Enum enum)
{
>const char *Dump$enum.ShortName($enum.ShortName value)
>{
>    switch(value)
>    {
    foreach(val in enum.Values)
    {
>    case $val.ShortName:
>        return "$val.ShortName";
    }
>    default:
>        return NULL;
>    }
>}
}

Sample Input

enum TestEnum
{
    Value1,
    Value2,
    Value3,
};

Sample Output

const char *DumpTestEnum(TestEnum value)
{
    switch(value)
    {
    case Value1:
        return "Value1";
    case Value2:
        return "Value2";
    case Value3:
        return "Value3";
    default:
        return NULL;
    }
}
A detailed reference on RefactorScript syntax and data model is available here.
See this page for a full list of RefactorScripts shipped with VisualGDB.