appendUnsignedInt method

void appendUnsignedInt(
  1. int value
)

Converts an unsigned int to a variable amount of bytes The first bit of each byte is used for continuation info, the other seven bits for data. the value of the first bit is 1 if the following byte belongs to the field, 0 otherwise. each byte holds seven bits of the numeric value, starting with the least significant ones.

Implementation

void appendUnsignedInt(int value) {
  _bufferPosition += 10;
  _ensureBuffer();
  int realByteCount = 0;
  while (value > 0x7f) {
    _bufferData.add((value & 0x7f) | 0x80);
    value = value >> 7;
    ++realByteCount;
  }
  _bufferData.add(value);
  ++realByteCount;
  _bufferPosition -= (10 - realByteCount);
}