https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
21enum class Context
22{
28 DATA,
35};
36
40struct 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
81Path getPath(std::string path, const GetPathOptions & options = {});
82
93Path getPathExplicit(const std::string & data_name,
94 const std::string & path,
95 const std::optional<std::string> & base = std::optional<std::string>());
96}
Context
Context for where a data file came from.
@ ABSOLUTE
An absolute path.
@ RELATIVE_NOT_FOUND
Relative to the base, but not found.
@ RELATIVE
Relative to the base (typically an input file)
@ INVALID
Unused for default.
@ DATA
From installed/in-tree data.
@ ABSOLUTE_NOT_FOUND
Absolute, but not found.
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.
Path getPath(std::string path, const GetPathOptions &options={})
Get the data path for a given path, searching the registered data.
Options to be passed to getPath().
bool graceful
Whether or not to error whenever a path is not found.
std::optional< std::string > base
The base path by which to search for relative paths.
bool search_all_data
Whether or not to search all registered data.
Representation of a data file path.
Path(const std::string &path, const Context context, const std::optional< std::string > &data_name=std::optional< std::string >())
std::optional< std::string > data_name
The name of the data registry the file came from (with context == DATA)
Context context
Context for the file (where it came from)