43 lines
996 B
C++
43 lines
996 B
C++
#include "api.hpp"
|
|
|
|
#include <cstddef>
|
|
#include <cstdint>
|
|
#include <fstream>
|
|
#include <iomanip>
|
|
#include <locale>
|
|
|
|
PLUGIN_EXPORT std::uint32_t plugin_api_version(){
|
|
return PLUGIN_API_VERSION;
|
|
}
|
|
|
|
PLUGIN_EXPORT PluginType plugin_type(){
|
|
return PluginType::Output;
|
|
}
|
|
|
|
PLUGIN_EXPORT const char* plugin_name(){
|
|
return "CSV output";
|
|
}
|
|
|
|
PLUGIN_EXPORT const char* plugin_description(){
|
|
return "Writes calculated solution points to a CSV file";
|
|
}
|
|
|
|
PLUGIN_EXPORT int write_output(const OutputParameters* parameters){
|
|
|
|
std::ofstream stream(parameters->destination_path);
|
|
if (!stream)
|
|
return 1;
|
|
|
|
stream.imbue(std::locale::classic());
|
|
stream << std::setprecision(17);
|
|
stream << "t,x1,x2,x3\n";
|
|
|
|
for (size_t index = 0; index < parameters->point_count; ++index){
|
|
SolutionPoint point = parameters->points[index];
|
|
stream << point.t << ',' << point.x1 << ','
|
|
<< point.x2 << ',' << point.x3 << '\n';
|
|
}
|
|
|
|
return stream ? 0 : 2;
|
|
}
|