Bug 9716 – [Feature request] {std.stdio} A range to manage both stream and file

Status
NEW
Severity
enhancement
Priority
P4
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-03-14T03:45:19Z
Last change time
2024-12-01T16:16:53Z
Assigned to
No Owner
Creator
bioinfornatics
Moved to GitHub: phobos#9961 →

Comments

Comment #0 by bioinfornatics — 2013-03-14T03:45:19Z
Dear, When you need to manage various file format and trying to fit as a phobos File it appear below feature could be really interesting. by example you have a parser you want to construct is from various file type you can grant some methods. ----------------------------------------------------------- template isFileType(F) { enum bool isFileType = is(typeof( { ubyte[] buf; F f = void; // can define a FileType object if (f.eof) {} // can test for end of file if (f.isOpen) {} // can test for opened file f.name; // can invoke name f.close(); // can invoke close r.write(); // can invoke write() r.rawWrite( "" ); // can invoke rawWrite() r.rawRead( buf ); // can invoke rawRead() })); } struct FileType( F ) if( isFileType( F ) ) { F _f; this( F file ){ _f = file; } alias _f this; }
Comment #1 by bioinfornatics — 2013-03-17T17:29:05Z
By example we can do with it a range to manage both stream and file http://dpaste.dzfl.pl/1f2bcf39
Comment #2 by bearophile_hugs — 2013-03-17T17:42:28Z
I suggest you to give a more precise title to this issue.
Comment #3 by bioinfornatics — 2013-03-18T01:05:51Z
English is not my first language so if you have a good one. You are welcome :-)
Comment #4 by robert.schadek — 2024-12-01T16:16:53Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/phobos/issues/9961 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB