Elements 6.3.1
A C++ base framework for the Euclid Software.
Loading...
Searching...
No Matches
Path.h
Go to the documentation of this file.
1
35#ifndef ELEMENTSKERNEL_ELEMENTSKERNEL_PATH_H_
36#define ELEMENTSKERNEL_ELEMENTSKERNEL_PATH_H_
37
38#include <map> // for map
39#include <string> // for string
40#include <utility> // for forward
41#include <vector> // for vector
42
43#include <boost/filesystem/path.hpp> // for path
44
45#include "ElementsKernel/Export.h" // ELEMENTS_API
46
47namespace Elements {
48inline namespace Kernel {
49namespace Path {
50
52
57using Item = boost::filesystem::path;
58
64
70
77
83
89
105ELEMENTS_API std::vector<Item> getLocationsFromEnv(const std::string& path_variable, bool exist_only = false);
106
122ELEMENTS_API std::vector<Item> getLocations(const Type& path_type, bool exist_only = false);
123
140template <typename T, typename U>
141ELEMENTS_API Item getPathFromLocations(const T& file_name, const std::vector<U>& locations);
142// Template instantiation for the most common types
143extern template ELEMENTS_API Item getPathFromLocations(const Item& file_name, const std::vector<Item>& locations);
144extern template ELEMENTS_API Item getPathFromLocations(const Item& file_name,
145 const std::vector<std::string>& locations);
146extern template ELEMENTS_API Item getPathFromLocations(const std::string& file_name,
147 const std::vector<Item>& locations);
148extern template ELEMENTS_API Item getPathFromLocations(const std::string& file_name,
149 const std::vector<std::string>& locations);
150
167template <typename T, typename U>
169// Template instantiation for the most common types
171 const std::vector<Item>& locations);
173 const std::vector<std::string>& locations);
175 const std::vector<Item>& locations);
177 const std::vector<std::string>& locations);
178
192template <typename T>
193ELEMENTS_API Item getPathFromEnvVariable(const T& file_name, const std::string& path_variable);
194// Template instantiation for the most common types
195extern template ELEMENTS_API Item getPathFromEnvVariable<Item>(const Item& file_name, const std::string& path_variable);
197 const std::string& path_variable);
198
206template <typename T>
208// Template instantiation for the most common types
209extern template ELEMENTS_API std::string joinPath(const std::vector<Item>& path_list);
210
212
220template <typename... Args>
221ELEMENTS_API auto join(Args&&... args) -> decltype(joinPath(std::forward<Args>(args)...));
222
231
239template <typename... Args>
240ELEMENTS_API auto split(Args&&... args) -> decltype(splitPath(std::forward<Args>(args)...));
241
251template <typename T, typename U>
253// Template instantiation for the most common types
254extern template ELEMENTS_API std::vector<Item> multiPathAppend(const std::vector<Item>& initial_locations,
255 const std::vector<Item>& suffixes);
256extern template ELEMENTS_API std::vector<Item> multiPathAppend(const std::vector<Item>& initial_locations,
257 const std::vector<std::string>& suffixes);
259 const std::vector<Item>& suffixes);
261 const std::vector<std::string>& suffixes);
269template <typename T>
271// Template instantiation for the most common types
273
275
276} // namespace Path
277} // namespace Kernel
278} // namespace Elements
279
284#define ELEMENTSKERNEL_ELEMENTSKERNEL_PATH_IMPL_
285#include "ElementsKernel/_impl/Path.tpp" // IWYU pragma: export
286#undef ELEMENTSKERNEL_ELEMENTSKERNEL_PATH_IMPL_
287
288#endif // ELEMENTSKERNEL_ELEMENTSKERNEL_PATH_H_
289
defines the macros to be used for explicit export of the symbols
implementation of the templates declared in ElementsKernel/Path.h
T forward(T... args)
ELEMENTS_API const std::map< Type, const std::vector< std::string > > SUFFIXES
map containing the default project installation suffixes for each variable
Definition Path.cpp:56
ELEMENTS_API const std::map< Type, const std::vector< std::string > > DEFAULT_LOCATIONS
map containing the default external locations for each variable
Definition Path.cpp:64
ELEMENTS_API std::vector< Item > getAllPathFromLocations(const T &file_name, const std::vector< U > &locations)
retrieve all the paths from a file name and a set of location to look into
ELEMENTS_API std::vector< Item > getLocationsFromEnv(const std::string &path_variable, bool exist_only=false)
function to get the locations from an environment variable
Definition Path.cpp:82
ELEMENTS_API auto join(Args &&... args) -> decltype(joinPath(std::forward< Args >(args)...))
alias for the joinPath function
ELEMENTS_API std::vector< Item > removeDuplicates(const std::vector< T > &path_list)
remove duplicated paths keeping the order
ELEMENTS_API std::string joinPath(const std::vector< T > &path_list)
collate a vector of path into a string using PATH_SEP
#define ELEMENTS_API
Dummy definitions for the backward compatibility mode.
Definition Export.h:74
ELEMENTS_API auto split(Args &&... args) -> decltype(splitPath(std::forward< Args >(args)...))
alias for the splitPath function
ELEMENTS_API Item getPathFromLocations(const T &file_name, const std::vector< U > &locations)
retrieve path from a file name and a set of location to look into
ELEMENTS_API const std::map< Type, const std::string > VARIABLE
map containing the name of the path variable for each type
Definition Path.cpp:48
ELEMENTS_API std::vector< Item > splitPath(const std::string &path_string)
split a string into a vector of path using PATH_SEP
Definition Path.cpp:104
ELEMENTS_API const std::map< Type, const bool > HAS_SUBLEVELS
map containing the sub-level property of the path components
Definition Path.cpp:72
ELEMENTS_API std::vector< Item > getLocations(const Type &path_type, bool exist_only=false)
function to get the locations for the specific type
Definition Path.cpp:100
ELEMENTS_API const std::string PATH_SEP
Separator of path entries. Usually ":" on Unix.
Definition Path.cpp:44
ELEMENTS_API Item getPathFromEnvVariable(const T &file_name, const std::string &path_variable)
retrieve path from a file name and an environment variable to look into
ELEMENTS_API std::vector< Item > multiPathAppend(const std::vector< T > &initial_locations, const std::vector< U > &suffixes)
path join each suffix to each initial locations
boost::filesystem::path Item
Definition Path.h:57
template ELEMENTS_API Item getPathFromEnvVariable< Item >(const Item &file_name, const std::string &path_variable)
template ELEMENTS_API Item getPathFromEnvVariable< std::string >(const std::string &file_name, const std::string &path_variable)