LCOV - code coverage report
Current view: top level - include/interfaces - NamingInterface.h (source / functions) Hit Total Coverage
Test: idaholab/moose thermal_hydraulics: #32971 (54bef8) with base c6cf66 Lines: 25 26 96.2 %
Date: 2026-05-29 20:41:18 Functions: 4 4 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             : #pragma once
      11             : 
      12             : #include "ThermalHydraulicsApp.h"
      13             : 
      14             : class ThermalHydraulicsApp;
      15             : class NamingInterface;
      16             : 
      17             : /**
      18             :  * Interface for handling names
      19             :  */
      20             : class NamingInterface
      21             : {
      22             : public:
      23             :   NamingInterface() {}
      24             : 
      25             :   /**
      26             :    * Build a name from a prefix, number and possible suffix
      27             :    */
      28             :   std::string
      29        9352 :   genName(const std::string & prefix, unsigned int id, const std::string & suffix = "") const
      30             :   {
      31        9352 :     std::stringstream ss;
      32        9352 :     ss << prefix << ":" << id;
      33        9352 :     if (!suffix.empty())
      34        9352 :       ss << ":" << suffix;
      35        9352 :     return ss.str();
      36        9352 :   }
      37             : 
      38             :   /**
      39             :    * Build a name from a prefix, 2 numbers and possible suffix
      40             :    */
      41             :   std::string genName(const std::string & prefix,
      42             :                       unsigned int i,
      43             :                       unsigned int j,
      44             :                       const std::string & suffix = "") const
      45             :   {
      46             :     std::stringstream ss;
      47             :     ss << prefix << ":" << i << ":" << j;
      48             :     if (!suffix.empty())
      49             :       ss << ":" << suffix;
      50             :     return ss.str();
      51             :   }
      52             : 
      53             :   /**
      54             :    * Build a name from 2 strings and a number
      55             :    */
      56        5216 :   std::string genName(const std::string & prefix, const std::string & name, unsigned int i) const
      57             :   {
      58        5216 :     std::stringstream ss;
      59       10432 :     ss << prefix << ":" << name << ":" << i;
      60        5216 :     return ss.str();
      61        5216 :   }
      62             : 
      63             :   /**
      64             :    * Build a name from strings
      65             :    */
      66      162374 :   std::string genName(const std::string & prefix,
      67             :                       const std::string & middle,
      68             :                       const std::string & suffix = "") const
      69             :   {
      70      162374 :     std::stringstream ss;
      71      162374 :     ss << prefix << ":" << middle;
      72      162374 :     if (!suffix.empty())
      73       29907 :       ss << ":" << suffix;
      74      162374 :     return ss.str();
      75      162374 :   }
      76             : 
      77             :   /**
      78             :    * Build a name from strings that is safe to use in input files (i.e. can be exposed to users)
      79             :    */
      80          46 :   std::string genSafeName(const std::string & prefix,
      81             :                           const std::string & middle,
      82             :                           const std::string & suffix = "") const
      83             :   {
      84          46 :     std::stringstream ss;
      85          46 :     ss << prefix << "_" << middle;
      86          46 :     if (!suffix.empty())
      87           0 :       ss << "_" << suffix;
      88          46 :     return ss.str();
      89          46 :   }
      90             : };

Generated by: LCOV version 1.14