xoreos  0.0.5
Classes | Public Types | Public Member Functions | Static Public Attributes | Private Types | Private Member Functions | Private Attributes | List of all members
Aurora::GDAFile Class Reference

Class to hold the GFF'd two-dimensional array of a GDA file. More...

#include <gdafile.h>

Inheritance diagram for Aurora::GDAFile:
Inheritance graph
[legend]
Collaboration diagram for Aurora::GDAFile:
Collaboration graph
[legend]

Classes

struct  Header
 

Public Types

enum  Type {
  kTypeEmpty = -1, kTypeString = 0, kTypeInt = 1, kTypeFloat = 2,
  kTypeBool = 3, kTypeResource = 4
}
 
typedef std::vector< HeaderHeaders
 

Public Member Functions

 GDAFile (Common::SeekableReadStream *gda)
 Take over this stream and read a GDA file out of it. More...
 
 ~GDAFile ()
 
void add (Common::SeekableReadStream *gda)
 Add another GDA with the same column structure to the bottom of this GDA. More...
 
size_t getColumnCount () const
 Return the number of columns in the array. More...
 
size_t getRowCount () const
 Return the number of rows in the array. More...
 
bool hasRow (size_t row) const
 Does this row exist in the GDA? More...
 
const HeadersgetHeaders () const
 Get the column headers. More...
 
const GFF4StructgetRow (size_t row) const
 Get a row as a GFF4 struct. More...
 
size_t findRow (uint32 id) const
 Find a row by its ID value. More...
 
size_t findColumn (const Common::UString &name) const
 Find a column by its name. More...
 
size_t findColumn (uint32 hash) const
 Find a column by its hash. More...
 
Common::UString getString (size_t row, uint32 columnHash, const Common::UString &def="") const
 
Common::UString getString (size_t row, const Common::UString &columnName, const Common::UString &def="") const
 
int32 getInt (size_t row, uint32 columnHash, int32 def=0) const
 
int32 getInt (size_t row, const Common::UString &columnName, int32 def=0) const
 
float getFloat (size_t row, uint32 columnHash, float def=0.0f) const
 
float getFloat (size_t row, const Common::UString &columnName, float def=0.0f) const
 

Static Public Attributes

static const size_t kInvalidColumn = SIZE_MAX
 
static const size_t kInvalidRow = SIZE_MAX
 

Private Types

typedef Common::PtrVector< GFF4FileGFF4s
 
typedef const GFF4ListColumns
 
typedef const GFF4ListRow
 
typedef std::vector< RowRows
 
typedef std::vector< size_t > RowStarts
 
typedef std::map< uint32, size_t > ColumnHashMap
 
typedef std::map< Common::UString, size_t > ColumnNameMap
 

Private Member Functions

void load (Common::SeekableReadStream *gda)
 
Type identifyType (const Columns &columns, const Row &rows, size_t column) const
 
const GFF4StructgetRowColumn (size_t row, uint32 hash, size_t &column) const
 
const GFF4StructgetRowColumn (size_t row, const Common::UString &name, size_t &column) const
 

Private Attributes

GFF4s _gff4s
 
Headers _headers
 
Columns _columns
 
Rows _rows
 
size_t _rowCount
 
RowStarts _rowStarts
 
ColumnHashMap _columnHashMap
 
ColumnNameMap _columnNameMap
 

Detailed Description

Class to hold the GFF'd two-dimensional array of a GDA file.

GDAs works very similar to 2DA files (see TwoDAFile in 2dafile.h). But instead of keeping the data inside a simple ASCII or binary format, GDAs store their table data inside a V4.0 GFF.

Moreover, GDAs do not contain column headers as strings. Instead, they only store the CRC32 hash of the lower-case string encoded in UTF-16LE. As such, it is not possible to directly list the column names of a GDA without prior knowledge.

Several GDAs with the same column layout can also be combined into an MGDA, creating a merged, combined table. This is commonly used by the Dragon Age games. Within these MGDAs, rows are not anymore identified by raw row index (since this index is now meaningless), but by an "ID" column.

Definition at line 62 of file gdafile.h.

Member Typedef Documentation

◆ ColumnHashMap

typedef std::map<uint32, size_t> Aurora::GDAFile::ColumnHashMap
private

Definition at line 142 of file gdafile.h.

◆ ColumnNameMap

typedef std::map<Common::UString, size_t> Aurora::GDAFile::ColumnNameMap
private

