hoa_script::ScriptDescriptor Class Reference

An abstract class for representing open script files. More...

#include <script.h>

Inheritance diagram for hoa_script::ScriptDescriptor:

Inheritance graph
[legend]
Collaboration diagram for hoa_script::ScriptDescriptor:

Collaboration graph
[legend]
List of all members.

Public Member Functions

bool IsErrorDetected ()
 Returns true if any errors have been detected but not retrieved.
bool IsFileOpen ()
 Returns true if the file is open.
 ScriptDescriptor ()
virtual ~ScriptDescriptor ()
 If there are any error messages remaining, the destructor will print them when in debug mode.
Class Member Access Functions
void ClearErrors ()
 Clears any error messages that have been logged.
const SCRIPT_ACCESS_MODE GetAccessMode ()
 
Note:
This can also be used to determine what type of derived object this object points to (read, write, modify)

std::string GetErrorMessages ()
 Returns a string containing all error messages.
const std::string & GetFilename ()
std::vector< std::string > GetOpenTables ()
File access functions
virtual void CloseFile ()=0
 Closes the script file and sets the _access_mode member to SCRIPT_CLOSED.
virtual bool OpenFile ()=0
 Opens the file named by the classes' _filename member.
virtual bool OpenFile (const std::string &file_name)=0

Protected Attributes

SCRIPT_ACCESS_MODE _access_mode
 The access mode for the file, including whether or not the file is closed.
std::ostringstream _error_messages
 Contains a list of errors that have occured in recent operations.
std::string _filename
 The name of the file that the class object represents.
std::vector< std::string > _open_tables
 The names of the Lua tables that are currently open.

Friends

class GameScript

Detailed Description

An abstract class for representing open script files.

****************************************************************************

This class is an abstract class for representing a Lua script file. Files with a .lua extension are human-readable, uncompiled Lua text files and files with a .hoa extension are compiled script files.

Note:
Compiled Lua files exhibit faster performance than uncompile files.

Definition at line 98 of file script.h.


Constructor & Destructor Documentation

hoa_script::ScriptDescriptor::ScriptDescriptor (  )  [inline]

Definition at line 102 of file script.h.

References _access_mode, _error_messages, _filename, and hoa_script::SCRIPT_CLOSED.

virtual hoa_script::ScriptDescriptor::~ScriptDescriptor (  )  [inline, virtual]

If there are any error messages remaining, the destructor will print them when in debug mode.

Definition at line 106 of file script.h.


Member Function Documentation

void hoa_script::ScriptDescriptor::ClearErrors (  )  [inline]

Clears any error messages that have been logged.

Note:
Be careful when calling this function. It won't do any harm, but if used incorrectly it will deny you useful information when debugging your code or script.

Definition at line 148 of file script.h.

References _error_messages.

Referenced by GetErrorMessages().

virtual void hoa_script::ScriptDescriptor::CloseFile (  )  [pure virtual]

Closes the script file and sets the _access_mode member to SCRIPT_CLOSED.

Implemented in hoa_script::ModifyScriptDescriptor, hoa_script::ReadScriptDescriptor, and hoa_script::WriteScriptDescriptor.

const SCRIPT_ACCESS_MODE hoa_script::ScriptDescriptor::GetAccessMode (  )  [inline]

Note:
This can also be used to determine what type of derived object this object points to (read, write, modify)

Definition at line 141 of file script.h.

References _access_mode.

std::string hoa_script::ScriptDescriptor::GetErrorMessages (  )  [inline]

Returns a string containing all error messages.

Returns:
A string containing a list of error messages, or an empty string if no errors occured
Note:
Everytime this function is called, the error messages stored by the class are cleared.
You can use this method in place of IsErrorDetected() if you like by simply checking if the return value is an empty string. It is highly recommended that you check for errors after making a block of read/write/modify calls. You may choose to check errors after every call if you like, but this practice is usually not recommended.

Definition at line 160 of file script.h.

References _error_messages, and ClearErrors().

Referenced by hoa_global::GlobalAttackPoint::_LoadData(), hoa_boot::BootMode::BootMode(), hoa_global::GlobalArmor::GlobalArmor(), hoa_global::GlobalCharacter::GlobalCharacter(), hoa_global::GlobalEnemy::GlobalEnemy(), hoa_global::GlobalItem::GlobalItem(), hoa_global::GlobalSkill::GlobalSkill(), hoa_global::GlobalWeapon::GlobalWeapon(), hoa_system::GameSystem::SingletonInitialize(), and hoa_input::GameInput::SingletonInitialize().

Here is the call graph for this function:

const std::string& hoa_script::ScriptDescriptor::GetFilename (  )  [inline]

Definition at line 137 of file script.h.

