22#include "../../kernel.hpp"
23#include "../utils/tools.hpp"
33Package::Package() : sCommand(
""), sMainProcedure(
""), sArgumentList(
""), sType(
"TYPE_UNSPECIFIED"), sLicense(
""), sName(
"Plugin"),
sVersion(
"<AUTO>"), sAuthor(
"User"), sDescription(
"Description"), sMenuEntry(
""), sDocumentationIndexID(
""), sKeyWords(
"NONE"), sChangesLog(
"NONE")
90std::string
Package::getOptionValue(
const std::string& sInstallInfoString,
const std::string& sOption,
const std::string& sDefault)
97 std::string sOptionValue =
getArgAtPos(sInstallInfoString,
findParameter(sInstallInfoString, sOption,
'=')+sOption.length());
102 if (sOptionValue.length())
107 if (sDefault.length() && (sOptionValue.find(
' ') != std::string::npos || sOptionValue.find(
',') != std::string::npos))
108 sOptionValue =
"(" + sOptionValue +
")";
128 return sCommand +
"," +
sMainProcedure +
"," +
sArgumentList +
"," +
sType +
"," +
sName +
"," +
sVersion +
"," +
sAuthor +
"," +
sDescription +
"," +
sDocumentationIndexID +
"," +
sLicense +
"," +
sMenuEntry +
"," +
sKeyWords +
"," +
sChangesLog +
",";
152 if (!sDefinitionString.length())
157 if (!sDefinitionString.length())
162 if (!sDefinitionString.length())
167 if (!sDefinitionString.length())
172 if (!sDefinitionString.length())
177 if (!sDefinitionString.length())
182 if (!sDefinitionString.length())
187 if (!sDefinitionString.length())
203 return sType.substr(0, 11) ==
"TYPE_PLUGIN";
362 std::string sSignature =
sCommand +
" ";
365 sSignature +=
"EX -set PAR ";
366 else if (
sArgumentList.find(
"<EXPRESSION>") != std::string::npos)
368 else if (
sArgumentList.find(
"<PARAMSTRING>") != std::string::npos)
369 sSignature +=
"-PAR ";
370 else if (
sArgumentList.find(
"<CMDSTRING>") != std::string::npos)
371 sSignature +=
"(...) ";
373 if (
sType.find(
"TYPE_PLUGIN_WITH_RETURN_VALUE") != std::string::npos)
374 sSignature +=
"-> ARG";
503 std::string sLine =
"";
546 std::string sExpr =
"";
547 std::string sParams =
"";
548 std::string sCommand =
"";
549 std::string sCommandLine =
"";
586 if (sCommandLine.find(
"-set") != std::string::npos || sCommandLine.find(
"--") != std::string::npos)
588 if (sCommandLine.find(
"-set") != std::string::npos)
589 sParams = sCommandLine.substr(sCommandLine.find(
"-set"));
591 sParams = sCommandLine.substr(sCommandLine.find(
"--"));
594 if (sParams.length())
596 sExpr = sCommandLine.substr(sCommandLine.find(_plugin.
sCommand)+_plugin.
sCommand.length());
597 sExpr.erase(sExpr.find(sParams));
601 sExpr = sCommandLine.substr(sCommandLine.find(_plugin.
sCommand)+_plugin.
sCommand.length());
604 sParams =
"\"" + sParams +
"\"";
606 else if (
sPluginVarList.find(
"<PARAMSTRING>") != std::string::npos)
608 if (sCommandLine.find(
'-') != std::string::npos)
609 sParams = sCommandLine.substr(sCommandLine.find(
'-', sCommandLine.find(_plugin.
sCommand)));
612 sParams =
"\"" + sParams +
"\"";
615 sCommand =
"\"" + sCommandLine +
"\"";
617 for (
unsigned int i = 1; i < sCommandLine.length()-1; i++)
619 if (sCommandLine[i] ==
'"' && sCommandLine[i-1] !=
'\\')
620 sCommandLine.insert(i,1,
'\\');
623 if (sParams.length())
625 for (
unsigned int i = 1; i < sParams.length()-1; i++)
627 if (sParams[i] ==
'"' && sParams[i-1] !=
'\\')
628 sParams.insert(i,1,
'\\');
646 if (_plugin.
sType.find(
"TYPE_PLUGIN_WITH_RETURN_VALUE") != std::string::npos)
647 sCmd.replace(_match.
nPos, sCommandLine.length(),
"<<RETURNVAL>>");
666 static std::string sProtectedCommands =
";quit;help;find;uninstall;install;include;credits;about;continue;break;var;cst;tab;global;throw;namespace;return;abort;explicit;str;if;else;elseif;endif;while;endwhile;for;endfor;switch;case;default;endswitch;";
667 bool bAllowOverride =
false;
670 Package _package(sInstallInfoString);
676 if (
getArgAtPos(sInstallInfoString,
findParameter(sInstallInfoString,
"flags",
'=')+5).find(
"ENABLE_FORCE_OVERRIDE") != std::string::npos)
677 bAllowOverride =
true;
687 if (sProtectedCommands.find(
";" + _package.
sCommand +
";") != std::string::npos)
707 for (
unsigned int j = i+1; j <
vPackageInfo.size(); j++)
773 std::string sPluginName = _sPluginName;
779 if (sPluginName.length())
791 &&
vPackageInfo[i].sDocumentationIndexID.find(
";"+_sHelpId) == std::string::npos
792 &&
vPackageInfo[i].sDocumentationIndexID.find(_sHelpId+
";") == std::string::npos
793 &&
vPackageInfo[i].sDocumentationIndexID.find(
";"+_sHelpId+
";") == std::string::npos)
794 vPackageInfo[i].sDocumentationIndexID +=
";" + _sHelpId;
809 vPackageInfo.back().sDocumentationIndexID +=
";" + _sHelpId;
831 if (
findCommand(sCmd,
"explicit").sString ==
"explicit")
859 std::string sHLPIDs =
"<<NO_HLP_ENTRY>>";
894 std::map<std::string, std::string> mMenuMap;
const std::string sVersion
This class implements the basic input/ output file system and provides functionalities to work with f...
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 pre...
static NumeReKernel * getInstance()
This static member function returns a a pointer to the singleton instance of the kernel.
void refreshFunctionTree()
This member function informs the GUI to reload the contents of the function tree as soon as possible.
This class implements a single declared package. It can be constructed directly from an install infor...
std::string getCommandSignature() const
Creates a command signature for a plugin depending on the selected command line exraction tags of the...
std::string sDocumentationIndexID
std::string sMainProcedure
Package()
Default constructor.
bool operator!=(const Package &_plugin) const
This member function is an overload for the inequality comparison operator.
std::string getLicense() const
Returns the package license.
std::string getChangesLog() const
Returns the package changeslog.
void importDefinition(std::string sDefinitionString)
This member function will import the package definition from the passed definition string.
std::string getOptionValue(const std::string &sInstallInfoString, const std::string &sOption, const std::string &sDefault)
This private member function extracts the option value of the passed option and replaces it by its de...
std::string getName() const
Returns the package name.
std::string sArgumentList
bool operator==(const Package &_plugin) const
This member function is an overload for the equality comparison operator.
std::string getDescription() const
Returns the package description.
std::string exportDefinition() const
This member function will create the definition export string to be written to the plugin definition ...
void update(const Package &_plugin)
This member function can be used to update a package definition with a newer definition....
std::string stripParentheses(const std::string &sString) const
This private member function removes the surrounding parentheses, if available.
bool isPlugin() const
Returns, whether the current package provides plugin functionalities.
std::string getMenuEntry() const
Returns the menu entry of this plugin.
void incrementVersion()
This member function will increment the package version number by a build count.
std::string getKeyWords() const
Returns the package keywords.
std::string getAuthor() const
Returns the package author.
This class implements the procedure plugin system. It will be a parent class of the procedure class.
PackageManager()
PluginManager default constructor.
void addHelpIndex(const std::string &_sPluginName, std::string _sHelpId)
This member function adds the passed documentation index ID to the plugin definition.
std::string deletePackage(const std::string &sPackage)
This member function deletes the plugin with the passed name from the internal set of definitions and...
std::vector< Package > vPackageInfo
std::string getPluginInfoPath()
This member function simply returns the plugin definition file path.
std::string sPluginProcName
bool loadPlugins()
This member function will read the plugin definitions from the definitions file and create the intern...
bool isPluginCmd(const std::string &sCmd) const
This member function determines, whether the passed command line contains a plugin command.
bool evalPluginCmd(std::string &sCmd)
This member function converts the call to a plugin in the passed command line into a call to the corr...
~PackageManager()
PluginManager destructor. Will close the internal file stream if it is still open.
void updatePluginFile()
This member function will update the plugin definition file with the internal plugin definitions.
std::string sPluginDefinitionFile
bool declareNewPackage(const std::string &sInstallInfoString)
This member function declares a new plugin from the passed install information string.
PackageManager & operator=(const PackageManager &_manager)
This is the overload for the assignment operator.
std::map< std::string, std::string > getMenuMap() const
Returns the menu map connecting menu entry names with their corresponding procedure,...
std::string sPluginVarList
void assign(const PackageManager &_manager)
This private member function handles the actual copy process.
Common exception class for all exceptions thrown in NumeRe.
@ PLUGIN_MAY_NOT_OVERRIDE
@ PLUGINNAME_ALREADY_EXISTS
@ PLUGINCMD_ALREADY_EXISTS
static size_t invalid_position
CONSTCD11 std::enable_if<!std::chrono::treat_as_floating_point< T >::value, T >::type trunc(T t) NOEXCEPT
void StripSpaces(std::string &)
Removes leading and trailing white spaces and tabulator characters.
int findParameter(const std::string &sCmd, const std::string &sParam, const char cFollowing)
This function searches the passed parameter in the passed command string. If something is found,...
Structure for the findCommand function.