#include <boost/algorithm/string.hpp>
#include <fstream>
+#include <memory>
#include <ostream>
#include <sstream>
#include <unordered_map>
xbt_assert(not path.empty(), "Cannot parse a trace from an empty filename");
xbt_assert(trace_list.find(path) == trace_list.end(), "Refusing to define trace %s twice", path.c_str());
- const std::ifstream* f = surf_ifsopen(path);
+ auto f = std::unique_ptr<std::ifstream>(surf_ifsopen(path));
xbt_assert(not f->fail(), "Cannot open file '%s' (path=%s)", path.c_str(), (boost::join(surf_path, ":")).c_str());
std::stringstream buffer;
buffer << f->rdbuf();
- delete f;
return Profile::from_string(path, buffer.str(), -1);
}
auto* parse_content = new std::map<std::string, sg_size_t>();
- std::ifstream* fs = surf_ifsopen(filename);
+ auto fs = std::unique_ptr<std::ifstream>(surf_ifsopen(filename));
xbt_assert(not fs->fail(), "Cannot open file '%s' (path=%s)", filename.c_str(),
(boost::join(surf_path, ":")).c_str());
parse_content->insert({tokens.front(), size});
}
} while (not fs->eof());
- delete fs;
return parse_content;
}
auto* parse_content = new std::map<std::string, sg_size_t>();
- std::ifstream* fs = surf_ifsopen(filename);
+ auto fs = std::unique_ptr<std::ifstream>(surf_ifsopen(filename));
xbt_assert(not fs->fail(), "Cannot open file '%s' (path=%s)", filename.c_str(),
(boost::join(surf_path, ":")).c_str());
parse_content->insert({tokens.front(), size});
}
} while (not fs->eof());
- delete fs;
return parse_content;
}