/[hyperestraier_wrappers]/trunk/perl/HyperEstraierWrapper.cpp
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/perl/HyperEstraierWrapper.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 9 by dpavlin, Thu Sep 8 16:42:55 2005 UTC revision 32 by dpavlin, Tue Oct 11 14:04:20 2005 UTC
# Line 13  Line 13 
13  #include <estnode.h>  #include <estnode.h>
14    
15  /* backward compatibility for 0.5.4 */  /* backward compatibility for 0.5.4 */
16    /*
17  #ifndef ESTCONDAGITO  #ifndef ESTCONDAGITO
18  #define ESTCONDAGITO ESTCONDAGIT  #define ESTCONDAGITO ESTCONDAGIT
19  #endif  #endif
20    */
21    
22  namespace estraier {  namespace estraier {
23    
# Line 415  namespace estraier { Line 417  namespace estraier {
417                          if (!db) throw IOError("closed database");                          if (!db) throw IOError("closed database");
418                          return est_mtdb_size(db);                          return est_mtdb_size(db);
419                  }                  }
420                  void set_cache_size(size_t size, int anum, int tnum) {                  void set_cache_size(size_t size, int anum, int tnum, int rnum) {
421                          /**                          /**
422                           * set the maximum size of the cache memory of a database                           * set the maximum size of the cache memory of a database
423                           */                           */
424                          if (!db) throw IOError("closed database");                          if (!db) throw IOError("closed database");
425                          est_mtdb_set_cache_size(db, size, anum, tnum);                          est_mtdb_set_cache_size(db, size, anum, tnum, rnum);
426                  }                  }
427                  void set_special_cache(const char *name, int num) {                  void set_special_cache(const char *name, int num) {
428                          /**                          /**
# Line 455  namespace estraier { Line 457  namespace estraier {
457                  return vs;                  return vs;
458          }          }
459    
460          class NetEnv {          class ResultDocument {
         private:  
                 int ok;  
461          public:          public:
                 NetEnv() {  
                         ok = est_init_net_env();  
                         if (! ok) throw IOError("can't init net env");  
                 }  
                 ~NetEnv() {  
                         est_free_net_env();  
                 }  
         };  
   
         class NodeDocument {  
         private:  
462                  ESTRESDOC *rdoc;                  ESTRESDOC *rdoc;
463          public:                  ResultDocument(ESTRESDOC *_rdoc) {
464                  NodeDocument(ESTNODERES *nres, int index) {                          rdoc = _rdoc;
                         rdoc = est_noderes_get_doc(nres, index);  
465                  }                  }
466                  const char *uri(void) {                  const char *uri(void) {
467                          return est_resdoc_uri(rdoc);                          return est_resdoc_uri(rdoc);
# Line 499  namespace estraier { Line 487  namespace estraier {
487          private:          private:
488                  ESTNODERES *nres;                  ESTNODERES *nres;
489          public:          public:
490                  NodeRes(ESTNODE *node, ESTCOND *cond, int depth) {                  NodeRes(ESTNODE *node, Condition *cond, int depth) {
491                          nres = est_node_search(node, cond, depth);                          nres = est_node_search(node, cond->cond, depth);
492                  }                  }
493                  ~NodeRes() {                  ~NodeRes() {
494                          est_noderes_delete(nres);                          est_noderes_delete(nres);
# Line 518  namespace estraier { Line 506  namespace estraier {
506                  int doc_num(void) {                  int doc_num(void) {
507                          return est_noderes_doc_num(nres);                          return est_noderes_doc_num(nres);
508                  }                  }
509                  NodeDocument * get_doc(int index) {                  ResultDocument * get_doc(int index) {
510                          return new NodeDocument(nres, index);                          ESTRESDOC *rdoc = est_noderes_get_doc(nres, index);
511                            if (rdoc) {
512                                    return new ResultDocument(rdoc);
513                            } else {
514                                    return NULL;
515                            }
516                  }                  }
517          };          };
518    
519          class Node {          class Node {
520          private:          private:
521                  ESTNODE *node;                  ESTNODE *node;
522                    int netenv_ok;
523          public:          public:
524                  Node(const char *url) {                  Node(const char *url) {
525                            netenv_ok = est_init_net_env();
526                            if (! netenv_ok) throw IOError("can't init net env");
527                          node = est_node_new(url);                          node = est_node_new(url);
528                          if (! node) throw IOError("can't create node");                          if (! node) throw IOError("can't create node");
529                  }                  }
530                  ~Node() {                  ~Node() {
531                          est_node_delete(node);                          est_node_delete(node);
532                            est_free_net_env();
533                  }                  }
534                  void set_proxy(const char *host, int port) {                  void set_proxy(const char *host, int port) {
535                          est_node_set_proxy(node, host, port);                          est_node_set_proxy(node, host, port);
# Line 603  namespace estraier { Line 600  namespace estraier {
600                  double size(void) {                  double size(void) {
601                          return est_node_size(node);                          return est_node_size(node);
602                  }                  }
603                  NodeRes * search(ESTCOND *cond, int depth) {                  NodeRes * search(Condition *cond, int depth) {
604                          return new NodeRes(node, cond, depth);                          return new NodeRes(node, cond, depth);
605                  }                  }
606                  int set_user(const char *name, int mode) {                  int set_user(const char *name, int mode) {

Legend:
Removed from v.9  
changed lines
  Added in v.32

  ViewVC Help
Powered by ViewVC 1.1.26