Hyperiso 1.0.3
Modular flavour-physics calculations, Wilson coefficients and statistical inference
Loading...
Searching...
No Matches
LineProcessor.cpp
Go to the documentation of this file.
1#include "LineProcessor.h"
2
3LineProcessor::LineProcessor(IncludeManager& includeManager, MartyFileWriter& filewriter, bool forceMode)
4 : includeManager(includeManager),fileWriter(filewriter), forceMode(forceMode) {}
5
6void LineProcessor::processLine(std::ofstream& outputFile, const std::string& currentLine) {
7 if (currentLine.find("//42") != std::string::npos && !forceMode) {
8 this->done = true;
9 }
10
11 if (done && !forceMode) {
12 outputFile << currentLine << "\n";
13 return;
14 } else if (currentLine.find("int main") != std::string::npos) {
15 outputFile << "int main(int argc, char** argv) {\n";
16 }
17 else if (currentLine.find("return 0;") != std::string::npos) {
18 // Parse invocation-local paths before opening the parameter file.
19 fileWriter.add_argpars(outputFile);
20 fileWriter.add_input_reader(outputFile);
21 fileWriter.add_output_writer(outputFile);
22 outputFile << currentLine << "\n";
23 } else if (currentLine.find("using namespace") != std::string::npos) {
24 includeManager.addIncludes(outputFile);
25 outputFile << currentLine << "\n";
26 } else {
27 outputFile << currentLine << "\n";
28 }
29}
Declares a line-based transformer for MARTY-generated C++ files.
Manages insertion of required #include directives.
void addIncludes(std::ofstream &outputFile)
Writes the required #include directives to the output stream.
void processLine(std::ofstream &outputFile, const std::string &currentLine)
Processes a single line of input and writes to the output file.
LineProcessor(IncludeManager &includeManager, MartyFileWriter &filewriter, bool forceMode)
Constructs a LineProcessor with the given helpers and mode.
Emits C++ helper code to handle CLI, IO and Wilson output.
void add_output_writer(std::ofstream &outputFile)
Writes C++ code that handles writing Wilson coefficients to a CSV.
void add_argpars(std::ofstream &outputFile)
Writes C++ code to parse command-line arguments.
void add_input_reader(std::ofstream &outputFile)
Writes C++ code to read numerical parameters from disk.