readVaxInt32 method

int readVaxInt32(
  1. int offset
)

Reads a part of the buffer encoded as VAX integer.

Interprets the bytes as a 32-bit signed integer value. The VAX representation is always little endian, regardless of the native platform representation. If the host is little endian, the method is more efficient (no conversion is necessary). Otherwise, a memory copying is necessary. This method in principle returns the same value as isc_vax_integer from libfbclient, but is implemented entirely in Dart. See also FbClient.iscVaxInteger.

Implementation

int readVaxInt32(int offset) {
  if (Endian.host == Endian.little) {
    return readInt32(offset);
  } else {
    const byteCnt = 4;
    final bytes = Uint8List(byteCnt);
    for (var i = 0; i < byteCnt; i++) {
      bytes[i] = this[offset + byteCnt - 1 - i];
    }
    return fromBytesAsSigned(bytes);
  }
}