add method
Implementation
@override
int add(List<int> data, int offset) {
while (offset < data.length && data[offset] <= tokenSpace) {
offset++;
}
if (offset >= data.length) {
return offset; // No more bytes to process.
}
for (int o = offset; o < data.length; o++) {
final byte = data[o];
if (_nullOffset > 0) {
if (byte != _nullTokens[_nullOffset]) {
throw CodableException.unexpectedType(expected: 'null', actual: String.fromCharCode(byte));
}
_nullOffset++;
if (_nullOffset == 4) {
onValue(null);
_isDone = true;
return o + 1; // Return the next offset after the null value.
}
continue; // Continue to the next byte.
} else if (byte == tokenN) {
_nullOffset++;
continue; // Start reading null.
} else {
parent.decodeObject(onValue, using: using);
_isDone = true;
return o; // Return the current offset, which is the first byte of the value.
}
}
return data.length; // All bytes processed, no more entries.
}