FIFE
2008.0
|
#include <rawdata.h>
Public Member Functions | |
std::vector< uint8_t > | getDataInBytes () |
std::vector< std::string > | getDataInLines () |
unsigned int | getDataLength () const |
unsigned int | getCurrentIndex () const |
void | setIndex (unsigned int index) |
void | moveIndex (int offset) |
template<typename T > | |
T | readSingle () |
void | readInto (uint8_t *buffer, size_t len) |
uint8_t | read8 () |
uint16_t | read16Little () |
uint32_t | read32Little () |
uint16_t | read16Big () |
uint32_t | read32Big () |
std::string | readString (size_t len) |
void | read (std::string &outbuffer, int size=-1) |
bool | getLine (std::string &buffer) |
Used to access diffrent kinds of data.
RawData uses RawDataSource to get the real data - that way the user doesn't have to know where the data comes from (real files, files inside archives etc.)
unsigned int FIFE::RawData::getCurrentIndex | ( | ) | const |
get the current index
Definition at line 75 of file rawdata.cpp.
Referenced by getLine(), and moveIndex().
std::vector< uint8_t > FIFE::RawData::getDataInBytes | ( | ) |
get the data as a vector of bytes
Definition at line 49 of file rawdata.cpp.
References getDataLength(), and readInto().
std::vector< std::string > FIFE::RawData::getDataInLines | ( | ) |
unsigned int FIFE::RawData::getDataLength | ( | ) | const |
get the complete datalength
Definition at line 71 of file rawdata.cpp.
References FIFE::RawDataSource::getSize().
Referenced by getDataInBytes(), getLine(), read(), readInto(), and setIndex().
bool FIFE::RawData::getLine | ( | std::string & | buffer | ) |
reads until a \n is encountered or no more data is available
buffer | if successfull the new string will be assigned to buffer |
Definition at line 150 of file rawdata.cpp.
References getCurrentIndex(), getDataLength(), and read8().
Referenced by getDataInLines().
void FIFE::RawData::moveIndex | ( | int | offset | ) |
move the current index
offset | the offset |
IndexOverflow | if we move outside the datalength |
Definition at line 86 of file rawdata.cpp.
References getCurrentIndex(), and setIndex().
void FIFE::RawData::read | ( | std::string & | outbuffer, |
int | size = -1 |
||
) |
Reads all data into the buffer Created to especially fulfill python file interface requirements
Definition at line 133 of file rawdata.cpp.
References getDataLength(), and FIFE::RawDataSource::readInto().
uint16_t FIFE::RawData::read16Big | ( | ) |
reads a uint16_t bigEndian and converts them to the host-byteorder
IndexOverflow |
Definition at line 114 of file rawdata.cpp.
Referenced by FIFE::LZSSDecoder::decode().
uint16_t FIFE::RawData::read16Little | ( | ) |
reads a uint16_t littleEndian and converts them to the host-byteorder
IndexOverflow |
Definition at line 104 of file rawdata.cpp.
uint32_t FIFE::RawData::read32Big | ( | ) |
reads a uint16_t bigEndian and converts them to the host-byteorder
IndexOverflow |
Definition at line 119 of file rawdata.cpp.
uint32_t FIFE::RawData::read32Little | ( | ) |
reads a uint16_t littleEndian and converts them to the host-byteorder
IndexOverflow |
Definition at line 109 of file rawdata.cpp.
uint8_t FIFE::RawData::read8 | ( | ) |
reads 1 byte
Definition at line 100 of file rawdata.cpp.
Referenced by getLine().
void FIFE::RawData::readInto | ( | uint8_t * | buffer, |
size_t | len | ||
) |
read len bytes into buffer
buffer | the data will be written into it |
len | len bytes will be written |
IndexOverflow | if currentindex + len > getCurrentIndex() |
Definition at line 90 of file rawdata.cpp.
References getDataLength(), and FIFE::RawDataSource::readInto().
Referenced by FIFE::LZSSDecoder::decode(), getDataInBytes(), FIFE::ZipSource::open(), readSingle(), and readString().
T FIFE::RawData::readSingle | ( | ) | [inline] |
helper-function
reads sizeof(T) bytes - should be used with fixed-size datatypes like uint32_t, uint16_t, uint8_t etc.
Definition at line 93 of file rawdata.h.
References readInto().
std::string FIFE::RawData::readString | ( | size_t | len | ) |
read a string with len bytes, not assuming a terminating 0
len | the stringlen |
IndexOverflow |
Definition at line 124 of file rawdata.cpp.
References readInto().
void FIFE::RawData::setIndex | ( | unsigned int | index | ) |
set the current index
index | the new index |
IndexOverflow | if index is >= getDataLength() |
Definition at line 79 of file rawdata.cpp.
References getDataLength().
Referenced by moveIndex(), and FIFE::ZipSource::open().