deal.II version GIT relicensing-1982-gbb401394a0 2024-10-13 08:40:01+00:00
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
Loading...
Searching...
No Matches
path_search.h
Go to the documentation of this file.
1// ------------------------------------------------------------------------
2//
3// SPDX-License-Identifier: LGPL-2.1-or-later
4// Copyright (C) 2005 - 2023 by the deal.II authors
5//
6// This file is part of the deal.II library.
7//
8// Part of the source code is dual licensed under Apache-2.0 WITH
9// LLVM-exception OR LGPL-2.1-or-later. Detailed license information
10// governing the source code and code contributions can be found in
11// LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II.
12//
13// ------------------------------------------------------------------------
14
15#ifndef dealii_path_search_h
16#define dealii_path_search_h
17
18
19#include <deal.II/base/config.h>
20
22
23#include <fstream>
24#include <map>
25#include <memory>
26#include <string>
27#include <vector>
28
29
31
83{
84public:
89 {
95 after_none
96 };
97
104 PathSearch(const std::string &cls, const unsigned int debug = 0);
105
122 std::string
123 find(const std::string &filename, const char *open_mode = "r");
124
143 std::string
144 find(const std::string &filename,
145 const std::string &suffix,
146 const char *open_mode = "r");
147
151 template <typename StreamType>
152 void
153 show(StreamType &stream) const;
154
158 static void
159 add_class(const std::string &cls);
160
165 void
166 add_path(const std::string &path, Position pos = back);
167
172 void
173 add_suffix(const std::string &suffix, Position pos = back);
174
179 DeclException1(ExcNoClass,
180 std::string,
181 << "The class " << arg1
182 << " must be registered before referring it in PathSearch.");
188 DeclException2(ExcFileNotFound,
189 std::string,
190 std::string,
191 << "The file \"" << arg1 << "\" was not found in the path for "
192 << "files of class " << arg2 << '.');
193
194private:
198 using map_type = std::map<std::string, std::vector<std::string>>::value_type;
199
203 static void
204 initialize_classes();
205
210 static std::vector<std::string> &
211 get_path_list(const std::string &cls);
212
217 static std::vector<std::string> &
218 get_suffix_list(const std::string &cls);
219
223 const std::string cls;
224
228 static std::map<std::string, std::vector<std::string>> path_lists;
229
233 static std::map<std::string, std::vector<std::string>> suffix_lists;
234
238 std::vector<std::string> &my_path_list;
239
243 std::vector<std::string> &my_suffix_list;
244
248 const unsigned int debug;
249
253 static std::string empty;
254};
255
256
257/* ----------------------------- inline functions ------------------------- */
258
259
260template <typename StreamType>
261inline void
262PathSearch::show(StreamType &out) const
263{
264 out << "DEAL_II_" << cls << "PATH=\"";
265 bool first = true;
266 for (const auto &p : my_path_list)
267 {
268 if (!first)
269 out << ':';
270 out << p;
271 first = false;
272 }
273 out << '"' << std::endl << " Suffixes";
274 for (const auto &s : my_suffix_list)
275 out << " \"" << s << '"';
276 out << std::endl;
277}
278
280
281#endif
void show(StreamType &stream) const
static std::map< std::string, std::vector< std::string > > path_lists
const std::string cls
std::vector< std::string > & my_suffix_list
static std::map< std::string, std::vector< std::string > > suffix_lists
const unsigned int debug
std::vector< std::string > & my_path_list
@ back
Add new item at end of list.
Definition path_search.h:91
@ front
Add new item at front of list.
Definition path_search.h:93
std::map< std::string, std::vector< std::string > >::value_type map_type
static std::string empty
#define DEAL_II_DEPRECATED
Definition config.h:205
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:498
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:499
Point< 2 > first
Definition grid_out.cc:4623
#define DeclException2(Exception2, type1, type2, outsequence)
Definition exceptions.h:534
#define DeclException1(Exception1, type1, outsequence)
Definition exceptions.h:511