Views
Foundation Package API Reference Guide
Product Documentation:
Views Documentation Home
List of all members | Public Member Functions
IlvScript Class Reference

Scripting class. More...

#include <ilviews/base/script.h>

Public Member Functions

 IlvScript (IlvScriptContext *context)
 Constructor. More...
 
 IlvScript (IlvScriptContext *context, const char *contents, const char *name=0, const char *path=0)
 Constructor. More...
 
 IlvScript (IlvScriptContext *context, IlUInt nLines, const char *const *lines, const char *name=0, const char *path=0)
 Constructor. More...
 
 IlvScript (IlvScriptContext *context, istream &istr, const char *filename=0, const char *name=0)
 Constructor. More...
 
virtual ~IlvScript ()
 Destructor. More...
 
const char * getContents () const
 Gets the script contents. More...
 
const char *const * getContentsArray (IlUInt &nLines) const
 Gets the script contents. More...
 
IlvScriptContextgetContext () const
 Gets the script context. More...
 
IlvScriptLanguagegetLanguage () const
 Gets the scripting language. More...
 
const IlSymbolgetLanguageName () const
 Gets the name of the scripting language. More...
 
const char * getName () const
 Gets the script name. More...
 
const char * getPathName () const
 Gets the script path name. More...
 
IlvScriptType getType () const
 Gets the script type. More...
 
IlBoolean isPersistent () const
 Gets the persistence capability. More...
 
void setContents (const char *contents)
 Sets the script contents. More...
 
void setContentsArray (IlUInt nLines, const char *const *lines)
 Sets the script contents. More...
 
void setName (const char *name)
 Sets the script name. More...
 
void setPathName (const char *pathName)
 Sets the script path name. More...
 
void setPersistent (IlBoolean persistent)
 Sets the persistence capability. More...
 
virtual void write (IlvOutputFile &os) const
 Saves the script contents. More...
 

Detailed Description

Scripting class.

Library: xviews or winviews or mviews (mutually exclusive)

This class holds a script. Typically, a script is a piece of code that can be loaded and saved, and sometimes compiled.

See also
IlvScriptContext.

Constructor & Destructor Documentation

◆ IlvScript() [1/4]

IlvScript::IlvScript ( IlvScriptContext context)

Constructor.

The constructor initializes a new empty IlvScript.

Parameters
contextThe script context where this script will be stored.

◆ IlvScript() [2/4]

IlvScript::IlvScript ( IlvScriptContext context,
istream &  istr,
const char *  filename = 0,
const char *  name = 0 
)

Constructor.

The constructor initializes a new IlvScript that is read from a stream.

Parameters
contextThe script context where this script will be stored.
istrThe input stream from which the script is read.
filenameThe file name of this stream, or 0 if the stream has no associated file. This is used in error messages for easier correction.
nameThe name of that script, or 0 if you do not want this script to have a name. Named scripts can be retrieved easily from a script context. This string is copied internally.

◆ IlvScript() [3/4]

IlvScript::IlvScript ( IlvScriptContext context,
const char *  contents,
const char *  name = 0,
const char *  path = 0 
)

Constructor.

The constructor initializes a new IlvScript that is created from a string.

Parameters
contextThe script context where this script will be stored.
contentsThe string from which the script is created. This must be a 0 terminated string with valid scripting contents. This string is copied internally.
nameThe name of that script, or 0 if you do not want this script to have a name. Named scripts can be retrieved easily from a script context. This string is copied internally.
pathA path that can identify the script, or 0 if the script has no associated path. This is used in error messages for easier correction. This string is copied internally.

◆ IlvScript() [4/4]

IlvScript::IlvScript ( IlvScriptContext context,
IlUInt  nLines,
const char *const *  lines,
const char *  name = 0,
const char *  path = 0 
)

Constructor.

The constructor initializes a new IlvScript that is created from an array of strings (typically, an array of lines).

