Binary (non-character-based) file iterators

I'm looking for binary (value_type = unsigned char) input and output iterators for files. This is as opposed to a character base iterator (which rules out ostream_iterator<>). I don't need anything fancy (in fact, I'm just copying whole files to and from archives). I know that Sprit has an input iterator which is a forward iterator, and I could use that. I've already started to write them with Boost.Iterator; but this seems like something you should expect to find somewhere in boost already.

2009/12/21 Jason Felice <jason.m.felice@gmail.com>:
I'm looking for binary (value_type = unsigned char) input and output iterators for files. This is as opposed to a character base iterator (which rules out ostream_iterator<>).
If you can accept char instead of unsigned char, then use the standard streambuf iterators, istreambuf_iterator and ostreambuf_iterator.

Hi, First, could you confirm my belief that there is no STL or Boost container that can sort a list of values such that one can insert arbitrary values in O(log n) and also find the nth highest value in O(log n) time (see http://stackoverflow.com/questions/1746402/whats-a-qt-or-open-source-c-templ... for some discussion)? Second, I'm implementing such a container on top of a simple b-tree template. Would there be any interest in my cleaning it up and contributing it to boost? (I'd mostly have to add smart pointers for copy-on-write compatibility).

AMDG Hans Joseph Solbrig wrote:
First, could you confirm my belief that there is no STL or Boost container that can sort a list of values such that one can insert arbitrary values in O(log n) and also find the nth highest value in O(log n) time (see http://stackoverflow.com/questions/1746402/whats-a-qt-or-open-source-c-templ... for some discussion)?
Second, I'm implementing such a container on top of a simple b-tree template. Would there be any interest in my cleaning it up and contributing it to boost?
(I'd mostly have to add smart pointers for copy-on-write compatibility).
I believe that the data structure for this is called a rank tree. I don't think there's an implementation in Boost, although there might be something in a SOC project from a few years ago. https://svn.boost.org/trac/boost/browser/sandbox/SOC/2006/tree In Christ, Steven Watanabe

On Mon, Dec 21, 2009 at 3:41 PM, Scott McMurray <me22.ca+boost@gmail.com> wrote:
2009/12/21 Jason Felice <jason.m.felice@gmail.com>:
I'm looking for binary (value_type = unsigned char) input and output iterators for files. This is as opposed to a character base iterator (which rules out ostream_iterator<>).
If you can accept char instead of unsigned char, then use the standard streambuf iterators, istreambuf_iterator and ostreambuf_iterator.
Can I rely on there being no character set or line ending translation for an istream_iterator<char>, even with ios::binary? I thought not.

On Mon, Dec 21, 2009 at 8:08 PM, Jason Felice <jason.m.felice@gmail.com> wrote:
On Mon, Dec 21, 2009 at 3:41 PM, Scott McMurray <me22.ca+boost@gmail.com> wrote:
2009/12/21 Jason Felice <jason.m.felice@gmail.com>:
I'm looking for binary (value_type = unsigned char) input and output iterators for files. This is as opposed to a character base iterator (which rules out ostream_iterator<>).
If you can accept char instead of unsigned char, then use the standard streambuf iterators, istreambuf_iterator and ostreambuf_iterator.
Can I rely on there being no character set or line ending translation for an istream_iterator<char>, even with ios::binary? I thought not.
The answer appears to be "yes". After much research, the codecvt<char,char,..> locale facet is specialized to do nothing, so no character set conversion will occur for narrow versions of the stream, regardless of locale. (ios::binary is required, of course).
participants (4)
-
Hans Joseph Solbrig
-
Jason Felice
-
Scott McMurray
-
Steven Watanabe