00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include <iostream>
00024 #include "weDiffLib.h"
00025
00026 using namespace std;
00027
00028 int main(int argc, char* argv[])
00029 {
00030 WeCmpResults* res;
00031
00032 string t1 = "This file is part of webEngine";
00033 string t2 = "this file was part Of dtl";
00034
00035 if (argc > 1) {
00036 t1 = argv[1];
00037 }
00038 if (argc > 2) {
00039 t2 = argv[2];
00040 }
00041
00042 cout << "Compare '" << t1 << "' and '" << t2 << "'" << endl;
00043 cout << "Case sensitive comparison:" << endl;
00044 res = WeTextDiff(t1, t2, weCmpNothing);
00045 for (unsigned i = 0; i < res->size(); i++) {
00046 cout << "Block #" << i << endl;
00047 switch (res->at(i)->state) {
00048 case weCmpEqual:
00049 cout << "weCmpEqual: ";
00050 break;
00051 case weCmpDeleted:
00052 cout << "weCmpDeleted: ";
00053 break;
00054 case weCmpInserted:
00055 cout << "weCmpInserted: ";
00056 break;
00057 default:
00058 cout << "warning! unknown state (" << int(res->at(i)->state) << ")";
00059 break;
00060 };
00061 string data = boost::get<string>(res->at(i)->entity);
00062 cout << "'" << data << "'" <<endl;
00063 }
00064 cout << endl << "Case insensitive comparison:" << endl;
00065 res = WeTextDiff(t1, t2, weCmpCaseInsens);
00066 for (unsigned i = 0; i < res->size(); i++) {
00067 cout << "Block #" << i << endl;
00068 switch (res->at(i)->state) {
00069 case weCmpEqual:
00070 cout << "weCmpEqual: ";
00071 break;
00072 case weCmpDeleted:
00073 cout << "weCmpDeleted: ";
00074 break;
00075 case weCmpInserted:
00076 cout << "weCmpInserted: ";
00077 break;
00078 default:
00079 cout << "warning! unknown state (" << int(res->at(i)->state) << ")";
00080 break;
00081 };
00082 string data = boost::get<string>(res->at(i)->entity);
00083 cout << "'" << data << "'" <<endl;
00084 }
00085 cout << endl << "Case insensitive, collapsed spaces comparison:" << endl;
00086 res = WeTextDiff(t1, t2, (weCmpMode)(weCmpCaseInsens | weCmpCollapseSpace));
00087 for (unsigned i = 0; i < res->size(); i++) {
00088 cout << "Block #" << i << endl;
00089 switch (res->at(i)->state) {
00090 case weCmpEqual:
00091 cout << "weCmpEqual: ";
00092 break;
00093 case weCmpDeleted:
00094 cout << "weCmpDeleted: ";
00095 break;
00096 case weCmpInserted:
00097 cout << "weCmpInserted: ";
00098 break;
00099 default:
00100 cout << "warning! unknown state (" << int(res->at(i)->state) << ")";
00101 break;
00102 };
00103 string data = boost::get<string>(res->at(i)->entity);
00104 cout << "'" << data << "'" <<endl;
00105 }
00106 return 0;
00107 }
00108