diff --git a/lib/agent/experimental/CSV_Writer.cpp b/lib/agent/experimental/CSV_Writer.cpp index f12e605..d3b55fd 100644 --- a/lib/agent/experimental/CSV_Writer.cpp +++ b/lib/agent/experimental/CSV_Writer.cpp @@ -1,86 +1,92 @@ #include "rosa/agent/experimental/CSV_Writer.hpp" //#include //#include #define STRINGLENGTH 5000 void CSV_Writer :: initialize_csv_writer(char* filepath_write) { //fpointer_write = fopen(filepath_write, "w"); - fopen_s(&fpointer_write, filepath_write, "w"); - +#if defined (_WIN64) || (__WIN32__) || (_WIN32) + fopen_s(&fpointer_write, filepath_write, "w"); +#elif defined(__linux__) + fpointer_write = fopen(filepath_write, "w"); + if (fpointer_write == NULL) { + printf("Parth: %s not found \n", filepath_write); + } +#endif //if (fpointer_write == NULL) { //printf("Path: %s", filepath_write); //} } CSV_Writer :: CSV_Writer(char* filepath_write) { set_name((char *)NO_NAME); initialize_csv_writer(filepath_write); } CSV_Writer :: CSV_Writer(char* name, char* filepath_write) { set_name(name); initialize_csv_writer(filepath_write); } bool CSV_Writer :: write_field(int dataset) { if(fpointer_write) { fprintf(fpointer_write, "%i", dataset); return true; } return false; } bool CSV_Writer :: write_field(float dataset) { if(fpointer_write) { fprintf(fpointer_write, "%f", dataset); return true; } return false; } bool CSV_Writer :: write_field(char* dataset) { if(fpointer_write) { fprintf(fpointer_write, "%s", dataset); return true; } return false; } bool CSV_Writer :: make_new_field() { if(fpointer_write) { fprintf(fpointer_write, ","); return true; } return false; } bool CSV_Writer :: make_new_line() { if(fpointer_write) { fprintf(fpointer_write, "\n"); return true; } return false; } bool CSV_Writer :: write_row_data(unsigned int num_of_datasets, float* datasets) { if(fpointer_write) { for(unsigned int d_ix=0; d_ix #include +#include #define STRINGLENGTH 5000 /* void CSV_Reader :: initialize_csvreader(char* filepath_read, unsigned int num_of_datasets, unsigned int* list_of_datasets, unsigned int start_row) { //fpointer_read = fopen(filepath_read, "r"); fopen_s(&fpointer_read, filepath_read, "r"); this->num_of_datasets = num_of_datasets; //TODO: sort.. falls es nicht in aufsteigender folge kommt for(unsigned int d_ix=0; d_ixlist_of_datasets[d_ix] = list_of_datasets[d_ix]; } row = 1; this->start_row = start_row; } */ void CSVreaderModule :: initialize_csvreader(FILE* fpointer, unsigned int column, unsigned int start_row) { //fpointer_read = fopen(filepath_read, "r"); //TODO: file ponter schon aus CSV-Reader Creator Funktion übergeben.. dann kann man nämlich ausgeben, wenn da was nicht erstellt werden kann //bool file_opened = fopen_s(&fpointer_read, filepath_read, "r"); //TODO: etwas mit flag this->fpointer = fpointer; this->row = 1; this->column = column; this->start_row = start_row; flag_csv_reader_configured = true; } /* CSV_Reader :: CSV_Reader(char* filepath_read, unsigned int num_of_data_sets, unsigned int* list_of_datasets, unsigned int start_row) { set_name(NO_NAME); initialize_csvreader(filepath_read, num_of_data_sets, list_of_datasets, start_row); } CSV_Reader :: CSV_Reader(char* name, char* filepath_read, unsigned int num_of_data_sets, unsigned int* list_of_datasets, unsigned int start_row) { set_name(name); initialize_csvreader(filepath_read, num_of_data_sets, list_of_datasets, start_row); } */ CSVreaderModule :: CSVreaderModule() { set_name((char *)NO_NAME); flag_csv_reader_configured = false; } CSVreaderModule :: CSVreaderModule(char* name) { set_name(name); flag_csv_reader_configured = false; } CSVreaderModule :: CSVreaderModule(FILE* fpointer, unsigned int column, unsigned int start_row) { set_name((char *)NO_NAME); if(fpointer) { initialize_csvreader(fpointer, column, start_row); } else { flag_csv_reader_configured = false; } } CSVreaderModule :: CSVreaderModule(char* name, FILE* fpointer, unsigned int column, unsigned int start_row) { set_name(name); if(fpointer) { initialize_csvreader(fpointer, column, start_row); } else { flag_csv_reader_configured = false; } } /* CSV_Reader :: CSV_Reader(char* name, char* filepath_read, int column, int start_row) { } */ //XXX: Wird nicht mehr benutzt //TODO: überarbeiten nach folgendem Beispiel https://msdn.microsoft.com/en-us/library/ftsafwz3.aspx bool CSVreaderModule :: read_one_row() { if(fpointer) { char readrow[STRINGLENGTH] = "";//, electedfield[STRINGLENGTH] = ""; //TODO: move following for-loop to "initialize_csvreader(...) for(;row Module :: Module() { set_name((char*)NO_NAME); } Module :: Module(char* name) { set_name(name); } void Module :: set_name(char* name) { - strncpy_s (this->name, name, MAX_LENGTH_NAME); +#if defined (_WIN64) || (__WIN32__) || (_WIN32) + strncpy_s (this->name, name, MAX_LENGTH_NAME); +#elif defined(__linux__) + strncpy(this->name, name, MAX_LENGTH_NAME); +#endif } char* Module :: get_name() { return this->name; -} \ No newline at end of file +}