Definition at line 143 of file gdafile.h.

◆ Columns

typedef const GFF4List* Aurora::GDAFile::Columns
private

Definition at line 137 of file gdafile.h.

◆ GFF4s

Definition at line 136 of file gdafile.h.

◆ Headers

typedef std::vector<Header> Aurora::GDAFile::Headers

Definition at line 84 of file gdafile.h.

◆ Row

typedef const GFF4List* Aurora::GDAFile::Row
private

Definition at line 138 of file gdafile.h.

◆ Rows

typedef std::vector<Row> Aurora::GDAFile::Rows
private

Definition at line 139 of file gdafile.h.

◆ RowStarts

typedef std::vector<size_t> Aurora::GDAFile::RowStarts
private

Definition at line 140 of file gdafile.h.

Member Enumeration Documentation

◆ Type

Enumerator
kTypeEmpty 
kTypeString 
kTypeInt 
kTypeFloat 
kTypeBool 
kTypeResource 

Definition at line 67 of file gdafile.h.

Constructor & Destructor Documentation

◆ GDAFile()

Aurora::GDAFile::GDAFile ( Common::SeekableReadStream gda)

Take over this stream and read a GDA file out of it.

Definition at line 48 of file gdafile.cpp.

References load().

Here is the call graph for this function:

◆ ~GDAFile()

Aurora::GDAFile::~GDAFile ( )

Definition at line 54 of file gdafile.cpp.

Member Function Documentation

◆ add()

void Aurora::GDAFile::add ( Common::SeekableReadStream gda)

Add another GDA with the same column structure to the bottom of this GDA.

This effectively pastes the GDAs together, creating one combined table. Note that the row numbers will be continuous and therefore will be different depending on the order of the pasting, making them useless for row identification. An ID column should be used for this case.

The ownership stream will be transferred to this GDAFile object.

Definition at line 306 of file gdafile.cpp.

References _columns, _gff4s, _rowCount, _rows, _rowStarts, Common::StackException::add(), Common::debugTag(), Aurora::GFF4Struct::getList(), identifyType(), kG2DAID, Aurora::GFF4FieldNamesEnum::kGFF4G2DAColumnHash, Aurora::GFF4FieldNamesEnum::kGFF4G2DAColumnList, Aurora::GFF4FieldNamesEnum::kGFF4G2DARowList, kVersion01, and kVersion02.

Here is the call graph for this function:

◆ findColumn() [1/2]

size_t Aurora::GDAFile::findColumn ( const Common::UString name) const

Find a column by its name.

Definition at line 118 of file gdafile.cpp.

References _columnNameMap, Common::hashStringCRC32(), Common::kEncodingUTF16LE, and Common::UString::toLower().

Referenced by findRow(), and getRowColumn().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ findColumn() [2/2]

size_t Aurora::GDAFile::findColumn ( uint32  hash) const

◆ findRow()

size_t Aurora::GDAFile::findRow ( uint32  id) const

◆ getColumnCount()

size_t Aurora::GDAFile::getColumnCount ( ) const

Return the number of columns in the array.

Definition at line 57 of file gdafile.cpp.

References _columns.

Referenced by Aurora::TwoDAFile::load().

Here is the caller graph for this function:

◆ getFloat() [1/2]

float Aurora::GDAFile::getFloat ( size_t  row,
uint32  columnHash,
float  def = 0.0f 
) const

Definition at line 202 of file gdafile.cpp.

References Aurora::GFF4Struct::getDouble(), and getRowColumn().

Referenced by Engines::Sonic::Placeable::load(), and Engines::Sonic::Area::loadDefinition().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getFloat() [2/2]

float Aurora::GDAFile::getFloat ( size_t  row,
const Common::UString columnName,
float  def = 0.0f 
) const

Definition at line 211 of file gdafile.cpp.

References Aurora::GFF4Struct::getDouble(), and getRowColumn().

Here is the call graph for this function:

◆ getHeaders()

const GDAFile::Headers & Aurora::GDAFile::getHeaders ( ) const

Get the column headers.

Definition at line 65 of file gdafile.cpp.

References _headers.

Referenced by Aurora::TwoDAFile::load().

Here is the caller graph for this function:

◆ getInt() [1/2]

int32 Aurora::GDAFile::getInt ( size_t  row,
uint32  columnHash,
int32  def = 0 
) const

◆ getInt() [2/2]

