git-svn-id: https://profuse.googlecode.com/svn/branches/v2@99 aa027e90-d47c-11dd-86d7-074df07e0730

This commit is contained in:
ksherlock
2009-11-24 03:56:19 +00:00
parent 9f0b5f1004
commit 2209b44225
4 changed files with 20 additions and 112 deletions

View File

@@ -218,103 +218,4 @@ void MappedFile::reset()
_dosOrder = false;
}
/*
uint8_t MappedFile::read8(size_t location) const
{
// check for size?
uint8_t *map = (uint8_t *)_map;
return map[location];
}
*/
uint16_t MappedFile::read16(size_t location, int byteOrder) const
{
// check for size?
uint8_t *map = (uint8_t *)_map;
switch(byteOrder)
{
case LittleEndian:
return (map[location + 1] << 8)
| (map[location]);
case BigEndian:
return (map[location] << 8)
| (map[location+1]);
default:
return 0;
}
}
uint32_t MappedFile::read32(size_t location, int byteOrder) const
{
// check for size?
uint8_t *map = (uint8_t *)_map;
switch(byteOrder)
{
case LittleEndian:
return (map[location+3] << 24)
| (map[location+2] << 16)
| (map[location+1] << 8)
| (map[location])
;
case BigEndian:
return (map[location] << 24)
| (map[location+1] << 16)
| (map[location+2] << 8)
| (map[location+3])
;
default:
return 0;
}
}
/*
void MappedFile::write8(size_t location, uint8_t data)
{
uint8_t *map = (uint8_t *)_map;
map[location] = data;
}
*/
void MappedFile::write16(size_t location, uint16_t data, int byteOrder)
{
uint8_t *map = (uint8_t *)_map;
switch(byteOrder)
{
case LittleEndian:
map[location] = data & 0xff;
map[location+1] = (data >> 8) & 0xff;
break;
case BigEndian:
map[location] = (data >> 8) & 0xff;
map[location+1] = data & 0xff;
break;
}
}
void MappedFile::write32(size_t location, uint32_t data, int byteOrder)
{
uint8_t *map = (uint8_t *)_map;
switch(byteOrder)
{
case LittleEndian:
map[location] = data & 0xff;
map[location+1] = (data >> 8) & 0xff;
map[location+2] = (data >> 16) & 0xff;
map[location+3] = (data >> 24) & 0xff;
break;
case BigEndian:
map[location] = (data >> 24) & 0xff;
map[location+1] = (data >> 16) & 0xff;
map[location+2] = (data >> 8) & 0xff;
map[location+3] = data & 0xff;
break;
}
}