Elements  5.12.0
A C++ base framework for the Euclid Software.
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 <string> // for string
39 #include <vector> // for vector
40 #include <map> // for map
41 #include <utility> // for forward
42 #include <boost/filesystem.hpp> // for boost::filesystem
43 
44 #include "ElementsKernel/Export.h" // ELEMENTS_API
45 
46 namespace Elements {
47 namespace Path {
48 
49 enum class Type {
50  executable,
51  library,
52  python,
54  auxiliary
55 };
56 
62 
67 ELEMENTS_API extern const std::string PATH_SEP;
68 
74 
81 
87 
93 
109 ELEMENTS_API std::vector<Item> getLocationsFromEnv(const std::string& path_variable, bool exist_only = false);
110 
126 ELEMENTS_API std::vector<Item> getLocations(const Type& path_type, bool exist_only = false);
127 
144 template <typename T, typename U>
145 ELEMENTS_API Item getPathFromLocations(const T& file_name, const std::vector<U>& locations);
146 // Template instantiation for the most common types
147 extern template
148 ELEMENTS_API Item getPathFromLocations(const Item& file_name, const std::vector<Item>& locations);
149 extern template
151 extern template
153 extern template
155 
156 
173 template <typename T, typename U>
175 getAllPathFromLocations(const T& file_name, const std::vector<U>& locations);
176 // Template instantiation for the most common types
177 extern template
179 getAllPathFromLocations(const Item& file_name, const std::vector<Item>& locations);
180 extern template
182 getAllPathFromLocations(const Item& file_name, const std::vector<std::string>& locations);
183 extern template
185 getAllPathFromLocations(const std::string& file_name, const std::vector<Item>& locations);
186 extern template
189 
203 template <typename T>
205 getPathFromEnvVariable(const T& file_name, const std::string& path_variable);
206 // Template instantiation for the most common types
207 extern template
209 getPathFromEnvVariable<Item>(const Item& file_name, const std::string& path_variable);
210 extern template
212 getPathFromEnvVariable<std::string>(const std::string& file_name, const std::string& path_variable);
213 
221 template <typename T>
223 // Template instantiation for the most common types
224 extern template
226 
227 extern template
229 
237 template <typename... Args>
238 ELEMENTS_API auto join(Args&&... args) -> decltype(joinPath(std::forward<Args>(args)...));
239 
248 
256 template <typename... Args>
257 ELEMENTS_API auto split(Args&&... args) -> decltype(splitPath(std::forward<Args>(args)...));
258 
268 template <typename T, typename U>
270 multiPathAppend(const std::vector<T>& initial_locations, const std::vector<U>& suffixes);
271 // Template instantiation for the most common types
272 extern template
274 multiPathAppend(const std::vector<Item>& initial_locations, const std::vector<Item>& suffixes);
275 extern template
277 multiPathAppend(const std::vector<Item>& initial_locations, const std::vector<std::string>& suffixes);
278 extern template
280 multiPathAppend(const std::vector<std::string>& initial_locations, const std::vector<Item>& suffixes);
281 extern template
283 multiPathAppend(const std::vector<std::string>& initial_locations, const std::vector<std::string>& suffixes);
291 template <typename T>
294 // Template instantiation for the most common types
295 extern template
298 
299 extern template
302 
303 
304 } // namespace Path
305 } // namespace Elements
306 
307 #define ELEMENTSKERNEL_ELEMENTSKERNEL_PATH_IMPL_
309 #undef ELEMENTSKERNEL_ELEMENTSKERNEL_PATH_IMPL_
310 
311 #endif // ELEMENTSKERNEL_ELEMENTSKERNEL_PATH_H_
312 
defines the macros to be used for explicit export of the symbols
ELEMENTS_API const std::map< Type, const std::string > VARIABLE
map containing the name of the path variable for each type
Definition: Path.cpp:44
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:101
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:96
ELEMENTS_API auto join(Args &&... args) -> decltype(joinPath(std::forward< Args >(args)...))
alias for the joinPath function
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
#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 const std::map< Type, const std::vector< std::string > > DEFAULT_LOCATIONS
map containing the default external locations for each variable
Definition: Path.cpp:60
ELEMENTS_API std::string joinPath(const std::vector< T > &path_list)
collate a vector of path into a string using PATH_SEP
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
ELEMENTS_API const std::map< Type, const bool > HAS_SUBLEVELS
map containing the sub-level property of the path components
Definition: Path.cpp:68
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::string PATH_SEP
Separator of path entries. Usually ":" on Unix.
Definition: Path.cpp:42
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:52
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 > removeDuplicates(const std::vector< T > &path_list)
remove duplicated paths keeping the order
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:76
Elements::Path::Item path
Definition: DataSyncUtils.h:39
template ELEMENTS_API Item getPathFromEnvVariable< Item >(const Item &file_name, const std::string &path_variable)
boost::filesystem::path Item
Definition: Path.h:61