Issue 9716 - [Feature request] {std.stdio} A range to manage both stream and file
Summary: [Feature request] {std.stdio} A range to manage both stream and file
Status: NEW
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: All All
: P4 enhancement
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-03-14 03:45 UTC by bioinfornatics
Modified: 2024-12-01 16:16 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description bioinfornatics 2013-03-14 03:45:19 UTC
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 bioinfornatics 2013-03-17 17:29:05 UTC
By example we can do with it a range to manage both stream and file

http://dpaste.dzfl.pl/1f2bcf39
Comment 2 bearophile_hugs 2013-03-17 17:42:28 UTC
I suggest you to give a more precise title to this issue.
Comment 3 bioinfornatics 2013-03-18 01:05:51 UTC
English is not my first language so if you have a good one. You are welcome :-)
Comment 4 dlangBugzillaToGithub 2024-12-01 16:16:53 UTC
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