diff options
author | bloodstalker <thabogre@gmail.com> | 2017-05-20 17:04:18 +0000 |
---|---|---|
committer | bloodstalker <thabogre@gmail.com> | 2017-05-20 17:04:18 +0000 |
commit | 7259fcb6202fa82f14bad41825c22f4eb80c0076 (patch) | |
tree | 55e64501422162d32124950cdaa34f158d3afa59 | |
parent | added an xml report base class (diff) | |
download | mutator-7259fcb6202fa82f14bad41825c22f4eb80c0076.tar.gz mutator-7259fcb6202fa82f14bad41825c22f4eb80c0076.zip |
added an xml report base class
Diffstat (limited to '')
-rw-r--r-- | mutator_report.h | 116 |
1 files changed, 66 insertions, 50 deletions
diff --git a/mutator_report.h b/mutator_report.h index 69f177d..e6b1936 100644 --- a/mutator_report.h +++ b/mutator_report.h @@ -37,64 +37,80 @@ using namespace tinyxml2; /*********************************************************************************************************************/ namespace Devi { /*********************************************************************************************************************/ -/*@DEVI- for both report classes, if the program gets terminated, since the destructor does not close -the report files, what happens to them is implementation-defined in case of let's say an exit, but since -we erase the files everytime a new instance of mutator-lvl0 is called, we are fine. or so i think.*/ -/*@DEVI- in case of a crash, the XML report will only hold the base node, while the JSON report will -contain all the reports up until the crash. tinyxml2 writes the nodes to file on SaveFile which is -called in SaveReport so that's why.*/ -class XMLReport -{ -public: - XMLReport(); - ~XMLReport(); - - void XMLCreateReport(void); - void XMLAddNode(ASTContext* ASTC, SourceLocation SL, std::string MisraRule, std::string Description); - /*overloaded for rule checks that announce the result on onendoftranslation instead of run - since they dont have access to matchresult or astcontext.*/ - void XMLAddNode(FullSourceLoc FSL, SourceLocation SL, std::string MisraRule, std::string Description); - /*another overload to support the xml output for PPCallbacks.*/ - void XMLAddNode(const SourceManager &SM, SourceLocation SL, std::string MisraRule, std::string Description); - - void XMLAddNode(std::string FilePath, std::string MisraRule, std::string Description); - - void XMLAddNode(unsigned Line, unsigned Column, std::string FileName, std::string MisraRule, std::string Description); - - bool isReportEmpty(void); - - void SaveReport(void); - -private: - XMLDocument XMLReportDoc; - XMLElement* RootPointer; -}; + class XMLReportBase + { + public: + XMLReportBase(); + ~XMLReportBase(); + + void CreateReport(void); + + virtual void AddNode(void) = 0; + + void SaveReport(void); + + private: + XMLDocument Doc; + XMLElement* RootPointer; + }; +/*********************************************************************************************************************/ + /*@DEVI- for both report classes, if the program gets terminated, since the destructor does not close + the report files, what happens to them is implementation-defined in case of let's say an exit, but since + we erase the files everytime a new instance of mutator-lvl0 is called, we are fine. or so i think.*/ + /*@DEVI- in case of a crash, the XML report will only hold the base node, while the JSON report will + contain all the reports up until the crash. tinyxml2 writes the nodes to file on SaveFile which is + called in SaveReport so that's why.*/ + class XMLReport + { + public: + XMLReport(); + ~XMLReport(); + + void XMLCreateReport(void); + void XMLAddNode(ASTContext* ASTC, SourceLocation SL, std::string MisraRule, std::string Description); + /*overloaded for rule checks that announce the result on onendoftranslation instead of run + since they dont have access to matchresult or astcontext.*/ + void XMLAddNode(FullSourceLoc FSL, SourceLocation SL, std::string MisraRule, std::string Description); + /*another overload to support the xml output for PPCallbacks.*/ + void XMLAddNode(const SourceManager &SM, SourceLocation SL, std::string MisraRule, std::string Description); + + void XMLAddNode(std::string FilePath, std::string MisraRule, std::string Description); + + void XMLAddNode(unsigned Line, unsigned Column, std::string FileName, std::string MisraRule, std::string Description); + + bool isReportEmpty(void); + + void SaveReport(void); + + private: + XMLDocument XMLReportDoc; + XMLElement* RootPointer; + }; /*********************************************************************************************************************/ -class JSONReport -{ -public: - JSONReport(); + class JSONReport + { + public: + JSONReport(); - void JSONCreateReport(void); - void JSONAddElement(ASTContext* ASTC, SourceLocation SL, std::string MisraRule, std::string Description); - /*overload for checks that announce the result in onendoftranslation unit.*/ - void JSONAddElement(FullSourceLoc FSL, SourceLocation SL, std::string MisraRule, std::string Description); - /*overload for PPCallbacks.*/ - void JSONAddElement(const SourceManager &SM, SourceLocation SL, std::string MisraRule, std::string Description); + void JSONCreateReport(void); + void JSONAddElement(ASTContext* ASTC, SourceLocation SL, std::string MisraRule, std::string Description); + /*overload for checks that announce the result in onendoftranslation unit.*/ + void JSONAddElement(FullSourceLoc FSL, SourceLocation SL, std::string MisraRule, std::string Description); + /*overload for PPCallbacks.*/ + void JSONAddElement(const SourceManager &SM, SourceLocation SL, std::string MisraRule, std::string Description); - void JSONAddElement(std::string FilePath, std::string MisraRule, std::string Description); + void JSONAddElement(std::string FilePath, std::string MisraRule, std::string Description); - void JSONAddElement(unsigned Line, unsigned Column, std::string FileName, std::string MisraRule, std::string Description); + void JSONAddElement(unsigned Line, unsigned Column, std::string FileName, std::string MisraRule, std::string Description); - void CloseReport(void); + void CloseReport(void); -private: - std::ofstream JSONRepFile; -}; + private: + std::ofstream JSONRepFile; + }; /*********************************************************************************************************************/ /*********************************************************************************************************************/ -/*end of namespace Devi*/ -} +} //end of namespace devi #endif /*********************************************************************************************************************/ /*last line intentionally left blank.*/ |