getValueAsString method

String getValueAsString(
  1. int row,
  2. int column, {
  3. int? length,
  4. Encoding? encoding,
})

Access to the data Access to the data

Implementation

// dynamic operator [](int index){
// }
/// Access to the data
String getValueAsString(int row, int column,
    {int? length, Encoding? encoding}) {
  if (row < 0 || row >= rows || column < 0 || column >= columns)
    throw LibPqException("Row or column index out of range!");
  final valuePoiter = psql.pq.PQgetvalue(res, row, column);

  int _length(Pointer<Uint8> codeUnits) {
    var length = 0;
    while (codeUnits[length] != 0) {
      length++;
    }
    return length;
  }

  final codeUnits = valuePoiter.cast<Uint8>();
  if (length != null) {
    RangeError.checkNotNegative(length, 'length');
  } else {
    length = _length(codeUnits);
  }
  final bytes = codeUnits.asTypedList(length);

  return encoding != null
      ? encoding.decode(bytes)
      : psql.encoding.decode(bytes);
}