NumeRe v1.1.4
NumeRe: Framework für Numerische Rechnungen
Script Class Reference

#include <script.hpp>

Inheritance diagram for Script:
Collaboration diagram for Script:

Public Member Functions

 Script ()
 Default constructor. More...
 
 ~Script ()
 Destructor. More...
 
std::string getNextScriptCommand ()
 This member function is the main interface to the internal managed script. It will always return the next valid script line. More...
 
std::string getScriptFileName () const
 
void setPredefinedFuncs (const std::string &sPredefined)
 
unsigned int getCurrentLine () const
 
void openScript (std::string &_sScriptFileName)
 This member function opens the script with the passed file name. More...
 
void close ()
 This member function closes an opened script. More...
 
void returnCommand ()
 This member function closes the script, if the code reached a "return" statement. More...
 
void setInstallProcedures (bool _bInstall=true)
 
bool isOpen () const
 
bool isValid () const
 
bool wasLastCommand ()
 
bool installProcedures () const
 
- Public Member Functions inherited from FileSystem
 FileSystem ()
 Default constructor. More...
 
FileSystemassign (const FileSystem &_fSys)
 Assignment member function to copy the settings from another FileSystem instance. More...
 
std::string ValidFileName (std::string _sFileName, const std::string sExtension=".dat", bool checkExtension=true, bool doCleanPath=true) const
 This member function evaluates, whether the passed filename is a valid filename. One may supply a preferred filename extension. More...
 
std::string ValidFolderName (std::string _sFileName, bool doCleanPath=true, bool appendTrailingSeparator=true) const
 This member function evaluates, whether the passed foldername is a valid foldername. More...
 
std::string ValidizeAndPrepareName (const std::string &_sFileName, const std::string &sExtension=".dat") const
 This member function validizes the passed file name and creates the needed folders on-the-fly. More...
 
int setPath (std::string _sPath, bool bMkDir, std::string _sExePath)
 This member function may be used to set the preferred file path of the current FileSystem instance. More...
 
void createRevisionsFolder ()
 This member function creates the hidden revisions folders for the version control system. More...
 
std::string getPath () const
 Returns the default path of this FileSystem instance. More...
 
std::vector< std::string > getFileParts (const std::string &sFilePath) const
 This member function separates all path parts into single strings: the drive letter, the path, the name and the extension. This function may also handle folder paths and network paths. More...
 
FileInfo getFileInfo (const std::string &sFilePath) const
 Return the file information about the passed file path. More...
 
void setTokens (std::string _sTokens)
 This member function may be used to update the path placeholders of the current FileSystem instance. More...
 
bool isFile (const std::string &_sPath) const
 This function determines, whether a path name indicates a file or a folder. More...
 
void initializeFromKernel ()
 Member function to remote-initialize the class from the kernel. Cannot be used during kernel start-up. More...
 
void setProgramPath (std::string _sExePath)
 
std::string getProgramPath () const
 
void declareFileType (const std::string &sFileType)
 

Private Types

enum  { ENABLE_DEFAULTS = 0x0 , ENABLE_FULL_LOGGING = 0x1 , DISABLE_SCREEN_OUTPUT = 0x2 }
 

Private Member Functions

bool startInstallation (std::string &sScriptCommand)
 This member function starts the current installation section. More...
 
bool handleInstallInformation (std::string &sScriptCommand)
 This member function handles the install information tags of the current installation section. More...
 
void writeDocumentationArticle (std::string &sScriptCommand)
 This member function writes the appended documentation article to the target file. More...
 
void writeLayout (std::string &sScriptCommand)
 This member function writes the embedded window layout to the target file. More...
 
void writeProcedure ()
 Writes a procedure including the comments to a procedure file. More...
 
bool writeWholeFile ()
 Writes the contents of a whole file to the target file, which has been specified by the XML-like tags. More...
 
void evaluateInstallInformation (std::string &sInstallInfoString)
 This member function evaluates the flags from the installation information string and also removes unnecessary comments. More...
 
std::string getNextScriptCommandFromScript ()
 This member function returns the next valid line from the currently opened script. More...
 
std::string getNextScriptCommandFromInclude ()
 This member function returns the next valid line from the included script. More...
 
