decode static method
Implementation
static List<ProtocolBufferDecoderResult> decode(List<int> bytes) {
final List<ProtocolBufferDecoderResult> results = [];
int index = 0;
while (index < bytes.length) {
int tag = bytes[index++];
int fieldId = tag >> 3;
int wireType = tag & 0x07;
switch (wireType) {
case 2:
final decodeLength = _decodeVarint(bytes.sublist(index));
index += decodeLength.consumed;
results.add(ProtocolBufferDecoderResult(
tagNumber: fieldId,
value: bytes.sublist(index, index + decodeLength.value)));
index += decodeLength.value;
continue;
case 0:
final decodeInt = _decodeInt(bytes.sublist(index));
index += decodeInt.consumed;
final result = ProtocolBufferDecoderResult(
tagNumber: fieldId, value: decodeInt.value);
results.add(result);
continue;
default:
throw UnimplementedError("protobuf wiretype not supported.");
}
}
return results;
}