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); |
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); |
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); |
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) { |