std::string handleIncludeSyntax (std::string &sScriptCommand)
 This member function handles the script include syntax ("@SCRIPT") and prepares the included file stream. More...
 
bool handleLocalDefinitions (std::string &sScriptCommand)
 This private member function handles the definition and replacement of local functions. More...
 

Private Attributes

std::unique_ptr< StyledTextFilem_script
 
std::unique_ptr< Includerm_include
 
Logger m_logger
 
std::string sScriptFileName
 
bool bValidScript
 
bool bLastScriptCommand
 
int nLine
 
int nInstallModeFlags
 
bool isInstallMode
 
bool isInInstallSection
 
std::string sHelpID
 
std::string sInstallID
 
std::vector< std::string > vInstallPackages
 
unsigned int nCurrentPackage
 
FunctionDefinitionManager _localDef
 
SymDefManager _symdefs
 

Additional Inherited Members

- Protected Member Functions inherited from FileSystem
int createFolders (const std::string &_sPath) const
 This member function creates all missing directories in the passed path. More...
 
- Protected Attributes inherited from FileSystem
std::string sPath
 
std::string sExecutablePath
 
std::string sTokens [7][2]
 
std::string sValidExtensions
 

Detailed Description

Definition at line 35 of file script.hpp.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private
Enumerator
ENABLE_DEFAULTS 
ENABLE_FULL_LOGGING 
DISABLE_SCREEN_OUTPUT 

Definition at line 41 of file script.hpp.

Constructor & Destructor Documentation

◆ Script()

Script::Script ( )

Default constructor.

Definition at line 36 of file script.cpp.

References bLastScriptCommand, bValidScript, ENABLE_DEFAULTS, isInstallMode, nCurrentPackage, nInstallModeFlags, and nLine.

◆ ~Script()

Script::~Script ( )

Destructor.

Definition at line 50 of file script.cpp.

References close(), and m_script.

Here is the call graph for this function:

Member Function Documentation

◆ close()

void Script::close ( )

◆ evaluateInstallInformation()

void Script::evaluateInstallInformation ( std::string &  sInstallInfoString)
private

This member function evaluates the flags from the installation information string and also removes unnecessary comments.

Parameters
sInstallInfoStringstd::string&
Returns
void

Definition at line 717 of file script.cpp.

References _lang, DISABLE_SCREEN_OUTPUT, ENABLE_FULL_LOGGING, findParameter(), Language::get(), getArgAtPos(), m_logger, nInstallModeFlags, NumeReKernel::print(), Logger::push_line(), and toSystemCodePage().

Referenced by handleInstallInformation().

Here is the call graph for this function:

◆ getCurrentLine()

unsigned int Script::getCurrentLine ( ) const
inline

◆ getNextScriptCommand()

string Script::getNextScriptCommand ( )

This member function is the main interface to the internal managed script. It will always return the next valid script line.

Returns
string

Definition at line 1055 of file script.cpp.

References getNextScriptCommandFromInclude(), getNextScriptCommandFromScript(), handleIncludeSyntax(), handleLocalDefinitions(), SyntaxError::invalid_position, isInstallMode, m_include, m_script, SyntaxError::PROCEDURE_WITHOUT_INSTALL_FOUND, and sScriptFileName.

Referenced by NumeReKernel::handleCommandLineSource().

Here is the call graph for this function:

◆ getNextScriptCommandFromInclude()

string Script::getNextScriptCommandFromInclude ( )
private

This member function returns the next valid line from the included script.

Returns
string

Definition at line 967 of file script.cpp.

References m_include.

Referenced by getNextScriptCommand().

◆ getNextScriptCommandFromScript()

std::string Script::getNextScriptCommandFromScript ( )
private

This member function returns the next valid line from the currently opened script.

Returns
std::string

Definition at line 751 of file script.cpp.

References _lang, bLastScriptCommand, Logger::close(), close(), DISABLE_SCREEN_OUTPUT, ENABLE_FULL_LOGGING, findCommand(), Language::get(), NumeReKernel::getInstance(), handleInstallInformation(), NumeReKernel::installationDone(), Logger::is_open(), isInInstallSection, isInstallMode, m_logger, m_script, nInstallModeFlags, nLine, NumeReKernel::print(), Logger::push(), Logger::push_line(), sScriptFileName, startInstallation(), StripSpaces(), toSystemCodePage(), writeDocumentationArticle(), writeLayout(), writeProcedure(), and writeWholeFile().

