writeEnum method

  1. @override
void writeEnum(
  1. CppOptions generatorOptions,
  2. Root root,
  3. Indent indent,
  4. Enum anEnum, {
  5. required String dartPackageName,
})
override

Writes a single Enum to indent. This is needed in most generators.

Implementation

@override
void writeEnum(
  CppOptions generatorOptions,
  Root root,
  Indent indent,
  Enum anEnum, {
  required String dartPackageName,
}) {
  indent.newln();
  addDocumentationComments(
      indent, anEnum.documentationComments, _docCommentSpec);
  indent.write('enum class ${anEnum.name} ');
  indent.addScoped('{', '};', () {
    enumerate(anEnum.members, (int index, final EnumMember member) {
      addDocumentationComments(
          indent, member.documentationComments, _docCommentSpec);
      final String valueName = 'k${_pascalCaseFromCamelCase(member.name)}';
      indent.writeln(
          '$valueName = $index${index == anEnum.members.length - 1 ? '' : ','}');
    });
  });
}