Reference documentation for deal.II version 9.5.0
\(\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// Copyright (C) 2005 - 2022 by the deal.II authors
4//
5// This file is part of the deal.II library.
6//
7// The deal.II library is free software; you can use it, redistribute
8// it, and/or modify it under the terms of the GNU Lesser General
9// Public License as published by the Free Software Foundation; either
10// version 2.1 of the License, or (at your option) any later version.
11// The full text of the license can be found in the file LICENSE.md at
12// the top level directory of deal.II.
13//
14// ---------------------------------------------------------------------
15
16#ifndef dealii_path_search_h
17#define dealii_path_search_h
18
19
20#include <deal.II/base/config.h>
21
23
24#include <fstream>
25#include <map>
26#include <memory>
27#include <string>
28#include <vector>
29
30
32
84{
85public:
90 {
97 };
98
105 PathSearch(const std::string &cls, const unsigned int debug = 0);
106
123 std::string
124 find(const std::string &filename, const char *open_mode = "r");
125
144 std::string
145 find(const std::string &filename,
146 const std::string &suffix,
147 const char * open_mode = "r");
148
152 template <class StreamType>
153 void
154 show(StreamType &stream) const;
155
159 static void
160 add_class(const std::string &cls);
161
166 void
167 add_path(const std::string &path, Position pos = back);
168
173 void
174 add_suffix(const std::string &suffix, Position pos = back);
175
181 std::string,
182 << "The class " << arg1
183 << " must be registered before referring it in PathSearch.");
190 std::string,
191 std::string,
192 << "The file \"" << arg1 << "\" was not found in the path for "
193 << "files of class " << arg2 << '.');
194
195private:
199 using map_type = std::map<std::string, std::vector<std::string>>::value_type;
200
204 static void
206
211 static std::vector<std::string> &
212 get_path_list(const std::string &cls);
213
218 static std::vector<std::string> &
219 get_suffix_list(const std::string &cls);
220
224 const std::string cls;
225
229 static std::map<std::string, std::vector<std::string>> path_lists;
230
234 static std::map<std::string, std::vector<std::string>> suffix_lists;
235
239 std::vector<std::string> &my_path_list;
240
244 std::vector<std::string> &my_suffix_list;
245
249 const unsigned int debug;
250
254 static std::string empty;
255};
256
257
258/* ----------------------------- inline functions ------------------------- */
259
260
261template <class StreamType>
262inline void
263PathSearch::show(StreamType &out) const
264{
265 out << "DEAL_II_" << cls << "PATH=\"";
266 bool first = true;
267 for (const auto &p : my_path_list)
268 {
269 if (!first)
270 out << ':';
271 out << p;
272 first = false;
273 }
274 out << '"' << std::endl << " Suffixes";
275 for (const auto &s : my_suffix_list)
276 out << " \"" << s << '"';
277 out << std::endl;
278}
279
281
282#endif
std::string find(const std::string &filename, const char *open_mode="r")
static std::vector< std::string > & get_path_list(const std::string &cls)
void show(StreamType &stream) const
static std::vector< std::string > & get_suffix_list(const std::string &cls)
static std::map< std::string, std::vector< std::string > > path_lists
const std::string cls
void add_path(const std::string &path, Position pos=back)
std::vector< std::string > & my_suffix_list
static std::map< std::string, std::vector< std::string > > suffix_lists
static void add_class(const std::string &cls)
const unsigned int debug
std::vector< std::string > & my_path_list
@ back
Add new item at end of list.
Definition path_search.h:92
@ after_none
Add in path list after empty element.
Definition path_search.h:96
@ front
Add new item at front of list.
Definition path_search.h:94
void add_suffix(const std::string &suffix, Position pos=back)
std::map< std::string, std::vector< std::string > >::value_type map_type
static std::string empty
static void initialize_classes()
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:472
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:473
Point< 2 > first
Definition grid_out.cc:4615
static ::ExceptionBase & ExcFileNotFound(std::string arg1, std::string arg2)
#define DeclException2(Exception2, type1, type2, outsequence)
Definition exceptions.h:533
static ::ExceptionBase & ExcNoClass(std::string arg1)
#define DeclException1(Exception1, type1, outsequence)
Definition exceptions.h:510