/[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 12 by dpavlin, Thu Sep 8 22:51:10 2005 UTC
# Line 455  namespace estraier { Line 455  namespace estraier {
455                  return vs;                  return vs;
456          }          }
457    
458          class NetEnv {          class ResultDocument {
         private:  
                 int ok;  
459          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:  
460                  ESTRESDOC *rdoc;                  ESTRESDOC *rdoc;
461          public:                  ResultDocument(ESTRESDOC *_rdoc) {
462                  NodeDocument(ESTNODERES *nres, int index) {                          rdoc = _rdoc;
                         rdoc = est_noderes_get_doc(nres, index);  
463                  }                  }
464                  const char *uri(void) {                  const char *uri(void) {
465                          return est_resdoc_uri(rdoc);                          return est_resdoc_uri(rdoc);
# Line 499  namespace estraier { Line 485  namespace estraier {
485          private:          private:
486                  ESTNODERES *nres;                  ESTNODERES *nres;
487          public:          public:
488                  NodeRes(ESTNODE *node, ESTCOND *cond, int depth) {                  NodeRes(ESTNODE *node, Condition *cond, int depth) {
489                          nres = est_node_search(node, cond, depth);                          nres = est_node_search(node, cond->cond, depth);
490                  }                  }
491                  ~NodeRes() {                  ~NodeRes() {
492                          est_noderes_delete(nres);                          est_noderes_delete(nres);
# Line 518  namespace estraier { Line 504  namespace estraier {
504                  int doc_num(void) {                  int doc_num(void) {
505                          return est_noderes_doc_num(nres);                          return est_noderes_doc_num(nres);
506                  }                  }
507                  NodeDocument * get_doc(int index) {                  ResultDocument * get_doc(int index) {
508                          return new NodeDocument(nres, index);                          ESTRESDOC *rdoc = est_noderes_get_doc(nres, index);
509                            if (rdoc) {
510                                    return new ResultDocument(rdoc);
511                            } else {
512                                    throw IOError("wtf? no document?");
513                                    return NULL;
514                            }
515                  }                  }
516          };          };
517    
518          class Node {          class Node {
519          private:          private:
520                  ESTNODE *node;                  ESTNODE *node;
521                    int netenv_ok;
522          public:          public:
523                  Node(const char *url) {                  Node(const char *url) {
524                            netenv_ok = est_init_net_env();
525                            if (! netenv_ok) throw IOError("can't init net env");
526                          node = est_node_new(url);                          node = est_node_new(url);
527                          if (! node) throw IOError("can't create node");                          if (! node) throw IOError("can't create node");
528                  }                  }
529                  ~Node() {                  ~Node() {
530                          est_node_delete(node);                          est_node_delete(node);
531                            est_free_net_env();
532                  }                  }
533                  void set_proxy(const char *host, int port) {                  void set_proxy(const char *host, int port) {
534                          est_node_set_proxy(node, host, port);                          est_node_set_proxy(node, host, port);
# Line 603  namespace estraier { Line 599  namespace estraier {
599                  double size(void) {                  double size(void) {
600                          return est_node_size(node);                          return est_node_size(node);
601                  }                  }
602                  NodeRes * search(ESTCOND *cond, int depth) {                  NodeRes * search(Condition *cond, int depth) {
603                          return new NodeRes(node, cond, depth);                          return new NodeRes(node, cond, depth);
604                  }                  }
605                  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.12

  ViewVC Help
Powered by ViewVC 1.1.26