Make custom change printer example more mature

printers.hpp does not depend anymore on includes or usings order
inside strdiff_cp.cpp file.
This commit is contained in:
Wiktor Lawski 2020-09-12 16:47:17 +02:00
parent 6b030d6397
commit afddfbccf6
2 changed files with 13 additions and 16 deletions

View File

@ -1,23 +1,25 @@
#ifndef DTL_PRINTERS #ifndef DTL_PRINTERS
#define DTL_PRINTERS #define DTL_PRINTERS
#include <dtl/dtl.hpp>
template <typename sesElem, typename stream = ostream > template <typename sesElem, typename stream = ostream >
class customChangePrinter : public Printer < sesElem, stream > class customChangePrinter : public dtl::Printer < sesElem, stream >
{ {
public : public :
customChangePrinter () : Printer < sesElem, stream > () {} customChangePrinter () : dtl::Printer < sesElem, stream > () {}
customChangePrinter (stream& out) : Printer < sesElem, stream > (out) {} customChangePrinter (stream& out) : dtl::Printer < sesElem, stream > (out) {}
~customChangePrinter () {} ~customChangePrinter () {}
void operator() (const sesElem& se) const { void operator() (const sesElem& se) const {
switch (se.second.type) { switch (se.second.type) {
case SES_ADD: case dtl::SES_ADD:
this->out_ << "Add: " << se.first << endl; this->out_ << "Add: " << se.first << std::endl;
break; break;
case SES_DELETE: case dtl::SES_DELETE:
this->out_ << "Delete: " << se.first << endl; this->out_ << "Delete: " << se.first << std::endl;
break; break;
case SES_COMMON: case dtl::SES_COMMON:
this->out_ << "Common: " << se.first << endl; this->out_ << "Common: " << se.first << std::endl;
break; break;
} }
} }

View File

@ -1,19 +1,14 @@
#include <dtl/dtl.hpp> #include <dtl/dtl.hpp>
#include "common.hpp" #include "common.hpp"
#include <iostream> #include <iostream>
#include <sstream> #include <sstream>
#include <string> #include <string>
#include "printers.hpp"
using namespace std; using namespace std;
using dtl::Diff; using dtl::Diff;
using dtl::SES_ADD;
using dtl::SES_DELETE;
using dtl::SES_COMMON;
using dtl::Printer;
#include "printers.hpp"
int main(int argc, char *argv[]){ int main(int argc, char *argv[]){