Parameters
contextThe script context where this script will be stored.
nLinesThe number of strings in the array lines.
linesThe array of at least nLines lines from which the script is created. Each string in the array must be a 0 terminated string, and the concatenation of all the strings should be a valid scripting contents. This array and all the strings it holds are copied internally.
nameThe name of that script, or 0 if you do not want this script to have a name. Named scripts can be retrieved easily from a script context. This string is copied internally.
pathA path that can identify the script, or 0 if the script has no associated path. This is used in error messages for easier correction. This string is copied internally.

◆ ~IlvScript()

virtual IlvScript::~IlvScript ( )
virtual

Destructor.

Releases the memory used by the script.

Member Function Documentation

◆ getContents()

const char* IlvScript::getContents ( ) const

Gets the script contents.

This member function should be used only when the script is of the type IlvInlineScript.

Returns
the contents of the script as a string. The returned string must not be modified or deleted by the user.

◆ getContentsArray()

const char* const* IlvScript::getContentsArray ( IlUInt nLines) const

Gets the script contents.

Parameters
nLinesThe size of the returned array (that is, usually, the number of lines in the script).
Returns
The contents of the script as an array of strings. This member function should be used only if the script is of the type IlvInlineScript. The returned array and its contents must not be modified or deleted by the user.

◆ getContext()

IlvScriptContext* IlvScript::getContext ( ) const

Gets the script context.

Returns
the script context of this script.

◆ getLanguage()

IlvScriptLanguage* IlvScript::getLanguage ( ) const

Gets the scripting language.

Returns
The scripting language used by this script.

◆ getLanguageName()

const IlSymbol* IlvScript::getLanguageName ( ) const

Gets the name of the scripting language.

Returns
The name of the scripting language used in this script. This method is useful when you do not want to link with an interpreter, but still want to manipulate script languages, script contexts and scripts.

◆ getName()

const char* IlvScript::getName ( ) const

Gets the script name.

Returns
The name of the script or 0 if the script has no name. The returned string must not be deleted or modified by the user.

◆ getPathName()

const char* IlvScript::getPathName ( ) const

Gets the script path name.

Returns
The path name of the script, or 0 if it has none. This member function should be used only if the script is of the type IlvLinkedScript. The returned string must not be deleted or modified by the user.

◆ getType()

IlvScriptType IlvScript::getType ( ) const

Gets the script type.

Returns
The type of this script. Scripts of the type IlvLinkedScript reference an external file that contains the script code. When such a script is saved, only the path name of the external file is saved. When the script is loaded, it opens the specified file in order to access the script code.

◆ isPersistent()

IlBoolean IlvScript::isPersistent ( ) const

Gets the persistence capability.

Scripts are persistent by default. Non-persistent script cannot be saved.

Returns
IlTrue if the script is persistent. Otherwise, it returns IlFalse.
See also
setPersistent.

◆ setContents()

void IlvScript::setContents ( const char *  contents)

Sets the script contents.

The type of the script changes to the IlvInlineScript.

Parameters
contentsThe string that will be copied and stored as the new script contents.

◆ setContentsArray()

void IlvScript::setContentsArray ( IlUInt  nLines,
const char *const *  lines 
)

Sets the script contents.

Parameters
nLinesThe number of strings if the array lines.
linesThe array of strings that are copied and stored as the new script contents. The type of the script changes to IlvInlineScript.

◆ setName()

void IlvScript::setName ( const char *  name)

Sets the script name.

Parameters
nameThe string that will be copied and stored as the new name of this script.

◆ setPathName()

void IlvScript::setPathName ( const char *  pathName)

Sets the script path name.

Parameters
pathNameThe string that will be copied and stored as the path name of the script. The type of the script changes to IlvLinkedScript.

◆ setPersistent()

void IlvScript::setPersistent ( IlBoolean  persistent)

Sets the persistence capability.

Parameters
persistentThe new persistence capability of this script.

◆ write()

virtual void IlvScript::write ( IlvOutputFile os) const
virtual

Saves the script contents.

Parameters
osThe output file that where the script is saved.