| 114 | #endif |
| 115 | |
| 116 | bool gnuplot::output(const std::string &filename) { |
| 117 | if (filename.empty()) { |
| 118 | output_ = filename; |
| 119 | terminal_ = default_terminal_type(); |
| 120 | return true; |
| 121 | } |
| 122 | |
| 123 | // look at the extension |
| 124 | #ifndef CXX_NO_FILESYSTEM |
| 125 | namespace fs = std::filesystem; |
| 126 | fs::path p{filename}; |
| 127 | std::string ext = p.extension().string(); |
| 128 | #else |
| 129 | std::string ext = filename.substr(filename.find_last_of('.')); |
| 130 | #endif |
| 131 | |
| 132 | // check terminal for that extension |
| 133 | SV_CONSTEXPR auto exts = extension_terminal(); |
| 134 | auto it = std::find_if(exts.begin(), exts.end(), |
| 135 | [&](const auto &e) { return e.first == ext; }); |
| 136 | |
| 137 | // if there is a terminal |
| 138 | if (it != exts.end()) { |
| 139 | // terminal name is the file format |
| 140 | output(filename, std::string(it->second)); |
| 141 | return true; |
| 142 | } else { |
| 143 | // set file format to dumb |
| 144 | std::cerr << "No gnuplot terminal for " << ext << " files" |
| 145 | << std::endl; |
| 146 | std::cerr << "Setting terminal to \"dumb\"" << std::endl; |
| 147 | output(filename, "dumb"); |
| 148 | return false; |
| 149 | } |
| 150 | } |
| 151 | |
| 152 | bool gnuplot::output(const std::string &filename, |
| 153 | const std::string &format) { |
no test coverage detected