Changeset 14274 for lang/python

Show
Ignore:
Timestamp:
06/20/08 00:25:01 (5 months ago)
Author:
ayu
Message:
  • added swig IF.
Location:
lang/python/incsearch
Files:
2 added
4 modified

Legend:

Unmodified
Added
Removed
  • lang/python/incsearch/include/DocDb.h

    r14238 r14274  
    66#include <vector> 
    77 
    8 using namespace qdbm; 
    9  
    108namespace incsearch{ 
    119 
    1210class DocDbWriter{ 
    1311private: 
    14   Villa villa; 
     12  qdbm::Villa villa; 
    1513public: 
    1614  DocDbWriter(const std::string& dbname); 
    1715  ~DocDbWriter(); 
    18   void put(const std::string& word, const std::string& fname, const std::string& name); 
     16  void put(const std::string& word, const std::string& data); 
    1917}; 
    2018 
    2119class DocDbReader{ 
    2220private: 
    23   Villa villa; 
     21  qdbm::Villa villa; 
    2422  boost::mutex mtx; 
    2523public: 
  • lang/python/incsearch/incsearch/incsearch.i

    r14238 r14274  
    1 %module  
     1%module db 
    22 
    33%include "std_vector.i" 
     4%include "std_string.i" 
    45%{ 
    56#include <vector> 
    6 #include "ward.h" 
    7 #include "wardupdator.h" 
     7#include <string> 
     8#include <boost/thread/thread.hpp> 
     9#include <xvilla.h> 
     10#include "DocDb.h" 
    811%} 
    9 %include "ward.h" 
     12%include "DocDb.h" 
    1013 
    11 %template(SizeVec) std::vector<std::size_t>; 
    12 %template(DoubleVec) std::vector<double>; 
    13 %template(Matrix) std::vector<std::vector<double> >; 
    14 %template(Histories) std::vector<History>; 
     14%template(StringVec) std::vector<std::string>; 
    1515  
  • lang/python/incsearch/src/DocDb.cpp

    r14238 r14274  
    55 
    66#include "DocDb.h" 
    7 using namespace qdbm; 
    87 
    98namespace incsearch{ 
    10   DocDbWriter::DocDbWriter(const std::string& dbname): villa(dbname.c_str(), Villa::OWRITER | Villa::OCREAT) 
     9  DocDbWriter::DocDbWriter(const std::string& dbname): villa(dbname.c_str(), qdbm::Villa::OWRITER | qdbm::Villa::OCREAT) 
    1110  {} 
    1211 
     
    1615  } 
    1716 
    18   void DocDbWriter::put(const std::string& word, const std::string& fname, const std::string& name){ 
    19     std::string val = fname+"\t"+name; 
    20     villa.put(word.c_str(), word.size()+1, val.c_str(), val.size()+1, Villa::DDUP); 
     17  void DocDbWriter::put(const std::string& word, const std::string& data){ 
     18    villa.put(word.c_str(), word.size()+1, data.c_str(), data.size()+1, qdbm::Villa::DDUP); 
    2119  } 
    2220 
    23   DocDbReader::DocDbReader(const std::string& dbname): villa(dbname.c_str(), Villa::OREADER), mtx() 
     21  DocDbReader::DocDbReader(const std::string& dbname): villa(dbname.c_str(), qdbm::Villa::OREADER), mtx() 
    2422  {} 
    2523 
     
    5553        villa.curnext(); 
    5654      } 
    57     }catch(Villa_error& e){ 
    58       if(e.code() != Villa::ENOITEM) throw e; 
     55    }catch(qdbm::Villa_error& e){ 
     56      if(e.code() != qdbm::Villa::ENOITEM) throw e; 
    5957    } 
    6058  } 
  • lang/python/incsearch/src/test.cpp

    r14238 r14274  
    1919  {//このスコープでDB作成 
    2020    DocDbWriter d("sample"); 
    21     d.put("ABC", "FF1", "NN1"); 
    22     d.put("ABD", "FF2", "NN2"); 
    23     d.put("AB", "FF3", "NN3"); 
    24     d.put("XYZ", "FF4", "NN4"); 
    25     d.put("XYX", "FF5", "NN5"); 
    26     d.put("XAB", "FF6", "NN6"); 
     21    d.put("ABC", "FF1\tNN1"); 
     22    d.put("ABD", "FF2\tNN2"); 
     23    d.put("AB", "FF3\tNN3"); 
     24    d.put("XYZ", "FF4\tNN4"); 
     25    d.put("XYX", "FF5\tNN5"); 
     26    d.put("XAB", "FF6\tNN6"); 
    2727  } 
    2828