libgamecommon
libgamecommon

libgamecommon provides a number of utility functions for working with binary files.

Classes

Examples

Reading endian-specific data

using namespace camoto;
myfile->open("test.dat");
uint16_t value;
// Read a 16-bit (two byte) little-endian integer
myfile >> u16le(value);
// Same again but value in file is in big-endian instead
myfile >> u16be(value);
// Reading multiple values
uint32_t value;
uint8_t byte;
myfile >> u32le(value) >> u8(byte);

Creating a substream

using namespace camoto;
myfile->open("test.dat");
// Create a stream starting 10 bytes into test.dat and 15 bytes long.
sub->open(myfile, 10, 15, NULL);
sub->seekp(0, stream::start);
sub->write(...); // data is written at offset 10 in test.dat

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.