Public Member Functions | Static Private Member Functions | List of all members
cet::lookup_policy_selector Class Reference

#include <filepath_maker.h>

Public Member Functions

std::unique_ptr< filepath_makerselect (std::string const &spec, std::string paths) const
 
std::string help_message () const
 

Static Private Member Functions

static constexpr auto none () noexcept
 
static constexpr auto all () noexcept
 
static constexpr auto nonabsolute () noexcept
 
static constexpr auto after1 () noexcept
 
static constexpr auto permissive () noexcept
 

Detailed Description

Definition at line 111 of file filepath_maker.h.

Member Function Documentation

static constexpr auto cet::lookup_policy_selector::after1 ( )
inlinestaticprivatenoexcept

Definition at line 134 of file filepath_maker.h.

135  {
136  return "after1";
137  }
static constexpr auto cet::lookup_policy_selector::all ( )
inlinestaticprivatenoexcept

Definition at line 124 of file filepath_maker.h.

125  {
126  return "all";
127  }
std::string cet::lookup_policy_selector::help_message ( ) const

Definition at line 143 of file filepath_maker.cc.

144 {
145  using namespace std::string_literals;
146  std::map<std::string, std::vector<std::string>> policies;
147  policies.emplace(none(), std::vector{"No lookup is done for any files."s});
148  policies.emplace(
149  all(),
150  std::vector{"Lookup is performed for all files presented to the filepath-"s,
151  "making object."s});
152  policies.emplace(
153  nonabsolute(),
154  std::vector{"Lookup is performed only for files that are not absolute--"s,
155  "i.e. file names not beginning with the '/' character."s});
156  policies.emplace(
157  after1(),
158  std::vector{"No lookup for the first file, and only lookup is performed"s,
159  "for all subsequent files."s});
160  policies.emplace(
161  permissive(),
162  std::vector{
163  "The first file can be an absolute path, a path relative to '.',"s,
164  "or a path that can be looked up; all subsequent files must be"s,
165  "looked up. This is the policy used by the art framework; it is"s,
166  "sometimes referred to as the first-absolute-or-lookup-with-dot"s,
167  "policy."s});
168  std::string result{"\nThe following file-lookup policies are supported:\n"};
169  for (auto const& [name, description] : policies) {
170  result += "\n '";
171  result += name;
172  result += "'\n";
173  for (auto const& line : description) {
174  result += " ";
175  result += line;
176  result += '\n';
177  }
178  }
179  result += '\n';
180  return result;
181 }
static QCString name
Definition: declinfo.cpp:673
static constexpr auto all() noexcept
static QCString result
std::string string
Definition: nybbler.cc:12
struct vector vector
static constexpr auto none() noexcept
static constexpr auto nonabsolute() noexcept
static constexpr auto permissive() noexcept
void line(double t, double *p, double &x, double &y, double &z)
static QCString * s
Definition: config.cpp:1042
static constexpr auto after1() noexcept
static constexpr auto cet::lookup_policy_selector::nonabsolute ( )
inlinestaticprivatenoexcept

Definition at line 129 of file filepath_maker.h.

130  {
131  return "nonabsolute";
132  }
static constexpr auto cet::lookup_policy_selector::none ( )
inlinestaticprivatenoexcept

Definition at line 119 of file filepath_maker.h.

120  {
121  return "none";
122  }
static constexpr auto cet::lookup_policy_selector::permissive ( )
inlinestaticprivatenoexcept

Definition at line 139 of file filepath_maker.h.

140  {
141  return "permissive";
142  }
std::unique_ptr< filepath_maker > cet::lookup_policy_selector::select ( std::string const &  spec,
std::string  paths 
) const

Definition at line 108 of file filepath_maker.cc.

110 {
111  if (policy == none()) {
112  return std::make_unique<filepath_maker>();
113  }
114 
115  if (policy == all()) {
116  return std::make_unique<filepath_lookup>(move(env_or_paths));
117  }
118 
119  if (policy == nonabsolute()) {
120  return std::make_unique<filepath_lookup_nonabsolute>(move(env_or_paths));
121  }
122 
123  if (policy == after1()) {
124  return std::make_unique<filepath_lookup_after1>(move(env_or_paths));
125  }
126 
127  if (policy == permissive()) {
128  auto search_paths = cet::getenv(env_or_paths);
129  if (empty(search_paths)) {
130  // 'env_or_paths' is not environment variable; assume it's a
131  // list of colon-delimited paths.
132  search_paths = env_or_paths;
133  }
134  return std::make_unique<filepath_first_absolute_or_lookup_with_dot>(
135  move(search_paths));
136  }
137 
138  throw cet::exception("Configuration")
139  << "An unsupported file-lookup policy was selected.";
140 }
static constexpr auto all() noexcept
static constexpr auto none() noexcept
std::string getenv(std::string const &name)
Definition: getenv.cc:15
def move(depos, offset)
Definition: depos.py:107
static constexpr auto nonabsolute() noexcept
static constexpr auto permissive() noexcept
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
decltype(auto) constexpr empty(T &&obj)
ADL-aware version of std::empty.
Definition: StdUtils.h:97
static constexpr auto after1() noexcept

The documentation for this class was generated from the following files: