Typedefs | Functions
liblist.cxx File Reference
#include <string>
#include <iostream>
#include <vector>
#include <sstream>
#include <memory>
#include "cetlib/LibraryManager.h"

Go to the source code of this file.

Typedefs

typedef std::vector< std::stringNameList
 

Functions

int main (int argc, char **argv)
 

Typedef Documentation

Definition at line 22 of file liblist.cxx.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 24 of file liblist.cxx.

24  {
25  const string myname = "listlibs";
26  bool help = false;
27  string libtype = "tool";
28  string pattern;
29  if ( argc > 1 ) {
30  string arg = argv[1];
31  if ( arg == "-h" ) help = true;
32  else libtype = arg;
33  }
34  if ( argc > 2 ) {
35  string arg = argv[2];
36  if ( arg == "-h" ) help = true;
37  else pattern = arg;
38  }
39  if ( help ) {
40  cout << "Usage: " << argv[0] << " [type] [pattern]" << endl;
41  cout << " Lists plugin libraries of a specified type." << endl;
42  cout << " type [tool] - library type (tool, service, module, ...)" << endl;
43  cout << " pattern [] - pattern in library name" << endl;
44  return 0;
45  }
46  // Find the libs.
47  NameList libnames;
48  LibraryManager libmgr(libtype);
49  unsigned int nlib = libmgr.getLoadableLibraries(libnames);
50  if ( pattern.size() ) {
51  NameList newnames;
52  for ( string libname : libnames ) {
53  if ( libname.find(pattern) != string::npos ) newnames.push_back(libname);
54  }
55  libnames = newnames;
56  }
57  unsigned int nsel = libnames.size();
58  if ( pattern.size() && nlib > 0 ) cout << "Selected " << nsel << " of ";
59  else cout << "Found ";
60  cout << nlib << " " << libtype << " librar";
61  cout << (nlib==1 ? "y" : "ies");
62  cout << (nsel ? ":" : ".");
63  for ( string libname : libnames ) {
64  cout << "\n " << libname;
65  }
66  cout << endl;
67  return 0;
68 }
std::string pattern
Definition: regex_t.cc:35
QTextStream & endl(QTextStream &s)
std::vector< std::string > NameList
Definition: liblist.cxx:22