loadable_libraries.cc
Go to the documentation of this file.
3 
4 #include <iostream>
5 #include <regex>
6 #include <utility>
7 #include <vector>
8 
9 namespace {
10  std::string const regex_prefix{"([-A-Za-z0-9]*_)*"};
11  std::regex const slash{"/"};
12 
14  pattern(std::string const& spec)
15  {
16  std::string const canonSpec = std::regex_replace(spec, slash, "_");
17  return regex_prefix + canonSpec + "_";
18  }
19 
20  inline std::vector<std::string>
21  getLibraries(cet::LibraryManager const& lm)
22  {
23  std::vector<std::string> result;
24  lm.getLoadableLibraries(result);
25  return result;
26  }
27 }
28 
29 void
30 cet::loadable_libraries(std::ostream& os,
31  std::string const& spec,
32  std::string const& suffix)
33 {
34  cet::LibraryManager const lm{suffix, pattern(spec + ".*")};
35  auto const& libs = getLibraries(lm);
36 
37  std::string str{};
38  for (auto const& lib : libs) {
39  auto const& libspecs = lm.getSpecsByPath(lib);
40  if (libspecs.first.find(spec) == 0) {
41  str += libspecs.first;
42  str += '\n';
43  }
44  // Not all libraries have a long spec.
45  if (!libspecs.second.empty() && libspecs.second.find(spec) == 0) {
46  str += libspecs.second;
47  str += '\n';
48  }
49  }
50  os << str;
51 }
static QCString result
std::string string
Definition: nybbler.cc:12
size_t getLoadableLibraries(std::vector< std::string > &list) const
std::string pattern
Definition: regex_t.cc:35
void loadable_libraries(std::ostream &os, std::string const &spec, std::string const &suffix)
static QCString str