writeGeneralCodec method

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

Writes the custom codec to indent.

Implementation

@override
void writeGeneralCodec(
  CppOptions generatorOptions,
  Root root,
  Indent indent, {
  required String dartPackageName,
}) {
  indent.newln();
  indent.write(
      'class $_codecSerializerName : public $_standardCodecSerializer ');
  indent.addScoped('{', '};', () {
    _writeAccessBlock(indent, _ClassAccess.public, () {
      _writeFunctionDeclaration(indent, _codecSerializerName,
          isConstructor: true);
      _writeFunctionDeclaration(indent, 'GetInstance',
          returnType: '$_codecSerializerName&',
          isStatic: true, inlineBody: () {
        indent.writeln('static $_codecSerializerName sInstance;');
        indent.writeln('return sInstance;');
      });
      indent.newln();
      _writeFunctionDeclaration(indent, 'WriteValue',
          returnType: _voidType,
          parameters: <String>[
            'const flutter::EncodableValue& value',
            'flutter::ByteStreamWriter* stream'
          ],
          isConst: true,
          isOverride: true);
    });
    indent.writeScoped(' protected:', '', () {
      _writeFunctionDeclaration(indent, 'ReadValueOfType',
          returnType: 'flutter::EncodableValue',
          parameters: <String>[
            'uint8_t type',
            'flutter::ByteStreamReader* stream'
          ],
          isConst: true,
          isOverride: true);
    });
  }, nestCount: 0);
  indent.newln();
}