FIFE  2008.0
 All Classes Namespaces Functions Variables Enumerations Enumerator Pages
FIFE::RawData Class Reference

#include <rawdata.h>

Collaboration diagram for FIFE::RawData:
Collaboration graph

Public Member Functions

std::vector< uint8_t > getDataInBytes ()
 
std::vector< std::string > getDataInLines ()
 
uint32_t getDataLength () const
 
uint32_t getCurrentIndex () const
 
void setIndex (uint32_t index)
 
void moveIndex (int32_t 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, int32_t 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

uint32_t FIFE::RawData::getCurrentIndex ( ) const

get the current index

Returns
the current index

Definition at line 79 of file rawdata.cpp.

std::vector< uint8_t > FIFE::RawData::getDataInBytes ( )

get the data as a vector of bytes This does not append a null terminator to the end

Definition at line 49 of file rawdata.cpp.

std::vector< std::string > FIFE::RawData::getDataInLines ( )

get the data in distinct lines

Definition at line 65 of file rawdata.cpp.

uint32_t FIFE::RawData::getDataLength ( ) const

get the complete datalength

Returns
the complete datalength

Definition at line 75 of file rawdata.cpp.

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 154 of file rawdata.cpp.

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

move the current index

Parameters
offsetthe offset
Exceptions
IndexOverflowif we move outside the datalength

Definition at line 90 of file rawdata.cpp.

void FIFE::RawData::read ( std::string &  outbuffer,
int32_t  size = -1 
)

Reads all data into the buffer This does not append a null terminator to the end Created to especially fulfill python file interface requirements

Definition at line 138 of file rawdata.cpp.

uint16_t FIFE::RawData::read16Big ( )

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

Exceptions
IndexOverflow

Definition at line 118 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 108 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 123 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 113 of file rawdata.cpp.

uint8_t FIFE::RawData::read8 ( )

reads 1 byte

Definition at line 104 of file rawdata.cpp.

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 94 of file rawdata.cpp.

Referenced by FIFE::LZSSDecoder::decode(), FIFE::ZipSource::open(), and readSingle().

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 94 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 Appends a null terminator character to the end

Parameters
lenthe stringlen
Returns
the string
Exceptions
IndexOverflow

Definition at line 128 of file rawdata.cpp.

void FIFE::RawData::setIndex ( uint32_t  index)

set the current index

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

Definition at line 83 of file rawdata.cpp.

Referenced by FIFE::ZipSource::open().

Here is the caller graph for this function:


The documentation for this class was generated from the following files: