Xped
Loading...
Searching...
No Matches
Helpers.hpp
Go to the documentation of this file.
1#ifndef XPED_MODELS_HELPERS_HPP_
2#define XPED_MODELS_HELPERS_HPP_
3
4#include <map>
5#include <string>
6#include <vector>
7
8#include "Xped/Util/Param.hpp"
9
10namespace Xped::internal {
11
12std::string format_params(const std::string& name, const std::map<std::string, Param>& params, const std::vector<std::string>& used_params)
13{
14 std::string inner;
15 for(const auto& p : used_params) {
16 if(p != used_params.back()) {
17 fmt::format_to(std::back_inserter(inner), "{}={:.2f}, ", p, params.at(p).get<double>());
18 } else {
19 fmt::format_to(std::back_inserter(inner), "{}={:.2f}", p, params.at(p).get<double>());
20 }
21 }
22 std::string res = fmt::format("{}({})", name, inner);
23 return res;
24}
25
26std::string create_filename(const std::string& name, const std::map<std::string, Param>& params, const std::vector<std::string>& used_params)
27{
28 std::string res = name + "_";
29 for(const auto& p : used_params) {
30 if(p != used_params.back()) {
31 fmt::format_to(std::back_inserter(res), "{}={:.2f}_", p, params.at(p).get<double>());
32 } else {
33 fmt::format_to(std::back_inserter(res), "{}={:.2f}", p, params.at(p).get<double>());
34 }
35 }
36 return res;
37}
38
39} // namespace Xped::internal
40#endif
Definition: reverse_pass_callback_alloc.hpp:8
std::string format_params(const std::string &name, const std::map< std::string, Param > &params, const std::vector< std::string > &used_params)
Definition: Helpers.hpp:12
std::string create_filename(const std::string &name, const std::map< std::string, Param > &params, const std::vector< std::string > &used_params)
Definition: Helpers.hpp:26