From 7ebc9400514d8c43a8158779ce5fa0ce06e9467d Mon Sep 17 00:00:00 2001 From: Luca Ciucci Date: Wed, 6 Oct 2021 11:25:46 +0200 Subject: [PATCH 1/3] Update gnuplot.h --- include/gnuplot.h | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/include/gnuplot.h b/include/gnuplot.h index cb6cfa4..c7b6f54 100644 --- a/include/gnuplot.h +++ b/include/gnuplot.h @@ -24,28 +24,37 @@ #include #include +#if defined(_MSC_VER) || defined(_WIN32) +#include +#define _MR_GPCPP_POPEN _popen +#define _MR_GPCPP_PCLOSE _pclose +#else +#define _MR_GPCPP_POPEN popen +#define _MR_GPCPP_PCLOSE pclose +#endif + class GnuplotPipe { public: inline GnuplotPipe(bool persist = true) { std::cout << "Opening gnuplot... "; - pipe = popen(persist ? "gnuplot -persist" : "gnuplot", "w"); + pipe = _MR_GPCPP_POPEN(persist ? "gnuplot -persist" : "gnuplot", "w"); if (!pipe) std::cout << "failed!" << std::endl; else std::cout << "succeded." << std::endl; } - inline virtual ~GnuplotPipe(){ - if (pipe) pclose(pipe); + inline virtual ~GnuplotPipe() { + if (pipe) _MR_GPCPP_PCLOSE(pipe); } - void sendLine(const std::string& text, bool useBuffer = false){ + void sendLine(const std::string& text, bool useBuffer = false) { if (!pipe) return; if (useBuffer) buffer.push_back(text + "\n"); else fputs((text + "\n").c_str(), pipe); } - void sendEndOfData(unsigned repeatBuffer = 1){ + void sendEndOfData(unsigned repeatBuffer = 1) { if (!pipe) return; for (unsigned i = 0; i < repeatBuffer; i++) { for (auto& line : buffer) fputs(line.c_str(), pipe); @@ -54,11 +63,11 @@ class GnuplotPipe { fflush(pipe); buffer.clear(); } - void sendNewDataBlock(){ + void sendNewDataBlock() { sendLine("\n", !buffer.empty()); } - void writeBufferToFile(const std::string& fileName){ + void writeBufferToFile(const std::string& fileName) { std::ofstream fileOut(fileName); for (auto& line : buffer) fileOut << line; fileOut.close(); @@ -71,3 +80,7 @@ class GnuplotPipe { FILE* pipe; std::vector buffer; }; + + +#undef _MR_GPCPP_POPEN +#undef _MR_GPCPP_PCLOSE \ No newline at end of file From c3a8fc8f99934b63edca9d0b13f55e960068bb81 Mon Sep 17 00:00:00 2001 From: Luca Ciucci Date: Wed, 6 Oct 2021 12:31:51 +0200 Subject: [PATCH 2/3] Create .gitignore For CMake project --- .gitignore | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..bbbea4e --- /dev/null +++ b/.gitignore @@ -0,0 +1,34 @@ + +################################################################ +# Default GitHub's CMake gitignore +################################################################ + +CMakeLists.txt.user +CMakeCache.txt +CMakeFiles +CMakeScripts +Testing +Makefile +cmake_install.cmake +install_manifest.txt +compile_commands.json +CTestTestfile.cmake +_deps + +################################################################ +# Additional Gitignores +################################################################ + +################################ +# Visual Studio +################################ + +# default VS stuff folder +.vs/ + +# default VS output folder +out/ + +################################################################ +# Git added +################################################################ \ No newline at end of file From 86dd10170f050970e63cb8489f10d4b7880b60fc Mon Sep 17 00:00:00 2001 From: Luca Ciucci Date: Wed, 6 Oct 2021 12:32:01 +0200 Subject: [PATCH 3/3] Create CMakeLists.txt --- CMakeLists.txt | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..e69de29