https://mooseframework.inl.gov
DataFileUtils.h
Go to the documentation of this file.
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 
16 {
17 
21 enum class Context
22 {
24  RELATIVE,
26  ABSOLUTE,
28  DATA,
34  INVALID
35 };
36 
40 struct Path
41 {
43  Path(const std::string & path,
44  const Context context,
45  const std::optional<std::string> & data_name = std::optional<std::string>())
47  {
48  }
49  // Path to the file
50  std::string path;
54  std::optional<std::string> data_name;
55 };
56 
61 {
65  std::optional<std::string> base;
67  bool search_all_data = true;
72  bool graceful = false;
73 };
74 
81 Path getPath(std::string path, const GetPathOptions & options = {});
82 
93 Path getPathExplicit(const std::string & data_name,
94  const std::string & path,
95  const std::optional<std::string> & base = std::optional<std::string>());
96 }
Path getPathExplicit(const std::string &data_name, const std::string &path, const std::optional< std::string > &base=std::optional< std::string >())
Get the data path for a given path, searching the registered data given an explicit data search path...
Relative to the base (typically an input file)
bool search_all_data
Whether or not to search all registered data.
Definition: DataFileUtils.h:67
Context context
Context for the file (where it came from)
Definition: DataFileUtils.h:52
From installed/in-tree data.
bool graceful
Whether or not to error whenever a path is not found.
Definition: DataFileUtils.h:72
Relative to the base, but not found.
Path getPath(std::string path, const GetPathOptions &options={})
Get the data path for a given path, searching the registered data.
Definition: DataFileUtils.C:22
Context
Context for where a data file came from.
Definition: DataFileUtils.h:21
Options to be passed to getPath().
Definition: DataFileUtils.h:60
Representation of a data file path.
Definition: DataFileUtils.h:40
std::optional< std::string > base
The base path by which to search for relative paths.
Definition: DataFileUtils.h:65
std::optional< std::string > data_name
The name of the data registry the file came from (with context == DATA)
Definition: DataFileUtils.h:54
Path(const std::string &path, const Context context, const std::optional< std::string > &data_name=std::optional< std::string >())
Definition: DataFileUtils.h:43