Referenced by getNextScriptCommand().

Here is the call graph for this function:

◆ getScriptFileName()

std::string Script::getScriptFileName ( ) const
inline

◆ handleIncludeSyntax()

string Script::handleIncludeSyntax ( std::string &  sScriptCommand)
private

This member function handles the script include syntax ("@SCRIPT") and prepares the included file stream.

Parameters
sScriptCommandstring&
Returns
string

Definition at line 985 of file script.cpp.

References SyntaxError::invalid_position, Includer::is_including_syntax(), m_include, m_script, and SyntaxError::SCRIPT_NOT_EXIST.

Referenced by getNextScriptCommand().

Here is the call graph for this function:

◆ handleInstallInformation()

bool Script::handleInstallInformation ( std::string &  sScriptCommand)
private

◆ handleLocalDefinitions()

bool Script::handleLocalDefinitions ( std::string &  sScriptCommand)
private

This private member function handles the definition and replacement of local functions.

Parameters
sScriptCommandstring&
Returns
bool

Definition at line 1018 of file script.cpp.

References _localDef, _symdefs, FunctionDefinitionManager::call(), SymDefManager::createSymbol(), FunctionDefinitionManager::defineFunc(), findCommand(), SymDefManager::resolveSymbols(), Match::sString, and SYMDEF_COMMAND.

Referenced by getNextScriptCommand().

Here is the call graph for this function:

◆ installProcedures()

bool Script::installProcedures ( ) const
inline

Definition at line 114 of file script.hpp.

References isInstallMode.

◆ isOpen()

◆ isValid()

◆ openScript()

void Script::openScript ( std::string &  _sScriptFileName)

This member function opens the script with the passed file name.

Parameters
_sScriptFileNamestring&
Returns
void

Definition at line 67 of file script.cpp.

References _localDef, _symdefs, bValidScript, SymDefManager::clear(), close(), ENABLE_DEFAULTS, SyntaxError::invalid_position, m_script, nInstallModeFlags, nLine, FunctionDefinitionManager::reset(), SyntaxError::SCRIPT_NOT_EXIST, sHelpID, sInstallID, sScriptFileName, and FileSystem::ValidFileName().

Referenced by close(), cmd_install(), and cmd_start().

Here is the call graph for this function:

◆ returnCommand()

void Script::returnCommand ( )

This member function closes the script, if the code reached a "return" statement.

Returns
void

This function has to be called from the outside, because this class won't track this command internally.

Definition at line 176 of file script.cpp.

References _lang, Logger::close(), close(), DISABLE_SCREEN_OUTPUT, Language::get(), NumeReKernel::installationDone(), Logger::is_open(), m_logger, m_script, nInstallModeFlags, NumeReKernel::print(), Logger::push(), and toSystemCodePage().

Referenced by NumeReKernel::handleFlowControls().

Here is the call graph for this function:

◆ setInstallProcedures()

void Script::setInstallProcedures ( bool  _bInstall = true)
inline

Definition at line 96 of file script.hpp.

References isInstallMode.

Referenced by cmd_install().

◆ setPredefinedFuncs()

void Script::setPredefinedFuncs ( const std::string &  sPredefined)
inline

Definition at line 87 of file script.hpp.

References _localDef, and FunctionDefinitionManager::setPredefinedFuncs().

Referenced by NumeReKernel::StartUp().

Here is the call graph for this function:

◆ startInstallation()

bool Script::startInstallation ( std::string &  sScriptCommand)
private

This member function starts the current installation section.

Parameters
sScriptCommandstring&
Returns
bool

Definition at line 204 of file script.cpp.

References SyntaxError::CANNOT_OPEN_LOGFILE, getTimeStamp(), handleInstallInformation(), SyntaxError::invalid_position, isInInstallSection, m_logger, Logger::open(), Logger::push_line(), FileSystem::sTokens, and StripSpaces().

Referenced by getNextScriptCommandFromScript().

Here is the call graph for this function:

◆ wasLastCommand()

bool Script::wasLastCommand ( )
inline

◆ writeDocumentationArticle()

void Script::writeDocumentationArticle ( std::string &  sScriptCommand)
private

