1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
|
//
// Collection.cc
//
// Collection: Specifies a list of databases to use in the search
//
// Part of the ht://Dig package <https://htdig.sourceforge.net/>
// Copyright (c) 1995-2004 The ht://Dig Group
// For copyright details, see the file COPYING in your distribution
// or the GNU Library General Public License (LGPL) version 2 or later
// <http://www.gnu.org/copyleft/lgpl.html>
//
// $Id: Collection.cc,v 1.7 2004/05/28 13:15:24 lha Exp $
//
#ifdef HAVE_CONFIG_H
#include "htconfig.h"
#endif /* HAVE_CONFIG_H */
#include "htsearch.h"
#include "Collection.h"
#include "ResultMatch.h"
#include "WeightWord.h"
#include "StringMatch.h"
#include "QuotedStringList.h"
#include "URL.h"
#include "HtURLCodec.h"
#ifdef HAVE_STD
#include <fstream>
#ifdef HAVE_NAMESPACES
using namespace std;
#endif
#else
#include <fstream.h>
#endif /* HAVE_STD */
#include <stdio.h>
#include <ctype.h>
#ifndef _MSC_VER /* _WIN32 */
#include <syslog.h>
#endif
#include <locale.h>
//*****************************************************************************
//
Collection::Collection(const char *name, const char *word_file,
const char *index_file, const char *doc_file,
const char *doc_excerpt)
{
collectionName = name;
wordFile = word_file;
indexFile = index_file;
docFile = doc_file;
docExcerpt = doc_excerpt;
matches = NULL;
searchWords = NULL;
searchWordsPattern = NULL;
isopen = 0;
}
Collection::~Collection()
{
if(matches) delete matches;
if(searchWords) delete searchWords;
if(searchWordsPattern) delete searchWordsPattern;
Close();
}
void
Collection::Open()
{
if (!isopen)
{
docDB.Read(docFile, indexFile, docExcerpt);
}
isopen = 1;
}
void
Collection::Close()
{
if (isopen)
{
docDB.Close();
}
isopen = 0;
}
DocumentRef *
Collection::getDocumentRef(int id)
{
Open();
return docDB[id];
}
int
Collection::ReadExcerpt(DocumentRef &ref)
{
Open();
return docDB.ReadExcerpt(ref);
}
|