LCOV - code coverage report
Current view: top level - src/Tools/Display/Terminal/Dump - Terminal_dump.cpp (source / functions) Hit Total Coverage
Test: streampu_clean.info Lines: 39 43 90.7 %
Date: 2024-07-31 15:48:41 Functions: 2 3 66.7 %

          Line data    Source code
       1             : #include <algorithm>
       2             : #include <cassert>
       3             : #include <cmath>
       4             : #include <iomanip>
       5             : #include <ios>
       6             : 
       7             : #include "Tools/Display/Terminal/Dump/Terminal_dump.hpp"
       8             : #include "Tools/Display/rang_format/rang_format.h"
       9             : #include "Tools/Exception/exception.hpp"
      10             : 
      11             : using namespace spu;
      12             : using namespace spu::tools;
      13             : 
      14          14 : Terminal_dump::Terminal_dump(const std::vector<tools::Reporter*>& reporters)
      15          14 :   : Terminal_std(reporters)
      16             : {
      17          14 : }
      18             : 
      19           0 : Terminal_dump::Terminal_dump(const std::vector<std::unique_ptr<tools::Reporter>>& reporters)
      20           0 :   : Terminal_std(reporters)
      21             : {
      22           0 : }
      23             : 
      24             : void
      25         117 : Terminal_dump::report(std::ostream& stream, bool final)
      26             : {
      27         117 :     std::ios::fmtflags f(stream.flags());
      28             : 
      29         117 :     std::vector<Reporter::report_t> report_list;
      30         585 :     for (unsigned r = 0; r < this->reporters.size(); r++)
      31         468 :         report_list.push_back(this->reporters[r]->report(final));
      32             : 
      33         117 :     bool is_not_over = true;
      34         264 :     while (is_not_over)
      35             :     {
      36         147 :         stream << data_tag;
      37             : 
      38         147 :         is_not_over = false;
      39         735 :         for (unsigned r = 0; r < this->reporters.size(); r++)
      40         588 :             if (this->reporters[r] != nullptr)
      41             :             {
      42         588 :                 auto& report = report_list[r];
      43         588 :                 auto& groups = this->reporters[r]->get_groups();
      44             : 
      45         588 :                 assert(report.size() == groups.size());
      46             : 
      47        1176 :                 for (unsigned g = 0; g < groups.size(); g++)
      48             :                 {
      49         588 :                     if (report[g].size()) assert(report[g].size() % groups[g].second.size() == 0);
      50             : 
      51         588 :                     stream << report_style << std::string(extra_spaces(groups[g]), ' ') << rang::style::reset;
      52             : 
      53        2499 :                     for (unsigned c = 0; c < groups[g].second.size(); c++)
      54             :                     {
      55        1911 :                         auto text = report[g].size() ? report[g][c] : "-";
      56             : 
      57             :                         size_t column_with =
      58        1911 :                           std::get<2>(groups[g].second[c]) ? std::get<2>(groups[g].second[c]) : def_column_width;
      59        1911 :                         if (text.size() < (size_t)column_with)
      60             :                         {
      61        1911 :                             text += " ";
      62        1911 :                             text.insert(0, column_with - text.size(), ' ');
      63             :                         }
      64             : 
      65        1911 :                         stream << text;
      66             : 
      67        1911 :                         if (c != (groups[g].second.size() - 1))
      68        1323 :                             stream << report_style << col_separator << rang::style::reset;
      69        1911 :                     }
      70         588 :                     if (report[g].size())
      71         532 :                         report[g].erase(report[g].begin(), report[g].begin() + groups[g].second.size());
      72         588 :                     is_not_over = is_not_over ? is_not_over : report[g].size() > 0;
      73             : 
      74         588 :                     if (g != (groups.size() - 1)) stream << report_style << group_separator << rang::style::reset;
      75             :                 }
      76             : 
      77         588 :                 if (r != (this->reporters.size() - 1)) stream << report_style << group_separator << rang::style::reset;
      78             :             }
      79             :             else
      80           0 :                 throw tools::runtime_error(__FILE__, __LINE__, __func__, "'this->reporters' contains null pointer.");
      81             : 
      82         147 :         stream << std::endl;
      83             :     }
      84             : 
      85         117 :     stream.flags(f);
      86         117 :     stream.flush();
      87         207 : }

Generated by: LCOV version 1.14