Elements  6.2
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 <boost/filesystem.hpp> // for boost::filesystem
39 #include <map> // for map
40 #include <string> // for string
41 #include <utility> // for forward
42 #include <vector> // for vector
43 
44 #include "ElementsKernel/Export.h" // ELEMENTS_API
45 
46 namespace Elements {
47 inline namespace Kernel {
48 namespace Path {
49 
51 
57 
62 ELEMENTS_API extern const std::string PATH_SEP;
63 
69 
76 
82 
88 
104 ELEMENTS_API std::vector<Item> getLocationsFromEnv(const std::string& path_variable, bool exist_only = false);
105 
121 ELEMENTS_API std::vector<Item> getLocations(const Type& path_type, bool exist_only = false);
122 
139 template <typename T, typename U>
140 ELEMENTS_API Item getPathFromLocations(const T& file_name, const std::vector<U>& locations);
141 // Template instantiation for the most common types
142 extern template ELEMENTS_API Item getPathFromLocations(const Item& file_name, const std::vector<Item>& locations);
143 extern template ELEMENTS_API Item getPathFromLocations(const Item& file_name,
144  const std::vector<std::string>& locations);
145 extern template ELEMENTS_API Item getPathFromLocations(const std::string& file_name,
146  const std::vector<Item>& locations);
147 extern template ELEMENTS_API Item getPathFromLocations(const std::string& file_name,
148  const std::vector<std::string>& locations);
149 
166 template <typename T, typename U>
167 ELEMENTS_API std::vector<Item> getAllPathFromLocations(const T& file_name, const std::vector<U>& locations);
168 // Template instantiation for the most common types
169 extern template ELEMENTS_API std::vector<Item> getAllPathFromLocations(const Item& file_name,
170  const std::vector<Item>& locations);
171 extern template ELEMENTS_API std::vector<Item> getAllPathFromLocations(const Item& file_name,
172  const std::vector<std::string>& locations);
173 extern template ELEMENTS_API std::vector<Item> getAllPathFromLocations(const std::string& file_name,
174  const std::vector<Item>& locations);
175 extern template ELEMENTS_API std::vector<Item> getAllPathFromLocations(const std::string& file_name,
176  const std::vector<std::string>& locations);
177 
191 template <typename T>
192 ELEMENTS_API Item getPathFromEnvVariable(const T& file_name, const std::string& path_variable);
193 // Template instantiation for the most common types
194 extern template ELEMENTS_API Item getPathFromEnvVariable<Item>(const Item& file_name, const std::string& path_variable);
195 extern template ELEMENTS_API Item getPathFromEnvVariable<std::string>(const std::string& file_name,
196  const std::string& path_variable);
197 
205 template <typename T>
207 // Template instantiation for the most common types
208 extern template ELEMENTS_API std::string joinPath(const std::vector<Item>& path_list);
209 
210 extern template ELEMENTS_API std::string joinPath(const std::vector<std::string>& path_list);
211 
219 template <typename... Args>
220 ELEMENTS_API auto join(Args&&... args) -> decltype(joinPath(std::forward<Args>(args)...));
221 
230 
238 template <typename... Args>
239 ELEMENTS_API auto split(Args&&... args) -> decltype(splitPath(std::forward<Args>(args)...));
240 
250 template <typename T, typename U>
251 ELEMENTS_API std::vector<Item> multiPathAppend(const std::vector<T>& initial_locations, const std::vector<U>& suffixes);
252 // Template instantiation for the most common types
253 extern template ELEMENTS_API std::vector<Item> multiPathAppend(const std::vector<Item>& initial_locations,
254  const std::vector<Item>& suffixes);
255 extern template ELEMENTS_API std::vector<Item> multiPathAppend(const std::vector<Item>& initial_locations,
256  const std::vector<std::string>& suffixes);
257 extern template ELEMENTS_API std::vector<Item> multiPathAppend(const std::vector<std::string>& initial_locations,
258  const std::vector<Item>& suffixes);
259 extern template ELEMENTS_API std::vector<Item> multiPathAppend(const std::vector<std::string>& initial_locations,
260  const std::vector<std::string>& suffixes);
268 template <typename T>
270 // Template instantiation for the most common types
271 extern template ELEMENTS_API std::vector<Item> removeDuplicates(const std::vector<Item>& path_list);
272 
274 
275 } // namespace Path
276 } // namespace Kernel
277 } // namespace Elements
278 
279 #define ELEMENTSKERNEL_ELEMENTSKERNEL_PATH_IMPL_
281 #undef ELEMENTSKERNEL_ELEMENTSKERNEL_PATH_IMPL_
282 
283 #endif // ELEMENTSKERNEL_ELEMENTSKERNEL_PATH_H_
284 
Elements::Kernel::Path::Item
boost::filesystem::path Item
Definition: Path.h:56
Elements::Kernel::Path::Type::executable
@ executable
Export.h
defines the macros to be used for explicit export of the symbols
Elements::Kernel::Path::SUFFIXES
const ELEMENTS_API std::map< Type, const std::vector< std::string > > SUFFIXES
map containing the default project installation suffixes for each variable
Definition: Path.cpp:52
std::string
STL class.
Elements::Kernel::Path::getLocationsFromEnv
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:70
Elements::Kernel::Path::split
ELEMENTS_API auto split(Args &&... args) -> decltype(splitPath(std::forward< Args >(args)...))
alias for the splitPath function
std::vector
STL class.
Elements::Kernel::Path::Type
Type
Definition: Path.h:50
Elements::Kernel::Path::getPathFromLocations
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::Kernel::Path::getLocations
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:88
Elements::Kernel::Path::HAS_SUBLEVELS
const ELEMENTS_API std::map< Type, const bool > HAS_SUBLEVELS
map containing the sub-level property of the path components
Definition: Path.cpp:64
Elements::Kernel::Path::getPathFromEnvVariable< Item >
template ELEMENTS_API Item getPathFromEnvVariable< Item >(const Item &file_name, const std::string &path_variable)
Elements::Kernel::Path::getPathFromEnvVariable
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::Kernel::Path::VARIABLE
const ELEMENTS_API std::map< Type, const std::string > VARIABLE
map containing the name of the path variable for each type
Definition: Path.cpp:46
Elements::Kernel::Path::Type::python
@ python
ELEMENTS_API
#define ELEMENTS_API
Dummy definitions for the backward compatibility mode.
Definition: Export.h:74
Elements::Kernel::Path::Type::library
@ library
Elements::Kernel::Path::multiPathAppend
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::Kernel::Path::join
ELEMENTS_API auto join(Args &&... args) -> decltype(joinPath(std::forward< Args >(args)...))
alias for the joinPath function
Elements::Kernel::Path::getAllPathFromLocations
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::Kernel::Path::DEFAULT_LOCATIONS
const ELEMENTS_API std::map< Type, const std::vector< std::string > > DEFAULT_LOCATIONS
map containing the default external locations for each variable
Definition: Path.cpp:58
std::map
STL class.
Elements::Kernel::Path::PATH_SEP
const ELEMENTS_API std::string PATH_SEP
Separator of path entries. Usually ":" on Unix.
Definition: Path.cpp:44
Path.tpp
Elements::Kernel::Path::Type::auxiliary
@ auxiliary
Elements::Kernel::Path::splitPath
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:92
Elements::Kernel::Path::removeDuplicates
ELEMENTS_API std::vector< Item > removeDuplicates(const std::vector< T > &path_list)
remove duplicated paths keeping the order
Elements::Kernel::Path::joinPath
ELEMENTS_API std::string joinPath(const std::vector< T > &path_list)
collate a vector of path into a string using PATH_SEP
Elements::Kernel::Path::Type::configuration
@ configuration
Elements
Definition: callBackExample.h:35
Elements::Services::DataSync::path
Path::Item path
importing the path item from ElementsKernel
Definition: DataSyncUtils.h:41