Lumiera 0.pre.04~rc.1
»edit your freedom«
Loading...
Searching...
No Matches
searchpath.hpp
Go to the documentation of this file.
1/*
2 SEARCHPATH.hpp - helpers for searching directory lists and locating modules
3
4 Copyright (C)
5 2011, Hermann Vosseler <Ichthyostega@web.de>
6
7  **Lumiera** is free software; you can redistribute it and/or modify it
8  under the terms of the GNU General Public License as published by the
9  Free Software Foundation; either version 2 of the License, or (at your
10  option) any later version. See the file COPYING for further details.
11
12*/
13
14
24#ifndef COMMON_SEARCHPATH_H
25#define COMMON_SEARCHPATH_H
26
27#include "lib/error.hpp"
28#include "lib/nocopy.hpp"
29#include "lib/regex.hpp"
30#include "lib/file.hpp"
31
32#include <string>
33#include <boost/algorithm/string.hpp>
34
35
36namespace lib {
37 namespace error = lumiera::error;
38
39 using std::string;
40
41 using SubMatch = std::smatch::value_type const&;
42
43
44 using LERR_(ITER_EXHAUST);
45
46
48 fs::path findExePath();
49
52 string replaceMagicLinkerTokens (string const& src);
53
54
63 {
64 static const regex ACCEPT_PATHELEMENT;
65
66 public:
67 SearchPathSplitter() = default;
68 SearchPathSplitter (string& searchPath)
70 { }
71
72 LIFT_PARENT_INCREMENT_OPERATOR (std::sregex_iterator);
74
75 using value_type = std::string;
78
79 string
80 operator*() const
81 {
82 if (!isValid())
83 throw error::Logic ("Search path exhausted."
84 ,LERR_(ITER_EXHAUST));
85
86 string pathElm = util::RegexSearchIter::operator*()[2];
87 pathElm = boost::algorithm::trim_right_copy(pathElm);
88 return replaceMagicLinkerTokens (pathElm);
89 }
90 };
91
92
93
102 string resolveModulePath (fs::path moduleName, string searchPath = "");
103
104
105
106} // namespace lib
107#endif
Helper: Access a path Specification as a sequence of filesystem Paths.
SearchPathSplitter(string &searchPath)
ENABLE_USE_IN_STD_RANGE_FOR_LOOPS(SearchPathSplitter)
string operator*() const
LIFT_PARENT_INCREMENT_OPERATOR(std::sregex_iterator)
static const regex ACCEPT_PATHELEMENT
Lumiera error handling (C++ interface).
#define LERR_(_NAME_)
Definition error.hpp:45
Includes the C++ Filesystem library and provides some convenience helpers.
Implementation namespace for support and library code.
std::smatch::value_type const & SubMatch
fs::path findExePath()
retrieve the location of the executable
string replaceMagicLinkerTokens(string const &src)
replace $ORIGIN tokens in the given string
LumieraError< LERR_(LOGIC)> Logic
Definition error.hpp:207
Mix-Ins to allow or prohibit various degrees of copying and cloning.
Convenience wrappers and helpers for dealing with regular expressions.
wrapped regex iterator to allow usage in foreach loops
Definition regex.hpp:42
bool isValid() const
Definition regex.hpp:55