12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- import 'dart:convert';
- import 'dart:io';
- import 'dart:typed_data';
- ///Not used for now.
- class VidUsDataWriter {
- final BytesBuilder _builder = new BytesBuilder();
- Uint8List get data => _builder.toBytes();
- void writeString(String value) {
- var data = utf8.encode(value);
- var length = data.length;
- writeInt(length);
- _builder.add(data);
- }
- void writeInt(int value) {
- var data = Uint8List(4);
- data.buffer.asByteData().setInt32(0, value, Endian.little);
- _builder.add(data);
- }
- void writeInt16(int value) {
- var data = Uint8List(2);
- data.buffer.asByteData().setInt16(0, value, Endian.little);
- _builder.add(data);
- }
- void writeInt64(int value) {
- var data = Uint8List(8);
- data.buffer.asByteData().setInt64(0, value, Endian.little);
- _builder.add(data);
- }
- void writeFloat(double value) {
- var data = Uint8List(4);
- data.buffer.asByteData().setFloat32(0, value, Endian.little);
- _builder.add(data);
- }
- void writeDouble(double value) {
- var data = Uint8List(8);
- data.buffer.asByteData().setFloat64(0, value, Endian.little);
- _builder.add(data);
- }
- void writeBool(bool value) {
- _builder.addByte(value ? 1 : 0);
- }
- void writeByte(int value) {
- _builder.addByte(value);
- }
- void writeBytes(Uint8List value) {
- writeInt(value.length);
- _builder.add(value);
- }
- void writeLongs(Int64List value) {
- _builder.add(value.buffer.asUint8List());
- }
- }
|