Buffer.read

Reads an array using the system's endianness.

  1. T read()
  2. T read()
  3. T read(size_t length)
  4. T read(size_t size)
    class Buffer
    pure @trusted
    T
    read
    (
    T
    )
    (
    size_t size
    )
    if (
    isArray!T &&
    )
  5. B read()

Throws

BufferOverflowException if there isn't enough data to read.

Examples

t {
		
		Buffer buffer = new Buffer("!hello");
		assert(buffer.read!(ubyte[])(1) == [33]);
		assert(buffer.read!string(5) == "hello");

		buffer.data = [1, 2, 3];
		version(BigEndian) assert(buffer.data!ubyte == [0, 0, 0, 1, 0, 0, 0, 2, 0, 0, 0, 3]);
		version(LittleEndian) assert(buffer.data!ubyte == [1, 0, 0, 0, 2, 0, 0, 0, 3, 0, 0, 0]);
		assert(buffer.read!(int[])(3) == [1, 2, 3]);

Meta