Changeset 204
- Timestamp:
- 10/29/06 20:39:56 (2 years ago)
- Files:
-
- 06/libkombilo/search.cc (modified) (3 diffs)
- 06/libkombilo/search.h (modified) (5 diffs)
- 06/libkombilo/testsearch.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
06/libkombilo/search.cc
r203 r204 3489 3489 if (rc) throw DBError(); 3490 3490 3491 string sql = "select "; // those two we need in any case3491 string sql = "select "; 3492 3492 sql += format1; 3493 3493 sql += " from games order by "; … … 3502 3502 // SQLITE_ERROR may occur since table might not yet exist 3503 3503 3504 readPlayersList(); 3505 3504 3506 if (rc == SQLITE_OK && !readDBs) { 3505 3507 for(unsigned int a=0; a < 20*boardsizes.size(); a++) { … … 3926 3928 pl.continuations = new Continuation[pattern.sizeX*pattern.sizeY]; 3927 3929 delete searchOptions; 3930 } 3931 3932 3933 int GameList::plSize() { 3934 return pl.size(); 3935 } 3936 3937 string GameList::plEntry(int i) { 3938 if (i < 0 || i >= pl.size()) return ""; 3939 else return pl[i]; 3940 } 3941 3942 int rpl_callback(void *pl, int argc, char **argv, char **azColName) { 3943 if (!argc) return 1; 3944 ((vector<string>*)pl)->push_back(string(argv[0])); 3945 return 0; 3946 } 3947 3948 void GameList::readPlayersList() throw(DBError) { 3949 if (pl.size()) pl = vector<string>(); 3950 int rc = sqlite3_exec(db, "select p from (select pw p from games union select pb p from games) order by lower(p)", rpl_callback, &pl, 0); 3951 if (rc != SQLITE_OK) throw DBError(); 3928 3952 } 3929 3953 06/libkombilo/search.h
r203 r204 584 584 Continuation* continuations; 585 585 586 // ---------------------------------------------------------------------------- 586 587 // the following methods provide the user interface 587 588 589 // ------- constructor -------------------------------------------------------- 588 590 // p_options will be copied by GameList, so the caller has to free the pointer 589 591 GameList(char* DBNAME, std::string ORDERBY="", std::string FORMAT="", ProcessOptions* p_options=0) throw(DBError); 590 592 593 // ------- processing SGF games (to populate the db) -------------------------- 591 594 void start_processing(int PROCESSVARIATIONS=-1) throw(DBError); 592 595 int process(const char* sgf, const char* path, const char* fn, const char* DBTREE = 0) throw(SGFError,DBError); 593 596 void finalize_processing() throw(DBError); 594 597 598 // ------- pattern search ----------------------------------------------------- 595 599 // options is copied in the search method (if != 0), so the caller has to free the pointer 596 600 void search(Pattern& pattern, SearchOptions* options = 0) throw(DBError); … … 598 602 Continuation lookupContinuation(char x, char y); 599 603 604 // ------- game info search --------------------------------------------------- 600 605 void gisearch(char* sql, int complete=0) throw(DBError); 601 606 607 // ------- tagging ------------------------------------------------------------ 602 608 void tagsearch(int tag) throw(DBError); 603 609 void setTag(int tag, int start=0, int end=0) throw(DBError); … … 605 611 std::vector<int> getTags(int i, int tag=0) throw(DBError); // note the order of arguments! 606 612 613 // ------- misc --------------------------------------------------------------- 607 614 void reset(); // reset currentList to all 608 615 void resetFormat(std::string ORDERBY="", std::string FORMAT=""); … … 615 622 std::string getCurrentProperty(int i, std::string tag) throw (DBError); 616 623 624 // ------- list of all players ------------------------------------------------- 625 int plSize(); 626 std::string plEntry(int i); 627 628 // ----------------------------------------------------------------------------- 617 629 // internal methods (called from the algorithm classes) 618 630 ~GameList(); … … 642 654 std::vector<std::string>* SGFtags; 643 655 std::string sql_ins_rnp; // sql string to insert root node properties 656 std::vector<std::string> pl; // list of all players 657 void readPlayersList() throw(DBError); 644 658 }; 645 659 06/libkombilo/testsearch.py
r201 r204 53 53 print gl.currentEntryAsString(gl.size()-1) 54 54 print gl.getCurrentProperty(gl.size()-1, 'PW'), gl.getSGF(gl.size()-1) 55 55 56 gl.reset() 57 gl.tagsearch(HANDI_TAG) 58 print gl.size(), 'handicap games' 56 59 60 print gl.plSize(), 'players in the whole database.' 61 for i in range(100,110): 62 print 'Player %d: %s' % (i, gl.plEntry(i)) 63