int32 Aurora::GDAFile::getInt ( size_t  row,
const Common::UString columnName,
int32  def = 0 
) const

Definition at line 193 of file gdafile.cpp.

References getRowColumn(), and Aurora::GFF4Struct::getSint().

Here is the call graph for this function:

◆ getRow()

const GFF4Struct * Aurora::GDAFile::getRow ( size_t  row) const

Get a row as a GFF4 struct.

Definition at line 73 of file gdafile.cpp.

References _rows, and _rowStarts.

Referenced by getRowColumn(), hasRow(), and Aurora::TwoDAFile::load().

Here is the caller graph for this function:

◆ getRowColumn() [1/2]

const GFF4Struct * Aurora::GDAFile::getRowColumn ( size_t  row,
uint32  hash,
size_t &  column 
) const
private

Definition at line 149 of file gdafile.cpp.

References findColumn(), getRow(), and kInvalidColumn.

Referenced by getFloat(), getInt(), and getString().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getRowColumn() [2/2]

const GFF4Struct * Aurora::GDAFile::getRowColumn ( size_t  row,
const Common::UString name,
size_t &  column 
) const
private

Definition at line 157 of file gdafile.cpp.

References findColumn(), getRow(), and kInvalidColumn.

Here is the call graph for this function:

◆ getRowCount()

size_t Aurora::GDAFile::getRowCount ( ) const

Return the number of rows in the array.

Definition at line 61 of file gdafile.cpp.

References _rowCount.

Referenced by Aurora::TwoDAFile::load(), Engines::Sonic::Area::loadDefinition(), and Engines::Sonic::Console::updateAreas().

Here is the caller graph for this function:

◆ getString() [1/2]

Common::UString Aurora::GDAFile::getString ( size_t  row,
uint32  columnHash,
const Common::UString def = "" 
) const

◆ getString() [2/2]

Common::UString Aurora::GDAFile::getString ( size_t  row,
const Common::UString columnName,
const Common::UString def = "" 
) const

Definition at line 174 of file gdafile.cpp.

References getRowColumn(), and Aurora::GFF4Struct::getString().

Here is the call graph for this function:

◆ hasRow()

bool Aurora::GDAFile::hasRow ( size_t  row) const

Does this row exist in the GDA?

Definition at line 69 of file gdafile.cpp.

References getRow().

Referenced by Engines::Sonic::Placeable::load(), and Engines::Sonic::Area::loadDefinition().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ identifyType()

GDAFile::Type Aurora::GDAFile::identifyType ( const Columns columns,
const Row rows,
size_t  column 
) const
private

◆ load()

void Aurora::GDAFile::load ( Common::SeekableReadStream gda)
private

Member Data Documentation

◆ _columnHashMap

ColumnHashMap Aurora::GDAFile::_columnHashMap
mutableprivate

Definition at line 157 of file gdafile.h.

Referenced by findColumn().

◆ _columnNameMap

ColumnNameMap Aurora::GDAFile::_columnNameMap
mutableprivate

Definition at line 158 of file gdafile.h.

Referenced by findColumn().

◆ _columns

Columns Aurora::GDAFile::_columns
private

Definition at line 150 of file gdafile.h.

Referenced by add(), findColumn(), getColumnCount(), and load().

◆ _gff4s

GFF4s Aurora::GDAFile::_gff4s
private

Definition at line 146 of file gdafile.h.

Referenced by add(), and load().

◆ _headers

Headers Aurora::GDAFile::_headers
private

Definition at line 148 of file gdafile.h.

Referenced by getHeaders(), and load().

◆ _rowCount

size_t Aurora::GDAFile::_rowCount
private

Definition at line 153 of file gdafile.h.

Referenced by add(), findRow(), getRowCount(), and load().

◆ _rows

Rows Aurora::GDAFile::_rows
private

Definition at line 151 of file gdafile.h.

Referenced by add(), findRow(), getRow(), and load().

◆ _rowStarts

RowStarts Aurora::GDAFile::_rowStarts
private

Definition at line 155 of file gdafile.h.

Referenced by add(), getRow(), and load().

◆ kInvalidColumn

const size_t Aurora::GDAFile::kInvalidColumn = SIZE_MAX
static

Definition at line 64 of file gdafile.h.

Referenced by findColumn(), findRow(), and getRowColumn().

◆ kInvalidRow

const size_t Aurora::GDAFile::kInvalidRow = SIZE_MAX
static

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