Opened 18 months ago

Closed 4 weeks ago

#915 closed request (fixed)

read and write numbers in binary format

Reported by: Peter Owned by: Peter
Priority: major Milestone: yat 0.18
Component: utility Version: trunk
Keywords: Cc:

Description

I have an app that writes temporary results to a file to use later. As these files can quite large I'd like to write them in binary format rather than text. A quick web search hits up a lot of comments that this is not portable, but for my use case that is not really relevant as it's the same program on the same machine reading and writing and as long as the limitation is documented I see no problem. The problem is of course that numbers are not represented the same way on different system, so just flushing the memory to a stream won't be portable in the sense that you could write data on one machine and then read it somewhere else.

The read is more or less already implemented in the RNG class when reading a seed from "dev/urandom".

Change History (5)

comment:1 Changed 18 months ago by Peter

Component: testutility

comment:2 Changed 18 months ago by Peter

Type: defectrequest

comment:3 Changed 18 months ago by Peter

I forgot to mention that GSL provides e.g. for the gsl_matrix struct a gsl_matrix_fwrite function, but needless to say I'd prefer C++ streams.

Also, it would be convenient with iterators behaving just like istream_iterator and ostream_iterator in std, but using these functions rather than operator<< and >>.

comment:4 Changed 5 weeks ago by Peter

Milestone: yat 0.x+yat 0.18
Owner: changed from Jari Häkkinen to Peter
Status: newaccepted

I have already implemented this as a template is a different project (kyle), so can port the code to yat.

comment:5 Changed 4 weeks ago by Peter

Resolution: fixed
Status: acceptedclosed

In 3902:

closes #915. New functions that read and write numbers in binary format.

Note: See TracTickets for help on using tickets.