5 #include <boost/algorithm/string/classification.hpp> 
    6 #include <boost/algorithm/string/split.hpp> 
    7 #include <boost/algorithm/string/replace.hpp> 
    8 #include <boost/lexical_cast.hpp> 
    9 #include <boost/foreach.hpp> 
   15   : move(mv), nodeIndex(ni), time(0)
 
   36     moves.push_back(moveIndex);
 
   44     NumEffectState copy(initial);
 
   48     BOOST_FOREACH(
Move move, moves) {
 
   54     playerNames[0]=playerNames[1]=
"";
 
   59     start_date = boost::gregorian::date();
 
   73     playerNames[player]=str;
 
   76     return playerNames[player];
 
   80     initialState.initPawnMask();
 
   83     if (! initialState.isConsistent(
true))
 
   85       const char *msg = 
"Record: bad initial state";
 
   86       std::cerr << msg << 
" " << __FILE__ << 
" " << __LINE__ << 
"\n";
 
   87       throw CsaIOError(msg);
 
   89     return NumEffectState(initialState);
 
   96     mrs.push_back(moveRecord);
 
  100     return &nrs.
at(index);
 
  103     return &nrs.
at(index);
 
  106     if (static_cast<size_t>(index) >= mrs.size())
 
  109       return &mrs.at(index);
 
  112     if (static_cast<size_t>(index) >= mrs.size())
 
  115       return &mrs.at(index);
 
  118     return nrs.
at(index);
 
  122     std::vector<std::string> values;
 
  123     boost::algorithm::split(values, date_str, boost::algorithm::is_any_of(
"/"));
 
  124     if (values.size() < 3) {
 
  125       std::cerr << 
"ERROR: Invalid date format found: " 
  131     } 
else if (values.size() > 3) {
 
  132       std::cerr << 
"WARNING: Invalid date format found: " 
  139     BOOST_FOREACH(std::string& value, values) {
 
  140       static const CArray<const char *,9> kanji = {{
 
  143       for (
size_t i=0; i<kanji.size(); ++i)
 
  144         boost::algorithm::replace_all(value, kanji[i], std::string(1, 
char(
'0'+i)));
 
  150       year  = boost::lexical_cast<
int>(values[0]);
 
  151       month = boost::lexical_cast<
int>(values[1]);
 
  152       if (month == 0) month = 1;
 
  153       if (
"??" == values[2]) {
 
  154         std::cerr << 
"WARNING: Invalid date format found: " 
  161       } 
else if (values[2].size() > 2) {
 
  162         std::cerr << 
"WARNING: Invalid date format found: " 
  168         day = boost::lexical_cast<
int>(values[2].substr(0,2));
 
  170         day = boost::lexical_cast<
int>(values[2]);
 
  172       if (day == 0) day = 1;
 
  173       start_date = boost::gregorian::date(year, month, day);
 
  174       assert(!start_date.is_special());
 
  175     } 
catch (boost::bad_lexical_cast& e) {
 
  176       std::cerr << 
"Invalid date format found: " 
  181                 << e.what() << std::endl;
 
  182     } 
catch (boost::gregorian::bad_day_of_month& ebdm) {
 
  183       std::cerr << 
"Bad day of month: " 
  188                 << ebdm.what() << std::endl;
 
  202     assert(state->isValidMove(move));
 
  204     int newNode=rec->addNodeRecord();
 
  205     int newMove=rec->addMoveRecord(
MoveRecord(move,newNode));
 
  206     (*rec)[nodeIndex].addMoveRecord(newMove);
 
  208     lastMoveIndex=newMove;
 
  210     assert(state->isConsistent() || ((std::cerr << move <<
"\n"<< *state),0));
 
  211     NumEffectState copy(*state);
 
  214     assert(state->isConsistent() || ((std::cerr << move <<
"\n"<< *state),0));
 
  215     for(boost::ptr_vector<record::RecordVisitorObserver>::iterator each = observers.begin(); each != observers.end(); ++each){ 
 
  222     return os << 
"MoveRecord(" << 
 
  233     NumEffectState state(initial_state);
 
  238     while(node->
size()>0){
 
  239       int moveIndex=node->
at(0);
 
  244       state.makeMove(move);
 
  245       assert(state.isConsistent());
 
  255     vector<int> dummy_time;
 
  256     getMoves(moves, dummy_time);
 
  265     for (
int i=0;i<4;i++) {
 
  266       ret = (ret<<8)|(cs[i]&255);
 
  275     for (
int i = 0; i < 4; i++)
 
  277         buf[i] = (n >> (8 * (4 - i - 1))) & 255;
 
  279     os.write(&buf[0], 4);
 
  287                  vector<std::string>& comments,
 
  288                  vector<SearchInfo>& info)
 const  
  291   while(node->
size()>0){
 
  292     const int moveIndex=node->
at(0);
 
  295     moves.push_back(move);
 
  296     times.push_back(mr->
getTime());
 
  298     info.push_back(mr->
info);
 
  307   vector<std::string> dummy_comments;
 
  308   vector<SearchInfo> dummy_info;
 
  309   getMoves(moves, times, dummy_comments, dummy_info);