LCOV - code coverage report
Current view: top level - src/utils - FileLineInfo.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 2bf808 Lines: 32 32 100.0 %
Date: 2025-07-17 01:28:37 Functions: 13 13 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //* This file is part of the MOOSE framework
       2             : //* https://mooseframework.inl.gov
       3             : //*
       4             : //* All rights reserved, see COPYRIGHT for full restrictions
       5             : //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
       6             : //*
       7             : //* Licensed under LGPL 2.1, please see LICENSE for details
       8             : //* https://www.gnu.org/licenses/lgpl-2.1.html
       9             : 
      10             : #include "FileLineInfo.h"
      11             : 
      12   114125683 : FileLineInfo::FileLineInfo() : _line(-1) {}
      13             : 
      14   114121069 : FileLineInfo::FileLineInfo(const std::string & f, int l) : _line(l), _file(f) {}
      15             : 
      16             : bool
      17   114535389 : FileLineInfo::isValid() const
      18             : {
      19   114535389 :   return !_file.empty() && _line >= 0;
      20             : }
      21             : 
      22             : int
      23      410643 : FileLineInfo::line() const
      24             : {
      25      410643 :   return _line;
      26             : }
      27             : 
      28             : std::string
      29      410643 : FileLineInfo::file() const
      30             : {
      31      410643 :   return _file;
      32             : }
      33             : 
      34             : void
      35   114121069 : FileLineInfoMap::addInfo(const std::string & key0, const std::string & file, int line)
      36             : {
      37   114121069 :   FileLineInfo f(file, line);
      38   114121069 :   if (f.isValid())
      39   114121056 :     _map[key0] = f;
      40   114121069 : }
      41             : 
      42             : void
      43    13034984 : FileLineInfoMap::addInfo(const std::string & key0,
      44             :                          const std::string & key1,
      45             :                          const std::string & file,
      46             :                          int line)
      47             : {
      48    13034984 :   addInfo(makeKey(key0, key1), file, line);
      49    13034984 : }
      50             : 
      51             : void
      52     7497712 : FileLineInfoMap::addInfo(const std::string & key0,
      53             :                          const std::string & key1,
      54             :                          const std::string & key2,
      55             :                          const std::string & file,
      56             :                          int line)
      57             : {
      58     7497712 :   addInfo(makeKey(key0, key1, key2), file, line);
      59     7497712 : }
      60             : 
      61             : std::string
      62    13065639 : FileLineInfoMap::makeKey(const std::string & key0, const std::string & key1) const
      63             : {
      64    26131278 :   return key0 + "%" + key1;
      65             : }
      66             : 
      67             : std::string
      68     7519450 : FileLineInfoMap::makeKey(const std::string & key0,
      69             :                          const std::string & key1,
      70             :                          const std::string & key2) const
      71             : {
      72    15038900 :   return key0 + "%" + key1 + "%" + key2;
      73             : }
      74             : 
      75             : FileLineInfo
      76      456904 : FileLineInfoMap::getInfo(const std::string & key0) const
      77             : {
      78      456904 :   auto it = _map.find(key0);
      79      456904 :   if (it == _map.end())
      80        4627 :     return FileLineInfo();
      81      452277 :   return it->second;
      82             : }
      83             : 
      84             : FileLineInfo
      85       30655 : FileLineInfoMap::getInfo(const std::string & key0, const std::string & key1) const
      86             : {
      87       61310 :   return getInfo(makeKey(key0, key1));
      88             : }
      89             : 
      90             : FileLineInfo
      91       21738 : FileLineInfoMap::getInfo(const std::string & key0,
      92             :                          const std::string & key1,
      93             :                          const std::string & key2) const
      94             : {
      95       43476 :   return getInfo(makeKey(key0, key1, key2));
      96             : }

Generated by: LCOV version 1.14