Initial commit
This commit is contained in:
46
TestGenerator/src/code_generator.h
Normal file
46
TestGenerator/src/code_generator.h
Normal file
@@ -0,0 +1,46 @@
|
||||
#ifndef CODE_GENERATOR_H
|
||||
#define CODE_GENERATOR_H
|
||||
|
||||
#include "data_structures.h"
|
||||
#include "json_parser.h"
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
|
||||
class CodeGenerator {
|
||||
private:
|
||||
Config config;
|
||||
std::map<std::string, SetupFile> commonSetups;
|
||||
std::map<std::string, SetupFile> variantSetups;
|
||||
std::map<std::string, Variable> globalVariables;
|
||||
|
||||
// Parse JSON helpers
|
||||
Instrument parseInstrument(std::shared_ptr<JsonValue> json);
|
||||
Property parseProperty(std::shared_ptr<JsonValue> json);
|
||||
Variable parseVariable(std::shared_ptr<JsonValue> json);
|
||||
Setup parseSetup(std::shared_ptr<JsonValue> json);
|
||||
SetupFile parseSetupFile(std::shared_ptr<JsonValue> json);
|
||||
Template parseTemplate(std::shared_ptr<JsonValue> json);
|
||||
TestExecution parseTestExecution(std::shared_ptr<JsonValue> json);
|
||||
|
||||
// Code generation helpers
|
||||
std::string generateInstrumentDefinitions();
|
||||
std::string generateTestClass(const Template& tmpl, const TestExecution& testExec);
|
||||
std::string generateSetupMethod(const std::string& setupName, const std::string& instrumentName);
|
||||
std::string generateMainFile(const std::vector<std::string>& testNames);
|
||||
|
||||
// Variable substitution
|
||||
std::string substituteVariables(const std::string& expr, const std::map<std::string, std::string>& localVars);
|
||||
std::string processVariableExpression(const std::string& expr);
|
||||
|
||||
// Setup merging
|
||||
Setup mergeSetup(const std::string& setupName, const std::string& instrumentName);
|
||||
|
||||
public:
|
||||
CodeGenerator(const Config& cfg);
|
||||
|
||||
bool loadConfigurations();
|
||||
bool generateCode();
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user