Select Git revision
-
Christophe Geuzaine authoredChristophe Geuzaine authored
To learn more about this project, read the wiki.
OnelabParser.cpp 52.18 KiB
#include "OnelabClients.h"
#include <algorithm>
#include "mathex.h"
// reserved keywords for the onelab parser
namespace olkey{
static std::string deflabel("onelab.tags");
static std::string label("OL."), comment("#"), separator(";");
static std::string line(label+"line");
static std::string begin(label+"block");
static std::string end(label+"endblock");
static std::string include(label+"include");
static std::string message(label+"msg");
static std::string showParam(label+"show");
static std::string showGmsh(label+"merge");
static std::string dump(label+"dump");
static std::string ifcond(label+"if");
static std::string iftrue(label+"iftrue"), ifntrue(label+"ifntrue");
static std::string olelse(label+"else"), olendif(label+"endif");
static std::string getValue(label+"get");
static std::string mathex(label+"eval");
static std::string getRegion(label+"region");
}
// Client member functions defined here because they use parser commands
bool MetaModel::findCommandLine(const std::string &client, const std::string &host){
std::string fileName;
size_t pos;
//std::cout << "FHF search cmdl: " << client << " , " << host << std::endl;
fileName = getWorkingDir() + genericNameFromArgs + onelabExtension + ".save";
std::ifstream infile(fileName.c_str());
if(infile.is_open()){
while(infile.good()){
std::string line;
getline(infile,line);
if( (pos=line.find(olkey::separator)) != std::string::npos){
std::string name, action;
std::vector<std::string> args;
extract(line.substr(0,pos),name,action,args);
// (name, action, args) = client.commandLine(cmdl{,rhost{,rdir}})
std::string cmdl="", rhost="localhost", rdir="";
cmdl = args[0];
if(args.size() > 1) rhost= args[1];
if(args.size() > 2) rdir = args[2];
if(name == client){
if( (host.empty() && (rhost != "localhost" )) ||
(host.size() && (rhost == host)) ) {
OLMsg::SetOnelabString(name + "/CommandLine", cmdl, false);
if(rhost.compare("localhost")){
OLMsg::SetOnelabString(name + "/HostName", rhost, false);
if(rdir.size())
OLMsg::SetOnelabString(name + "/RemoteDir", rdir, false);
}
//std::cout << "FHF found cmdl: " << cmdl << "," << rhost << std::endl;
return true;
}
}
}
}
}
infile.close();
return false;
}