DataInput

A simple way to read binary data from an arbitrary InputStream, such as a file:

auto input = new DataInput (new File ("path"));
auto x = input.int32;
auto y = input.float64;
auto l = input.read (buffer);           // read raw data directly
auto s = cast(char[]) input.array;      // read length, allocate space
input.close;

Constructors

this
this(InputStream stream)

Propagate ctor to superclass.

Members

Aliases

get
alias get = array
Undocumented in source.
getBool
alias getBool = boolean
Undocumented in source.
getByte
alias getByte = int8
Undocumented in source.
getDouble
alias getDouble = float64
Undocumented in source.
getFloat
alias getFloat = float32
Undocumented in source.
getInt
alias getInt = int32
Undocumented in source.
getLong
alias getLong = int64
Undocumented in source.
getShort
alias getShort = int16
Undocumented in source.

Enums

Native
anonymousenum Native

Endian variations.

Functions

allocate
DataInput allocate(Allocate allocate)

Set the array allocator.

array
uint array(void[] dst)

Read an array back into a user-provided workspace. The space must be sufficiently large enough to house all of the array, and the actual number of bytes is returned.

array
void[] array()

Read an array back from the source, with the assumption it has been written using DataOutput.put() or otherwise prefixed with an integer representing the total number of bytes within the array content. That's *bytes*, not elements.

boolean
bool boolean()
endian
DataInput endian(int e)

Set current endian translation.

float32
float float32()
float64
double float64()
int16
short int16()
int32
int int32()
int64
long int64()
int8
byte int8()
read
size_t read(void[] data)

Variables

input
InputStream input;
Undocumented in source.

Inherited Members

From InputFilter

source
InputStream source;
Undocumented in source.
conduit
IConduit conduit()

Return the hosting conduit.

read
size_t read(void[] dst)

Read from conduit into a target array. The provided dst will be populated with content from the conduit.

load
void[] load(size_t max)

Load the bits from a stream, and return them all in an array. The dst array can be provided as an option, which will be expanded as necessary to consume the input.

flush
IOStream flush()

Clear any buffered content.

seek
long seek(long offset, Anchor anchor)

Seek on this stream. Target conduits that don't support seeking will throw an IOException.

input
InputStream input()

Return the upstream host of this filter.

close
void close()

Close the input.

Meta