MCPcopy Create free account
hub / github.com/alandefreitas/matplotplusplus / gnuplot_version

Method gnuplot_version

source/matplot/backend/gnuplot.cpp:341–383  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

339 }
340
341 std::tuple<int, int, int> gnuplot::gnuplot_version() {
342 static std::tuple<int, int, int> version{0, 0, 0};
343 const bool dont_know_gnuplot_version_yet =
344 version == std::tuple<int, int, int>({0, 0, 0});
345 if (dont_know_gnuplot_version_yet) {
346 std::string version_str =
347 run_and_get_output("gnuplot --version 2>&1");
348 std::string version_major = std::regex_replace(
349 version_str,
350 std::regex("[^]*gnuplot (\\d+)\\.\\d+ patchlevel \\d+ *"),
351 "$1");
352 std::string version_minor = std::regex_replace(
353 version_str,
354 std::regex("[^]*gnuplot \\d+\\.(\\d+) patchlevel \\d+ *"),
355 "$1");
356 std::string version_patch = std::regex_replace(
357 version_str,
358 std::regex("[^]*gnuplot \\d+\\.\\d+ patchlevel (\\d+) *"),
359 "$1");
360 try {
361 std::get<0>(version) = std::stoi(version_major);
362 } catch (...) {
363 std::get<0>(version) = 0;
364 }
365 try {
366 std::get<1>(version) = std::stoi(version_minor);
367 } catch (...) {
368 std::get<1>(version) = 0;
369 }
370 try {
371 std::get<2>(version) = std::stoi(version_patch);
372 } catch (...) {
373 std::get<2>(version) = 0;
374 }
375 const bool still_dont_know_gnuplot_version =
376 version == std::tuple<int, int, int>({0, 0, 0});
377 if (still_dont_know_gnuplot_version) {
378 // assume it's 5.2.6 by convention
379 version = std::tuple<int, int, int>({5, 2, 6});
380 }
381 }
382 return version;
383 }
384
385 bool gnuplot::terminal_has_title_option(const std::string &t) {
386 SV_CONSTEXPR std::string_view whitelist[] = {

Callers

nothing calls this directly

Calls 1

run_and_get_outputFunction · 0.85

Tested by

no test coverage detected