ClValue.list constructor

ClValue.list(
  1. List<ClValue> values
)

Implementation

ClValue.list(List<ClValue> values) {
  ByteDataWriter mem = ByteDataWriter(endian: Endian.little);
  if (values.isEmpty) {
    throw ArgumentError('List cannot be empty');
  }
  final innerTypeDesc = values.first.clTypeDescriptor;
  clTypeDescriptor = ClListTypeDescriptor(innerTypeDesc);
  mem.writeInt32(values.length);
  for (ClValue value in values) {
    if (innerTypeDesc == value.clTypeDescriptor) {
      mem.write(value.bytes);
    } else {
      throw ArgumentError('All elements of list must have the same type');
    }
  }
  bytes = mem.toBytes();
  parsed = "";
}