5 #include <boost/algorithm/string/trim.hpp> 
    6 #include <boost/functional/hash.hpp> 
    7 #include "boost/foreach.hpp" 
    8 #include "boost/format.hpp" 
    9 #include "boost/multi_array.hpp" 
   10 #include <boost/program_options.hpp> 
   23 typedef boost::multi_array<unsigned int, 4> 
array_t;
 
   35   players_t::const_iterator each_player = players.begin();
 
   36   for (; each_player != players.end(); ++each_player)
 
   38     if (each_player->second == 
id)
 
   41   assert(each_player != players.end());
 
   42   return each_player->first;
 
   47   players_t::const_iterator hit = players.find(player);
 
   48   if (hit == players.end())
 
   53       std::cerr << 
"No longer accomodate a new player.\n";
 
   56     const unsigned int new_id = players.size();
 
   57     players.insert(std::make_pair(player, new_id));
 
   71   winloss[black][white][0][
static_cast<unsigned int>(gr)] += 1;
 
   75     winloss[white][black][1][1] += 1;  
 
   79     winloss[white][black][1][0] += 1;  
 
   84     winloss[white][black][1][2] += 1;  
 
   89                          const osl::vector<osl::Move>& 
moves)
 
   91   std::ifstream in(csa_file.c_str());
 
   94     std::cerr << 
"File not found: " << csa_file << 
"\n";
 
  100   while (std::getline(in, line))
 
  102     if (line.find(
"%TORYO") != std::string::npos)
 
  127   if (duplicates.
regist(moves))
 
  133   const unsigned int black_id = 
setPlayer(black);
 
  134   const unsigned int white_id = 
setPlayer(white);
 
  142   out << 
"=== Total [ #wins / #losses / #others ] ===\n";
 
  144   for (
unsigned int player_a = 0; player_a < players.size(); ++player_a)
 
  147     for (
unsigned int player_b = 0; player_b < players.size(); ++player_b)
 
  149       if (player_a == player_b)
 
  154       unsigned int wins = 0, losses = 0, others = 0;
 
  155       wins += 
winloss[player_a][player_b][0][0];   
 
  156       wins += 
winloss[player_a][player_b][1][0];   
 
  157       losses += 
winloss[player_a][player_b][0][1]; 
 
  158       losses += 
winloss[player_a][player_b][1][1];
 
  159       others += 
winloss[player_a][player_b][0][2]; 
 
  160       others += 
winloss[player_a][player_b][1][2];
 
  162       out << boost::format(
"%5d/%5d/%5d ") 
 
  163         % wins % losses % others;
 
  174   out << 
"=== Left players are BLACK [ #wins / #losses / #others ] ===\n";
 
  175   out << boost::format(
"%= 17s ") % 
"";
 
  176   for (
unsigned int player_a = 0; player_a < players.size(); ++player_a)
 
  182   for (
unsigned int player_a = 0; player_a < players.size(); ++player_a)
 
  186     for (
unsigned int player_b = 0; player_b < players.size(); ++player_b)
 
  188       if (player_a == player_b)
 
  190         out << boost::format(
"%= 17s ") % 
"-";
 
  194       out << boost::format(
"%5d/%5d/%5d ") 
 
  195         % 
winloss[player_a][player_b][0][0]
 
  196         % 
winloss[player_a][player_b][0][1]
 
  197         % 
winloss[player_a][player_b][0][2];
 
  205 int main(
int argc, 
char **argv)
 
  209   boost::program_options::options_description command_line_options;
 
  210   command_line_options.add_options()
 
  211     (
"input-file", boost::program_options::value<std::vector<std::string> >(),
 
  212      "input files in the CSA format")
 
  213     (
"help", 
"Show help message");
 
  214   boost::program_options::variables_map 
vm;
 
  215   boost::program_options::positional_options_description p;
 
  216   p.add(
"input-file", -1);
 
  221       boost::program_options::command_line_parser(
 
  222         argc, argv).options(command_line_options).positional(p).
run(), vm);
 
  223     boost::program_options::notify(vm);
 
  224     if (vm.count(
"help"))
 
  226       std::cerr << 
"Usage: " << argv[0] << 
" [options] csa-file [...]\n";
 
  227       std::cerr << 
"       " << argv[0] << 
" [options]\n";
 
  228       std::cout << command_line_options << std::endl;
 
  232   catch (std::exception &e)
 
  234     std::cerr << 
"error in parsing options" << std::endl
 
  235               << e.what() << std::endl;
 
  236     std::cerr << 
"Usage: " << argv[0] << 
" [options] csa-file [...]\n";
 
  237     std::cerr << 
"       " << argv[0] << 
" [options]\n";
 
  238     std::cerr << command_line_options << std::endl;
 
  242   std::vector<std::string> 
files;
 
  243   if (vm.count(
"input-file"))
 
  245     const std::vector<std::string> temp = vm[
"input-file"].as<std::vector<std::string> >();
 
  246     files.insert(files.end(), temp.begin(), temp.end());
 
  251     while(std::getline(std::cin , line))
 
  253       boost::algorithm::trim(line);
 
  254       files.push_back(line);
 
  260   BOOST_FOREACH(
const std::string& file, files)
 
  265   std::locale::global(std::locale(
""));
 
  268   check_duplicate.
print(std::cout);