|
| 1 | +#include "ConsoleExporter.h" |
| 2 | + |
| 3 | +#include <ostream> |
| 4 | + |
| 5 | +ConsoleExporter::ConsoleExporter(std::ostream& out, std::ostream& log) |
| 6 | + : m_out(out) |
| 7 | + , m_log(log) { |
| 8 | +} |
| 9 | + |
| 10 | +void ConsoleExporter::Log(const std::string& message) { |
| 11 | + m_log << message << std::flush; |
| 12 | +} |
| 13 | + |
| 14 | +void ConsoleExporter::WriteHeader() {} |
| 15 | +void ConsoleExporter::WriteFooter( |
| 16 | + const Options& options, |
| 17 | + int files, |
| 18 | + long locsTotal, |
| 19 | + const ProcessResult& processResult) { |
| 20 | + m_out |
| 21 | + << "Configuration:" |
| 22 | + << std::endl |
| 23 | + << " Number of files: " |
| 24 | + << files |
| 25 | + << std::endl |
| 26 | + << " Minimal block size: " |
| 27 | + << options.GetMinBlockSize() |
| 28 | + << std::endl |
| 29 | + << " Minimal characters in line: " |
| 30 | + << options.GetMinChars() |
| 31 | + << std::endl |
| 32 | + << " Ignore preprocessor directives: " |
| 33 | + << options.GetIgnorePrepStuff() |
| 34 | + << std::endl |
| 35 | + << " Ignore same filenames: " |
| 36 | + << options.GetIgnoreSameFilename() |
| 37 | + << std::endl |
| 38 | + << std::endl |
| 39 | + << "Results:" |
| 40 | + << std::endl |
| 41 | + << " Lines of code: " |
| 42 | + << locsTotal |
| 43 | + << std::endl |
| 44 | + << " Duplicate lines of code: " |
| 45 | + << processResult.DuplicateLines() |
| 46 | + << std::endl |
| 47 | + << " Total " |
| 48 | + << processResult.Blocks() |
| 49 | + << " duplicate block(s) found." |
| 50 | + << std::endl |
| 51 | + << std::endl; |
| 52 | +} |
| 53 | + |
| 54 | +void ConsoleExporter::ReportSeq( |
| 55 | + int line1, |
| 56 | + int line2, |
| 57 | + int count, |
| 58 | + const SourceFile& source1, |
| 59 | + const SourceFile& source2) { |
| 60 | + m_out |
| 61 | + << source1.GetFilename() |
| 62 | + << "(" << source1.GetLine(line1).GetLineNumber() << ")" |
| 63 | + << std::endl; |
| 64 | + m_out |
| 65 | + << source2.GetFilename() |
| 66 | + << "(" << source2.GetLine(line2).GetLineNumber() << ")" |
| 67 | + << std::endl; |
| 68 | + for (int j = 0; j < count; j++) { |
| 69 | + m_out << source1.GetLine(j + line1).GetLine() << std::endl; |
| 70 | + } |
| 71 | + |
| 72 | + m_out << std::endl; |
| 73 | +} |
0 commit comments