Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #9414
| From | Ian Collins <ian-news@hotmail.com> |
|---|---|
| Newsgroups | comp.lang.c++ |
| Subject | Re: Create an istream from an fd? |
| Date | 2011-08-29 07:52 +1200 |
| Message-ID | <9bvkjeFopsU12@mid.individual.net> (permalink) |
| References | (4 earlier) <9btaq6FopsU5@mid.individual.net> <2be71f2e-9a18-42ab-a7ec-bc7f8ccb215e@i9g2000yqk.googlegroups.com> <pan.2011.08.28.03.31.29.633000@nowhere.com> <9btskaFopsU6@mid.individual.net> <pan.2011.08.28.19.03.15.384000@nowhere.com> |
On 08/29/11 07:03 AM, Nobody wrote: > On Sun, 28 Aug 2011 15:56:58 +1200, Ian Collins wrote: > >>>> (The standard could have required an implementation defined >>>> typedef for the file descriptor in filebuf, and a constructor >>>> for that, but as far as I know, no one proposed such a thing.) >>> >>> It could have required a version of filebuf::open() (or similar) taking >>> a FILE*, given that<cstdio> is part of the standard. >> >> Then you would end up with two layers of buffering > > I see no reason why you would need two layers of buffering. The streambuf > can rely upon the stdio layer's buffering; it doesn't have to provide its > own. Yet more kludgery. >> and considering the similarity between C's fopen and constructing an >> fstream, gain very little. > > fopen() and freopen() are typically not the only way to get a FILE*, even > if they're the only mechanisms specified by the standard. They also can't be used for things like sockets, pipes and doors. > It's one thing to only specify the most portable mechanisms for creating a > stdio stream, but another thing to assume that no other mechanisms exist, > effectively treating stdio as a hermetically-sealed unit which isn't to be > extended. > > As it stands, any implementation wishing to extend the mechanisms for > creating streams has to do so twice: once for cstdio, once for ios. Why? In C they'd extend stdio, in C++ they can use streambufs. >> It also wouldn't solve one of the most common (at least for me) >> requirements: a stream over an existing file descriptor that isn't a >> regular file. > > fdopen() doesn't care whether the descriptor refers to a regular file. > fdopen() isn't portable, but then neither are descriptors. So? fopen() can't be used for to open them either. > And whatever's there for stdin (etc) and cin (etc) already has to deal > with whatever the standard descriptors are associated with, whether a > file, tty, pipe, socket, etc. Which isn't exposed to the user. Unless the user can create a FILE* from one of those, the internal mechanism isn't much use. C++ already provides the mechanism to extend std::streambuf (the appropriate virtual members) and using it it trivial. -- Ian Collins
Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Create an istream from an fd? Noah Roberts <roberts.noah@gmail.com> - 2011-08-26 08:54 -0700
Re: Create an istream from an fd? Leigh Johnston <leigh@i42.co.uk> - 2011-08-26 17:05 +0100
Re: Create an istream from an fd? Victor Bazarov <v.bazarov@comcast.invalid> - 2011-08-26 12:20 -0400
Re: Create an istream from an fd? Vaclav Zeman <vzeman79@sh.cvut.cz> - 2011-08-26 18:34 +0200
Re: Create an istream from an fd? Ian Collins <ian-news@hotmail.com> - 2011-08-27 08:48 +1200
Re: Create an istream from an fd? "Alf P. Steinbach" <alf.p.steinbach:usenet@gmail.com> - 2011-08-27 01:26 +0200
Re: Create an istream from an fd? Ian Collins <ian-news@hotmail.com> - 2011-08-27 11:30 +1200
Re: Create an istream from an fd? "Alf P. Steinbach" <alf.p.steinbach:usenet@gmail.com> - 2011-08-27 02:46 +0200
Re: Create an istream from an fd? Ian Collins <ian-news@hotmail.com> - 2011-08-28 10:52 +1200
Re: Create an istream from an fd? James Kanze <james.kanze@gmail.com> - 2011-08-27 16:35 -0700
Re: Create an istream from an fd? Nobody <nobody@nowhere.com> - 2011-08-28 04:31 +0100
Re: Create an istream from an fd? Ian Collins <ian-news@hotmail.com> - 2011-08-28 15:56 +1200
Re: Create an istream from an fd? Nobody <nobody@nowhere.com> - 2011-08-28 20:03 +0100
Re: Create an istream from an fd? Ian Collins <ian-news@hotmail.com> - 2011-08-29 07:52 +1200
Re: Create an istream from an fd? James Kanze <james.kanze@gmail.com> - 2011-08-29 03:54 -0700
Re: Create an istream from an fd? Leigh Johnston <leigh@i42.co.uk> - 2011-08-29 13:55 +0100
Re: Create an istream from an fd? Nobody <nobody@nowhere.com> - 2011-08-29 20:12 +0100
Re: Create an istream from an fd? Ian Collins <ian-news@hotmail.com> - 2011-08-30 07:49 +1200
Re: Create an istream from an fd? Nobody <nobody@nowhere.com> - 2011-08-30 04:40 +0100
Re: Create an istream from an fd? Ian Collins <ian-news@hotmail.com> - 2011-08-30 15:51 +1200
Re: Create an istream from an fd? Nobody <nobody@nowhere.com> - 2011-08-31 00:03 +0100
Re: Create an istream from an fd? Ian Collins <ian-news@hotmail.com> - 2011-08-31 11:55 +1200
Re: Create an istream from an fd? Nobody <nobody@nowhere.com> - 2011-09-02 00:50 +0100
Re: Create an istream from an fd? Ian Collins <ian-news@hotmail.com> - 2011-08-28 16:04 +1200
Re: Create an istream from an fd? Nobody <nobody@nowhere.com> - 2011-08-27 02:40 +0100
csiph-web