dumpCppTagDb.cxx
Go to the documentation of this file.00001 #include <iostream>
00002 #include <stdlib.h>
00003
00004 #include <cxxtls/cpptagdb.h>
00005 #include <cxxtls/options.h>
00006 #include <cxxtls/foreach.h>
00007
00008 using namespace std;
00009
00010
00011 #include <stdio.h>
00012
00013 bool somethingDisplayed=false;
00014
00015
00016 int main(int argc, char **argv, char **environ)
00017 {
00018
00019 cxxtls::ProgramOptions ops("-f,-s,-d,-h,--help,-fm:-cm:-CM:-d,-fr:",
00020 argc,
00021 argv,
00022 environ
00023 );
00024
00025
00026 if(ops.option("-h") || ops.option("--help") || ops.argv.size() < 2)
00027 {
00028 cerr <<"\ndumpCppTagDb.exe -- display the cpptagdb.exe generated database." << endl;
00029 cerr << endl;
00030 cerr <<" Usage: " << endl;
00031 cerr << endl;
00032 cerr <<" dumpCppTagDb.exe [options] databaseFile" << endl;
00033 cerr <<" Options:" << endl;
00034 cerr <<" -s show all symbol information" << endl;
00035 cerr <<" -f list all files containing symbols" << endl;
00036 cerr <<" -fm n print files matching name n" << endl;
00037 cerr <<" -fr r1 find file r1 relative to dirs mentioned in symbols" << endl;
00038 cerr <<" -d list all directories definining symbols" << endl;
00039 cerr <<" -h print help" << endl;
00040 cerr <<" --help print help" << endl;
00041 cerr <<" -CM m1 print class members matching m1 (case sensitive)" << endl;
00042 cerr <<" -cm m2 print class members matching m2 (case insensitive)" << endl;
00043 cerr << endl;
00044 exit(0);
00045 }
00046
00047
00048 int line;
00049
00050 cxxtls::CppTagDB::Info info;
00051
00052
00053 int err = info.populate(ops.argv[1], line);
00054
00055 if(err)
00056 {
00057 cerr << "Error: " << err << " at line " << line << " in file '" << ops.argv[1] << "'" << endl;
00058 exit(1);
00059 }
00060 else
00061 if(ops.option("-f"))
00062 {
00063 CXXTLS_FOREACH(cxxtls::CppTagDB::Info::FilesMap::value_type const &cur, info.files_)
00064 {
00065 cout << cur.second << endl;
00066 }
00067 }
00068 else
00069 if(ops.option("-fm"))
00070 {
00071 string fileNodeName = *ops.option("-fm").begin();
00072
00073 vector<string> matches;
00074
00075 info.findMatchingFiles(fileNodeName, matches);
00076
00077 cout << "files matching " << fileNodeName << " are:" << endl;
00078
00079 CXXTLS_FOREACH(string const &cur, matches) cout << " " << cur << endl;
00080
00081
00082
00083 }
00084 else
00085 if(ops.option("-CM"))
00086 {
00087 string memberName = *ops.option("-CM").begin();
00088
00089 vector<cxxtls::CppTagDB::SymbolInfo const *> matches;
00090
00091 info.findMatchingMembers(memberName, matches);
00092
00093 cout << "Out of " << info.symbols_.children_.size() <<
00094
00095 " symbols, the following Symbols match " << memberName << " are:" << endl;
00096
00097 CXXTLS_FOREACH(cxxtls::CppTagDB::SymbolInfo const *cur, matches)
00098 cout << " " << cur->fullname_ << endl;
00099
00100
00101
00102 }
00103 else
00104 if(ops.option("-cm"))
00105 {
00106 string memberName = *ops.option("-cm").begin();
00107
00108 vector<cxxtls::CppTagDB::SymbolInfo const *> matches;
00109
00110 info.findMatchingMembers(memberName, matches, false);
00111
00112 cout << "Out of " << info.symbols_.children_.size() <<
00113
00114 " symbols, the following Symbols match " << memberName << " are:" << endl;
00115
00116 CXXTLS_FOREACH(cxxtls::CppTagDB::SymbolInfo const *cur, matches)
00117 cout << " " << cur->fullname_ << endl;
00118
00119
00120
00121 }
00122 else
00123 if(ops.option("-d"))
00124 {
00125
00126 CXXTLS_FOREACH(string const &cur, info.directories_) cout << " " << cur << endl;
00127
00128
00129 }
00130 else
00131 if(ops.option("-s"))
00132 {
00133
00134 cout << info << endl;
00135
00136 }
00137 else
00138 if(ops.option("-fr"))
00139 {
00140 string relativePath = *ops.option("-fr").begin();
00141
00142 vector<string> matches;
00143
00144 info.findRelativeFiles(relativePath, matches);
00145
00146 cout << "Matching files are:" << endl;
00147
00148 CXXTLS_FOREACH(string const &cur, matches)
00149 cout << " " << cur << endl;
00150
00151 }
00152 else
00153 {
00154 cerr << "Unknown option: you can't get here from there" << endl;
00155 }
00156 }