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

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>

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

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 GFF4StructgetTopLevel () 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< StructTemplateStructTemplates
 
typedef std::vector< Common::UStringSharedStrings
 
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)
 
GFF4StructfindStruct (uint64 id)
 
Common::SeekableSubReadStreamEndiangetStream (uint32 offset) const
 
const StructTemplategetStructTemplate (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...
 

Detailed Description

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.

Member Typedef Documentation

◆ SharedStrings

typedef std::vector<Common::UString> Aurora::GFF4File::SharedStrings
private

Definition at line 157 of file gff4file.h.

◆ StructMap

typedef std::map<uint64, GFF4Struct *> Aurora::GFF4File::StructMap
private

Definition at line 158 of file gff4file.h.

◆ StructTemplates

typedef std::vector<StructTemplate> Aurora::GFF4File::StructTemplates
private

Definition at line 156 of file gff4file.h.

Member Enumeration Documentation

◆ Platform

Enumerator
kPlatformPC 
kPlatformPS3 
kPlatformXbox360 

Definition at line 118 of file gff4file.h.

Constructor & Destructor Documentation

◆ GFF4File() [1/2]

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

Here is the call graph for this function:

◆ GFF4File() [2/2]

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.

Here is the call graph for this function:

◆ ~GFF4File()

Aurora::GFF4File::~GFF4File ( )

Definition at line 97 of file gff4file.cpp.

References clear().

Here is the call graph for this function:

Member Function Documentation

◆ clear()

void Aurora::GFF4File::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().

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

◆ findStruct()

GFF4Struct * Aurora::GFF4File::findStruct ( uint64  id)
private

Definition at line 286 of file gff4file.cpp.

References _structs.

Referenced by Aurora::GFF4Struct::loadGeneric(), and Aurora::GFF4Struct::loadStructs().

Here is the caller graph for this function:

◆ getDataOffset()

uint32 Aurora::GFF4File::getDataOffset ( ) const
private

◆ getNativeEncoding()

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

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

◆ getPlatform()

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.

◆ getSharedString()

Common::UString Aurora::GFF4File::getSharedString ( uint32  i) const
private

Definition at line 316 of file gff4file.cpp.

References _sharedStrings.

Referenced by Aurora::GFF4Struct::getString(), and Aurora::GFF4Struct::getTalkString().

Here is the caller graph for this function:

◆ getStream()

Common::SeekableSubReadStreamEndian & Aurora::GFF4File::getStream ( uint32  offset) const
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().

Here is the caller graph for this function:

◆ getStructTemplate()

const GFF4File::StructTemplate & Aurora::GFF4File::getStructTemplate ( uint32  i) const
private

Definition at line 304 of file gff4file.cpp.

References _structTemplates.

Referenced by Aurora::GFF4Struct::loadStructs().

Here is the caller graph for this function:

◆ getTopLevel()

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

Here is the caller graph for this function:

◆ getType()

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.

◆ getTypeVersion()

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.

◆ hasSharedStrings()

bool Aurora::GFF4File::hasSharedStrings ( ) const
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().

Here is the caller graph for this function:

◆ isBigEndian()

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

Here is the call graph for this function:

◆ load()

void Aurora::GFF4File::load ( uint32  type)
private

Definition at line 143 of file gff4file.cpp.

References Common::StackException::add(), clear(), loadHeader(), loadStrings(), and loadStructs().

Referenced by GFF4File().

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

◆ loadHeader()

void Aurora::GFF4File::loadHeader ( uint32  type)
private

◆ loadStrings()

void Aurora::GFF4File::loadStrings ( )
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().

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

◆ loadStructs()

void Aurora::GFF4File::loadStructs ( )
private

◆ registerStruct()

void Aurora::GFF4File::registerStruct ( uint64  id,
GFF4Struct strct 
)
private

Definition at line 264 of file gff4file.cpp.

References _structs.

Referenced by Aurora::GFF4Struct::GFF4Struct().

Here is the caller graph for this function:

◆ unregisterStruct()

void Aurora::GFF4File::unregisterStruct ( uint64  id)
private

Definition at line 282 of file gff4file.cpp.

References _structs.

Referenced by Aurora::GFF4Struct::GFF4Struct().

Here is the caller graph for this function:

Friends And Related Function Documentation

◆ GFF4Struct

friend class GFF4Struct
friend

Definition at line 201 of file gff4file.h.

Referenced by loadStructs().

Member Data Documentation

◆ _header

Header Aurora::GFF4File::_header
private

◆ _origStream

Common::ScopedPtr<Common::SeekableReadStream> Aurora::GFF4File::_origStream
private

Definition at line 162 of file gff4file.h.

Referenced by clear(), GFF4File(), and loadHeader().

◆ _sharedStrings

SharedStrings Aurora::GFF4File::_sharedStrings
private

The shared strings used in V4.1.

Definition at line 171 of file gff4file.h.

Referenced by getSharedString(), and loadStrings().

◆ _stream

Common::ScopedPtr<Common::SeekableSubReadStreamEndian> Aurora::GFF4File::_stream
private

Definition at line 163 of file gff4file.h.

Referenced by clear(), getStream(), loadHeader(), loadStrings(), and loadStructs().

◆ _structs

StructMap Aurora::GFF4File::_structs
private

All actual structs in this GFF4.

Definition at line 174 of file gff4file.h.

Referenced by clear(), findStruct(), registerStruct(), and unregisterStruct().

◆ _structTemplates

StructTemplates Aurora::GFF4File::_structTemplates
private

All struct templates in this GFF4.

Definition at line 168 of file gff4file.h.

Referenced by getStructTemplate(), and loadStructs().

◆ _topLevelStruct

GFF4Struct* Aurora::GFF4File::_topLevelStruct
private

The top-level struct.

Definition at line 176 of file gff4file.h.

Referenced by clear(), getTopLevel(), and loadStructs().


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