I2C Device Class
This is a generic class which abstracts bit and byte I2C R/W functions. It is part of The I2C Device Library.
There are examples in many of the classes that demonstrate basic usage patterns. The I2Cdev class is built to be used statically, reducing the memory requirement if you have multiple I2C devices in your project. Only one instance of the I2Cdev class is required.
HMC5883L Compass Library