UncompressedData.fromBlob constructor
UncompressedData.fromBlob(
- List<int> rawBytes
)
Implementation
factory UncompressedData.fromBlob(List<int> rawBytes) {
if (rawBytes.isEmpty) {
throw WinmdException('Bad signature');
}
// Smallest -- one byte
if ((rawBytes[0] & 0x80) == 0x00) // 0??? ????
{
final value = rawBytes[0];
final length = 1;
return UncompressedData(value, length);
}
// Medium -- two bytes
else if ((rawBytes[0] & 0xC0) == 0x80) // 10?? ????
{
if (rawBytes.length < 2) {
throw WinmdException('Bad signature');
} else {
final value = (rawBytes[0] & 0x3f) << 8 | rawBytes[1];
final length = 2;
return UncompressedData(value, length);
}
}
// Large -- four bytes
else if ((rawBytes[0] & 0xE0) == 0xC0) // 110? ????
{
if (rawBytes.length < 4) {
throw WinmdException('Bad signature');
} else {
final value = (rawBytes[0] & 0x1f) << 24 |
(rawBytes[1]) << 16 |
(rawBytes[2]) << 8 |
(rawBytes[3]);
final length = 4;
return UncompressedData(value, length);
}
} else // We don't recognize this encoding
{
throw WinmdException('Bad signature');
}
}