File indexing completed on 2025-08-05 08:19:08
0001
0002
0003
0004
0005 #ifndef UTIL_H
0006 #define UTIL_H
0007
0008 #include <iostream>
0009 #include <sstream>
0010
0011 #include <boost/filesystem.hpp>
0012 #include <boost/program_options/variables_map.hpp>
0013
0014 #include "../src/fwd_decl.h"
0015
0016
0017
0018
0019 VarMap make_var_map(std::map<std::string, boost::any>&& args);
0020
0021
0022 struct capture_stdout {
0023 capture_stdout() {
0024
0025 cout_orig = std::cout.rdbuf(stream.rdbuf());
0026 }
0027
0028 ~capture_stdout() {
0029
0030 std::cout.rdbuf(cout_orig);
0031 }
0032
0033 std::streambuf* cout_orig;
0034 std::stringstream stream;
0035 };
0036
0037
0038 struct temporary_path {
0039 temporary_path(const fs::path& ext = fs::path{})
0040 : path(
0041 fs::temp_directory_path() /
0042 fs::unique_path().replace_extension(ext)
0043 )
0044 {}
0045 ~temporary_path() {
0046 fs::remove_all(path);
0047 }
0048 const fs::path path;
0049 };
0050
0051 #endif