From 0ca38cc9fe6b6916cf9cf61f15f7be68dedb5619 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Wed, 28 Jan 2009 17:12:43 +0000 Subject: [PATCH] xml results: added a command line switch for generating simple results.xml file --- src/cppcheck.cpp | 22 ++++++++++++++++++++++ src/settings.cpp | 1 + src/settings.h | 3 +++ 3 files changed, 26 insertions(+) diff --git a/src/cppcheck.cpp b/src/cppcheck.cpp index d76760173..43e03dafe 100644 --- a/src/cppcheck.cpp +++ b/src/cppcheck.cpp @@ -95,6 +95,10 @@ std::string CppCheck::parseFromArgs(int argc, const char* const argv[]) else if (strcmp(argv[i], "-f") == 0 || strcmp(argv[i], "--force") == 0) _settings._force = true; + // Write results in results.xml + else if (strcmp(argv[i], "--xml-results") == 0) + _settings._xmlResults = true; + // Print help else if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0) { @@ -272,6 +276,24 @@ unsigned int CppCheck::check() _checkFunctionUsage.check(); } + // xml results.. + if (_settings._xmlResults) + { + std::ofstream fxml("results.xml"); + fxml << "\n" + << " \n" + << " cppcheck\n"; + if (_errorList.size()) + { + fxml << " \n"; + for (std::list::const_iterator it = _errorList.begin(); it != _errorList.end(); ++it) + fxml << *it << "\n"; + fxml << " \n"; + } + fxml << " \n" + << "\n"; + } + unsigned int result = _errorList.size(); _errorList.clear(); return result; diff --git a/src/settings.cpp b/src/settings.cpp index d24db3fca..32c48ab44 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -27,6 +27,7 @@ Settings::Settings() _errorsOnly = false; _verbose = false; _force = false; + _xmlResults = false; } Settings::~Settings() diff --git a/src/settings.h b/src/settings.h index 0b0a18097..ecc4f6592 100644 --- a/src/settings.h +++ b/src/settings.h @@ -39,6 +39,9 @@ public: /** Force checking t he files with "too many" configurations. */ bool _force; + + /** write results in xml file results.xml */ + bool _xmlResults; }; #endif // SETTINGS_H