/********************************************************************** * * mgppsearch.cpp -- * Copyright (C) 1999 The New Zealand Digital Library Project * * A component of the Greenstone digital library software * from the New Zealand Digital Library Project at the * University of Waikato, New Zealand. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * *********************************************************************/ #include "gsdlconf.h" #include "mgppsearch.h" #include "fileutil.h" #include "GSDLQueryParser.h" #include "MGQuery.h" #include "TextGet.h" #include "queryinfo.h" static text_t getindexsuffix(const queryparamclass &qp) { text_t indexsuffix = "index"; text_t ind = qp.index; text_t sub = qp.subcollection; text_t lang = qp.language; indexsuffix = filename_cat(indexsuffix, ind + sub + lang, qp.collection); return indexsuffix; } //////////////////// // mgppsearch class // //////////////////// mgppsearchclass::mgppsearchclass () : searchclass() { gdbm_level = "Document"; } mgppsearchclass::~mgppsearchclass () { if (cache != NULL) { delete cache; cache = NULL; } if (indexData !=NULL) { indexData->UnloadData(); delete indexData; indexData = NULL; } } void mgppsearchclass::set_gdbm_level(text_t &level) { gdbm_level = level; } bool mgppsearchclass::search(const queryparamclass &queryparams, queryresultsclass &queryresult) { #ifdef __WIN32__ char basepath[]=""; #else char basepath[] = "/"; #endif char *indexname = (filename_cat(collectdir, getindexsuffix(queryparams))).getcstr(); // load index data if (indexData == NULL) { indexData = new IndexData(); } if (!indexData->LoadData (basepath, indexname)) { cerr<<"couldn't load index data\n"<LoadData (basepath, indexname)) { cerr<<"couldn't load index data\n"<,
, tags // mg converts to unicode, this may need to be added here??? //clean up textdata.UnloadData (); delete textname; return true; } // used to clear any cached databases for persistent versions of // Greenstone like the Windows local library void mgppsearchclass::unload_database () { if (indexData !=NULL) { indexData->UnloadData(); } }