int main(int argc, char *argv[]) { string inPath, outPath; // in - source code, out - xml report if(!processCmdLineArgs(argc, argv, inPath, outPath)) return 0; // cout << "Parsing..."; CppParser cpp; Project *project = cpp.parseFile(inPath); if(cpp.errorOccured()) { cout << "Error!" << endl; return 1; } cout << "Ok." << endl; // #if YYDEBUG == 1 // // TinyXML test TiXmlDocument doc; TiXmlDeclaration *decl = new TiXmlDeclaration("1.0", "utf-8", "yes"); doc.LinkEndChild(decl); // //TiXmlStylesheetReference *style = new TiXmlStylesheetReference("text/xsl", "test.xsl"); //doc.LinkEndChild(style); // TiXmlElement *root = new TiXmlElement("ASTM"); project->dumpXml(root); doc.LinkEndChild(root); // doc.SaveFile("astm_dump.xml"); // #endif // YYDEBUG == 1 // cout << "Analysing..."; // LinesOfCode loc(project->files[0]); CommentsDensity commdens(loc); CyclomaticComplexityNumber ccn(project->files[0]); DecisionDensity decdens(loc, ccn); NPathComplexity npath(project->files[0]); TotalFunctionCalls tfc(project->files[0]); NumberOfClasses noc(project->files[0]); LorenzKidd lk(project->files[0]); // string resultsFile = (outPath.size() > 0) ? outPath : "report.xml"; ofstream fout; fout.open(resultsFile.c_str()); if(!fout.is_open()) { cout << "Error writing the results!" << endl; return 2; } fout << "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n" << "<?xml-stylesheet href=\"sw_metrics.xsl\" type=\"text/xml\"?>\n" << "<sw_stats>\n" << "\t<file>" << inPath << "</file>\n" << loc.dumpResultXml() << commdens.dumpResultXml() << ccn.dumpResultXml() << decdens.dumpResultXml() << npath.dumpResultXml() << tfc.dumpResultXml() << noc.dumpResultXml() << lk.dumpResultXml() << "</sw_stats>\n"; // fout.close(); cout << "Ok." << endl; cout << "Results written into '" << resultsFile << "'." << endl; // //delete project; return 0; }