--- trunk/perl/HyperEstraierWrapper.cpp 2005/09/08 16:42:55 9 +++ trunk/perl/HyperEstraierWrapper.cpp 2005/09/10 08:22:04 17 @@ -455,25 +455,11 @@ return vs; } - class NetEnv { - private: - int ok; + class ResultDocument { public: - NetEnv() { - ok = est_init_net_env(); - if (! ok) throw IOError("can't init net env"); - } - ~NetEnv() { - est_free_net_env(); - } - }; - - class NodeDocument { - private: ESTRESDOC *rdoc; - public: - NodeDocument(ESTNODERES *nres, int index) { - rdoc = est_noderes_get_doc(nres, index); + ResultDocument(ESTRESDOC *_rdoc) { + rdoc = _rdoc; } const char *uri(void) { return est_resdoc_uri(rdoc); @@ -499,8 +485,8 @@ private: ESTNODERES *nres; public: - NodeRes(ESTNODE *node, ESTCOND *cond, int depth) { - nres = est_node_search(node, cond, depth); + NodeRes(ESTNODE *node, Condition *cond, int depth) { + nres = est_node_search(node, cond->cond, depth); } ~NodeRes() { est_noderes_delete(nres); @@ -518,21 +504,30 @@ int doc_num(void) { return est_noderes_doc_num(nres); } - NodeDocument * get_doc(int index) { - return new NodeDocument(nres, index); + ResultDocument * get_doc(int index) { + ESTRESDOC *rdoc = est_noderes_get_doc(nres, index); + if (rdoc) { + return new ResultDocument(rdoc); + } else { + return NULL; + } } }; class Node { private: ESTNODE *node; + int netenv_ok; public: Node(const char *url) { + netenv_ok = est_init_net_env(); + if (! netenv_ok) throw IOError("can't init net env"); node = est_node_new(url); if (! node) throw IOError("can't create node"); } ~Node() { est_node_delete(node); + est_free_net_env(); } void set_proxy(const char *host, int port) { est_node_set_proxy(node, host, port); @@ -603,7 +598,7 @@ double size(void) { return est_node_size(node); } - NodeRes * search(ESTCOND *cond, int depth) { + NodeRes * search(Condition *cond, int depth) { return new NodeRes(node, cond, depth); } int set_user(const char *name, int mode) {