FIFE 2008.0
FIFE::RawData Class Reference

#include <rawdata.h>

Collaboration diagram for FIFE::RawData:

List of all members.

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 >
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)

Detailed Description

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.)

Definition at line 48 of file rawdata.h.


Member Function Documentation

unsigned int FIFE::RawData::getCurrentIndex ( ) const

get the current index

Returns:
the current index

Definition at line 75 of file rawdata.cpp.

Referenced by getLine(), and moveIndex().

Here is the caller graph for this function:

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 ( )

get the data in distinct lines

Definition at line 61 of file rawdata.cpp.

References getLine().

unsigned int FIFE::RawData::getDataLength ( ) const

get the complete datalength

Returns:
the complete datalength

Definition at line 71 of file rawdata.cpp.

References FIFE::RawDataSource::getSize().

Referenced by getDataInBytes(), getLine(), read(), readInto(), and setIndex().

Here is the caller graph for this function:

bool FIFE::RawData::getLine ( std::string &  buffer)

reads until a \n is encountered or no more data is available

Parameters:
bufferif successfull the new string will be assigned to buffer
Returns:
true if data was available, false otherwise (in that case buffer won't be touched)

Definition at line 150 of file rawdata.cpp.

References getCurrentIndex(), getDataLength(), and read8().

Referenced by getDataInLines().

Here is the caller graph for this function:

void FIFE::RawData::moveIndex ( int  offset)

move the current index

Parameters:
offsetthe offset
Exceptions:
IndexOverflowif 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

Exceptions:
IndexOverflow

Definition at line 114 of file rawdata.cpp.

Referenced by FIFE::LZSSDecoder::decode().

Here is the caller graph for this function:

uint16_t FIFE::RawData::read16Little ( )

reads a uint16_t littleEndian and converts them to the host-byteorder

Exceptions:
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

Exceptions:
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

Exceptions:
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().

Here is the caller graph for this function:

void FIFE::RawData::readInto ( uint8_t *  buffer,
size_t  len 
)

read len bytes into buffer

Parameters:
bufferthe data will be written into it
lenlen bytes will be written
Exceptions:
IndexOverflowif 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().

Here is the caller graph for this function:

template<typename T >
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.

Returns:
the data

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

Parameters:
lenthe stringlen
Returns:
the string
Exceptions:
IndexOverflow

Definition at line 124 of file rawdata.cpp.

References readInto().

void FIFE::RawData::setIndex ( unsigned int  index)

set the current index

Parameters:
indexthe new index
Exceptions:
IndexOverflowif index is >= getDataLength()

Definition at line 79 of file rawdata.cpp.

References getDataLength().

Referenced by moveIndex(), and FIFE::ZipSource::open().

Here is the caller graph for this function:


The documentation for this class was generated from the following files:
 All Classes Namespaces Functions Variables Enumerations Enumerator