Stream

Stream is the base abstract class from which the other stream classes derive.

Stream's byte order is the format native to the computer.

Reading: These methods require that the readable flag be set. Problems with reading result in a ReadException being thrown. Stream implements the InputStream interface in addition to the readBlock method.

Writing: These methods require that the writeable flag be set. Problems with writing result in a WriteException being thrown. Stream implements the OutputStream interface in addition to the following methods: writeBlock copyFrom copyFrom

Seeking: These methods require that the seekable flag be set. Problems with seeking result in a SeekException being thrown. seek, seekSet, seekCur, seekEnd, position, size, toString, toHash

class Stream : InputStream , OutputStream {}

Constructors

this
this()
Undocumented in source.

Members

Functions

assertReadable
void assertReadable()
Undocumented in source. Be warned that the author may not have intended to support it.
assertSeekable
void assertSeekable()
Undocumented in source. Be warned that the author may not have intended to support it.
assertWriteable
void assertWriteable()
Undocumented in source. Be warned that the author may not have intended to support it.
close
void close()
Undocumented in source. Be warned that the author may not have intended to support it.
copyFrom
void copyFrom(Stream s)

Copies all data from s into this stream. This may throw ReadException or WriteException on failure. This restores the file position of s so that it is unchanged.

copyFrom
void copyFrom(Stream s, ulong count)

Copy a specified number of bytes from the given stream into this one. This may throw ReadException or WriteException on failure. Unlike the previous form, this doesn't restore the file position of s.

flush
void flush()
Undocumented in source. Be warned that the author may not have intended to support it.
getc
char getc()
Undocumented in source. Be warned that the author may not have intended to support it.
getcw
wchar getcw()
Undocumented in source. Be warned that the author may not have intended to support it.
opApply
int opApply(int delegate(ref char[] line) dg)
Undocumented in source. Be warned that the author may not have intended to support it.
opApply
int opApply(int delegate(ref ulong n, ref char[] line) dg)
Undocumented in source. Be warned that the author may not have intended to support it.
opApply
int opApply(int delegate(ref wchar[] line) dg)
Undocumented in source. Be warned that the author may not have intended to support it.
opApply
int opApply(int delegate(ref ulong n, ref wchar[] line) dg)
Undocumented in source. Be warned that the author may not have intended to support it.
printf
size_t printf(const(char)[] format, ...)
Undocumented in source. Be warned that the author may not have intended to support it.
read
size_t read(ubyte[] buffer)
Undocumented in source. Be warned that the author may not have intended to support it.
read
void read(byte x)
Undocumented in source. Be warned that the author may not have intended to support it.
read
void read(ubyte x)
Undocumented in source. Be warned that the author may not have intended to support it.
read
void read(short x)
Undocumented in source. Be warned that the author may not have intended to support it.
read
void read(ushort x)
Undocumented in source. Be warned that the author may not have intended to support it.
read
void read(int x)
Undocumented in source. Be warned that the author may not have intended to support it.
read
void read(uint x)
Undocumented in source. Be warned that the author may not have intended to support it.
read
void read(long x)
Undocumented in source. Be warned that the author may not have intended to support it.
read
void read(ulong x)
Undocumented in source. Be warned that the author may not have intended to support it.
read
void read(float x)
Undocumented in source. Be warned that the author may not have intended to support it.
read
void read(double x)
Undocumented in source. Be warned that the author may not have intended to support it.
read
void read(real x)
Undocumented in source. Be warned that the author may not have intended to support it.
read
void read(char x)
Undocumented in source. Be warned that the author may not have intended to support it.
read
void read(wchar x)
Undocumented in source. Be warned that the author may not have intended to support it.
read
void read(dchar x)
Undocumented in source. Be warned that the author may not have intended to support it.
read
void read(char[] s)
Undocumented in source. Be warned that the author may not have intended to support it.
read
void read(wchar[] s)
Undocumented in source. Be warned that the author may not have intended to support it.
readBlock
size_t readBlock(void* buffer, size_t size)

Read up to size bytes into the buffer and return the number of bytes actually read. A return value of 0 indicates end-of-file.

readExact
void readExact(void* buffer, size_t size)
Undocumented in source. Be warned that the author may not have intended to support it.
readLine
char[] readLine()
Undocumented in source. Be warned that the author may not have intended to support it.
readLine
char[] readLine(char[] result)
Undocumented in source. Be warned that the author may not have intended to support it.
readLineW
wchar[] readLineW()
Undocumented in source. Be warned that the author may not have intended to support it.
readLineW
wchar[] readLineW(wchar[] result)
Undocumented in source. Be warned that the author may not have intended to support it.
readString
char[] readString(size_t length)
Undocumented in source. Be warned that the author may not have intended to support it.
readStringW
wchar[] readStringW(size_t length)
Undocumented in source. Be warned that the author may not have intended to support it.
readf
int readf(...)
Undocumented in source. Be warned that the author may not have intended to support it.
seek
ulong seek(long offset, SeekPos whence)

