Hyperiso 1.0.3
Modular flavour-physics calculations, Wilson coefficients and statistical inference
Loading...
Searching...
No Matches
LineProcessor Class Reference

Processes lines of a template C++ file and injects custom code. More...

#include <LineProcessor.h>

Public Member Functions

 LineProcessor (IncludeManager &includeManager, MartyFileWriter &filewriter, bool forceMode)
 Constructs a LineProcessor with the given helpers and mode.
 
void processLine (std::ofstream &outputFile, const std::string &currentLine)
 Processes a single line of input and writes to the output file.
 

Detailed Description

Processes lines of a template C++ file and injects custom code.

LineProcessor is typically used to post-process a C++ file generated by MARTY:

  • it rewrites the main signature to accept argc, argv,
  • it injects extra #include directives,
  • it adds argument parsing and parameter IO code before return 0;,
  • it can stop modifying the file after a special marker (//42) unless forceMode is enabled.

Definition at line 30 of file LineProcessor.h.

Constructor & Destructor Documentation

◆ LineProcessor()

LineProcessor::LineProcessor ( IncludeManager includeManager,
MartyFileWriter filewriter,
bool  forceMode 
)

Constructs a LineProcessor with the given helpers and mode.

Parameters
includeManagerReference to an IncludeManager instance.
filewriterReference to a MartyFileWriter instance.
forceModeIf true, the processor keeps modifying the file even after encountering the //42 marker.

Definition at line 3 of file LineProcessor.cpp.

Member Function Documentation

◆ processLine()

void LineProcessor::processLine ( std::ofstream &  outputFile,
const std::string &  currentLine 
)

Processes a single line of input and writes to the output file.

The behavior depends on the contents of currentLine:

  • If it contains "//42" and forceMode == false, further injections are disabled and subsequent lines are passed through unchanged.
  • If it contains "int main", the signature is rewritten as int main(int argc, char** argv).
  • If it contains "return 0;", the method inserts:
    • parameter input reader code,
    • argument parsing code,
    • Wilson output writer code, before forwarding the return 0; line.
  • If it contains "using namespace", required includes are injected and the line is forwarded.
  • Otherwise, the line is simply forwarded to outputFile.
Parameters
outputFileStream representing the transformed C++ file.
currentLineCurrent line read from the input file.

Definition at line 6 of file LineProcessor.cpp.


The documentation for this class was generated from the following files: