#include #include "argumentanalyzer.h" ArgumentAnalyzer::ArgumentAnalyzer() { } int ArgumentAnalyzer::analyzeArguments(int argc, char *argv[]) { if( argc < 7 ) return printHelp(); int index = 1; this->testCaseArguments.outputFilename = argv[index++]; this->testCaseArguments.rows = std::stoull( argv[index++] ); this->testCaseArguments.columns = std::stoull( argv[index++] ); this->testCaseArguments.minTemperature = std::stod( argv[index++] ); this->testCaseArguments.maxTemperature = std::stod( argv[index++] ); this->testCaseArguments.variabilityFactor = std::stod( argv[index++] ); while ( index < argc ) { if ( index + 3 < argc ) { HeatSpot heatpoint; heatpoint.xPosition = std::stoull( argv[index++] ); heatpoint.yPosition = std::stoull( argv[index++] ); heatpoint.temperature = std::stod( argv[index++] ); heatpoint.radius = std::stoull( argv[index++] ); this->testCaseArguments.heatSpots.push_back(heatpoint); } else return (void)(std::cerr << "Error: incomplete heat point\n"), EXIT_FAILURE; } return EXIT_SUCCESS; } int ArgumentAnalyzer::printHelp() { std::cout << "usage: generator output_file rows cols min_temp max_temp variability_factor [heatspots]\n" << "heatspot format: x_position y_position temperature radius" << std::endl; return EXIT_FAILURE; }