Documentation | SupportKit | DataIO
SYNOPSIS
Perl
use HaikuR1::DataIO; # define MyDataIO subclass here my $reader = MyDataIO->new(); my $chunk = $reader->Read($length); my $writer = MyDataIO->new(); my $length_written = $writer->Write($chunk);
Python
from HaikuR1.SupportKit import DataIO # define MyDataIO subclass here reader = MyDataIO() chunk = reader.Read(length) writer = MyDataIO() length_written = writer.Write(chunk)
DESCRIPTION
Exposes the BDataIO. object.
For more information on DataIO, see the Be Book class description, the Be Book overview, and the Haiku Book class description.
NATIVE OBJECTS
As a convenience, you can substitute a native IO object or a native string in place of a DataIO; internally it will be wrapped in a suitable C++ object.
Since this internal C++ wrapper derives from BPositionIO, the guidelines for
native substitutions are found under
PositionIO.
METHODS
Constructor
Creates a DataIO object.
Perl
HaikuR1::DataIO->new();
Python
DataIO()
Flush
Flushes any temporary buffer; signals an error if it cannot. The default version does nothing.
May also be called as a hook.
Perl
$dataio->Flush();
Python
dataio.Flush()
Read
ReadExactly
Reads the given number of bytes from the source. Returns the string of bytes.
The default version signals the error B_NOT_SUPPORTED. ReadExactly
signals an error if it is unable to read the given length, whereas Read may
read fewer bytes.
The returned string may contain null bytes.
Read may also be called as a hook you pass an instance of a subclass to a
method (for example, Flattenable.Unflatten).
Additionally, since ReadExactly is internally implemented using Read,
calling ReadExactly will result in Read being called as a hook.
Perl
$dataio->Read($size); $dataio->ReadExactly($size);
Python
dataio.Read(size) dataio.ReadExactly(size)
sizeAn integer, the number of bytes to read.
Write
WriteExactly
Writes the given string of raw bytes from the destination. Returns the number
of bytes written. The default version signals the error B_NOT_SUPPORTED.
WriteExactly signals an error if it is unable to write the entire string,
whereas Write may write fewer bytes.
Write may also be called as a hook you pass an instance of a subclass to a
method (for example, Flattenable.Flatten).
Additionally, since WriteExactly is internally implemented using Write,
calling WriteExactly will result in Write being called as a hook.
Perl
$dataio->Write($buffer); $dataio->WriteExactly($buffer);
Python
dataio.Write(buffer) dataio.WriteExactly(buffer)
bufferA string of bytes to write; may contain null bytes.