thekid/rfc — Issue #190: RFC 0190: Readers and Writers
Author: thekid
Created: 2011-10-09 15:41:47+00:00
State: open

Scope of Change
====
To complement the input and output streams reading bytes from the underlying
data sources, Reader and Writer classes will take care of reading formats
defined ontop of these.

Rationale
====
Separate binary data and formatted data such as strings, as prerequisite for
Unicode support.

Functionality
====
The basics classes are io.streams.Reader and io.streams.Writer. These
classes work on input and output streams, respectively.

While streams are named [SOURCE][DIRECTION]Stream and always work on
binary untyped data, readers and writers are named [FORMAT][OPERATION]
and work on typed data.

Reader
----
TextReader - reads text

```php
read();
$t->readLine();
?>
```

BinaryReader - reads binary data. See unpack()

```php
read();
$t->readString();
$t->readInt32();
?>
```

Writer
----
TextWriter - writes text

```php
write($data);
$t->writeLine($data);
?>
```

BinaryWriter - writes binary data. See pack()

```php
write($data);
$t->writeString('...');
$t->writeInt32(1);
?>
```

Security considerations
====
n/a

Speed impact
====
n/a

Dependencies
====
None.

Related documents
====
None.

Comments
====