OptMain.cpp File Reference
#include <CMakeDefinitions.h>
#include <iostream>
#include <memory>
#include <stdexcept>
#include <string>
#include <array>
#include "Walls/InfiniteWall.h"
#include <stdio.h>

Functions

std::string ExecCommand (const char *cmd)
 
int main (int argc, char **argv)
 

Function Documentation

◆ ExecCommand()

std::string ExecCommand ( const char cmd)
40  {
41  std::array<char, 128> buffer;
42  std::string result;
43  std::unique_ptr<FILE, decltype(&pclose)> pipe(popen(cmd, "r"), pclose);
44  if (!pipe) {
45  std::string ret = "Could not run an extra OS command: "; ret.append(cmd);
46  throw std::runtime_error(ret);
47  }
48  while (fgets(buffer.data(), buffer.size(), pipe.get()) != nullptr) {
49  result += buffer.data();
50  }
51  return result;
52 }

Referenced by main().

◆ main()

int main ( int argc  ,
char **  argv 
)
56 {
57  std::string command;
58  command = "python3 " + getMercuryDPMSourceDir() + "/Tools/SimpleOpt/SimpleOpt.py " + getMercuryDPMSourceDir() + " " +
60  std::cout<<ExecCommand(command.c_str())<<std::endl;
61 }
const std::string getMercuryDPMSourceDir()
This file is used for generating definitions that give access to CMakeVariables from within a cpp fil...
Definition: CMakeDefinitions.cc:32
const std::string getMercuryDPMBuildDir()
Definition: CMakeDefinitions.cc:37
std::string ExecCommand(const char *cmd)
Definition: OptMain.cpp:40

References ExecCommand(), getMercuryDPMBuildDir(), and getMercuryDPMSourceDir().