Re: Streams filter API
| From: | Stefan Roehrich | Date: | Thu, 22 Aug 2002 16:24:48 +0000 |
| Subject: | Re: Streams filter API | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-87302@lists.php.net to get a copy of this message | ||
On 2002-08-20 22:47:51, Wez Furlong wrote:
> I've just comitted the streams filter API to CVS.
Looks really nice.
I just wanted to start and try to write an example for me, but then I
wondered about following:
> The concept is that a series of filters can be applied to a given
> stream instance (as a doubly-linked-list); writing to the stream
> causes the buffer to pass through the filters from head to tail,
> before finally being written to the underlying stream.
[...]
> Likewise, reading from the stream also causes the data to pass
> through the filters, but in the reverse order.
Is there some easy way to restrict a filter to work only in one
direction? Say I want a filter, which only can be used to read data,
but not to write.
Or a filter which is used for both ways, but not both at the same
time, so that you get the information at create time, if this filter
will be used for reading or for writing.
I think this will make it much easier to write e.g. compression or
crypto filters, because reading and writing to the same compressed
stream often is hard to achieve. I think this may be one reason, that
Java has different Input-/OutputStreams. If you know the direction at
create time, you can make your read or write initializations and then
only support this methods, otherwise you would have to delay the
initialization and make complex checks, that you don't read from a
stream you have started writing to or similar.
What do you think?
Stefan
PS: It would be really cool, if you could implement your own filters
in PHP. Maybe you have to provide a PHP function which gets a string
as paramter and returns another? Would that be possible?
--
Stefan Röhrich stefan@roehri.ch, sr@linux.de
http://www.roehri.ch/~sr/