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 {
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,
30  INVALID
31 };
32 
36 struct Path
37 {
39  Path(const std::string & path,
40  const Context context,
41  const std::optional<std::string> & data_name = std::optional<std::string>())
43  {
44  }
45  // Path to the file
46  std::string path;
50  std::optional<std::string> data_name;
51 };
52 
59 Path getPath(std::string path,
60  const std::optional<std::string> & base = std::optional<std::string>());
61 
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 }
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...
Context context
Context for the file (where it came from)
Definition: DataFileUtils.h:48
Context
Context for where a data file came from.
Definition: DataFileUtils.h:21
Representation of a data file path.
Definition: DataFileUtils.h:36
Path getPath(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.
Definition: DataFileUtils.C:22
std::optional< std::string > data_name
The name of the data registry the file came from (with context == DATA)
Definition: DataFileUtils.h:50
Path(const std::string &path, const Context context, const std::optional< std::string > &data_name=std::optional< std::string >())
Definition: DataFileUtils.h:39