Merge pull request #6 from wlawski/custom-change-printer-example-improvement

Make custom change printer example more mature
This commit is contained in:
Tatsuhiko Kubo 2020-09-21 15:35:11 +09:00 committed by GitHub
commit ef50138616
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 16 deletions

View File

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

View File

@ -1,19 +1,14 @@
#include <dtl/dtl.hpp>
#include "common.hpp"
#include <iostream>
#include <sstream>
#include <string>
#include "printers.hpp"
using namespace std;
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[]){