COOPY » Guide
version 0.6.5
|
00001 #include <coopy/MergeOutputVerboseDiff.h> 00002 #include <coopy/SheetStyle.h> 00003 #include <coopy/DataSheet.h> 00004 00005 #include <stdio.h> 00006 #include <stdlib.h> 00007 00008 std::string stringer_encoder(const coopy::cmp::TableField& x) { 00009 return x.toString(); 00010 } 00011 00012 #define WANT_MAP2STRING 00013 #define WANT_VECTOR2STRING 00014 #include <coopy/Stringer.h> 00015 00016 using namespace std; 00017 using namespace coopy::store; 00018 using namespace coopy::cmp; 00019 00020 00021 template <class T> 00022 string verbose_encoder(const std::vector<std::string>& lst, 00023 const std::map<std::string,T> & mp) { 00024 string x; 00025 for (vector<string>::const_iterator it = lst.begin(); 00026 it!=lst.end(); 00027 it++) { 00028 if (mp.find(*it)!=mp.end()) { 00029 if (x.length()>0) { 00030 x += " "; 00031 } 00032 x += *it; 00033 x += ":"; 00034 x += stringer_encoder(mp.find(*it)->second); 00035 } 00036 } 00037 return x; 00038 } 00039 00040 /* 00041 string index_encoder(const std::vector<std::string>& lst, 00042 const std::vector<int> & mp) { 00043 string x; 00044 int at = 0; 00045 for (vector<string>::const_iterator it = lst.begin(); 00046 it!=lst.end(); 00047 it++) { 00048 if (mp[at]) { 00049 if (x.length()>0) { 00050 x += " "; 00051 } 00052 x += *it; 00053 } 00054 at++; 00055 } 00056 return x; 00057 } 00058 */ 00059 00060 00061 bool MergeOutputVerboseDiff::changeColumn(const OrderChange& change) { 00062 fprintf(out,"changeColumn: %s\n", change.modeString().c_str()); 00063 fprintf(out," subject: %d\n", change.subject); 00064 fprintf(out," indexBefore: %s\n", vector2string(change.indicesBefore).c_str()); 00065 fprintf(out," indexAfter: %s\n", vector2string(change.indicesAfter).c_str()); 00066 fprintf(out," namesBefore: %s\n", vector2string(change.namesBefore).c_str()); 00067 fprintf(out," namesAfter: %s\n", vector2string(change.namesAfter).c_str()); 00068 fprintf(out,"\n"); 00069 return true; 00070 } 00071 00072 bool MergeOutputVerboseDiff::changeRow(const RowChange& change) { 00073 fprintf(out,"changeRow: %s\n", change.modeString().c_str()); 00074 fprintf(out," conds: %s\n", verbose_encoder(change.names,change.cond).c_str()); 00075 fprintf(out," vals: %s\n", verbose_encoder(change.names,change.val).c_str()); 00076 fprintf(out," indexes: %s\n", verbose_encoder(change.names,change.indexes).c_str()); 00077 fprintf(out," names: %s\n", vector2string(change.names).c_str()); 00078 fprintf(out," all: %s\n", vector2string(change.allNames).c_str()); 00079 fprintf(out,"sequent'l: %s\n", change.sequential?"true":"false"); 00080 if (change.conflicted) { 00081 fprintf(out," conflict: yes\n"); 00082 fprintf(out," alts: %s\n", verbose_encoder(change.names,change.conflictingVal).c_str()); 00083 fprintf(out," parents: %s\n", verbose_encoder(change.names,change.conflictingParentVal).c_str()); 00084 } 00085 /* 00086 if (change.context.beforeCount()!=0) { 00087 fprintf(out," context: covers %d row before this one\n", change.context.beforeCount()); 00088 fprintf(out," context: %s\n", verbose_encoder(change.allNames,change.context.getRow(-1)).c_str()); 00089 } 00090 */ 00091 fprintf(out,"\n"); 00092 return true; 00093 } 00094 00095 00096 bool MergeOutputVerboseDiff::changeName(const NameChange& change) { 00097 const vector<string>& names = change.names; 00098 bool final = change.final; 00099 bool constant = change.constant; 00100 fprintf(out,"declareNames: %s\n", 00101 vector2string(names).c_str()); 00102 fprintf(out," final: %d\n", final?1:0); 00103 fprintf(out," constant: %d\n", constant?1:0); 00104 if (change.strong) { 00105 fprintf(out," strong: %d\n", change.strong?1:0); 00106 } 00107 fprintf(out,"\n"); 00108 return true; 00109 } 00110 00111 bool MergeOutputVerboseDiff::setSheet(const char *name) { 00112 fprintf(out,"setSheet [%s]\n\n", stringer_encoder(string(name)).c_str()); 00113 return true; 00114 } 00115 00116 bool MergeOutputVerboseDiff::changePool(const PoolChange& change) { 00117 fprintf(out,"changePool: <%s>\n", stringer_encoder(change.poolName).c_str()); 00118 fprintf(out," link %s\n", vector2string(change.pool).c_str()); 00119 fprintf(out,"\n"); 00120 00121 return true; 00122 } 00123