Bug 5002 – possible std.stream improvements

Status
RESOLVED
Resolution
WONTFIX
Severity
enhancement
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2010-10-06T09:21:00Z
Last change time
2015-11-03T16:08:45Z
Assigned to
nobody
Creator
metalcaedes

Comments

Comment #0 by metalcaedes — 2010-10-06T09:21:40Z
I've got a few suggestions to make std.stream more convenient (and in one case just the documentation more clear). See my NG post [1] for details, I'll just summarize it here: * The documentation claims write( <basic type> ) is implementation specific - this is not true for most types - it's actually platform specific and with the EndianStream most read/write operations can safely be used between different platforms. Especially for the SocketStream this is good to know. * InputStream's read( <type> val ) sometimes is inconvenient, please add something like T read(T)() { T ret; readExact(&ret, ret.sizeof); return ret; } So one can use "myFun( s.read!float );" instead of "float x; s.read(x); myFun(x);" * Minor inconsistencies: add readExact(ubyte[] buf) to Inputstream, because there is a read(ubyte[] buf) and add writeExact(ubyte[] buf) to OutputStream because there is write(ubyte[] buf). * For convenience ubyte[] readExact(size_t len) might be nice. Thanks, - Daniel [1] http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D&article_id=118413 - my NG post on these matters (and also on bug 5001)
Comment #1 by nfxjfg — 2010-10-06T20:54:14Z
I thought std.stream is deprecated. Maybe "someone" could confirm and close this as invalid.
Comment #2 by metalcaedes — 2010-10-11T13:20:40Z
It will probably be deprecated, but at this time it isn't (there is no alternative yet, anyway). However I just realized that my idea for read() can't be implemented *that* easy because it wouldn't work properly with EndianStream. For that to work one would have to check whether T is a simple type (int, float, double, long, etc) and in that case call fixBO() in EndianStream (like the available, inconvenient read(<basic type>) methods in EndianStream already do). Or do it old school and provide readInt(), readUInt(), readLong(), readUlong(), readFloat() etc instead of using a template.
Comment #3 by rburners — 2015-11-03T16:08:45Z
std.stream is deprecated and will be removed in 2016