1 #ifndef LIBJMMCG_CORE_STATS_OUTPUT_HPP
2 #define LIBJMMCG_CORE_STATS_OUTPUT_HPP
36 std::ifstream os(stats_name);
38 std::vector<std::string> lines;
39 while (
std::getline(os, line)) {
40 lines.emplace_back(std::move(line));
45 const auto &last_entry=lines.rbegin();
46 assert(!last_entry->empty());
47 const auto slash_at=last_entry->find(
"\\");
48 assert(slash_at<last_entry->size());
49 auto end=std::next(&*last_entry->begin(), slash_at);
50 const unsigned long last_number=std::strtoul(last_entry->data(), &end, 10);
51 return last_number+1u;
55 struct file_wrapper
final {
58 file_wrapper(
char const *
const stats_name,
unsigned run_number)
noexcept(
false)
76 static std::unique_ptr<private_::file_wrapper> handle;
94 setup(
char const *
const stats_name)
noexcept(
false) {
95 handle.reset(
new private_::file_wrapper(stats_name, private_::find_run_num(stats_name)));
109 struct wrapper
final {
110 explicit wrapper(
char const *stats_name)
noexcept(
false) {
113 explicit wrapper(
std::string
const &stats_name)
noexcept(
false) {
114 setup(stats_name.c_str());
122 #ifdef BOOST_TEST_INCLUDED
129 make_fixture(
char const *stats_name)
noexcept(
false) {
130 return boost::unit_test::fixture<wrapper>(stats_name);