libgamecommon provides a number of utility functions for working with binary files.
Classes
-
stream_seg - transparently add and remove chunks of data in the middle of a stream
-
stream_sub - make a C++ iostream appear as a subsection of a larger stream
Examples
Reading endian-specific data
myfile->open("test.dat");
uint16_t value;
myfile >> u16le(value);
myfile >> u16be(value);
uint32_t value;
myfile >> u32le(value) >>
u8(byte);
Creating a substream
myfile->open("test.dat");
sub->open(myfile, 10, 15, NULL);
sub->write(...);
Creating a segmented_stream
See the segmented_stream test code.
More information
Additional information is available from the Camoto homepage http://www.shikadi.net/camoto.