xoreos
0.0.5
|
Class to hold the GFF'd two-dimensional array of a GDA file. More...
#include <gdafile.h>
Classes | |
struct | Header |
Public Types | |
enum | Type { kTypeEmpty = -1, kTypeString = 0, kTypeInt = 1, kTypeFloat = 2, kTypeBool = 3, kTypeResource = 4 } |
typedef std::vector< Header > | Headers |
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 Headers & | getHeaders () const |
Get the column headers. More... | |
const GFF4Struct * | getRow (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< GFF4File > | GFF4s |
typedef const GFF4List * | Columns |
typedef const GFF4List * | Row |
typedef std::vector< Row > | Rows |
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 GFF4Struct * | getRowColumn (size_t row, uint32 hash, size_t &column) const |
const GFF4Struct * | getRowColumn (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 |
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.
|
private |
|
private |
|
private |
|
private |
typedef std::vector<Header> Aurora::GDAFile::Headers |
|
private |
|
private |
|
private |
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().
Aurora::GDAFile::~GDAFile | ( | ) |
Definition at line 54 of file gdafile.cpp.
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.
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().
size_t Aurora::GDAFile::findColumn | ( | uint32 | hash | ) | const |
Find a column by its hash.
Definition at line 129 of file gdafile.cpp.
References _columnHashMap, _columns, Aurora::GFF4FieldNamesEnum::kGFF4G2DAColumn1, Aurora::GFF4FieldNamesEnum::kGFF4G2DAColumnHash, and kInvalidColumn.
size_t Aurora::GDAFile::findRow | ( | uint32 | id | ) | const |
Find a row by its ID value.
Definition at line 95 of file gdafile.cpp.
References _rowCount, _rows, findColumn(), kInvalidColumn, and kInvalidRow.
Referenced by Engines::DragonAge::Creature::findEquipModel(), Engines::DragonAge2::Creature::findEquipModel(), Engines::DragonAge2::Creature::getItemModel(), Engines::DragonAge::getMGDA(), Engines::DragonAge2::getMGDA(), Engines::DragonAge2::Placeable::load(), Engines::DragonAge::Placeable::load(), Engines::DragonAge2::Creature::loadModelsHeadList(), Engines::DragonAge::Creature::loadModelsHeadList(), and Engines::DragonAge::Creature::loadModelsParts().
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().
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().
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().
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().
Definition at line 184 of file gdafile.cpp.
References getRowColumn(), and Aurora::GFF4Struct::getSint().
Referenced by Engines::Sonic::Console::cmdListAreas(), Engines::DragonAge::Creature::findEquipModel(), Engines::DragonAge2::Creature::getItemModel(), Engines::Sonic::Area::loadDefinition(), Engines::DragonAge2::Creature::loadModelsHeadList(), Engines::DragonAge::Creature::loadModelsHeadList(), Engines::DragonAge2::Creature::loadModelsParts(), and Engines::Sonic::Console::updateAreas().
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().
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().
|
private |
Definition at line 149 of file gdafile.cpp.
References findColumn(), getRow(), and kInvalidColumn.
Referenced by getFloat(), getInt(), and getString().
|
private |
Definition at line 157 of file gdafile.cpp.
References findColumn(), getRow(), and kInvalidColumn.
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().
Common::UString Aurora::GDAFile::getString | ( | size_t | row, |
uint32 | columnHash, | ||
const Common::UString & | def = "" |
||
) | const |
Definition at line 165 of file gdafile.cpp.
References getRowColumn(), and Aurora::GFF4Struct::getString().
Referenced by Engines::DragonAge::Creature::createModelPart(), Engines::DragonAge2::Creature::createModelPart(), Engines::DragonAge::Creature::createModelPrefix(), Engines::DragonAge2::Creature::createModelPrefix(), Engines::DragonAge2::getMGDA(), Engines::DragonAge::getMGDA(), Engines::DragonAge::Placeable::load(), Engines::DragonAge2::Placeable::load(), Engines::DragonAge::Waypoint::load(), Engines::DragonAge2::Waypoint::load(), Engines::Sonic::Placeable::load(), Engines::Sonic::Area::loadDefinition(), Engines::DragonAge2::Creature::loadModelsHead(), Engines::DragonAge::Creature::loadModelsHead(), Engines::DragonAge2::Creature::loadModelsParts(), Engines::DragonAge::Creature::loadModelsParts(), Engines::DragonAge2::Creature::loadModelsSimple(), Engines::DragonAge::Creature::loadModelsSimple(), Engines::DragonAge2::Creature::loadModelsWelded(), and Engines::DragonAge::Creature::loadModelsWelded().
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().
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().
|
private |
Definition at line 220 of file gdafile.cpp.
References Aurora::GFF4Struct::kFieldTypeASCIIString, Aurora::GFF4Struct::kFieldTypeFloat32, Aurora::GFF4Struct::kFieldTypeFloat64, Aurora::GFF4Struct::kFieldTypeSint16, Aurora::GFF4Struct::kFieldTypeSint32, Aurora::GFF4Struct::kFieldTypeSint64, Aurora::GFF4Struct::kFieldTypeSint8, Aurora::GFF4Struct::kFieldTypeString, Aurora::GFF4Struct::kFieldTypeUint16, Aurora::GFF4Struct::kFieldTypeUint32, Aurora::GFF4Struct::kFieldTypeUint64, Aurora::GFF4Struct::kFieldTypeUint8, Aurora::GFF4FieldNamesEnum::kGFF4G2DAColumn1, Aurora::GFF4FieldNamesEnum::kGFF4G2DAColumnType, kTypeBool, kTypeEmpty, kTypeFloat, kTypeInt, kTypeResource, and kTypeString.
Referenced by add(), and load().
|
private |
Definition at line 274 of file gdafile.cpp.
References _columns, _gff4s, _headers, _rowCount, _rows, _rowStarts, Common::StackException::add(), Common::debugTag(), Aurora::GFF4Struct::getList(), identifyType(), kG2DAID, Aurora::GFF4FieldNamesEnum::kGFF4G2DAColumn1, Aurora::GFF4FieldNamesEnum::kGFF4G2DAColumnHash, Aurora::GFF4FieldNamesEnum::kGFF4G2DAColumnList, Aurora::GFF4FieldNamesEnum::kGFF4G2DARowList, kVersion01, and kVersion02.
Referenced by GDAFile().
|
mutableprivate |
Definition at line 157 of file gdafile.h.
Referenced by findColumn().
|
mutableprivate |
Definition at line 158 of file gdafile.h.
Referenced by findColumn().
|
private |
Definition at line 150 of file gdafile.h.
Referenced by add(), findColumn(), getColumnCount(), and load().
|
private |
|
private |
Definition at line 148 of file gdafile.h.
Referenced by getHeaders(), and load().
|
private |
|
private |
|
private |
|
static |
Definition at line 64 of file gdafile.h.
Referenced by findColumn(), findRow(), and getRowColumn().
|
static |
Definition at line 65 of file gdafile.h.
Referenced by Engines::DragonAge::Creature::createModelPart(), Engines::DragonAge2::Creature::createModelPart(), Engines::DragonAge::Creature::createModelPrefix(), Engines::DragonAge2::Creature::createModelPrefix(), Engines::DragonAge::Creature::findEquipModel(), Engines::DragonAge2::Creature::findEquipModel(), findRow(), Engines::DragonAge2::Creature::getItemModel(), Engines::DragonAge2::Creature::loadModelsHeadList(), and Engines::DragonAge::Creature::loadModelsHeadList().