References _filename.

Referenced by hoa_map::MapMode::_LoadTiles().

std::vector<std::string> hoa_script::ScriptDescriptor::GetOpenTables (  )  [inline]

Note:
This returns a copy, not a reference, because we don't want it to be modified outside of the class.

Definition at line 166 of file script.h.

References _open_tables.

bool hoa_script::ScriptDescriptor::IsErrorDetected (  )  [inline]

Returns true if any errors have been detected but not retrieved.

Definition at line 132 of file script.h.

References _error_messages.

Referenced by hoa_global::GlobalAttackPoint::_LoadData(), hoa_boot::BootMode::BootMode(), hoa_script::WriteScriptDescriptor::CloseFile(), hoa_script::ReadScriptDescriptor::CloseFile(), hoa_script::ModifyScriptDescriptor::CloseFile(), hoa_global::GlobalArmor::GlobalArmor(), hoa_global::GlobalCharacter::GlobalCharacter(), hoa_global::GlobalEnemy::GlobalEnemy(), hoa_global::GlobalItem::GlobalItem(), hoa_global::GlobalSkill::GlobalSkill(), hoa_global::GlobalWeapon::GlobalWeapon(), hoa_editor::Grid::LoadMap(), hoa_system::GameSystem::SingletonInitialize(), hoa_input::GameInput::SingletonInitialize(), and hoa_editor::Tileset::Tileset().

bool hoa_script::ScriptDescriptor::IsFileOpen (  )  [inline]

Returns true if the file is open.

Definition at line 128 of file script.h.

References _access_mode, and hoa_script::SCRIPT_CLOSED.

Referenced by hoa_global::GameGlobal::_LoadCharacter(), hoa_global::GlobalAttackPoint::_LoadData(), hoa_global::GameGlobal::_LoadEvents(), hoa_global::GameGlobal::_LoadInventory(), hoa_global::GameGlobal::_SaveCharacter(), hoa_global::GameGlobal::_SaveEvents(), hoa_global::GameGlobal::_SaveInventory(), hoa_script::WriteScriptDescriptor::CloseFile(), hoa_script::ReadScriptDescriptor::CloseFile(), hoa_script::ModifyScriptDescriptor::CloseFile(), hoa_script::ModifyScriptDescriptor::~ModifyScriptDescriptor(), hoa_script::ReadScriptDescriptor::~ReadScriptDescriptor(), and hoa_script::WriteScriptDescriptor::~WriteScriptDescriptor().

virtual bool hoa_script::ScriptDescriptor::OpenFile (  )  [pure virtual]

Opens the file named by the classes' _filename member.

Returns:
False on failure, true on success.

Implemented in hoa_script::ModifyScriptDescriptor, hoa_script::ReadScriptDescriptor, and hoa_script::WriteScriptDescriptor.

virtual bool hoa_script::ScriptDescriptor::OpenFile ( const std::string &  file_name  )  [pure virtual]

Parameters:
file_name The name of the Lua file to be opened.
Returns:
False on failure or true on success.
Note:
This is the only function that uses explicit error checking. An error in this function call will not change the return value of the GetErrors() function.

Implemented in hoa_script::ModifyScriptDescriptor, hoa_script::ReadScriptDescriptor, and hoa_script::WriteScriptDescriptor.


Friends And Related Function Documentation

friend class GameScript [friend]

Reimplemented in hoa_script::ModifyScriptDescriptor, hoa_script::ReadScriptDescriptor, and hoa_script::WriteScriptDescriptor.

Definition at line 99 of file script.h.


Member Data Documentation

SCRIPT_ACCESS_MODE hoa_script::ScriptDescriptor::_access_mode [protected]

The access mode for the file, including whether or not the file is closed.

Definition at line 175 of file script.h.

Referenced by hoa_script::WriteScriptDescriptor::CloseFile(), hoa_script::ReadScriptDescriptor::CloseFile(), hoa_script::ModifyScriptDescriptor::CloseFile(), GetAccessMode(), IsFileOpen(), hoa_script::ModifyScriptDescriptor::OpenFile(), ScriptDescriptor(), hoa_script::ModifyScriptDescriptor::~ModifyScriptDescriptor(), hoa_script::ReadScriptDescriptor::~ReadScriptDescriptor(), and hoa_script::WriteScriptDescriptor::~WriteScriptDescriptor().

std::ostringstream hoa_script::ScriptDescriptor::_error_messages [protected]

Contains a list of errors that have occured in recent operations.

Definition at line 178 of file script.h.

