NumeRe v1.1.4
NumeRe: Framework für Numerische Rechnungen
script.hpp
Go to the documentation of this file.
1/*****************************************************************************
2 NumeRe: Framework fuer Numerische Rechnungen
3 Copyright (C) 2014 Erik Haenel et al.
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17******************************************************************************/
18
19
20// Header-Datei zur Script-Klasse
21
22#ifndef SCRIPT_HPP
23#define SCRIPT_HPP
24
25#include <string>
26#include <memory>
27
28#include "io/filesystem.hpp"
29#include "io/styledtextfile.hpp"
30#include "io/logger.hpp"
31#include "maths/define.hpp"
32#include "symdef.hpp"
34
35class Script : public FileSystem
36{
37 private:
38 std::unique_ptr<StyledTextFile> m_script;
39 std::unique_ptr<Includer> m_include;
40
41 enum
42 {
46 };
47
49 std::string sScriptFileName;
50
53 int nLine;
57
58 std::string sHelpID;
59 std::string sInstallID;
60
61 std::vector<std::string> vInstallPackages;
62 unsigned int nCurrentPackage;
63
66
67 bool startInstallation(std::string& sScriptCommand);
68 bool handleInstallInformation(std::string& sScriptCommand);
69 void writeDocumentationArticle(std::string& sScriptCommand);
70 void writeLayout(std::string& sScriptCommand);
71 void writeProcedure();
72 bool writeWholeFile();
73 void evaluateInstallInformation(std::string& sInstallInfoString);
76 std::string handleIncludeSyntax(std::string& sScriptCommand);
77 bool handleLocalDefinitions(std::string& sScriptCommand);
78
79
80 public:
81 Script();
82 ~Script();
83
84 std::string getNextScriptCommand();
85 inline std::string getScriptFileName() const
86 {return sScriptFileName;}
87 inline void setPredefinedFuncs(const std::string& sPredefined)
88 {
89 _localDef.setPredefinedFuncs(sPredefined);
90 }
91 inline unsigned int getCurrentLine() const
92 {return m_include && m_include->is_open() ? m_include->getCurrentLine() : nLine;}
93 void openScript(std::string& _sScriptFileName);
94 void close();
95 void returnCommand();
96 inline void setInstallProcedures(bool _bInstall = true)
97 {
98 isInstallMode = _bInstall;
99 return;
100 }
101 inline bool isOpen() const
102 {return m_script.get() != nullptr;};
103 inline bool isValid() const
104 {return bValidScript;};
105 inline bool wasLastCommand()
106 {
108 {
109 bLastScriptCommand = false;
110 return true;
111 }
112 return false;
113 }
114 inline bool installProcedures() const
115 {return isInstallMode;}
116};
117
118#endif
119
This class implements the basic input/ output file system and provides functionalities to work with f...
Definition: filesystem.hpp:92
This class implements the function definition managing instance.
Definition: define.hpp:74
void setPredefinedFuncs(const std::string &sPredefined)
This member function updates the internal list of predefined functions. If the list is whitespace-sep...
Definition: define.cpp:1158
This class represents a simple logging functionality, which might be extended in the future to handle...
Definition: logger.hpp:33
std::unique_ptr< Includer > m_include
Definition: script.hpp:39
FunctionDefinitionManager _localDef
Definition: script.hpp:64
bool isOpen() const
Definition: script.hpp:101
bool handleInstallInformation(std::string &sScriptCommand)
This member function handles the install information tags of the current installation section.
Definition: script.cpp:247
Script()
Default constructor.
Definition: script.cpp:36
void openScript(std::string &_sScriptFileName)
This member function opens the script with the passed file name.
Definition: script.cpp:67
bool isInInstallSection
Definition: script.hpp:56
bool writeWholeFile()
Writes the contents of a whole file to the target file, which has been specified by the XML-like tags...
Definition: script.cpp:652
bool isInstallMode
Definition: script.hpp:55
void writeDocumentationArticle(std::string &sScriptCommand)
This member function writes the appended documentation article to the target file.
Definition: script.cpp:390
SymDefManager _symdefs
Definition: script.hpp:65
void writeProcedure()
Writes a procedure including the comments to a procedure file.
Definition: script.cpp:585
bool installProcedures() const
Definition: script.hpp:114
void evaluateInstallInformation(std::string &sInstallInfoString)
This member function evaluates the flags from the installation information string and also removes un...
Definition: script.cpp:717
bool bLastScriptCommand
Definition: script.hpp:52
unsigned int nCurrentPackage
Definition: script.hpp:62
std::string getNextScriptCommandFromInclude()
This member function returns the next valid line from the included script.
Definition: script.cpp:967
bool wasLastCommand()
Definition: script.hpp:105
std::vector< std::string > vInstallPackages
Definition: script.hpp:61
@ ENABLE_DEFAULTS
Definition: script.hpp:43
@ ENABLE_FULL_LOGGING
Definition: script.hpp:44
@ DISABLE_SCREEN_OUTPUT
Definition: script.hpp:45
void setInstallProcedures(bool _bInstall=true)
Definition: script.hpp:96
void writeLayout(std::string &sScriptCommand)
This member function writes the embedded window layout to the target file.
Definition: script.cpp:472
Logger m_logger
Definition: script.hpp:48
void close()
This member function closes an opened script.
Definition: script.cpp:107
~Script()
Destructor.
Definition: script.cpp:50
std::unique_ptr< StyledTextFile > m_script
Definition: script.hpp:38
std::string sInstallID
Definition: script.hpp:59
std::string sScriptFileName
Definition: script.hpp:49
std::string getScriptFileName() const
Definition: script.hpp:85
bool bValidScript
Definition: script.hpp:51
std::string getNextScriptCommandFromScript()
This member function returns the next valid line from the currently opened script.
Definition: script.cpp:751
std::string getNextScriptCommand()
This member function is the main interface to the internal managed script. It will always return the ...
Definition: script.cpp:1055
bool startInstallation(std::string &sScriptCommand)
This member function starts the current installation section.
Definition: script.cpp:204
unsigned int getCurrentLine() const
Definition: script.hpp:91
std::string sHelpID
Definition: script.hpp:58
int nLine
Definition: script.hpp:53
void returnCommand()
This member function closes the script, if the code reached a "return" statement.
Definition: script.cpp:176
bool handleLocalDefinitions(std::string &sScriptCommand)
This private member function handles the definition and replacement of local functions.
Definition: script.cpp:1018
int nInstallModeFlags
Definition: script.hpp:54
std::string handleIncludeSyntax(std::string &sScriptCommand)
This member function handles the script include syntax ("@SCRIPT") and prepares the included file str...
Definition: script.cpp:985
void setPredefinedFuncs(const std::string &sPredefined)
Definition: script.hpp:87
bool isValid() const
Definition: script.hpp:103
This class handles the file-static constants, which are more or less macros similar to #define in C/C...
Definition: symdef.hpp:32