COOPY » Guide
version 0.6.5
|
00001 #ifndef COOPY_COOPY_H 00002 #define COOPY_COOPY_H 00003 00004 #include <coopy/PolySheet.h> 00005 #include <coopy/PolyBook.h> 00006 #include <coopy/Patcher.h> 00007 #include <coopy/WrapBook.h> 00008 #include <coopy/Patcher.h> 00009 #include <coopy/CompareFlags.h> 00010 00011 namespace coopy { 00012 namespace app { 00013 class Coopy; 00014 } 00015 } 00016 00022 class coopy::app::Coopy { 00023 private: 00024 coopy::cmp::Patcher *patcher; 00025 std::string output; 00026 coopy::store::TextBook *output_book; 00027 coopy::store::WrapBook output_sheet; 00028 public: 00029 coopy::cmp::CompareFlags flags; 00030 00031 Coopy() { 00032 patcher = 0/*NULL*/; 00033 output = "-"; 00034 output_book = 0/*NULL*/; 00035 } 00036 00037 virtual ~Coopy() { 00038 reset(); 00039 } 00040 00041 void reset() { 00042 if (patcher!=0/*NULL*/) { 00043 delete patcher; 00044 patcher = 0/*NULL*/; 00045 } 00046 } 00047 00048 bool setFormat(const char *name, const char *version = NULL) { 00049 reset(); 00050 patcher = coopy::cmp::Patcher::createByName(name,version); 00051 return patcher!=0/*NULL*/; 00052 } 00053 00054 bool checkFormat() { 00055 if (patcher) return true; 00056 return setFormat("tdiff"); 00057 } 00058 00059 bool setOutput(const char *filename) { 00060 output = filename; 00061 return true; 00062 } 00063 00064 bool setOutput(coopy::store::DataSheet& sheet) { 00065 output_sheet.attach(sheet,false); 00066 output_book = &output_sheet; 00067 return true; 00068 } 00069 00070 bool setOutput(coopy::store::TextBook& book) { 00071 output_book = &book; 00072 return true; 00073 } 00074 00075 bool compare(coopy::store::TextBook& pivot, 00076 coopy::store::TextBook& local, 00077 coopy::store::TextBook& remote); 00078 00079 bool compare(coopy::store::TextBook& local, 00080 coopy::store::TextBook& remote) { 00081 return compare(local,local,remote); 00082 } 00083 00084 bool compare(coopy::store::DataSheet& pivot, 00085 coopy::store::DataSheet& local, 00086 coopy::store::DataSheet& remote) { 00087 coopy::store::WrapBook book1(pivot,false); 00088 coopy::store::WrapBook book2(local,false); 00089 coopy::store::WrapBook book3(remote,false); 00090 return compare(book1,book2,book3); 00091 } 00092 00093 bool compare(coopy::store::DataSheet& local, 00094 coopy::store::DataSheet& remote) { 00095 return compare(local,local,remote); 00096 } 00097 00098 bool merge(coopy::store::DataSheet& pivot, 00099 coopy::store::DataSheet& local, 00100 coopy::store::DataSheet& remote) { 00101 coopy::store::WrapBook book1(pivot,false); 00102 coopy::store::WrapBook book2(local,false); 00103 coopy::store::WrapBook book3(remote,false); 00104 return merge(book1,book2,book3); 00105 } 00106 00107 bool merge(coopy::store::TextBook& pivot, 00108 coopy::store::TextBook& local, 00109 coopy::store::TextBook& remote); 00110 00111 bool patch(coopy::store::TextBook& local, 00112 coopy::store::TextBook& mod); 00113 00114 bool patch(coopy::store::DataSheet& local, 00115 coopy::store::DataSheet& mod) { 00116 coopy::store::WrapBook book2(local,false); 00117 coopy::store::WrapBook book3(mod,false); 00118 return patch(book2,book3); 00119 } 00120 00121 int getChangeCount() const { 00122 if (!patcher) return 0; 00123 return patcher->getChangeCount(); 00124 } 00125 00126 static coopy::store::PolySheet createSheet(); 00127 00128 static coopy::store::PolyBook createBook(coopy::store::PolySheet sheet); 00129 00130 static coopy::store::PolyBook loadBook(const char *filename); 00131 00132 }; 00133 00134 00135 #endif