This member function writes the appended documentation article to the target file.

Parameters
sScriptCommandstring&
Returns
void

Definition at line 390 of file script.cpp.

References Documentation::addFileToDocumentationIndex(), PackageManager::addHelpIndex(), DocumentationFile::getArticles(), NumeReKernel::getInstance(), NumeReKernel::getProcedureInterpreter(), NumeReKernel::getSettings(), m_script, nLine, DocumentationFile::print(), sHelpID, sInstallID, StripSpaces(), and FileSystem::ValidFileName().

Referenced by getNextScriptCommandFromScript().

Here is the call graph for this function:

◆ writeLayout()

void Script::writeLayout ( std::string &  sScriptCommand)
private

This member function writes the embedded window layout to the target file.

Parameters
sScriptCommandstd::string&
Returns
void

Definition at line 472 of file script.cpp.

References SyntaxError::CANNOT_READ_FILE, ENABLE_FULL_LOGGING, getArgAtPos(), SyntaxError::invalid_position, m_logger, m_script, nInstallModeFlags, nLine, Logger::push_line(), StripSpaces(), and FileSystem::ValidFileName().

Referenced by getNextScriptCommandFromScript().

Here is the call graph for this function:

◆ writeProcedure()

void Script::writeProcedure ( )
private

Writes a procedure including the comments to a procedure file.

Returns
void

Definition at line 585 of file script.cpp.

References _lang, DISABLE_SCREEN_OUTPUT, ENABLE_FULL_LOGGING, findCommand(), Language::get(), NumeReKernel::getInstance(), NumeReKernel::getProcedureInterpreter(), m_logger, m_script, nInstallModeFlags, nLine, NumeReKernel::print(), Logger::push_line(), Match::sString, StripSpaces(), toSystemCodePage(), and Procedure::writeProcedure().

Referenced by getNextScriptCommandFromScript().

Here is the call graph for this function:

◆ writeWholeFile()

bool Script::writeWholeFile ( )
private

Writes the contents of a whole file to the target file, which has been specified by the XML-like tags.

Returns
bool

Definition at line 652 of file script.cpp.

References ENABLE_FULL_LOGGING, Documentation::getArgAtPos(), m_logger, m_script, nInstallModeFlags, nLine, Logger::push_line(), replaceAll(), and FileSystem::ValidizeAndPrepareName().

Referenced by getNextScriptCommandFromScript().

Here is the call graph for this function:

Member Data Documentation

◆ _localDef

FunctionDefinitionManager Script::_localDef
private

Definition at line 64 of file script.hpp.

Referenced by close(), handleLocalDefinitions(), openScript(), and setPredefinedFuncs().

◆ _symdefs

SymDefManager Script::_symdefs
private

Definition at line 65 of file script.hpp.

Referenced by close(), handleLocalDefinitions(), and openScript().

◆ bLastScriptCommand

bool Script::bLastScriptCommand
private

Definition at line 52 of file script.hpp.

Referenced by close(), getNextScriptCommandFromScript(), Script(), and wasLastCommand().

◆ bValidScript

bool Script::bValidScript
private

Definition at line 51 of file script.hpp.

Referenced by close(), isValid(), openScript(), and Script().

◆ isInInstallSection

bool Script::isInInstallSection
private

◆ isInstallMode

bool Script::isInstallMode
private

◆ m_include

std::unique_ptr<Includer> Script::m_include
private

◆ m_logger

◆ m_script

◆ nCurrentPackage

unsigned int Script::nCurrentPackage
private

Definition at line 62 of file script.hpp.

Referenced by close(), and Script().

◆ nInstallModeFlags

◆ nLine

◆ sHelpID

std::string Script::sHelpID
private

Definition at line 58 of file script.hpp.

Referenced by close(), openScript(), and writeDocumentationArticle().

◆ sInstallID

std::string Script::sInstallID
private

Definition at line 59 of file script.hpp.

Referenced by close(), handleInstallInformation(), openScript(), and writeDocumentationArticle().

◆ sScriptFileName

std::string Script::sScriptFileName
private

◆ vInstallPackages

std::vector<std::string> Script::vInstallPackages
private

Definition at line 61 of file script.hpp.

Referenced by close(), and handleInstallInformation().


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