pairdiff.cc
Go to the documentation of this file.
00001 /* pairdiff.cc
00002  */
00003 
00004 #include "osl/eval/ppair/piecePairRawEval.h"
00005 #include "osl/record/csa.h"
00006 #include <boost/scoped_ptr.hpp>
00007 #include <iostream>
00008 #include <cstdlib>
00009 #include <cstdio>
00010 #include <unistd.h>
00011 
00012 // 二つのテーブルの差を表示
00013 
00014 using namespace osl;
00015 using namespace osl::eval;
00016 
00017 void usage(const char *prog)
00018 {
00019   using namespace std;
00020   cerr << "Usage: " << prog << " table1 table2"
00021        << endl;
00022   exit(1);
00023 }
00024 
00025 void show(std::ostream& os, Square pos, PtypeO ptypeo)
00026 {
00027   csaShow(os, pos);
00028   os << " ";
00029   os << getOwner(ptypeo);
00030   csaShow(os, getPtype(ptypeo));
00031 }
00032 
00033 int main(int argc, char **argv)
00034 {
00035   const char *program_name = argv[0];
00036   bool error_flag = false;
00037   const char *filename1 = 0;
00038   const char *filename2 = 0;
00039   
00040   // extern char *optarg;
00041   extern int optind;
00042   char c;
00043   while ((c = getopt(argc, argv, "vh")) != EOF)
00044   {
00045     switch(c)
00046     {
00047     default:    error_flag = true;
00048     }
00049   }
00050   argc -= optind;
00051   argv += optind;
00052 
00053   if (error_flag || (argc < 2))
00054     usage(program_name);
00055   filename1 = argv[0];
00056   filename2 = argv[1];
00057 
00058   boost::scoped_ptr<PiecePairRawTable> table1(new PiecePairRawTable());
00059   table1->loadFromBinaryFile(filename1);
00060   boost::scoped_ptr<PiecePairRawTable> table2(new PiecePairRawTable());
00061   table2->loadFromBinaryFile(filename2);
00062 
00063   for (unsigned int i=0; i<PiecePairRawTable::maxPairIndex; ++i)
00064   {
00065     const int val1 = table1->value(i);
00066     const int val2 = table2->value(i);
00067     if (val1 != val2)
00068     {
00069       size_t i1, i2;
00070       PiecePairRawTable::meltIndex(i, i1, i2);
00071       Square pos1, pos2;
00072       PtypeO ptypeo1, ptypeo2;
00073       PiecePairRawTable::meltIndex(i1, pos1, ptypeo1);
00074       PiecePairRawTable::meltIndex(i2, pos2, ptypeo2);
00075       show(std::cout, pos1, ptypeo1);
00076       std::cout << " ";
00077       show(std::cout, pos2, ptypeo2);
00078       std::cout << " : " << val1 << " != " << val2 << "\n";
00079     }
00080   }
00081 }
00082 
00083 
00084 /* ------------------------------------------------------------------------- */
00085 // ;;; Local Variables:
00086 // ;;; mode:c++
00087 // ;;; c-basic-offset:2
00088 // ;;; End:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines