Elements  5.10
A C++ base framework for the Euclid Software.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
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 
61 ELEMENTS_API extern const std::string PATH_SEP;
62 
68 
75 
81 
87 
104  bool exist_only = false);
105 
122 template <typename T, typename U>
123 ELEMENTS_API boost::filesystem::path getPathFromLocations(const T& file_name, const std::vector<U>& locations);
124 // Template instantiation for the most common types
125 extern template
127  const std::vector<boost::filesystem::path>& locations);
128 extern template
130  const std::vector<std::string>& locations);
131 extern template
133  const std::vector<boost::filesystem::path>& locations);
134 extern template
136  const std::vector<std::string>& locations);
137 
138 
155 template <typename T, typename U>
157 getAllPathFromLocations(const T& file_name, const std::vector<U>& locations);
158 // Template instantiation for the most common types
159 extern template
162  const std::vector<boost::filesystem::path>& locations);
163 extern template
166  const std::vector<std::string>& locations);
167 extern template
169 getAllPathFromLocations(const std::string& file_name,
170  const std::vector<boost::filesystem::path>& locations);
171 extern template
173 getAllPathFromLocations(const std::string& file_name,
174  const std::vector<std::string>& locations);
175 
189 template <typename T>
191 getPathFromEnvVariable(const T& file_name, const std::string& path_variable);
192 // Template instantiation for the most common types
193 extern template
195 getPathFromEnvVariable<boost::filesystem::path>(const boost::filesystem::path& file_name,
196  const std::string& path_variable);
197 extern template
199 getPathFromEnvVariable<std::string>(const std::string& file_name,
200  const std::string& path_variable);
201 
209 template <typename T>
211 // Template instantiation for the most common types
212 extern template
214 
215 extern template
217 
225 template <typename... Args>
226 ELEMENTS_API auto join(Args&&... args) -> decltype(joinPath(std::forward<Args>(args)...));
227 
236 
244 template <typename... Args>
245 ELEMENTS_API auto split(Args&&... args) -> decltype(splitPath(std::forward<Args>(args)...));
246 
256 template <typename T, typename U>
258 multiPathAppend(const std::vector<T>& initial_locations,
259  const std::vector<U>& suffixes);
260 // Template instantiation for the most common types
261 extern template
264  const std::vector<boost::filesystem::path>& suffixes);
265 extern template
268  const std::vector<std::string>& suffixes);
269 extern template
271 multiPathAppend(const std::vector<std::string>& initial_locations,
272  const std::vector<boost::filesystem::path>& suffixes);
273 extern template
275 multiPathAppend(const std::vector<std::string>& initial_locations,
276  const std::vector<std::string>& suffixes);
284 template <typename T>
286 removeDuplicates(const std::vector<T>& path_list);
287 // Template instantiation for the most common types
288 extern template
291 
292 extern template
295 
296 
297 } // namespace Path
298 } // namespace Elements
299 
301 
302 #endif // ELEMENTSKERNEL_ELEMENTSKERNEL_PATH_H_
303 
boost::filesystem::path getPathFromEnvVariable(const T &file_name, const std::string &path_variable)
retrieve path from a file name and an environment variable to look into
Definition: Path.icpp:83
auto split(Args &&...args) -> decltype(splitPath(std::forward< Args >(args)...))
alias for the splitPath function
Definition: Path.icpp:119
implementation of the templates declared in ElementsKernel/Path.h
boost::filesystem::path getPathFromLocations(const T &file_name, const std::vector< U > &locations)
retrieve path from a file name and a set of location to look into
Definition: Path.icpp:37
ELEMENTS_API const std::map< Type, const std::string > VARIABLE
map containing the name of the path variable for each type
Definition: Path.cpp:46
STL class.
STL class.
std::vector< boost::filesystem::path > multiPathAppend(const std::vector< T > &initial_locations, const std::vector< U > &suffixes)
path join each suffix to each initial locations
Definition: Path.icpp:125
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:54
defines the macros to be used for explicit export of the symbols
ELEMENTS_API const std::string PATH_SEP
Separator of path entries. Usually &quot;:&quot; on Unix.
Definition: Path.cpp:44
ELEMENTS_API std::vector< boost::filesystem::path > splitPath(const std::string &path_string)
split a string into a vector of path using PATH_SEP
Definition: Path.cpp:99
boost::filesystem::path path
Definition: DataSyncUtils.h:38
#define ELEMENTS_API
Dummy definitions for the backward compatibility mode.
Definition: Export.h:74
STL class.
std::string joinPath(const std::vector< T > &path_list)
collate a vector of path into a string using PATH_SEP
Definition: Path.icpp:95
std::vector< boost::filesystem::path > 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
Definition: Path.icpp:58
ELEMENTS_API const std::map< Type, const bool > HAS_SUBLEVELS
map containing the sub-level property of the path components
Definition: Path.cpp:70
auto join(Args &&...args) -> decltype(joinPath(std::forward< Args >(args)...))
alias for the joinPath function
Definition: Path.icpp:114
ELEMENTS_API std::vector< boost::filesystem::path > getLocationsFromEnv(const std::string &path_variable, bool exist_only=false)
function to get the locations from an environment variable
Definition: Path.cpp:79
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:62
std::vector< boost::filesystem::path > removeDuplicates(const std::vector< T > &path_list)
remove duplicated paths keeping the order
Definition: Path.icpp:150