Referenced by hoa_script::ModifyScriptDescriptor::_AddNewData(), hoa_script::ModifyScriptDescriptor::_CommitTable(), hoa_script::ReadScriptDescriptor::_DoesDataExist(), hoa_script::ModifyScriptDescriptor::_ModifyData(), hoa_script::ReadScriptDescriptor::_ReadData(), hoa_script::ReadScriptDescriptor::_ReadDataVector(), hoa_script::ReadScriptDescriptor::_ReadDataVectorHelper(), hoa_script::ReadScriptDescriptor::_ReadTableKeys(), hoa_script::WriteScriptDescriptor::_WriteData(), hoa_script::WriteScriptDescriptor::_WriteDataVector(), hoa_script::WriteScriptDescriptor::_WriteTablePath(), hoa_script::WriteScriptDescriptor::BeginCommentBlock(), ClearErrors(), hoa_script::WriteScriptDescriptor::CloseFile(), hoa_script::ReadScriptDescriptor::CloseFile(), hoa_script::ModifyScriptDescriptor::CloseFile(), hoa_script::ReadScriptDescriptor::CloseTable(), hoa_script::ModifyScriptDescriptor::CommitChanges(), hoa_script::WriteScriptDescriptor::EndCommentBlock(), hoa_script::WriteScriptDescriptor::EndTable(), GetErrorMessages(), hoa_script::ReadScriptDescriptor::GetTableSize(), IsErrorDetected(), hoa_script::ReadScriptDescriptor::OpenTable(), hoa_script::ReadScriptDescriptor::ReadFunctionPointer(), ScriptDescriptor(), hoa_script::WriteScriptDescriptor::WriteBool(), hoa_script::WriteScriptDescriptor::WriteBoolVector(), hoa_script::ModifyScriptDescriptor::~ModifyScriptDescriptor(), hoa_script::ReadScriptDescriptor::~ReadScriptDescriptor(), and hoa_script::WriteScriptDescriptor::~WriteScriptDescriptor().

std::string hoa_script::ScriptDescriptor::_filename [protected]

The name of the file that the class object represents.

Definition at line 172 of file script.h.

Referenced by hoa_script::GameScript::_AddOpenFile(), hoa_script::GameScript::_RemoveOpenFile(), hoa_script::WriteScriptDescriptor::CloseFile(), hoa_script::ReadScriptDescriptor::CloseFile(), hoa_script::ModifyScriptDescriptor::CloseFile(), hoa_script::ModifyScriptDescriptor::CommitChanges(), GetFilename(), hoa_script::WriteScriptDescriptor::OpenFile(), hoa_script::ReadScriptDescriptor::OpenFile(), hoa_script::ModifyScriptDescriptor::OpenFile(), ScriptDescriptor(), hoa_script::ModifyScriptDescriptor::~ModifyScriptDescriptor(), hoa_script::ReadScriptDescriptor::~ReadScriptDescriptor(), and hoa_script::WriteScriptDescriptor::~WriteScriptDescriptor().

std::vector<std::string> hoa_script::ScriptDescriptor::_open_tables [protected]

The names of the Lua tables that are currently open.

Definition at line 181 of file script.h.

Referenced by hoa_script::ModifyScriptDescriptor::_AddNewData(), hoa_script::ReadScriptDescriptor::_DoesDataExist(), hoa_script::ModifyScriptDescriptor::_ModifyData(), hoa_script::ReadScriptDescriptor::_ReadData(), hoa_script::ReadScriptDescriptor::_ReadDataVector(), hoa_script::ReadScriptDescriptor::_ReadTableKeys(), hoa_script::WriteScriptDescriptor::_WriteData(), hoa_script::WriteScriptDescriptor::_WriteDataVector(), hoa_script::WriteScriptDescriptor::_WriteTablePath(), hoa_script::WriteScriptDescriptor::BeginTable(), hoa_script::ReadScriptDescriptor::CloseAllTables(), hoa_script::WriteScriptDescriptor::CloseFile(), hoa_script::ReadScriptDescriptor::CloseFile(), hoa_script::ModifyScriptDescriptor::CloseFile(), hoa_script::ReadScriptDescriptor::CloseTable(), hoa_script::WriteScriptDescriptor::EndTable(), GetOpenTables(), hoa_script::ReadScriptDescriptor::GetTableSize(), hoa_script::ReadScriptDescriptor::OpenTable(), hoa_script::WriteScriptDescriptor::WriteBool(), hoa_script::WriteScriptDescriptor::WriteBoolVector(), hoa_script::ModifyScriptDescriptor::~ModifyScriptDescriptor(), hoa_script::ReadScriptDescriptor::~ReadScriptDescriptor(), and hoa_script::WriteScriptDescriptor::~WriteScriptDescriptor().


The documentation for this class was generated from the following file:
Generated on Fri Jul 6 23:15:50 2007 for Hero of Allacrost by  doxygen 1.5.1