Changeset 184

Show
Ignore:
Timestamp:
09/25/06 21:51:33 (2 years ago)
Author:
ug
Message:

Extended cpptest

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • 06/libkombilo/cpptest.cc

    r183 r184  
     1#include <fstream> 
     2#include <string> 
     3#include "boost/filesystem/operations.hpp" 
    14#include "search.h" 
     5 
     6using namespace boost::filesystem; 
    27 
    38int main() { 
    49        GameList gl("t1.db", "id", "[[PW]] - [[PB]] ([[winner]]), [[filename.]]", ALGO_FINALPOS | ALGO_MOVELIST | ALGO_HASH_FULL, 19); 
     10 
     11        gl.start_processing(); 
     12 
     13        directory_iterator end_itr; 
     14        string path = "/home/ug/go/gogod06/1999"; 
     15        for(directory_iterator it(path); it != end_itr; ++it) { 
     16                string n = it->string(); 
     17                if (n.substr(n.size()-4) == ".sgf") { 
     18                        ifstream infile; 
     19                        infile.open(it->native_file_string().c_str()); 
     20 
     21                        string sgf; 
     22                        string line; 
     23                        while (!infile.eof()) { 
     24                                getline(infile, line); 
     25                                sgf += line; 
     26                        } 
     27                        infile.close(); 
     28                        gl.process(sgf.c_str(), path.c_str(), n.c_str());    
     29                } 
     30        } 
     31        gl.finalize_processing(); 
     32        printf("Processed %d games.\n", gl.size()); 
     33 
    534        // gl.gisearch("pw = 'Hane Naoki'"); 
    6         // Pattern p(CENTER_PATTERN, 19, 3, 5, ".X..OX.OX.OXOXO") ; 
    7         vector<MoveNC> contList; 
    8         contList.push_back(MoveNC(6,15,'X')); 
    9         contList.push_back(MoveNC(6,13,'O')); 
    10         contList.push_back(MoveNC(4,15,'X')); 
    11  Pattern p(FULLBOARD_PATTERN, 19, 19, 19, ".....................O.O........OX......XO......X.OXX.XX...X,.OOXXX..OOOX.O....X.OXOOXOO..OX.......XOXXOXXOOXXOO....OX.XXXOOOXO.O.O...OXX..XOX..XO.X.XO...O.......X.....XO..O.,X....,.....XOO................X......X............X....O...........................................O.O...........O.....,.....X...........X.O.X............................................", contList); 
     35        Pattern p(CENTER_PATTERN, 19, 3, 5, ".X..OX.OX.OXOXO") ; 
     36        // vector<MoveNC> contList; 
     37        // contList.push_back(MoveNC(6,15,'X')); 
     38        // contList.push_back(MoveNC(6,13,'O')); 
     39        // contList.push_back(MoveNC(4,15,'X')); 
     40       // Pattern p(FULLBOARD_PATTERN, 19, 19, 19, ".....................O.O........OX......XO......X.OXX.XX...X,.OOXXX..OOOX.O....X.OXOOXOO..OX.......XOXXOXXOOXXOO....OX.XXXOOOXO.O.O...OXX..XOX..XO.X.XO...O.......X.....XO..O.,X....,.....XOO................X......X............X....O...........................................O.O...........O.....,.....X...........X.O.X............................................", contList); 
    1241        SearchOptions so; 
    1342        gl.search(p, so); 
  • 06/libkombilo/search.cc

    r183 r184  
    29552955 
    29562956 
    2957 int GameList::process(char* sgf, char* path, char* fn) throw(SGFError,DBError) { 
     2957int GameList::process(const char* sgf, const char* path, const char* fn) throw(SGFError,DBError) { 
    29582958 
    29592959        Cursor c = Cursor(sgf, 1); // parse sgf sloppily 
  • 06/libkombilo/search.h

    r183 r184  
    458458 
    459459                void start_processing() throw(DBError); 
    460                 int process(char* sgf, char* path, char* fn) throw(SGFError,DBError); 
     460                int process(const char* sgf, const char* path, const char* fn) throw(SGFError,DBError); 
    461461                void finalize_processing() throw(DBError); 
    462462                 
  • 06/libkombilo/sgfparser.cc

    r183 r184  
    382382int Node::sloppy = 1; 
    383383 
    384 Cursor::Cursor(char* sgf, int sloppy) throw(SGFError) { 
     384Cursor::Cursor(const char* sgf, int sloppy) throw(SGFError) { 
    385385  Node::sloppy = sloppy; 
    386386 
     
    412412} 
    413413 
    414 void Cursor::parse(char* s) throw(SGFError) { 
     414void Cursor::parse(const char* s) throw(SGFError) { 
    415415 
    416416        Node* curr = root;         
  • 06/libkombilo/sgfparser.h

    r183 r184  
    107107class Cursor { 
    108108        public: 
    109                 Cursor(char* sgf, int sloppy) throw(SGFError); 
     109                Cursor(const char* sgf, int sloppy) throw(SGFError); 
    110110                ~Cursor(); 
    111111 
     
    120120 
    121121                int noChildren(); 
    122                 void parse(char* s) throw(SGFError); 
     122                void parse(const char* s) throw(SGFError); 
    123123                void game(int n) throw(SGFError); 
    124124                void next(int n=0) throw(SGFError);