ScummVM API documentation
Agi::WagFileParser Class Reference

#include <wagparser.h>

Public Types

enum  { WINAGI_VERSION_LENGTH = 16 }
 
typedef Common::Array< WagPropertyPropertyList
 A type definition for an array of *.wag file properties.
 

Public Member Functions

 WagFileParser ()
 
 ~WagFileParser ()
 
void addPropFromIni (Common::INIFile &iniWagFile, Common::String section, Common::String key, Agi::WagProperty::WagPropertyCode code)
 
bool parse (const Common::FSNode &node)
 
const PropertyListgetProperties () const
 
const WagPropertygetProperty (const WagProperty::WagPropertyCode code) const
 
bool checkAgiVersionProperty (const WagProperty &version) const
 
uint16 convertToAgiVersionNumber (const WagProperty &version)
 
bool parsedOk () const
 

Protected Member Functions

bool checkWagVersion (Common::SeekableReadStream &stream)
 
bool endOfProperties (const Common::SeekableReadStream &stream) const
 

Protected Attributes

PropertyList _propList
 List of loaded properties from the file.
 
bool _parsedOk
 Did the parsing of the file go ok?
 

Detailed Description

Class for parsing *.wag files created by WinAGI. Using this class you can get information about fanmade AGI games if they have provided a *.wag file with them.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
WINAGI_VERSION_LENGTH 

WinAGI's version string's length (Always 16)

Constructor & Destructor Documentation

◆ WagFileParser()

Agi::WagFileParser::WagFileParser ( )

Constructor. Creates a WagFileParser object in a default state.

◆ ~WagFileParser()

Agi::WagFileParser::~WagFileParser ( )

Destructor.

Member Function Documentation

◆ addPropFromIni()

void Agi::WagFileParser::addPropFromIni ( Common::INIFile iniWagFile,
Common::String  section,
Common::String  key,
Agi::WagProperty::WagPropertyCode  code 
)

Add property to _propList from INI file, if key exist

Parameters
iniWagFileini loaded from WAG file stream
sectionini section
keyini key
codecorresponding WAG code

◆ parse()

bool Agi::WagFileParser::parse ( const Common::FSNode node)

Loads a *.wag file and parses it.

Note
After this you can access the loaded properties using getProperty() and getProperties() etc.
Parameters
filenameName of the file to be parsed.
Returns
True if parsed successfully, false otherwise.

◆ getProperties()

const PropertyList& Agi::WagFileParser::getProperties ( ) const
inline

Get list of the loaded properties.

Note
Use only after a call to parse() first.
Returns
The list of loaded properties.

◆ getProperty()

const WagProperty* Agi::WagFileParser::getProperty ( const WagProperty::WagPropertyCode  code) const

Get property with the given property code.

Note
Use only after a call to parse() first.
Returns
Pointer to the property if its found in memory, NULL otherwise.

TODO/FIXME: Handle cases where several properties with the given property code are found. At the moment we don't need this functionality because the properties we use for fallback detection probably don't have multiples in the WAG-file. TODO: Make this faster than linear time if desired/needed.

◆ checkAgiVersionProperty()

bool Agi::WagFileParser::checkAgiVersionProperty ( const WagProperty version) const

Tests if the given property contains a valid AGI interpreter version string. A valid AGI interpreter version string is of the form "X.Y" or "X,Y" where X is a single decimal digit and Y is a string of decimal digits (At least one digit).

Parameters
versionThe property to be tested.
Returns
True if the given property contains a valid AGI interpreter version string, false otherwise.

◆ convertToAgiVersionNumber()

uint16 Agi::WagFileParser::convertToAgiVersionNumber ( const WagProperty version)

Convert property's data to an AGI interpreter version number.

Parameters
versionThe property to be converted (Property code should be PC_INTVERSION).
Returns
AGI interpreter version number if successful, 0 otherwise.

◆ parsedOk()

bool Agi::WagFileParser::parsedOk ( ) const
inline

Was the file parsed successfully?

Returns
True if file was parsed successfully, false otherwise.

◆ checkWagVersion()

bool Agi::WagFileParser::checkWagVersion ( Common::SeekableReadStream stream)
protected

Checks if stream has a valid WinAGI version string in its end.

Parameters
streamThe stream to be checked.
Returns
True if reading was successful and stream contains a valid WinAGI version string, false otherwise.

◆ endOfProperties()

bool Agi::WagFileParser::endOfProperties ( const Common::SeekableReadStream stream) const
protected

Checks if we're at or past the end of the properties stored in the stream.

Parameters
streamThe stream whose seeking position is to be checked.
Returns
True if stream's seeking position is at or past the end of the properties, false otherwise.

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