Change the current position of the stream. whence is either SeekPos.Set, in which case the offset is an absolute index from the beginning of the stream, SeekPos.Current, in which case the offset is a delta from the current position, or SeekPos.End, in which case the offset is a delta from the end of the stream (negative or zero offsets only make sense in that case). This returns the new file position.

seekCur
ulong seekCur(long offset)
Undocumented in source. Be warned that the author may not have intended to support it.
seekEnd
ulong seekEnd(long offset)
Undocumented in source. Be warned that the author may not have intended to support it.
seekSet
ulong seekSet(long offset)

Aliases for their normal seek counterparts.

toHash
size_t toHash()

Get a hash of the stream by reading each byte and using it in a CRC-32 checksum.

toString
string toString()

Read the entire stream and return it as a string. If the stream is not seekable the contents from the current position to eof is read and returned.

ungetAvailable
bool ungetAvailable()
Undocumented in source. Be warned that the author may not have intended to support it.
ungetc
char ungetc(char c)
Undocumented in source. Be warned that the author may not have intended to support it.
ungetcw
wchar ungetcw(wchar c)
Undocumented in source. Be warned that the author may not have intended to support it.
vprintf
size_t vprintf(const(char)[] format, va_list args)
Undocumented in source. Be warned that the author may not have intended to support it.
vreadf
int vreadf(TypeInfo[] arguments, va_list args)
Undocumented in source. Be warned that the author may not have intended to support it.
write
size_t write(const(ubyte)[] buffer)
Undocumented in source. Be warned that the author may not have intended to support it.
write
void write(byte x)
Undocumented in source. Be warned that the author may not have intended to support it.
write
void write(ubyte x)
Undocumented in source. Be warned that the author may not have intended to support it.
write
void write(short x)
Undocumented in source. Be warned that the author may not have intended to support it.
write
void write(ushort x)
Undocumented in source. Be warned that the author may not have intended to support it.
write
void write(int x)
Undocumented in source. Be warned that the author may not have intended to support it.
write
void write(uint x)
Undocumented in source. Be warned that the author may not have intended to support it.
write
void write(long x)
Undocumented in source. Be warned that the author may not have intended to support it.
write
void write(ulong x)
Undocumented in source. Be warned that the author may not have intended to support it.
write
void write(float x)
Undocumented in source. Be warned that the author may not have intended to support it.
write
void write(double x)
Undocumented in source. Be warned that the author may not have intended to support it.
write
void write(real x)
Undocumented in source. Be warned that the author may not have intended to support it.
write
void write(char x)
Undocumented in source. Be warned that the author may not have intended to support it.
write
void write(wchar x)
Undocumented in source. Be warned that the author may not have intended to support it.
write
void write(dchar x)
Undocumented in source. Be warned that the author may not have intended to support it.
write
void write(const(char)[] s)
Undocumented in source. Be warned that the author may not have intended to support it.
write
void write(const(wchar)[] s)
Undocumented in source. Be warned that the author may not have intended to support it.
writeBlock
size_t writeBlock(void* buffer, size_t size)

Write up to size bytes from buffer in the stream, returning the actual number of bytes that were written.

writeExact
void writeExact(void* buffer, size_t size)
Undocumented in source. Be warned that the author may not have intended to support it.
writeLine
void writeLine(const(char)[] s)
Undocumented in source. Be warned that the author may not have intended to support it.
writeLineW
void writeLineW(const(wchar)[] s)
Undocumented in source. Be warned that the author may not have intended to support it.
writeString
void writeString(const(char)[] s)
Undocumented in source. Be warned that the author may not have intended to support it.
writeStringW
void writeStringW(const(wchar)[] s)
Undocumented in source. Be warned that the author may not have intended to support it.
writef
OutputStream writef(...)
Undocumented in source. Be warned that the author may not have intended to support it.
writefln
OutputStream writefln(...)
Undocumented in source. Be warned that the author may not have intended to support it.
writefx
OutputStream writefx(TypeInfo[] arguments, va_list argptr, int newline)
Undocumented in source. Be warned that the author may not have intended to support it.

Properties

