xoreos
0.0.5
|
A GFF (generic file format) V4.0/V4.1 file, found in Dragon Age: Origins, Dragon Age 2 and Sonic Chronicles: The Dark Brotherhood. More...
#include <gff4file.h>
Classes | |
struct | Header |
A GFF4 header. More... | |
struct | StructTemplate |
A template of a struct, used when loading a struct. More... | |
Public Member Functions | |
GFF4File (Common::SeekableReadStream *gff4, uint32 type=0xFFFFFFFF) | |
Take over this stream and read a GFF4 file out of it. More... | |
GFF4File (const Common::UString &gff4, FileType fileType, uint32 type=0xFFFFFFFF) | |
Request this resource from the ResourceManager and read a GFF4 file out of it. More... | |
~GFF4File () | |
uint32 | getType () const |
Return the GFF4's specific type. More... | |
uint32 | getTypeVersion () const |
Return the GFF4's specific type version. More... | |
uint32 | getPlatform () const |
Return the platform this GFF4 is for. More... | |
bool | isBigEndian () const |
Is the GFF4's platform natively big endian? More... | |
Common::Encoding | getNativeEncoding () const |
Return the native UTF-16 encoding according to the GFF4's platform. More... | |
const GFF4Struct & | getTopLevel () const |
Returns the top-level struct. More... | |
Public Member Functions inherited from Aurora::AuroraFile | |
AuroraFile () | |
void | clear () |
uint32 | getID () const |
Return the file's ID. More... | |
uint32 | getVersion () const |
Return the file's version. More... | |
bool | isUTF16LE () const |
Were the ID and version encoded in little-endian UTF-16 in the file? More... | |
Private Types | |
enum | Platform { kPlatformPC = MKTAG('P', 'C', ' ', ' '), kPlatformPS3 = MKTAG('P', 'S', '3', ' '), kPlatformXbox360 = MKTAG('X', '3', '6', '0') } |
typedef std::vector< StructTemplate > | StructTemplates |
typedef std::vector< Common::UString > | SharedStrings |
typedef std::map< uint64, GFF4Struct * > | StructMap |
Private Member Functions | |
void | load (uint32 type) |
void | loadHeader (uint32 type) |
void | loadStructs () |
void | loadStrings () |
void | clear () |
void | registerStruct (uint64 id, GFF4Struct *strct) |
void | unregisterStruct (uint64 id) |
GFF4Struct * | findStruct (uint64 id) |
Common::SeekableSubReadStreamEndian & | getStream (uint32 offset) const |
const StructTemplate & | getStructTemplate (uint32 i) const |
uint32 | getDataOffset () const |
bool | hasSharedStrings () const |
Common::UString | getSharedString (uint32 i) const |
Private Attributes | |
Common::ScopedPtr< Common::SeekableReadStream > | _origStream |
Common::ScopedPtr< Common::SeekableSubReadStreamEndian > | _stream |
Header | _header |
This GFF4's header. More... | |
StructTemplates | _structTemplates |
All struct templates in this GFF4. More... | |
SharedStrings | _sharedStrings |
The shared strings used in V4.1. More... | |
StructMap | _structs |
All actual structs in this GFF4. More... | |
GFF4Struct * | _topLevelStruct |
The top-level struct. More... | |
Friends | |
class | GFF4Struct |
Additional Inherited Members | |
Static Public Member Functions inherited from Aurora::AuroraFile | |
static void | readHeader (Common::ReadStream &stream, uint32 &id, uint32 &version, bool &utf16le) |
Read the header out of a stream. More... | |
static void | readHeader (Common::ReadStream &stream, uint32 &id, uint32 &version) |
Read the ID and version out of a stream. More... | |
static uint32 | readHeaderID (Common::ReadStream &stream) |
Read the ID out of a stream. More... | |
Protected Member Functions inherited from Aurora::AuroraFile | |
void | readHeader (Common::ReadStream &stream) |
Static Protected Member Functions inherited from Aurora::AuroraFile | |
static uint32 | convertUTF16LE (uint32 x1, uint32 x2) |
Protected Attributes inherited from Aurora::AuroraFile | |
uint32 | _id |
The file's ID. More... | |
uint32 | _version |
The file's version. More... | |
bool | _utf16le |
The file's ID and version are in little-endian UTF-16. More... | |
A GFF (generic file format) V4.0/V4.1 file, found in Dragon Age: Origins, Dragon Age 2 and Sonic Chronicles: The Dark Brotherhood.
Just like GFF V3.2/V3.3 files, GFF V4.0/V4.1 store hierarchical data, similar in concept to XML and hold, for example, module and campaign descriptions. Unlike version 3 of the format, version 4 is optimized for access speed, with fields indexed by a numerical value instead of a human-readable string. A collection of currently known field values and their meanings can be found in gff4fields.h.
Unlike GFF3, GFF4 has a new concept, the generic. A generic is a field of variable type. I.e. a field can contain any other type. A list of generics can even contain different types at different indices.
GFF V4.0/V4.1 files come in a multitude of types (ARE, DLG, ...), each with its own 4-byte type ID ('ARE ', 'DLG ', ...). When specified in the GFF4File constructor, the loader will enforce that it matches, and throw an exception should it not. Conversely, an ID of 0xFFFFFFFF means that no such type ID enforcement should be done. In both cases, the type ID read from the file can get access through getType().
GFF V4.1 files exclusively appear in Dragon Age 2 (but Dragon Age 2 also has GFF V4.0 files). The only difference between these versions is that V4.1 has support for a global string table and every string field can reference a string within this table, so that duplicated strings don't need to be stored multiple times.
Notes:
See also: GFF3File in gff3file.h for the earlier V3.2/V3.3 versions of the GFF format.
Definition at line 93 of file gff4file.h.
|
private |
Definition at line 157 of file gff4file.h.
|
private |
Definition at line 158 of file gff4file.h.
|
private |
Definition at line 156 of file gff4file.h.
|
private |
Enumerator | |
---|---|
kPlatformPC | |
kPlatformPS3 | |
kPlatformXbox360 |
Definition at line 118 of file gff4file.h.
Aurora::GFF4File::GFF4File | ( | Common::SeekableReadStream * | gff4, |
uint32 | type = 0xFFFFFFFF |
||
) |
Take over this stream and read a GFF4 file out of it.
Definition at line 79 of file gff4file.cpp.
References _origStream, and load().
Aurora::GFF4File::GFF4File | ( | const Common::UString & | gff4, |
FileType | fileType, | ||
uint32 | type = 0xFFFFFFFF |
||
) |
Request this resource from the ResourceManager and read a GFF4 file out of it.
Definition at line 87 of file gff4file.cpp.
References _origStream, load(), Common::ScopedPtrBase< T, Deallocator >::reset(), ResMan, and TypeMan.
Aurora::GFF4File::~GFF4File | ( | ) |
Definition at line 97 of file gff4file.cpp.
References clear().
|
private |
Definition at line 101 of file gff4file.cpp.
References _origStream, _stream, _structs, _topLevelStruct, and Common::ScopedPtrBase< T, Deallocator >::reset().
Referenced by load(), and ~GFF4File().
|
private |
Definition at line 286 of file gff4file.cpp.
References _structs.
Referenced by Aurora::GFF4Struct::loadGeneric(), and Aurora::GFF4Struct::loadStructs().
|
private |
Definition at line 300 of file gff4file.cpp.
References _header, and Aurora::GFF4File::Header::dataOffset.
Referenced by Aurora::GFF4Struct::getDataOffset(), Aurora::GFF4Struct::getListCount(), Aurora::GFF4Struct::getString(), and Aurora::GFF4Struct::getTalkString().
Common::Encoding Aurora::GFF4File::getNativeEncoding | ( | ) | const |
Return the native UTF-16 encoding according to the GFF4's platform.
Definition at line 128 of file gff4file.cpp.
References _header, Aurora::GFF4File::Header::isBigEndian(), Common::kEncodingUTF16BE, and Common::kEncodingUTF16LE.
Referenced by Aurora::GFF4Struct::getString(), and Aurora::GFF4Struct::getTalkString().
uint32 Aurora::GFF4File::getPlatform | ( | ) | const |
Return the platform this GFF4 is for.
Definition at line 120 of file gff4file.cpp.
References _header, and Aurora::GFF4File::Header::platformID.
|
private |
Definition at line 316 of file gff4file.cpp.
References _sharedStrings.
Referenced by Aurora::GFF4Struct::getString(), and Aurora::GFF4Struct::getTalkString().
|
private |
Definition at line 294 of file gff4file.cpp.
References _stream.
Referenced by Aurora::GFF4Struct::getData(), Aurora::GFF4Struct::getDataOffset(), Aurora::GFF4Struct::load(), and Aurora::GFF4Struct::loadStructs().
|
private |
Definition at line 304 of file gff4file.cpp.
References _structTemplates.
Referenced by Aurora::GFF4Struct::loadStructs().
const GFF4Struct & Aurora::GFF4File::getTopLevel | ( | ) | const |
Returns the top-level struct.
Definition at line 135 of file gff4file.cpp.
References _topLevelStruct.
Referenced by Engines::Sonic::Area::loadLayout().
uint32 Aurora::GFF4File::getType | ( | ) | const |
Return the GFF4's specific type.
Definition at line 112 of file gff4file.cpp.
References _header, and Aurora::GFF4File::Header::type.
uint32 Aurora::GFF4File::getTypeVersion | ( | ) | const |
Return the GFF4's specific type version.
Definition at line 116 of file gff4file.cpp.
References _header, and Aurora::GFF4File::Header::typeVersion.
|
private |
Definition at line 312 of file gff4file.cpp.
References _header, and Aurora::GFF4File::Header::hasSharedStrings.
Referenced by Aurora::GFF4Struct::getString(), Aurora::GFF4Struct::getTalkString(), and Aurora::GFF4Struct::load().
bool Aurora::GFF4File::isBigEndian | ( | ) | const |
Is the GFF4's platform natively big endian?
Definition at line 124 of file gff4file.cpp.
References _header, and Aurora::GFF4File::Header::isBigEndian().
|
private |
Definition at line 143 of file gff4file.cpp.
References Common::StackException::add(), clear(), loadHeader(), loadStrings(), and loadStructs().
Referenced by GFF4File().
|
private |
Definition at line 158 of file gff4file.cpp.
References _header, Aurora::AuroraFile::_id, _origStream, _stream, Aurora::AuroraFile::_version, Common::UString::c_str(), Common::debugTag(), Common::ScopedPtrBase< T, Deallocator >::get(), Aurora::GFF4File::Header::isBigEndian(), kGFFID, kVersion40, kVersion41, Aurora::GFF4File::Header::read(), Aurora::AuroraFile::readHeader(), Common::ScopedPtrBase< T, Deallocator >::reset(), Aurora::GFF4File::Header::structCount, and Aurora::GFF4File::Header::type.
Referenced by load().
|
private |
Definition at line 245 of file gff4file.cpp.
References _header, _sharedStrings, _stream, Aurora::GFF4File::Header::hasSharedStrings, Common::kEncodingUTF8, Common::readString(), Aurora::GFF4File::Header::stringCount, and Aurora::GFF4File::Header::stringOffset.
Referenced by load().
|
private |
Definition at line 182 of file gff4file.cpp.
References _header, Aurora::GFF4Struct::_refCount, _stream, _structTemplates, _topLevelStruct, Aurora::GFF4File::Header::dataOffset, Aurora::GFF4File::StructTemplate::fields, Aurora::GFF4File::StructTemplate::Field::flags, GFF4Struct, Aurora::GFF4File::StructTemplate::index, Aurora::GFF4File::StructTemplate::Field::label, Aurora::GFF4File::StructTemplate::label, Aurora::GFF4File::StructTemplate::Field::offset, Aurora::GFF4File::StructTemplate::size, Aurora::GFF4File::Header::structCount, and Aurora::GFF4File::StructTemplate::Field::type.
Referenced by load().
|
private |
Definition at line 264 of file gff4file.cpp.
References _structs.
Referenced by Aurora::GFF4Struct::GFF4Struct().
|
private |
Definition at line 282 of file gff4file.cpp.
References _structs.
Referenced by Aurora::GFF4Struct::GFF4Struct().
|
friend |
Definition at line 201 of file gff4file.h.
Referenced by loadStructs().
|
private |
This GFF4's header.
Definition at line 166 of file gff4file.h.
Referenced by getDataOffset(), getNativeEncoding(), getPlatform(), getType(), getTypeVersion(), hasSharedStrings(), isBigEndian(), loadHeader(), loadStrings(), and loadStructs().
|
private |
Definition at line 162 of file gff4file.h.
Referenced by clear(), GFF4File(), and loadHeader().
|
private |
The shared strings used in V4.1.
Definition at line 171 of file gff4file.h.
Referenced by getSharedString(), and loadStrings().
|
private |
Definition at line 163 of file gff4file.h.
Referenced by clear(), getStream(), loadHeader(), loadStrings(), and loadStructs().
|
private |
All actual structs in this GFF4.
Definition at line 174 of file gff4file.h.
Referenced by clear(), findStruct(), registerStruct(), and unregisterStruct().
|
private |
All struct templates in this GFF4.
Definition at line 168 of file gff4file.h.
Referenced by getStructTemplate(), and loadStructs().
|
private |
The top-level struct.
Definition at line 176 of file gff4file.h.
Referenced by clear(), getTopLevel(), and loadStructs().