private CharSequence generateEnumDisplay(final List<Token> tokens, final Token encodingToken)
    {
        final String enumName = formatClassName(encodingToken.applicableTypeName());
        final StringBuilder sb = new StringBuilder();

        new Formatter(sb).format("\n" +
            "    static const char *c_str(const %1$s::Value value)\n" +
            "    {\n" +
            "        switch (value)\n" +
            "        {\n",
            enumName);

        for (final Token token : tokens)
        {
            new Formatter(sb).format(
                "            case %1$s: return \"%1$s\";\n",
                formatForCppKeyword(token.name()));
        }

        sb.append("            case NULL_VALUE: return \"NULL_VALUE\";\n").append("        }\n\n");

        if (shouldDecodeUnknownEnumValues)
        {
            sb.append("        return \"SBE_UNKNOWN\";\n").append("    }\n\n");
        }
        else
        {
            new Formatter(sb).format(
                "        throw std::runtime_error(\"unknown value for enum %1$s [E103]:\");\n" +
                "    }\n\n",
                enumName);
        }

        new Formatter(sb).format(
            "    template<typename CharT, typename Traits>\n" +
            "    friend std::basic_ostream<CharT, Traits> & operator << (\n" +
            "        std::basic_ostream<CharT, Traits> &os, %1$s::Value m)\n" +
            "    {\n" +
            "        return os << %1$s::c_str(m);\n" +
            "    }\n",
            enumName);

        return sb;
    }
\n");
        sb.append("     * The states in which a encoder/decoder/codec can live.\n");
        sb.append("     *\n");
        sb.append("     * <p>The state machine diagram below, encoded in the dot language, describes\n");
        sb.append("     * the valid state transitions according to the order in which fields may be\n");
        sb.append("     * accessed safely. Tools such as PlantUML and Graphviz can render it.\n");
        sb.append("     *\n");
        sb.append("     * <pre>{@code\n");
        fieldPrecedenceModel.generateGraph(sb, "     *   ");
        sb.append("     * }</pre>\n");
        sb.append("
sbe-tool/src/main/java/uk/co/real_logic/sbe/generation/cpp/CppGenerator.java