available
size_t available [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.
eof
bool eof [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.
isOpen
bool isOpen [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.
position
ulong position [@property setter]

Sets file position. Equivalent to calling seek(pos, SeekPos.Set).

position
ulong position [@property getter]

Returns current file position. Equivalent to seek(0, SeekPos.Current).

size
ulong size [@property getter]

Retrieve the size of the stream in bytes. The stream must be seekable or a SeekException is thrown.

Variables

isopen
bool isopen;

Indicates whether this stream is open.

prevCr
bool prevCr;

For a non-seekable stream indicates that the last readLine or readLineW ended on a '\r' character.

readEOF
bool readEOF;

Indicates whether this stream is at eof after the last read attempt.

readable
bool readable;

Indicates whether this stream can be read from.

seekable
bool seekable;

Indicates whether this stream can be sought within.

writeable
bool writeable;

Indicates whether this stream can be written to.

Inherited Members

From InputStream

readExact
void readExact(void* buffer, size_t size)

Read exactly size bytes into the buffer.

read
size_t read(ubyte[] buffer)

Read a block of data big enough to fill the given array buffer.

read
void read(byte x)

Read a basic type or counted string.

read
void read(ubyte x)
Undocumented in source.
read
void read(short x)
Undocumented in source.
read
void read(ushort x)
Undocumented in source.
read
void read(int x)
Undocumented in source.
read
void read(uint x)
Undocumented in source.
read
void read(long x)
Undocumented in source.
read
void read(ulong x)
Undocumented in source.
read
void read(float x)
Undocumented in source.
read
void read(double x)
Undocumented in source.
read
void read(real x)
Undocumented in source.
read
void read(char x)
Undocumented in source.
read
void read(wchar x)
Undocumented in source.
read
void read(dchar x)
Undocumented in source.
read
void read(char[] s)
Undocumented in source.
read
void read(wchar[] s)
Undocumented in source.
readLine
char[] readLine()

Read a line that is terminated with some combination of carriage return and line feed or end-of-file.

readLine
char[] readLine(char[] result)
Undocumented in source.
readLineW
wchar[] readLineW()
Undocumented in source.
readLineW
wchar[] readLineW(wchar[] result)
Undocumented in source.
opApply
int opApply(int delegate(ref char[] line) dg)

Overload foreach statements to read the stream line by line and call the supplied delegate with each line or with each line with line number.

opApply
int opApply(int delegate(ref ulong n, ref char[] line) dg)
Undocumented in source.
opApply
int opApply(int delegate(ref wchar[] line) dg)
Undocumented in source.
opApply
int opApply(int delegate(ref ulong n, ref wchar[] line) dg)
Undocumented in source.
readString
char[] readString(size_t length)

Read a string of the given length, throwing ReadException if there was a problem.

readStringW
wchar[] readStringW(size_t length)

Read a string of the given length, throwing ReadException if there was a problem.

getc
char getc()

Read and return the next character in the stream.

getcw
wchar getcw()
Undocumented in source.
ungetc
char ungetc(char c)

Push a character back onto the stream.

ungetcw
wchar ungetcw(wchar c)
Undocumented in source.
vreadf
int vreadf(TypeInfo[] arguments, va_list args)

Scan a string from the input using a similar form to C's scanf and <a href="std_format.html">std.format</a>.

readf
int readf(...)
Undocumented in source.
available
size_t available [@property getter]

Retrieve the number of bytes available for immediate reading.

eof
bool eof [@property getter]

Return whether the current file position is the same as the end of the file.

isOpen
bool isOpen [@property getter]
Undocumented in source.

From OutputStream

writeExact
void writeExact(void* buffer, size_t size)

Write exactly size bytes from buffer, or throw a WriteException if that could not be done.

write
size_t write(const(ubyte)[] buffer)

Write as much of the buffer as possible, returning the number of bytes written.

write
void write(byte x)

Write a basic type.

write
void write(ubyte x)
Undocumented in source.
write
void write(short x)
Undocumented in source.
write
void write(ushort x)
Undocumented in source.
write
void write(int x)
Undocumented in source.
write
void write(uint x)
Undocumented in source.
write
void write(long x)
Undocumented in source.
write
void write(ulong x)
Undocumented in source.
write
void write(float x)
Undocumented in source.
write
void write(double x)
Undocumented in source.
write
void write(real x)
Undocumented in source.
write
void write(char x)
Undocumented in source.
write
void write(wchar x)
Undocumented in source.
write
void write(dchar x)
Undocumented in source.
write
void write(const(char)[] s)

Writes a string, together with its length.

write
void write(const(wchar)[] s)
Undocumented in source.
writeLine
void writeLine(const(char)[] s)

Write a line of text, appending the line with an operating-system-specific line ending.

writeLineW
void writeLineW(const(wchar)[] s)

Write a line of text, appending the line with an operating-system-specific line ending.

writeString
void writeString(const(char)[] s)

Write a string of text.

writeStringW
void writeStringW(const(wchar)[] s)

Write a string of text.

vprintf
size_t vprintf(const(char)[] format, va_list args)

Print a formatted string into the stream using printf-style syntax, returning the number of bytes written.

printf
size_t printf(const(char)[] format, ...)
Undocumented in source.
writef
OutputStream writef(...)

Print a formatted string into the stream using writef-style syntax. References: <a href="std_format.html">std.format</a>.

writefln
OutputStream writefln(...)
Undocumented in source.
writefx
OutputStream writefx(TypeInfo[] arguments, va_list argptr, int newline)
Undocumented in source.
flush
void flush()
Undocumented in source.
close
void close()
Undocumented in source.
isOpen
bool isOpen [@property getter]
Undocumented in source.

Meta