PixelLightAPI  .
Public Member Functions | Static Public Member Functions | Protected Member Functions
PLCore::ScriptManager Class Reference

Script manager. More...

#include <ScriptManager.h>

List of all members.

Public Member Functions

const Array< String > & GetScriptLanguages ()
 Returns a list of the names of the supported script languages.
String GetScriptLanguageByExtension (const String &sExtension)
 Returns the name of a script language by it's filename extension.
bool IsSupported (const String &sScriptLanguage)
 Checks whether or not a given script language is supported.
PLCORE_API String GetScriptLanguageExtension (const String &sScriptLanguage)
 Returns the filename extension of a given script language.
const Array< ScriptBinding * > & GetScriptBindings ()
 Returns a list of all script binding instances.
PLCORE_API ScriptCreate (const String &sScriptLanguage, bool bAddBindings=true)
 Creates a script instance.
PLCORE_API ScriptCreateFromFile (const String &sFilename, bool bAddBindings=true, String::EFormat nStringFormat=String::ASCII)
 Creates a script instance by using a given filename.

Static Public Member Functions

static PLCORE_API ScriptManagerGetInstance ()
static PLCORE_API bool HasInstance ()

Protected Member Functions

PLCORE_API ScriptManager ()
 Constructor.
virtual PLCORE_API ~ScriptManager ()
 Destructor.

Detailed Description

Script manager.


Constructor & Destructor Documentation

PLCORE_API PLCore::ScriptManager::ScriptManager ( ) [protected]
virtual PLCORE_API PLCore::ScriptManager::~ScriptManager ( ) [protected, virtual]

Destructor.


Member Function Documentation

static PLCORE_API ScriptManager* PLCore::ScriptManager::GetInstance ( ) [static]
static PLCORE_API bool PLCore::ScriptManager::HasInstance ( ) [static]

Returns a list of the names of the supported script languages.

Returns:
List of the names of the supported script languages

Returns the name of a script language by it's filename extension.

Parameters:
[in]sExtensionScript language filename extension to check (e.g. "js")
Returns:
Script language, empty string on error (possibly not supported filename extension)
bool PLCore::ScriptManager::IsSupported ( const String sScriptLanguage) [inline]

Checks whether or not a given script language is supported.

Parameters:
[in]sScriptLanguageScript language to check
Returns:
'true' if the given script language is supported, else 'false'
PLCORE_API String PLCore::ScriptManager::GetScriptLanguageExtension ( const String sScriptLanguage)

Returns the filename extension of a given script language.

Parameters:
[in]sScriptLanguageScript language to return the filename extension from
Returns:
The filename extension of the given script language, empty string on error (possibly not supported script language)
Note:
  • If the script language has more than one filename extension, the first filename extension will be returned

Returns a list of all script binding instances.

Returns:
List of all script binding instances
PLCORE_API Script* PLCore::ScriptManager::Create ( const String sScriptLanguage,
bool  bAddBindings = true 
)

Creates a script instance.

Parameters:
[in]sScriptLanguageScript language to use
[in]bAddBindingsIf 'true', add all available script bindings automatically (see "Script::AddBindings()")
Returns:
The created script instance, null pointer on error
PLCORE_API Script* PLCore::ScriptManager::CreateFromFile ( const String sFilename,
bool  bAddBindings = true,
String::EFormat  nStringFormat = String::ASCII 
)

Creates a script instance by using a given filename.

Parameters:
[in]sFilenameScript filename
[in]bAddBindingsIf 'true', add all available script bindings automatically (see "Script::AddBindings()")
[in]nStringFormatString encoding format to use when dealing with string functions (not supported by all file implementations)
Returns:
The created script instance, null pointer on error (Unknown filename extension? File not found? Error within the script?)
Remarks:
While the "Create()"-method only creates an empty script instance, the "CreateFromFile()"-method will
  • Create an empty script instance by using the filename extension as indication of the script language to use
  • Load in the script source code by using the given script filename
  • Assign the loaded script source code to the created, previously empty, script The result is a ready to be used script by just using this one method. The drawback is, that you can't use custom global functions when using this method because the custom global functions have to be defined before the script source code is assigned to the script (resulting in script compilation).
Note:
  • Convenience method
  • It's not recommended to use Unicode by because internally wchar_t is used and this data type has not the same size on every platform (use ASCII or UTF8 instead)

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


PixelLight PixelLight 0.9.11-R1
Copyright (C) 2002-2012 by The PixelLight Team
Last modified Thu Feb 23 2012 14:09:27
The content of this PixelLight document is published under the
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported