sqrat  0.9
sqrat
 All Classes Functions Variables Enumerations Enumerator Pages
Public Types | Public Member Functions | Static Public Attributes | List of all members
Sqrat::SqratVM Class Reference

Helper class that wraps a Squirrel virtual machine in a C++ API. More...

#include <sqratVM.h>

Public Types

enum  ERROR_STATE { SQRAT_NO_ERROR, SQRAT_COMPILE_ERROR, SQRAT_RUNTIME_ERROR }
 

Public Member Functions

 SqratVM (int initialStackSize=1024, unsigned char libsToLoad=LIB_ALL)
 
 ~SqratVM ()
 
HSQUIRRELVM GetVM ()
 
Sqrat::RootTableGetRootTable ()
 
Sqrat::ScriptGetScript ()
 
Sqrat::string GetLastErrorMsg ()
 
void SetLastErrorMsg (const Sqrat::string &str)
 
void SetPrintFunc (SQPRINTFUNCTION printFunc, SQPRINTFUNCTION errFunc)
 
void SetErrorHandler (SQFUNCTION runErr, SQCOMPILERERROR comErr)
 
ERROR_STATE DoString (const Sqrat::string &str)
 
ERROR_STATE DoFile (const Sqrat::string &file)
 

Static Public Attributes

static const unsigned char LIB_IO = 0x01
 Input/Output library.
 
static const unsigned char LIB_BLOB = 0x02
 Blob library.
 
static const unsigned char LIB_MATH = 0x04
 Math library.
 
static const unsigned char LIB_SYST = 0x08
 System library.
 
static const unsigned char LIB_STR = 0x10
 String library.
 
static const unsigned char LIB_ALL = LIB_IO | LIB_BLOB | LIB_MATH | LIB_SYST | LIB_STR
 All libraries.
 

Detailed Description

Helper class that wraps a Squirrel virtual machine in a C++ API.

Member Enumeration Documentation

Enumeration representing the different types of errors that may occur within a SqratVM

Enumerator
SQRAT_NO_ERROR 

For when no error has occurred.

SQRAT_COMPILE_ERROR 

For when a script compiling error has occurred.

SQRAT_RUNTIME_ERROR 

For when a script running error has occurred.

Constructor & Destructor Documentation

Sqrat::SqratVM::SqratVM ( int  initialStackSize = 1024,
unsigned char  libsToLoad = LIB_ALL 
)
inline

Default constructor

Parameters
initialStackSizeInitial size of the execution stack (if the stack is too small it will automatically grow)
libsToLoadSpecifies what standard Squirrel libraries should be loaded
Sqrat::SqratVM::~SqratVM ( )
inline

Destructor

Member Function Documentation

ERROR_STATE Sqrat::SqratVM::DoFile ( const Sqrat::string &  file)
inline

Runs a file containing a Squirrel script

Parameters
fileFile path containing a Squirrel script
Returns
An ERROR_STATE representing what happened
ERROR_STATE Sqrat::SqratVM::DoString ( const Sqrat::string &  str)
inline

Runs a string containing a Squirrel script

Parameters
strString containing a Squirrel script
Returns
An ERROR_STATE representing what happened
Sqrat::string Sqrat::SqratVM::GetLastErrorMsg ( )
inline

Gets the error message for the most recent Squirrel error with the VM

Returns
String containing a nice error message
Sqrat::RootTable& Sqrat::SqratVM::GetRootTable ( )
inline

Gets the root table for this VM

Returns
RootTable for the VM
Sqrat::Script& Sqrat::SqratVM::GetScript ( )
inline

Gets the associated Script for this VM

Returns
Script for the VM
HSQUIRRELVM Sqrat::SqratVM::GetVM ( )
inline

Gets the underlying Squirrel VM

Returns
Underlying Squirrel VM
void Sqrat::SqratVM::SetErrorHandler ( SQFUNCTION  runErr,
SQCOMPILERERROR  comErr 
)
inline

Sets the Squirrel error handlers

Parameters
runErrA pointer to the runtime error handler func
comErrA pointer to the compile error handler func
void Sqrat::SqratVM::SetLastErrorMsg ( const Sqrat::string &  str)
inline

Overwrites the most recent Squirrel error for this VM

Parameters
strA nice error message
void Sqrat::SqratVM::SetPrintFunc ( SQPRINTFUNCTION  printFunc,
SQPRINTFUNCTION  errFunc 
)
inline

Sets the print function of the virtual machine

Parameters
printFuncA pointer to the print func or NULL to disable the output
errFuncA pointer to the error func or NULL to disable the output
Remarks
The print function is used by the built-in Squirrel print function to output text.

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