LCOV - code coverage report
Current view: top level - include/utils - DataFileUtils.h (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 8601ad Lines: 4 4 100.0 %
Date: 2025-07-18 13:27:08 Functions: 2 2 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 <string>
      13             : #include <optional>
      14             : 
      15             : namespace Moose::DataFileUtils
      16             : {
      17             : 
      18             : /**
      19             :  * Context for where a data file came from
      20             :  */
      21             : enum class Context
      22             : {
      23             :   // Relative to the base (typically an input file)
      24             :   RELATIVE,
      25             :   // An absolute path
      26             :   ABSOLUTE,
      27             :   // From installed/in-tree data
      28             :   DATA,
      29             :   /// Unused for default
      30             :   INVALID
      31             : };
      32             : 
      33             : /**
      34             :  * Representation of a data file path
      35             :  */
      36             : struct Path
      37             : {
      38         229 :   Path() : path(), context(Context::INVALID), data_name() {}
      39         249 :   Path(const std::string & path,
      40             :        const Context context,
      41             :        const std::optional<std::string> & data_name = std::optional<std::string>())
      42         249 :     : path(path), context(context), data_name(data_name)
      43             :   {
      44         249 :   }
      45             :   // Path to the file
      46             :   std::string path;
      47             :   /// Context for the file (where it came from)
      48             :   Context context;
      49             :   /// The name of the data registry the file came from (with context == DATA)
      50             :   std::optional<std::string> data_name;
      51             : };
      52             : 
      53             : /**
      54             :  * Get the data path for a given path, searching the registered data
      55             :  *
      56             :  * @param path - The path; can be prefixed with <name>: to search only data from <name>
      57             :  * @param base - The base by which to search for the file relative to (optional)
      58             :  */
      59             : Path getPath(std::string path,
      60             :              const std::optional<std::string> & base = std::optional<std::string>());
      61             : 
      62             : /**
      63             :  * Get the data path for a given path, searching the registered data given an explicit
      64             :  * data search path.
      65             :  *
      66             :  * This exists primarily so that you don't need to call getPath("moose:file").
      67             :  *
      68             :  * @param data_name - The registered data name
      69             :  * @param path - The path
      70             :  * @param base - The base by which to search for the file relative to (optional)
      71             :  */
      72             : Path getPathExplicit(const std::string & data_name,
      73             :                      const std::string & path,
      74             :                      const std::optional<std::string> & base = std::optional<std::string>());
      75             : }

Generated by: LCOV version 1.14