difflib.cpp
#include <iostream>
#include "weDiffLib.h"
using namespace std;
int main(int argc, char* argv[])
{
WeCmpResults* res;
string t1 = "This file is part of webEngine";
string t2 = "this file was part Of dtl";
if (argc > 1) {
t1 = argv[1];
}
if (argc > 2) {
t2 = argv[2];
}
cout << "Compare '" << t1 << "' and '" << t2 << "'" << endl;
cout << "Case sensitive comparison:" << endl;
res = WeTextDiff(t1, t2, weCmpNothing);
for (unsigned i = 0; i < res->size(); i++) {
cout << "Block #" << i << endl;
switch (res->at(i)->state) {
case weCmpEqual:
cout << "weCmpEqual: ";
break;
case weCmpDeleted:
cout << "weCmpDeleted: ";
break;
case weCmpInserted:
cout << "weCmpInserted: ";
break;
default:
cout << "warning! unknown state (" << int(res->at(i)->state) << ")";
break;
};
string data = boost::get<string>(res->at(i)->entity);
cout << "'" << data << "'" <<endl;
}
cout << endl << "Case insensitive comparison:" << endl;
res = WeTextDiff(t1, t2, weCmpCaseInsens);
for (unsigned i = 0; i < res->size(); i++) {
cout << "Block #" << i << endl;
switch (res->at(i)->state) {
case weCmpEqual:
cout << "weCmpEqual: ";
break;
case weCmpDeleted:
cout << "weCmpDeleted: ";
break;
case weCmpInserted:
cout << "weCmpInserted: ";
break;
default:
cout << "warning! unknown state (" << int(res->at(i)->state) << ")";
break;
};
string data = boost::get<string>(res->at(i)->entity);
cout << "'" << data << "'" <<endl;
}
cout << endl << "Case insensitive, collapsed spaces comparison:" << endl;
res = WeTextDiff(t1, t2, (weCmpMode)(weCmpCaseInsens | weCmpCollapseSpace));
for (unsigned i = 0; i < res->size(); i++) {
cout << "Block #" << i << endl;
switch (res->at(i)->state) {
case weCmpEqual:
cout << "weCmpEqual: ";
break;
case weCmpDeleted:
cout << "weCmpDeleted: ";
break;
case weCmpInserted:
cout << "weCmpInserted: ";
break;
default:
cout << "warning! unknown state (" << int(res->at(i)->state) << ")";
break;
};
string data = boost::get<string>(res->at(i)->entity);
cout << "'" << data << "'" <<endl;
}
return 0;
}