1 #ifndef jb_config_files_location_hpp 2 #define jb_config_files_location_hpp 4 #include <boost/filesystem/path.hpp> 25 bool operator()(boost::filesystem::path
const& path);
36 std::vector<boost::filesystem::path>
const&
search_path()
const {
53 boost::filesystem::path
const& argv0,
54 std::function<
char const*(
char const*)> getenv,
55 char const* program_root_variable);
66 boost::filesystem::path
const& argv0,
67 std::function<
char const*(
char const*)> getenv);
117 boost::filesystem::path
const& argv0,
char const* program_root_variable,
118 getenv_functor getenv)
132 boost::filesystem::path
const& argv0, getenv_functor getenv)
143 boost::filesystem::path
const& argv0,
char const* program_root_variable)
150 char const* argv0,
char const* program_root_variable,
151 getenv_functor getenv)
153 boost::filesystem::path(argv0), program_root_variable, getenv) {
157 boost::filesystem::path(argv0), program_root_variable,
165 boost::filesystem::path(argv0), getenv_functor()) {
179 std::string
const& filename, validator_functor validator)
const {
180 for (
auto const& path : search_path()) {
181 auto full = path / filename;
182 if (validator(full)) {
186 std::string msg(
"Cannot find file in search path: ");
188 throw std::runtime_error(msg);
199 boost::filesystem::path
201 return find_configuration_file(filename, validator_functor());
225 #endif // jb_config_files_location_hpp
config_files_locations(char const *argv0)
config_files_locations(boost::filesystem::path const &argv0)
boost::filesystem::path find_configuration_file(std::string const &filename, validator_functor validator) const
Find a configuration file in the computed search path.
std::vector< boost::filesystem::path > const & search_path() const
Define the functor to validate if paths are readable.
config_files_locations(boost::filesystem::path const &argv0, char const *program_root_variable)
Convenience constructors.
std::vector< boost::filesystem::path > search_path_
config_files_locations(char const *argv0, char const *program_root_variable)
char const * operator()(char const *name)
boost::filesystem::path find_configuration_file(std::string const &filename) const
Find a configuration file in the computed search path.
Define the configuration file search algorithm for JayBeams.
config_files_locations(char const *argv0, char const *program_root_variable, getenv_functor getenv)
char const * bindir()
Return the binary installation directory directory.
config_files_locations(boost::filesystem::path const &argv0, getenv_functor getenv)
Constructor.
config_files_locations(boost::filesystem::path const &argv0, char const *program_root_variable, getenv_functor getenv)
Constructor.
char const * sysconfdir()
Return the system configuration directory.
config_files_locations(char const *argv0, getenv_functor getenv)
Define the functor to read configuration variables from the environment.
Compute the directories where a configuration file can be found.
The top-level namespace for the JayBeams library.