LCOV - code coverage report
Current view: top level - src/Tools/Display/rang_format - rang_format.cpp (source / functions) Hit Total Coverage
Test: streampu_clean.info Lines: 7 35 20.0 %
Date: 2024-06-12 12:04:18 Functions: 2 7 28.6 %

          Line data    Source code
       1             : #include "Tools/Display/rang_format/rang_format.h"
       2             : 
       3             : std::ostream&
       4           0 : format_error(std::ostream& os)
       5             : {
       6           0 :     os << rang::style::bold << rang::fg::red << "(EE) " << rang::style::reset;
       7           0 :     return os;
       8             : }
       9             : 
      10             : std::ostream&
      11           0 : format_warning(std::ostream& os)
      12             : {
      13           0 :     os << rang::style::bold << rang::fg::yellow << "(WW) " << rang::style::reset;
      14           0 :     return os;
      15             : }
      16             : 
      17             : std::ostream&
      18           0 : format_info(std::ostream& os)
      19             : {
      20           0 :     os << rang::style::bold << rang::fg::blue << "(II) " << rang::style::reset;
      21           0 :     return os;
      22             : }
      23             : 
      24             : std::ostream&
      25         112 : format_comment(std::ostream& os)
      26             : {
      27         112 :     os << rang::style::bold << "# " << rang::style::reset;
      28         112 :     return os;
      29             : }
      30             : 
      31             : std::ostream&
      32           0 : format_positive(std::ostream& os)
      33             : {
      34           0 :     os << rang::style::bold << rang::fg::green << "(II) " << rang::style::reset;
      35           0 :     return os;
      36             : }
      37             : 
      38             : std::ostream&
      39         112 : rang::operator<<(std::ostream& os, tag f)
      40             : {
      41         112 :     switch (f)
      42             :     {
      43           0 :         case rang::tag::error:
      44           0 :             return format_error(os);
      45           0 :         case rang::tag::warning:
      46           0 :             return format_warning(os);
      47           0 :         case rang::tag::info:
      48           0 :             return format_info(os);
      49         112 :         case rang::tag::comment:
      50         112 :             return format_comment(os);
      51           0 :         case rang::tag::positive:
      52           0 :             return format_positive(os);
      53             :     }
      54             : 
      55           0 :     return os;
      56             : }
      57             : 
      58             : void
      59           0 : rang::format_on_each_line(std::ostream& os, const std::string& str, rang::tag f)
      60             : {
      61           0 :     size_t pos = 0, old_pos = 0;
      62           0 :     while ((pos = str.find('\n', old_pos)) != std::string::npos)
      63             :     {
      64           0 :         os << f << str.substr(old_pos, pos - old_pos) << std::endl;
      65           0 :         old_pos = pos + 1;
      66             :     }
      67           0 :     if (!str.substr(old_pos, pos - old_pos).empty()) os << f << str.substr(old_pos, pos - old_pos);
      68           0 : }

Generated by: LCOV version 1.14