message: For sparse enums, use a switch statement to generate EnumNameXXX().
diff: @@ -981,6 +981,23 @@ class CppGenerator : public BaseGenerator {
  code_ += ";";
  code_ += " return EnumNames{{ENUM_NAME}}()[index];";
  + code_ += "}";
  + code_ += "";
  + } else {
  + code_ += "inline const char *EnumName{{ENUM_NAME}}({{ENUM_NAME}} e) {";
  +
  + code_ += " switch (e) {";
  +
  + for (auto it = enum_def.vals.vec.begin(); it != enum_def.vals.vec.end();
  + ++it) {
  + const auto &ev = **it;
  + code_ += " case {{ENUM_NAME}}_" + Name(ev) + ": return \"" +
  + Name(ev) + "\";";
  + }
  +
  + code_ += " default: return \"\";";
  + code_ += " }";
  +
  code_ += "}";
  code_ += "";
  }
  