compactor.h   compactor.h 
skipping to change at line 26 skipping to change at line 26
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
* USA * USA
*/ */
#ifndef XAPIAN_INCLUDED_COMPACTOR_H #ifndef XAPIAN_INCLUDED_COMPACTOR_H
#define XAPIAN_INCLUDED_COMPACTOR_H #define XAPIAN_INCLUDED_COMPACTOR_H
#include <xapian/base.h> #include <xapian/intrusive_ptr.h>
#include <xapian/visibility.h> #include <xapian/visibility.h>
#include <string> #include <string>
namespace Xapian { namespace Xapian {
/** Compact a database, or merge and compact several. /** Compact a database, or merge and compact several.
*/ */
class XAPIAN_VISIBILITY_DEFAULT Compactor { class XAPIAN_VISIBILITY_DEFAULT Compactor {
public: public:
/// Class containing the implementation. /// Class containing the implementation.
class Internal; class Internal;
typedef enum { STANDARD, FULL, FULLER } compaction_level; typedef enum { STANDARD, FULL, FULLER } compaction_level;
private: private:
/// @internal Reference counted internals. /// @internal Reference counted internals.
Xapian::Internal::RefCntPtr<Internal> internal; Xapian::Internal::intrusive_ptr<Internal> internal;
public: public:
Compactor(); Compactor();
virtual ~Compactor(); virtual ~Compactor();
/** Set the block size to use for tables in the output database. /** Set the block size to use for tables in the output database.
* *
* @param block_size The block size to use. Valid block sizes ar e * @param block_size The block size to use. Valid block sizes ar e
* currently powers of two between 2048 and 655 36, * currently powers of two between 2048 and 655 36,
skipping to change at line 84 skipping to change at line 84
* *
* @param multipass If true and merging more than 3 databases, * @param multipass If true and merging more than 3 databases,
* merge the postlists in multiple passes, which is generally faster b ut * merge the postlists in multiple passes, which is generally faster b ut
* requires more disk space for temporary files. By default we don't do * requires more disk space for temporary files. By default we don't do
* this. * this.
*/ */
void set_multipass(bool multipass); void set_multipass(bool multipass);
/** Set the compaction level. /** Set the compaction level.
* *
* @param compaction Available values are: * @param compaction Available values are: - Xapian::Compactor::STANDA
* - Xapian::Compactor::STANDARD - Don't split items unnecessarily. RD -
* - Xapian::Compactor::FULL - Split items whenever it saves space * Don't split items unnecessarily. - Xapian::Compactor::FULL - S
* (the default). plit
* - Xapian::Compactor::FULLER - Allow oversize items to save more s * items whenever it saves space (the default). -
pace * Xapian::Compactor::FULLER - Allow oversize items to save more spa
* (not recommended if you ever plan to update the compacted databas ce
e). * (not recommended if you ever plan to update the compacted database)
.
*/ */
void set_compaction_level(compaction_level compaction); void set_compaction_level(compaction_level compaction);
/** Set where to write the output. /** Set where to write the output.
* *
* @param destdir Output path. This can be the same as an input if th at * @param destdir Output path. This can be the same as an input if th at
* input is a stub database (in which case the database (s) * input is a stub database (in which case the database (s)
* listed in the stub will be compacted to a new databa se * listed in the stub will be compacted to a new databa se
* and then the stub will be atomically updated to poin t * and then the stub will be atomically updated to poin t
* to this new database). * to this new database).
 End of changes. 3 change blocks. 
10 lines changed or deleted 11 lines changed or added


 database.h   database.h 
/** \file database.h /** @file database.h
* \brief API for working with Xapian databases * @brief API for working with Xapian databases
*/ */
/* Copyright 1999,2000,2001 BrightStation PLC /* Copyright 1999,2000,2001 BrightStation PLC
* Copyright 2002 Ananova Ltd * Copyright 2002 Ananova Ltd
* Copyright 2002,2003,2004,2005,2006,2007,2008,2009,2011 Olly Betts * Copyright 2002,2003,2004,2005,2006,2007,2008,2009,2011,2012 Olly Betts
* Copyright 2006,2008 Lemur Consulting Ltd * Copyright 2006,2008 Lemur Consulting Ltd
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the * published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version. * License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
skipping to change at line 28 skipping to change at line 28
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
* USA * USA
*/ */
#ifndef XAPIAN_INCLUDED_DATABASE_H #ifndef XAPIAN_INCLUDED_DATABASE_H
#define XAPIAN_INCLUDED_DATABASE_H #define XAPIAN_INCLUDED_DATABASE_H
#include <iosfwd>
#include <string> #include <string>
#include <vector> #include <vector>
#include <xapian/base.h> #include <xapian/intrusive_ptr.h>
#include <xapian/document.h>
#include <xapian/types.h> #include <xapian/types.h>
#include <xapian/positioniterator.h> #include <xapian/positioniterator.h>
#include <xapian/postingiterator.h> #include <xapian/postingiterator.h>
#include <xapian/termiterator.h> #include <xapian/termiterator.h>
#include <xapian/valueiterator.h> #include <xapian/valueiterator.h>
#include <xapian/visibility.h> #include <xapian/visibility.h>
namespace Xapian { namespace Xapian {
class Document;
/** This class is used to access a database, or a group of databases. /** This class is used to access a database, or a group of databases.
* *
* For searching, this class is used in conjunction with an Enquire object . * For searching, this class is used in conjunction with an Enquire object .
* *
* @exception InvalidArgumentError will be thrown if an invalid * @exception InvalidArgumentError will be thrown if an invalid
* argument is supplied, for example, an unknown database type. * argument is supplied, for example, an unknown database type.
* *
* @exception DatabaseOpeningError may be thrown if the database cannot * @exception DatabaseOpeningError may be thrown if the database cannot
* be opened (for example, a required file cannot be found). * be opened (for example, a required file cannot be found).
* *
* @exception DatabaseVersionError may be thrown if the database is in an * @exception DatabaseVersionError may be thrown if the database is in an
* unsupported format (for example, created by a newer version of Xapian * unsupported format (for example, created by a newer version of Xapian
* which uses an incompatible format). * which uses an incompatible format).
*/ */
class XAPIAN_VISIBILITY_DEFAULT Database { class XAPIAN_VISIBILITY_DEFAULT Database {
public: public:
class Internal; class Internal;
/// @private @internal Reference counted internals. /// @private @internal Reference counted internals.
std::vector<Xapian::Internal::RefCntPtr<Internal> > internal; std::vector<Xapian::Internal::intrusive_ptr<Internal> > internal;
/** @private @internal Get a document from the database, but doesn't /** @private @internal Get a document from the database, but doesn't
* need to check if it exists. * need to check if it exists.
* *
* This method returns a Xapian::Document object which provides the * This method returns a Xapian::Document object which provides the
* information about a document. If the document doesn't exist, * information about a document. If the document doesn't exist,
* either a NULL pointer may be returned, or the returned object wi ll * either a NULL pointer may be returned, or the returned object wi ll
* throw DocNotFoundError when you try to access it. * throw DocNotFoundError when you try to access it.
* *
* The caller should delete the returned object when it has finishe d * The caller should delete the returned object when it has finishe d
* with it. * with it.
* *
* The returned value is cast to void* to avoid needing to include
* xapian/document.h from here.
*
* @param did The document id of the document to retrieve. * @param did The document id of the document to retrieve.
* *
* @return Pointer to Document::Internal object. * @return Pointer to Document::Internal object cast to void*.
*/ */
Document::Internal * get_document_lazily(Xapian::docid did) const; void * get_document_lazily_(Xapian::docid did) const;
/** Add an existing database (or group of databases) to those /** Add an existing database (or group of databases) to those
* accessed by this object. * accessed by this object.
* *
* @param database the database(s) to add. * @param database the database(s) to add.
*/ */
void add_database(const Database & database); void add_database(const Database & database);
/** Create a Database with no databases in. /** Create a Database with no databases in.
*/ */
skipping to change at line 130 skipping to change at line 135
void operator=(const Database &other); void operator=(const Database &other);
/** Re-open the database. /** Re-open the database.
* *
* This re-opens the database(s) to the latest available version(s) . * This re-opens the database(s) to the latest available version(s) .
* It can be used either to make sure the latest results are return ed, * It can be used either to make sure the latest results are return ed,
* or to recover from a Xapian::DatabaseModifiedError. * or to recover from a Xapian::DatabaseModifiedError.
* *
* Calling reopen() on a database which has been closed (with @a * Calling reopen() on a database which has been closed (with @a
* close()) will always raise a Xapian::DatabaseError. * close()) will always raise a Xapian::DatabaseError.
*
* @return true if the database might have been reopened (if fa
lse
* is returned, the database definitely hasn't been
* reopened, which applications may find useful when
* caching results, etc). In Xapian < 1.3.0, this meth
od
* did not return a value.
*/ */
void reopen(); bool reopen();
/** Close the database. /** Close the database.
* *
* This closes the database and closes all its file handles. * This closes the database and closes all its file handles.
* *
* For a WritableDatabase, if a transaction is active it will be * For a WritableDatabase, if a transaction is active it will be
* aborted, while if no transaction is active commit() will be * aborted, while if no transaction is active commit() will be
* implicitly called. Also the write lock is released. * implicitly called. Also the write lock is released.
* *
* Closing a database cannot be undone - in particular, calling * Closing a database cannot be undone - in particular, calling
skipping to change at line 164 skipping to change at line 175
* cached) * cached)
* *
* - raise a Xapian::DatabaseError exception indicating that the * - raise a Xapian::DatabaseError exception indicating that the
* database is closed. * database is closed.
* *
* The reason for this behaviour is that otherwise we'd have to che ck * The reason for this behaviour is that otherwise we'd have to che ck
* that the database is still open on every method call on every * that the database is still open on every method call on every
* object associated with a Database, when in many cases they are * object associated with a Database, when in many cases they are
* working on data which has already been loaded and so they are ab le * working on data which has already been loaded and so they are ab le
* to just behave correctly. * to just behave correctly.
*
* This method was added in Xapian 1.1.0.
*/ */
virtual void close(); virtual void close();
/// Return a string describing this object. /// Return a string describing this object.
virtual std::string get_description() const; virtual std::string get_description() const;
/** An iterator pointing to the start of the postlist /** An iterator pointing to the start of the postlist
* for a given term. * for a given term.
* *
* @param tname The termname to iterate postings for. If th e * @param tname The termname to iterate postings for. If th e
skipping to change at line 331 skipping to change at line 340
/// Get an upper bound on the length of a document in this DB. /// Get an upper bound on the length of a document in this DB.
Xapian::termcount get_doclength_upper_bound() const; Xapian::termcount get_doclength_upper_bound() const;
/// Get an upper bound on the wdf of term @a term. /// Get an upper bound on the wdf of term @a term.
Xapian::termcount get_wdf_upper_bound(const std::string & term) cons t; Xapian::termcount get_wdf_upper_bound(const std::string & term) cons t;
/// Return an iterator over the value in slot @a slot for each docum ent. /// Return an iterator over the value in slot @a slot for each docum ent.
ValueIterator valuestream_begin(Xapian::valueno slot) const; ValueIterator valuestream_begin(Xapian::valueno slot) const;
/// Return end iterator corresponding to valuestream_begin(). /// Return end iterator corresponding to valuestream_begin().
ValueIteratorEnd_ valuestream_end(Xapian::valueno) const { ValueIterator valuestream_end(Xapian::valueno) const {
return ValueIteratorEnd_(); return ValueIterator();
} }
/// Get the length of a document. /// Get the length of a document.
Xapian::termcount get_doclength(Xapian::docid did) const; Xapian::termcount get_doclength(Xapian::docid did) const;
/** Send a "keep-alive" to remote databases to stop them timing out. /** Send a "keep-alive" to remote databases to stop them timing out.
* *
* Has no effect on non-remote databases. * Has no effect on non-remote databases.
*/ */
void keep_alive(); void keep_alive();
skipping to change at line 475 skipping to change at line 484
* the database files) will have the same UUID. However, copies (m ade * the database files) will have the same UUID. However, copies (m ade
* with copydatabase, or xapian-compact) will have different UUIDs. * with copydatabase, or xapian-compact) will have different UUIDs.
* *
* If the backend does not support UUIDs or this database has no * If the backend does not support UUIDs or this database has no
* subdatabases, the UUID will be empty. * subdatabases, the UUID will be empty.
* *
* If this database has multiple sub-databases, the UUID string wil l * If this database has multiple sub-databases, the UUID string wil l
* contain the UUIDs of all the sub-databases. * contain the UUIDs of all the sub-databases.
*/ */
std::string get_uuid() const; std::string get_uuid() const;
/** Check the integrity of a database or database table.
*
* This method is currently experimental, and may change incompatib
ly
* or possibly even be removed. Feedback on how well it works and
* how it might be improved are welcome.
*
* @param path Path to database or table
* @param opts Options to use for check
* @param out std::ostream to write output to
*/
static size_t check(const std::string & path, int opts,
std::ostream &out);
/** Check the integrity of a database or database table.
*
* This method is currently experimental, and may change incompatib
ly
* or possibly even be removed. Feedback on how well it works and
* how it might be improved are welcome.
*
* @param path Path to database or table
* @param opts Options to use for check
*/
static size_t check(const std::string & path, int opts);
}; };
/** This class provides read/write access to a database. /** This class provides read/write access to a database.
*/ */
class XAPIAN_VISIBILITY_DEFAULT WritableDatabase : public Database { class XAPIAN_VISIBILITY_DEFAULT WritableDatabase : public Database {
public: public:
/** Destroy this handle on the database. /** Destroy this handle on the database.
* *
* If no other handles to this database remain, the database will b e * If no other handles to this database remain, the database will b e
* closed. * closed.
skipping to change at line 936 skipping to change at line 969
/** Open for read/write; create if no db exists. */ /** Open for read/write; create if no db exists. */
const int DB_CREATE_OR_OPEN = 1; const int DB_CREATE_OR_OPEN = 1;
/** Create a new database; fail if db exists. */ /** Create a new database; fail if db exists. */
const int DB_CREATE = 2; const int DB_CREATE = 2;
/** Overwrite existing db; create if none exists. */ /** Overwrite existing db; create if none exists. */
const int DB_CREATE_OR_OVERWRITE = 3; const int DB_CREATE_OR_OVERWRITE = 3;
/** Open for read/write; fail if no db exists. */ /** Open for read/write; fail if no db exists. */
const int DB_OPEN = 4; const int DB_OPEN = 4;
/** Show a short-format display of the B-tree contents.
*
* For use with Xapian::Database::check().
*/
const int DBCHECK_SHORT_TREE = 1;
/** Show a full display of the B-tree contents.
*
* For use with Xapian::Database::check().
*/
const int DBCHECK_FULL_TREE = 2;
/** Show the bitmap for the B-tree.
*
* For use with Xapian::Database::check().
*/
const int DBCHECK_SHOW_BITMAP = 4;
/** Show statistics for the B-tree.
*
* For use with Xapian::Database::check().
*/
const int DBCHECK_SHOW_STATS = 8;
} }
#endif /* XAPIAN_INCLUDED_DATABASE_H */ #endif /* XAPIAN_INCLUDED_DATABASE_H */
 End of changes. 15 change blocks. 
13 lines changed or deleted 74 lines changed or added


 dbfactory.h   dbfactory.h 
/** \file dbfactory.h /** @file dbfactory.h
* \brief Factory functions for constructing Database and WritableDatabase * @brief Factory functions for constructing Database and WritableDatabase
objects objects
*/ */
/* Copyright (C) 2005,2006,2007,2008,2009 Olly Betts /* Copyright (C) 2005,2006,2007,2008,2009,2011 Olly Betts
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the * published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version. * License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
* USA * USA
*/ */
#ifndef XAPIAN_INCLUDED_DBFACTORY_H #ifndef XAPIAN_INCLUDED_DBFACTORY_H
#define XAPIAN_INCLUDED_DBFACTORY_H #define XAPIAN_INCLUDED_DBFACTORY_H
#ifndef _MSC_VER
# include <sys/types.h>
#endif
#include <string> #include <string>
#include <xapian/types.h> #include <xapian/types.h>
#include <xapian/version.h> #include <xapian/version.h>
#include <xapian/visibility.h> #include <xapian/visibility.h>
namespace Xapian { namespace Xapian {
#ifdef _MSC_VER
typedef unsigned useconds_t;
#endif
class Database; class Database;
class WritableDatabase; class WritableDatabase;
/// Database factory functions which determine the database type automatica lly. /// Database factory functions which determine the database type automatica lly.
namespace Auto { namespace Auto {
/** Construct a Database object for a stub database file. /** Construct a Database object for a stub database file.
* *
* The stub database file contains serialised parameters for one * The stub database file contains serialised parameters for one
* or more databases. * or more databases.
skipping to change at line 157 skipping to change at line 165
* 8192 bytes. This parameter is ignored when opening an * 8192 bytes. This parameter is ignored when opening an
* existing database. * existing database.
*/ */
XAPIAN_VISIBILITY_DEFAULT XAPIAN_VISIBILITY_DEFAULT
WritableDatabase WritableDatabase
open(const std::string &dir, int action, int block_size = 8192); open(const std::string &dir, int action, int block_size = 8192);
} }
#endif #endif
#ifdef XAPIAN_HAS_FLINT_BACKEND
/// Database factory functions for the flint backend.
namespace Flint {
/** Construct a Database object for read-only access to a Flint database.
*
* @param dir pathname of the directory containing the database.
*/
XAPIAN_VISIBILITY_DEFAULT
Database open(const std::string &dir);
/** Construct a Database object for update access to a Flint database.
*
* @param dir pathname of the directory containing the database.
* @param action determines handling of existing/non-existing databas
e:
* - Xapian::DB_CREATE fail if database already exi
st,
* otherwise create new database.
* - Xapian::DB_CREATE_OR_OPEN open existing database, or c
reate new
* database if none exists.
* - Xapian::DB_CREATE_OR_OVERWRITE overwrite existing database, or crea
te
* new database if none exists.
* - Xapian::DB_OPEN open existing database, failing if n
one
* exists.
* @param block_size the Btree blocksize to use (in bytes), which must be
a
* power of two between 2048 and 65536 (inclusive). Th
e
* default (also used if an invalid value if passed) is
* 8192 bytes. This parameter is ignored when opening
an
* existing database.
*/
XAPIAN_VISIBILITY_DEFAULT
WritableDatabase
open(const std::string &dir, int action, int block_size = 8192);
}
#endif
#ifdef XAPIAN_HAS_REMOTE_BACKEND #ifdef XAPIAN_HAS_REMOTE_BACKEND
/// Database factory functions for the remote backend. /// Database factory functions for the remote backend.
namespace Remote { namespace Remote {
/** Construct a Database object for read-only access to a remote database /** Construct a Database object for read-only access to a remote database
* accessed via a TCP connection. * accessed via a TCP connection.
* *
* Access to the remote database is via a TCP connection to the specified * Access to the remote database is via a TCP connection to the specified
* host and port. * host and port.
* *
skipping to change at line 217 skipping to change at line 189
* then Xapian::NetworkTimeoutError is thrown. A timeo ut * then Xapian::NetworkTimeoutError is thrown. A timeo ut
* of 0 means don't timeout. (Default is 10000ms, whic h * of 0 means don't timeout. (Default is 10000ms, whic h
* is 10 seconds). * is 10 seconds).
* @param connect_timeout timeout to use when connecting to the server . * @param connect_timeout timeout to use when connecting to the server .
* If this timeout is exceeded then * If this timeout is exceeded then
* Xapian::NetworkTimeoutError is thrown. A * Xapian::NetworkTimeoutError is thrown. A
* timeout of 0 means don't timeout. (Default is * timeout of 0 means don't timeout. (Default is
* 10000ms, which is 10 seconds). * 10000ms, which is 10 seconds).
*/ */
XAPIAN_VISIBILITY_DEFAULT XAPIAN_VISIBILITY_DEFAULT
Database open(const std::string &host, unsigned int port, Xapian::timeout t imeout = 10000, Xapian::timeout connect_timeout = 10000); Database open(const std::string &host, unsigned int port, useconds_t timeou t = 10000, useconds_t connect_timeout = 10000);
/** Construct a WritableDatabase object for update access to a remote datab ase /** Construct a WritableDatabase object for update access to a remote datab ase
* accessed via a TCP connection. * accessed via a TCP connection.
* *
* Access to the remote database is via a TCP connection to the specified * Access to the remote database is via a TCP connection to the specified
* host and port. * host and port.
* *
* @param host hostname to connect to. * @param host hostname to connect to.
* @param port port number to connect to. * @param port port number to connect to.
* @param timeout timeout in milliseconds. If this timeout is exceede d * @param timeout timeout in milliseconds. If this timeout is exceede d
* for any individual operation on the remote database * for any individual operation on the remote database
* then Xapian::NetworkTimeoutError is thrown. (Defaul t * then Xapian::NetworkTimeoutError is thrown. (Defaul t
* is 0, which means don't timeout). * is 0, which means don't timeout).
* @param connect_timeout timeout to use when connecting to the server . * @param connect_timeout timeout to use when connecting to the server .
* If this timeout is exceeded then * If this timeout is exceeded then
* Xapian::NetworkTimeoutError is thrown. A * Xapian::NetworkTimeoutError is thrown. A
* timeout of 0 means don't timeout. (Default is * timeout of 0 means don't timeout. (Default is
* 10000ms, which is 10 seconds). * 10000ms, which is 10 seconds).
*/ */
XAPIAN_VISIBILITY_DEFAULT XAPIAN_VISIBILITY_DEFAULT
WritableDatabase open_writable(const std::string &host, unsigned int port, Xapian::timeout timeout = 0, Xapian::timeout connect_timeout = 10000); WritableDatabase open_writable(const std::string &host, unsigned int port, useconds_t timeout = 0, useconds_t connect_timeout = 10000);
/** Construct a Database object for read-only access to a remote database /** Construct a Database object for read-only access to a remote database
* accessed via a program. * accessed via a program.
* *
* Access to the remote database is done by running an external program and * Access to the remote database is done by running an external program and
* communicating with it on stdin/stdout. * communicating with it on stdin/stdout.
* *
* @param program the external program to run. * @param program the external program to run.
* @param args space-separated list of arguments to pass to program . * @param args space-separated list of arguments to pass to program .
* @param timeout timeout in milliseconds. If this timeout is exceede d * @param timeout timeout in milliseconds. If this timeout is exceede d
* for any individual operation on the remote database * for any individual operation on the remote database
* then Xapian::NetworkTimeoutError is thrown. A timeo ut * then Xapian::NetworkTimeoutError is thrown. A timeo ut
* of 0 means don't timeout. (Default is 10000ms, whic h * of 0 means don't timeout. (Default is 10000ms, whic h
* is 10 seconds). * is 10 seconds).
*/ */
XAPIAN_VISIBILITY_DEFAULT XAPIAN_VISIBILITY_DEFAULT
Database open(const std::string &program, const std::string &args, Xapian:: timeout timeout = 10000); Database open(const std::string &program, const std::string &args, useconds _t timeout = 10000);
/** Construct a WritableDatabase object for update access to a remote datab ase /** Construct a WritableDatabase object for update access to a remote datab ase
* accessed via a program. * accessed via a program.
* *
* Access to the remote database is done by running an external program and * Access to the remote database is done by running an external program and
* communicating with it on stdin/stdout. * communicating with it on stdin/stdout.
* *
* @param program the external program to run. * @param program the external program to run.
* @param args space-separated list of arguments to pass to program . * @param args space-separated list of arguments to pass to program .
* @param timeout timeout in milliseconds. If this timeout is exceede d * @param timeout timeout in milliseconds. If this timeout is exceede d
* for any individual operation on the remote database * for any individual operation on the remote database
* then Xapian::NetworkTimeoutError is thrown. (Defaul t * then Xapian::NetworkTimeoutError is thrown. (Defaul t
* is 0, which means don't timeout). * is 0, which means don't timeout).
*/ */
XAPIAN_VISIBILITY_DEFAULT XAPIAN_VISIBILITY_DEFAULT
WritableDatabase open_writable(const std::string &program, const std::strin g &args, Xapian::timeout timeout = 0); WritableDatabase open_writable(const std::string &program, const std::strin g &args, useconds_t timeout = 0);
} }
#endif #endif
} }
#endif /* XAPIAN_INCLUDED_DBFACTORY_H */ #endif /* XAPIAN_INCLUDED_DBFACTORY_H */
 End of changes. 9 change blocks. 
52 lines changed or deleted 16 lines changed or added


 document.h   document.h 
/** \file document.h /** @file document.h
* \brief API for working with documents * @brief API for working with documents
*/ */
/* Copyright 1999,2000,2001 BrightStation PLC /* Copyright 1999,2000,2001 BrightStation PLC
* Copyright 2002 Ananova Ltd * Copyright 2002 Ananova Ltd
* Copyright 2002,2003,2004,2006,2007,2009,2010 Olly Betts * Copyright 2002,2003,2004,2006,2007,2009,2010,2011 Olly Betts
* Copyright 2009 Lemur Consulting Ltd * Copyright 2009 Lemur Consulting Ltd
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the * published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version. * License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
skipping to change at line 30 skipping to change at line 30
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
* USA * USA
*/ */
#ifndef XAPIAN_INCLUDED_DOCUMENT_H #ifndef XAPIAN_INCLUDED_DOCUMENT_H
#define XAPIAN_INCLUDED_DOCUMENT_H #define XAPIAN_INCLUDED_DOCUMENT_H
#include <string> #include <string>
#include <xapian/base.h> #include <xapian/intrusive_ptr.h>
#include <xapian/types.h> #include <xapian/types.h>
#include <xapian/termiterator.h> #include <xapian/termiterator.h>
#include <xapian/valueiterator.h> #include <xapian/valueiterator.h>
#include <xapian/visibility.h> #include <xapian/visibility.h>
namespace Xapian { namespace Xapian {
/** A handle representing a document in a Xapian database. /** A handle representing a document in a Xapian database.
* *
* The Document class fetches information from the database lazily. Usual ly * The Document class fetches information from the database lazily. Usual ly
skipping to change at line 60 skipping to change at line 60
* We recommend you avoid designs where this behaviour is an issue, but if * We recommend you avoid designs where this behaviour is an issue, but if
* you need a way to make a non-lazy version of a Document object, you can do * you need a way to make a non-lazy version of a Document object, you can do
* this like so: * this like so:
* *
* doc = Xapian::Document::unserialise(doc.serialise()); * doc = Xapian::Document::unserialise(doc.serialise());
*/ */
class XAPIAN_VISIBILITY_DEFAULT Document { class XAPIAN_VISIBILITY_DEFAULT Document {
public: public:
class Internal; class Internal;
/// @private @internal Reference counted internals. /// @private @internal Reference counted internals.
Xapian::Internal::RefCntPtr<Internal> internal; Xapian::Internal::intrusive_ptr<Internal> internal;
/** @private @internal Constructor is only used by internal classes. /** @private @internal Constructor is only used by internal classes.
* *
* @param internal_ pointer to internal opaque class * @param internal_ pointer to internal opaque class
*/ */
explicit Document(Internal *internal_); explicit Document(Internal *internal_);
/** Copying is allowed. The internals are reference counted, so /** Copying is allowed. The internals are reference counted, so
* copying is cheap. * copying is cheap.
* *
skipping to change at line 235 skipping to change at line 235
return TermIterator(); return TermIterator();
} }
/// Count the values in this document. /// Count the values in this document.
Xapian::termcount values_count() const; Xapian::termcount values_count() const;
/// Iterator for the values in this document. /// Iterator for the values in this document.
ValueIterator values_begin() const; ValueIterator values_begin() const;
/// Equivalent end iterator for values_begin(). /// Equivalent end iterator for values_begin().
ValueIteratorEnd_ values_end() const { ValueIterator values_end() const {
return ValueIteratorEnd_(); return ValueIterator();
} }
/** Get the document id which is associated with this document (if a ny). /** Get the document id which is associated with this document (if a ny).
* *
* NB If multiple databases are being searched together, then this * NB If multiple databases are being searched together, then this
* will be the document id in the individual database, not the merg ed * will be the document id in the individual database, not the merg ed
* database! * database!
* *
* @return If this document came from a database, return the docume nt * @return If this document came from a database, return the docume nt
* id in that database. Otherwise, return 0 (in Xapian * id in that database. Otherwise, return 0 (in Xapian
 End of changes. 5 change blocks. 
7 lines changed or deleted 7 lines changed or added


 enquire.h   enquire.h 
/** \file enquire.h /** @file enquire.h
* \brief API for running queries * @brief API for running queries
*/ */
/* Copyright 1999,2000,2001 BrightStation PLC /* Copyright 1999,2000,2001 BrightStation PLC
* Copyright 2001,2002 Ananova Ltd * Copyright 2001,2002 Ananova Ltd
* Copyright 2002,2003,2004,2005,2006,2007,2008,2009,2011 Olly Betts * Copyright 2002,2003,2004,2005,2006,2007,2008,2009,2011 Olly Betts
* Copyright 2009 Lemur Consulting Ltd * Copyright 2009 Lemur Consulting Ltd
* Copyright 2011 Action Without Borders * Copyright 2011 Action Without Borders
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the * published by the Free Software Foundation; either version 2 of the
skipping to change at line 31 skipping to change at line 31
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
* USA * USA
*/ */
#ifndef XAPIAN_INCLUDED_ENQUIRE_H #ifndef XAPIAN_INCLUDED_ENQUIRE_H
#define XAPIAN_INCLUDED_ENQUIRE_H #define XAPIAN_INCLUDED_ENQUIRE_H
#include <string> #include <string>
#include <xapian/base.h> #include <xapian/intrusive_ptr.h>
#include <xapian/deprecated.h>
#include <xapian/keymaker.h>
#include <xapian/types.h> #include <xapian/types.h>
#include <xapian/termiterator.h> #include <xapian/termiterator.h>
#include <xapian/visibility.h> #include <xapian/visibility.h>
namespace Xapian { namespace Xapian {
class Database; class Database;
class Document; class Document;
class ErrorHandler; class ErrorHandler;
class ExpandDecider; class ExpandDecider;
class KeyMaker;
class MatchSpy; class MatchSpy;
class MSetIterator; class MSetIterator;
class Query; class Query;
class Weight; class Weight;
/** A match set (MSet). /** A match set (MSet).
* This class represents (a portion of) the results of a query. * This class represents (a portion of) the results of a query.
*/ */
class XAPIAN_VISIBILITY_DEFAULT MSet { class XAPIAN_VISIBILITY_DEFAULT MSet {
public: public:
class Internal; class Internal;
/// @private @internal Reference counted internals. /// @internal Reference counted internals.
Xapian::Internal::RefCntPtr<Internal> internal; Xapian::Internal::intrusive_ptr<Internal> internal;
/// @private @internal Constructor for internal use. /// @internal Constructor for internal use.
explicit MSet(MSet::Internal * internal_); explicit MSet(Internal * internal_);
/// Create an empty Xapian::MSet. /// Create an empty Xapian::MSet.
MSet(); MSet();
/// Destroy a Xapian::MSet. /// Destroy a Xapian::MSet.
~MSet(); ~MSet();
/// Copying is allowed (and is cheap). /// Copying is allowed (and is cheap).
MSet(const MSet & other); MSet(const MSet & other);
skipping to change at line 104 skipping to change at line 103
/** Fetch all the items in the MSet. /** Fetch all the items in the MSet.
*/ */
void fetch() const; void fetch() const;
/** This converts the weight supplied to a percentage score. /** This converts the weight supplied to a percentage score.
* The return value will be in the range 0 to 100, and will be 0 if * The return value will be in the range 0 to 100, and will be 0 if
* and only if the item did not match the query at all. * and only if the item did not match the query at all.
* *
* @param wt The weight to convert. * @param wt The weight to convert.
*/ */
Xapian::percent convert_to_percent(Xapian::weight wt) const; int convert_to_percent(double wt) const;
/// Return the percentage score for a particular item. /// Return the percentage score for a particular item.
Xapian::percent convert_to_percent(const MSetIterator &it) const; int convert_to_percent(const MSetIterator &it) const;
/** Return the term frequency of the given query term. /** Return the term frequency of the given query term.
* *
* @param tname The term to look for. * @param tname The term to look for.
* *
* This is sometimes more efficient than asking the database direct ly * This is sometimes more efficient than asking the database direct ly
* for the term frequency - in particular, if the term was in the * for the term frequency - in particular, if the term was in the
* query, its frequency will usually be cached in the MSet. * query, its frequency will usually be cached in the MSet.
*/ */
Xapian::doccount get_termfreq(const std::string &tname) const; Xapian::doccount get_termfreq(const std::string &tname) const;
/** Return the term weight of the given query term. /** Return the term weight of the given query term.
* *
* @param tname The term to look for. * @param tname The term to look for.
* *
* @exception Xapian::InvalidArgumentError is thrown if the term w as * @exception Xapian::InvalidArgumentError is thrown if the term w as
* not in the query. * not in the query.
*/ */
Xapian::weight get_termweight(const std::string &tname) const; double get_termweight(const std::string &tname) const;
/** The index of the first item in the result which was put into the /** The index of the first item in the result which was put into the
* MSet. * MSet.
* *
* This corresponds to the parameter "first" specified in * This corresponds to the parameter "first" specified in
* Xapian::Enquire::get_mset(). A value of 0 corresponds to the * Xapian::Enquire::get_mset(). A value of 0 corresponds to the
* highest result being the first item in the MSet. * highest result being the first item in the MSet.
*/ */
Xapian::doccount get_firstitem() const; Xapian::doccount get_firstitem() const;
skipping to change at line 194 skipping to change at line 193
* would match the query if collapsing wasn't used. * would match the query if collapsing wasn't used.
*/ */
Xapian::doccount get_uncollapsed_matches_upper_bound() const; Xapian::doccount get_uncollapsed_matches_upper_bound() const;
/** The maximum possible weight in the MSet. /** The maximum possible weight in the MSet.
* *
* This weight is likely not to be attained in the set of results, * This weight is likely not to be attained in the set of results,
* but represents an upper bound on the weight which a document * but represents an upper bound on the weight which a document
* could attain for the given query. * could attain for the given query.
*/ */
Xapian::weight get_max_possible() const; double get_max_possible() const;
/** The greatest weight which is attained by any document in the /** The greatest weight which is attained by any document in the
* database. * database.
* *
* If firstitem == 0 and the primary ordering is by relevance, this is * If firstitem == 0 and the primary ordering is by relevance, this is
* the weight of the first entry in the MSet. * the weight of the first entry in the MSet.
* *
* If no documents are found by the query, this will be 0. * If no documents are found by the query, this will be 0.
* *
* Note that calculation of max_attained requires calculation * Note that calculation of max_attained requires calculation
* of at least one result item - therefore, if no items were * of at least one result item - therefore, if no items were
* requested when the query was performed (by specifying * requested when the query was performed (by specifying
* maxitems = 0 in Xapian::Enquire::get_mset()), this value will be 0. * maxitems = 0 in Xapian::Enquire::get_mset()), this value will be 0.
*/ */
Xapian::weight get_max_attained() const; double get_max_attained() const;
/** The number of items in this MSet */ /** The number of items in this MSet */
Xapian::doccount size() const; Xapian::doccount size() const;
/** Required to allow use as an STL container. */ /** Required to allow use as an STL container. */
Xapian::doccount max_size() const { return size(); } Xapian::doccount max_size() const { return size(); }
/** Test if this MSet is empty */ /** Test if this MSet is empty */
bool empty() const; bool empty() const;
skipping to change at line 352 skipping to change at line 351
* *
* The rank is the position that this document is at in the ordered * The rank is the position that this document is at in the ordered
* list of results of the query. The result is 0-based - i.e. the * list of results of the query. The result is 0-based - i.e. the
* top-ranked document has a rank of 0. * top-ranked document has a rank of 0.
*/ */
Xapian::doccount get_rank() const { Xapian::doccount get_rank() const {
return mset.get_firstitem() + index; return mset.get_firstitem() + index;
} }
/// Get the weight of the document at the current position /// Get the weight of the document at the current position
Xapian::weight get_weight() const; double get_weight() const;
/** Get the collapse key for this document. /** Get the collapse key for this document.
*/ */
std::string get_collapse_key() const; std::string get_collapse_key() const;
/** Get an estimate of the number of documents that have been collap sed /** Get an estimate of the number of documents that have been collap sed
* into this one. * into this one.
* *
* The estimate will always be less than or equal to the actual * The estimate will always be less than or equal to the actual
* number of other documents satisfying the match criteria with the * number of other documents satisfying the match criteria with the
skipping to change at line 378 skipping to change at line 377
* documents. So this method may be used to inform the user that * documents. So this method may be used to inform the user that
* there are "at least N other matches in this group", or to contro l * there are "at least N other matches in this group", or to contro l
* whether to offer a "show other documents in this group" feature * whether to offer a "show other documents in this group" feature
* (but note that it may not offer it in every case where it would * (but note that it may not offer it in every case where it would
* show other documents). * show other documents).
*/ */
Xapian::doccount get_collapse_count() const; Xapian::doccount get_collapse_count() const;
/** This returns the weight of the document as a percentage score. /** This returns the weight of the document as a percentage score.
* *
* You probably don't want to show these percentage scores to end
* users in new applications - they're not really a percentage of
* anything meaningful, and research seems to suggest that users
* don't find numeric scores in search results useful.
*
* The return value will be an integer in the range 0 to 100: 0 * The return value will be an integer in the range 0 to 100: 0
* meaning that the item did not match the query at all. * meaning that the item did not match the query at all.
* *
* The intention is that the highest weighted document will get 100 * The intention is that the highest weighted document will get 100
* if it matches all the weight-contributing terms in the query. * if it matches all the weight-contributing terms in the query.
* However, currently it may get a lower percentage score if you * However, currently it may get a lower percentage score if you
* use a MatchDecider and the sorting is primarily by value. * use a MatchDecider and the sorting is primarily by value.
* In this case, the percentage for a particular document may vary * In this case, the percentage for a particular document may vary
* depending on the first, max_size, and checkatleast parameters * depending on the first, max_size, and checkatleast parameters
* passed to Enquire::get_mset() (this bug is hard to fix without * passed to Enquire::get_mset() (this bug is hard to fix without
* having to apply the MatchDecider to potentially many more * having to apply the MatchDecider to potentially many more
* documents, which is potentially costly). * documents, which is potentially costly).
*/ */
Xapian::percent get_percent() const; int get_percent() const;
/// Return a string describing this object. /// Return a string describing this object.
std::string get_description() const; std::string get_description() const;
/// Allow use as an STL iterator /// Allow use as an STL iterator
//@{ //@{
typedef std::bidirectional_iterator_tag iterator_category; // FIXME: could enhance to be a randomaccess_iterator typedef std::bidirectional_iterator_tag iterator_category; // FIXME: could enhance to be a randomaccess_iterator
typedef Xapian::docid value_type; typedef Xapian::docid value_type;
typedef Xapian::doccount_diff difference_type; typedef Xapian::doccount_diff difference_type;
typedef Xapian::docid * pointer; typedef Xapian::docid * pointer;
skipping to change at line 427 skipping to change at line 431
class ESetIterator; class ESetIterator;
/** Class representing an ordered set of expand terms (an ESet). /** Class representing an ordered set of expand terms (an ESet).
* This set represents the results of an expand operation, which is * This set represents the results of an expand operation, which is
* performed by Xapian::Enquire::get_eset(). * performed by Xapian::Enquire::get_eset().
*/ */
class XAPIAN_VISIBILITY_DEFAULT ESet { class XAPIAN_VISIBILITY_DEFAULT ESet {
public: public:
class Internal; class Internal;
/// @private @internal Reference counted internals. /// @internal Reference counted internals.
Xapian::Internal::RefCntPtr<Internal> internal; Xapian::Internal::intrusive_ptr<Internal> internal;
/// Construct an empty ESet /// Construct an empty ESet
ESet(); ESet();
/// Destructor. /// Destructor.
~ESet(); ~ESet();
/// Copying is allowed (and is cheap). /// Copying is allowed (and is cheap).
ESet(const ESet & other); ESet(const ESet & other);
skipping to change at line 540 skipping to change at line 544
ESetIterator operator--(int) { ESetIterator operator--(int) {
ESetIterator tmp = *this; ESetIterator tmp = *this;
--index; --index;
return tmp; return tmp;
} }
/// Get the term for the current position /// Get the term for the current position
const std::string & operator *() const; const std::string & operator *() const;
/// Get the weight of the term at the current position /// Get the weight of the term at the current position
Xapian::weight get_weight() const; double get_weight() const;
/// Return a string describing this object. /// Return a string describing this object.
std::string get_description() const; std::string get_description() const;
/// Allow use as an STL iterator /// Allow use as an STL iterator
//@{ //@{
typedef std::bidirectional_iterator_tag iterator_category; // FIXME: go for randomaccess_iterator! typedef std::bidirectional_iterator_tag iterator_category; // FIXME: go for randomaccess_iterator!
typedef std::string value_type; typedef std::string value_type;
typedef Xapian::termcount_diff difference_type; typedef Xapian::termcount_diff difference_type;
typedef std::string * pointer; typedef std::string * pointer;
skipping to change at line 576 skipping to change at line 580
/** A relevance set (R-Set). /** A relevance set (R-Set).
* This is the set of documents which are marked as relevant, for use * This is the set of documents which are marked as relevant, for use
* in modifying the term weights, and in performing query expansion. * in modifying the term weights, and in performing query expansion.
*/ */
class XAPIAN_VISIBILITY_DEFAULT RSet { class XAPIAN_VISIBILITY_DEFAULT RSet {
public: public:
/// Class holding details of RSet /// Class holding details of RSet
class Internal; class Internal;
/// @private @internal Reference counted internals. /// @internal Reference counted internals.
Xapian::Internal::RefCntPtr<Internal> internal; Xapian::Internal::intrusive_ptr<Internal> internal;
/// Copy constructor /// Copy constructor
RSet(const RSet &rset); RSet(const RSet &rset);
/// Assignment operator /// Assignment operator
void operator=(const RSet &rset); void operator=(const RSet &rset);
/// Default constructor /// Default constructor
RSet(); RSet();
skipping to change at line 655 skipping to change at line 659
*/ */
class XAPIAN_VISIBILITY_DEFAULT Enquire { class XAPIAN_VISIBILITY_DEFAULT Enquire {
public: public:
/// Copying is allowed (and is cheap). /// Copying is allowed (and is cheap).
Enquire(const Enquire & other); Enquire(const Enquire & other);
/// Assignment is allowed (and is cheap). /// Assignment is allowed (and is cheap).
void operator=(const Enquire & other); void operator=(const Enquire & other);
class Internal; class Internal;
/// @private @internal Reference counted internals. /// @internal Reference counted internals.
Xapian::Internal::RefCntPtr<Internal> internal; Xapian::Internal::intrusive_ptr<Internal> internal;
/** Create a Xapian::Enquire object. /** Create a Xapian::Enquire object.
* *
* This specification cannot be changed once the Xapian::Enquire is * This specification cannot be changed once the Xapian::Enquire is
* opened: you must create a new Xapian::Enquire object to access a * opened: you must create a new Xapian::Enquire object to access a
* different database, or set of databases. * different database, or set of databases.
* *
* The database supplied must have been initialised (ie, must not b e * The database supplied must have been initialised (ie, must not b e
* the result of calling the Database::Database() constructor). If * the result of calling the Database::Database() constructor). If
* you need to handle a situation where you have no index gracefull y, * you need to handle a situation where you have no index gracefull y,
skipping to change at line 823 skipping to change at line 827
* (default 0 => no percentage cut-off). * (default 0 => no percentage cut-off).
* @param weight_cutoff Minimum weight for a document to be returned . * @param weight_cutoff Minimum weight for a document to be returned .
* If a document has a lower score that this, it will not appea r * If a document has a lower score that this, it will not appea r
* in the MSet. It is usually only possible to choose an * in the MSet. It is usually only possible to choose an
* appropriate weight for cutoff based on the results of a * appropriate weight for cutoff based on the results of a
* previous run of the same query; this is thus mainly useful f or * previous run of the same query; this is thus mainly useful f or
* alerting operations. The other potential use is with a user * alerting operations. The other potential use is with a user
* specified weighting scheme. * specified weighting scheme.
* (default 0 => no weight cut-off). * (default 0 => no weight cut-off).
*/ */
void set_cutoff(Xapian::percent percent_cutoff, Xapian::weight weigh t_cutoff = 0); void set_cutoff(int percent_cutoff, double weight_cutoff = 0);
/** Set the sorting to be by relevance only. /** Set the sorting to be by relevance only.
* *
* This is the default. * This is the default.
*/ */
void set_sort_by_relevance(); void set_sort_by_relevance();
/** Set the sorting to be by value only. /** Set the sorting to be by value only.
* *
* Note that sorting by values uses a string comparison, so to use * Note that sorting by values uses a string comparison, so to use
skipping to change at line 846 skipping to change at line 850
* could use Xapian::sortable_serialise() (which works for floating * could use Xapian::sortable_serialise() (which works for floating
* point numbers as well as integers), or store numbers padded with * point numbers as well as integers), or store numbers padded with
* leading zeros or spaces, or with the number of digits prepended. * leading zeros or spaces, or with the number of digits prepended.
* *
* @param sort_key value number to sort on. * @param sort_key value number to sort on.
* *
* @param reverse If true, reverses the sort order. * @param reverse If true, reverses the sort order.
*/ */
void set_sort_by_value(Xapian::valueno sort_key, bool reverse); void set_sort_by_value(Xapian::valueno sort_key, bool reverse);
XAPIAN_DEPRECATED(void set_sort_by_value(Xapian::valueno sort_key));
/** Set the sorting to be by key generated from values only. /** Set the sorting to be by key generated from values only.
* *
* @param sorter The functor to use for generating keys. * @param sorter The functor to use for generating keys.
* *
* @param reverse If true, reverses the sort order. * @param reverse If true, reverses the sort order.
*/ */
void set_sort_by_key(Xapian::KeyMaker * sorter, bool reverse); void set_sort_by_key(Xapian::KeyMaker * sorter, bool reverse);
XAPIAN_DEPRECATED(void set_sort_by_key(Xapian::KeyMaker * sorter));
/** Set the sorting to be by value, then by relevance for documents /** Set the sorting to be by value, then by relevance for documents
* with the same value. * with the same value.
* *
* Note that sorting by values uses a string comparison, so to use * Note that sorting by values uses a string comparison, so to use
* this to sort by a numeric value you'll need to store the numeric * this to sort by a numeric value you'll need to store the numeric
* values in a manner which sorts appropriately. For example, you * values in a manner which sorts appropriately. For example, you
* could use Xapian::sortable_serialise() (which works for floating * could use Xapian::sortable_serialise() (which works for floating
* point numbers as well as integers), or store numbers padded with * point numbers as well as integers), or store numbers padded with
* leading zeros or spaces, or with the number of digits prepended. * leading zeros or spaces, or with the number of digits prepended.
* *
* @param sort_key value number to sort on. * @param sort_key value number to sort on.
* *
* @param reverse If true, reverses the sort order. * @param reverse If true, reverses the sort order.
*/ */
void set_sort_by_value_then_relevance(Xapian::valueno sort_key, void set_sort_by_value_then_relevance(Xapian::valueno sort_key,
bool reverse); bool reverse);
XAPIAN_DEPRECATED(void set_sort_by_value_then_relevance(Xapian::valu
eno sort_key));
/** Set the sorting to be by keys generated from values, then by /** Set the sorting to be by keys generated from values, then by
* relevance for documents with identical keys. * relevance for documents with identical keys.
* *
* @param sorter The functor to use for generating keys. * @param sorter The functor to use for generating keys.
* *
* @param reverse If true, reverses the sort order. * @param reverse If true, reverses the sort order.
*/ */
void set_sort_by_key_then_relevance(Xapian::KeyMaker * sorter, void set_sort_by_key_then_relevance(Xapian::KeyMaker * sorter,
bool reverse); bool reverse);
XAPIAN_DEPRECATED(void set_sort_by_key_then_relevance(Xapian::KeyMak
er * sorter));
/** Set the sorting to be by relevance then value. /** Set the sorting to be by relevance then value.
* *
* Note that sorting by values uses a string comparison, so to use * Note that sorting by values uses a string comparison, so to use
* this to sort by a numeric value you'll need to store the numeric * this to sort by a numeric value you'll need to store the numeric
* values in a manner which sorts appropriately. For example, you * values in a manner which sorts appropriately. For example, you
* could use Xapian::sortable_serialise() (which works for floating * could use Xapian::sortable_serialise() (which works for floating
* point numbers as well as integers), or store numbers padded with * point numbers as well as integers), or store numbers padded with
* leading zeros or spaces, or with the number of digits prepended. * leading zeros or spaces, or with the number of digits prepended.
* *
* Note that with the default BM25 weighting scheme parameters, * Note that with the default BM25 weighting scheme parameters,
* non-identical documents will rarely have the same weight, so * non-identical documents will rarely have the same weight, so
* this setting will give very similar results to * this setting will give very similar results to
* set_sort_by_relevance(). It becomes more useful with particular * set_sort_by_relevance(). It becomes more useful with particular
* BM25 parameter settings (e.g. BM25Weight(1,0,1,0,0)) or custom * BM25 parameter settings (e.g. BM25Weight(1,0,1,0,0)) or custom
* weighting schemes. * weighting schemes.
* *
* @param sort_key value number to sort on. * @param sort_key value number to sort on.
* *
* @param reverse If true, reverses the sort order of sort_key. * @param reverse If true, reverses the sort order.
* Beware that in 1.2.16 and earlier, the sense
* of this parameter was incorrectly inverted
* and inconsistent with the other set_sort_by_...
* methods. This was fixed in 1.2.17, so make that
* version a minimum requirement if this detail
* matters to your application.
*/ */
void set_sort_by_relevance_then_value(Xapian::valueno sort_key, void set_sort_by_relevance_then_value(Xapian::valueno sort_key,
bool reverse); bool reverse);
XAPIAN_DEPRECATED(void set_sort_by_relevance_then_value(Xapian::valu
eno sort_key));
/** Set the sorting to be by relevance, then by keys generated from /** Set the sorting to be by relevance, then by keys generated from
* values. * values.
* *
* Note that with the default BM25 weighting scheme parameters, * Note that with the default BM25 weighting scheme parameters,
* non-identical documents will rarely have the same weight, so * non-identical documents will rarely have the same weight, so
* this setting will give very similar results to * this setting will give very similar results to
* set_sort_by_relevance(). It becomes more useful with particular * set_sort_by_relevance(). It becomes more useful with particular
* BM25 parameter settings (e.g. BM25Weight(1,0,1,0,0)) or custom * BM25 parameter settings (e.g. BM25Weight(1,0,1,0,0)) or custom
* weighting schemes. * weighting schemes.
* *
* @param sorter The functor to use for generating keys. * @param sorter The functor to use for generating keys.
* *
* @param reverse If true, reverses the sort order of the generate * @param reverse If true, reverses the sort order.
d
* keys. Beware that in 1.2.16 and earlier, the se
nse
* of this parameter was incorrectly inverted
* and inconsistent with the other set_sort_by_...
* methods. This was fixed in 1.2.17, so make that
* version a minimum requirement if this detail
* matters to your application.
*/ */
void set_sort_by_relevance_then_key(Xapian::KeyMaker * sorter, void set_sort_by_relevance_then_key(Xapian::KeyMaker * sorter,
bool reverse); bool reverse);
XAPIAN_DEPRECATED(void set_sort_by_relevance_then_key(Xapian::KeyMak
er * sorter));
/** Get (a portion of) the match set for the current query. /** Get (a portion of) the match set for the current query.
* *
* @param first the first item in the result set to return. * @param first the first item in the result set to return.
* A value of zero corresponds to the first item * A value of zero corresponds to the first item
* returned being that with the highest score. * returned being that with the highest score.
* A value of 10 corresponds to the first 10 items * A value of 10 corresponds to the first 10 items
* being ignored, and the returned items starting * being ignored, and the returned items starting
* at the eleventh. * at the eleventh.
* @param maxitems the maximum number of items to return. If you * @param maxitems the maximum number of items to return. If you
* want all matches, then you can pass the result * want all matches, then you can pass the result
skipping to change at line 975 skipping to change at line 955
* looser. * looser.
* @param checkatleast the minimum number of items to check. Beca use * @param checkatleast the minimum number of items to check. Beca use
* the matcher optimises, it won't consider every * the matcher optimises, it won't consider every
* document which might match, so the total number * document which might match, so the total number
* of matches is estimated. Setting checkatleast * of matches is estimated. Setting checkatleast
* forces it to consider at least this many matche s * forces it to consider at least this many matche s
* and so allows for reliable paging links. * and so allows for reliable paging links.
* @param omrset the relevance set to use when performing the qu ery. * @param omrset the relevance set to use when performing the qu ery.
* @param mdecider a decision functor to use to decide whether a * @param mdecider a decision functor to use to decide whether a
* given document should be put in the MSet. * given document should be put in the MSet.
* @param matchspy a decision functor to use to decide whether a
* given document should be put in the MSet. The
* matchspy is applied to every document which is
* a potential candidate for the MSet, so if there
are
* checkatleast or more such documents, the matchs
py
* will see at least checkatleast. The mdecider i
s
* assumed to be a relatively expensive test so ma
y
* be applied in a lazier fashion.
*
* @deprecated The matchspy parameter is deprecated - use the
* newer MatchSpy class and add_matchspy() method
* instead.
* *
* @return A Xapian::MSet object containing the results of the * @return A Xapian::MSet object containing the results of the
* query. * query.
* *
* @exception Xapian::InvalidArgumentError See class documentation . * @exception Xapian::InvalidArgumentError See class documentation .
* *
* @{ * @{
*/ */
XAPIAN_DEPRECATED(
MSet get_mset(Xapian::doccount first, Xapian::doccount maxitems,
Xapian::doccount checkatleast,
const RSet * omrset,
const MatchDecider * mdecider,
const MatchDecider * matchspy) const);
MSet get_mset(Xapian::doccount first, Xapian::doccount maxitems, MSet get_mset(Xapian::doccount first, Xapian::doccount maxitems,
Xapian::doccount checkatleast = 0, Xapian::doccount checkatleast = 0,
const RSet * omrset = 0, const RSet * omrset = 0,
const MatchDecider * mdecider = 0) const; const MatchDecider * mdecider = 0) const;
MSet get_mset(Xapian::doccount first, Xapian::doccount maxitems, MSet get_mset(Xapian::doccount first, Xapian::doccount maxitems,
const RSet * omrset, const RSet * omrset,
const MatchDecider * mdecider = 0) const { const MatchDecider * mdecider = 0) const {
return get_mset(first, maxitems, 0, omrset, mdecider); return get_mset(first, maxitems, 0, omrset, mdecider);
} }
/** @} */ /** @} */
skipping to change at line 1090 skipping to change at line 1052
* @return An ESet object containing the results of the * @return An ESet object containing the results of the
* expand. * expand.
* *
* @exception Xapian::InvalidArgumentError See class documentation . * @exception Xapian::InvalidArgumentError See class documentation .
*/ */
ESet get_eset(Xapian::termcount maxitems, ESet get_eset(Xapian::termcount maxitems,
const RSet & omrset, const RSet & omrset,
int flags, int flags,
double k, double k,
const Xapian::ExpandDecider * edecider, const Xapian::ExpandDecider * edecider,
Xapian::weight min_wt) const; double min_wt) const;
/** Get terms which match a given document, by document id. /** Get terms which match a given document, by document id.
* *
* This method returns the terms in the current query which match * This method returns the terms in the current query which match
* the given document. * the given document.
* *
* It is possible for the document to have been removed from the * It is possible for the document to have been removed from the
* database between the time it is returned in an MSet, and the * database between the time it is returned in an MSet, and the
* time that this call is made. If possible, you should specify * time that this call is made. If possible, you should specify
* an MSetIterator instead of a Xapian::docid, since this will enab le * an MSetIterator instead of a Xapian::docid, since this will enab le
skipping to change at line 1160 skipping to change at line 1122
/** End iterator corresponding to get_matching_terms_begin() */ /** End iterator corresponding to get_matching_terms_begin() */
TermIterator get_matching_terms_end(const MSetIterator &/*it*/) cons t { TermIterator get_matching_terms_end(const MSetIterator &/*it*/) cons t {
return TermIterator(); return TermIterator();
} }
/// Return a string describing this object. /// Return a string describing this object.
std::string get_description() const; std::string get_description() const;
}; };
// Deprecated forms:
inline void
Enquire::set_sort_by_value(Xapian::valueno sort_key)
{
return set_sort_by_value(sort_key, true);
}
inline void
Enquire::set_sort_by_key(Xapian::KeyMaker * sorter)
{
return set_sort_by_key(sorter, true);
}
inline void
Enquire::set_sort_by_value_then_relevance(Xapian::valueno sort_key)
{
return set_sort_by_value_then_relevance(sort_key, true);
}
inline void
Enquire::set_sort_by_key_then_relevance(Xapian::KeyMaker * sorter)
{
return set_sort_by_key_then_relevance(sorter, true);
}
inline void
Enquire::set_sort_by_relevance_then_value(Xapian::valueno sort_key)
{
return set_sort_by_relevance_then_value(sort_key, true);
}
inline void
Enquire::set_sort_by_relevance_then_key(Xapian::KeyMaker * sorter)
{
return set_sort_by_relevance_then_key(sorter, true);
}
} }
#endif /* XAPIAN_INCLUDED_ENQUIRE_H */ #endif /* XAPIAN_INCLUDED_ENQUIRE_H */
 End of changes. 31 change blocks. 
118 lines changed or deleted 32 lines changed or added


 error.h   error.h 
/** @file error.h /** @file error.h
* @brief Hierarchy of classes which Xapian can throw as exceptions. * @brief Hierarchy of classes which Xapian can throw as exceptions.
*/ */
/* Warning: This file is generated by /data/home/olly/tmp/xapian-git-snapsh /* Warning: This file is generated by /data/home/olly/tmp/xapian-svn-snapsh
ot/tags/v1.2.21/xapian/xapian-core/generate-exceptions - do not modify dire ot/tags/1.3.0/xapian/xapian-core/generate-exceptions - do not modify direct
ctly! */ ly! */
/* Copyright (C) 2003,2004,2006,2007,2009 Olly Betts /* Copyright (C) 2003,2004,2006,2007,2008,2009,2011 Olly Betts
* Copyright (C) 2007 Richard Boulton
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the * published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version. * License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
skipping to change at line 53 skipping to change at line 54
/** Optional context information. /** Optional context information.
* *
* This context is intended for use by Xapian::ErrorHandler (for examp le * This context is intended for use by Xapian::ErrorHandler (for examp le
* so it can know which remote server is unreliable and report the pro blem * so it can know which remote server is unreliable and report the pro blem
* and remove that server from those being searched). But it's typica lly * and remove that server from those being searched). But it's typica lly
* a plain-text string, and so also fit for human consumption. * a plain-text string, and so also fit for human consumption.
*/ */
std::string context; std::string context;
/** The error string derived from my_errno.
*
* This string is generated from my_errno lazily.
*/
mutable std::string error_string;
/// The type of this error (e.g. DocNotFoundError.) /// The type of this error (e.g. DocNotFoundError.)
const char * type; const char * type;
/** Optional value of 'errno' associated with this error. /** Optional value of 'errno' associated with this error.
* *
* If no value is associated, this member variable will be 0. * If no value is associated, this member variable will be 0.
* *
* On UNIX, if this value is < 0, it's a negated h_errno value (giving * On UNIX, if this value is < 0, it's a negated h_errno value (giving
* an error from gethostbyname() or similar). * an error from gethostbyname() or similar).
* *
* On Windows, if this value is < 0, it's a negated Windows error code * On Windows, if this value is < 0, it's a negated Windows error code
* (as given by GetLastError()), while if it is >= WSABASEERR then it * (as given by GetLastError() or WSAGetLastError()).
is a
* WinSock error code (as given by WSAGetLastError()). Prior to Xapia
n
* 1.2.20 and 1.3.3, WSAGetLastError() codes were also negated.
* *
* NB We don't just call this member "errno" to avoid problems on * NB We don't just call this member "errno" to avoid problems on
* platforms where errno is a preprocessor macro. * platforms where errno is a preprocessor macro.
*/ */
int my_errno; int my_errno;
/** The error string derived from my_errno.
*
* This string is generated from my_errno lazily.
*/
mutable std::string error_string;
/// True if this error has already been passed to an ErrorHandler. /// True if this error has already been passed to an ErrorHandler.
bool already_handled; bool already_handled;
/// Don't allow assignment of the base class. /// Don't allow assignment of the base class.
void operator=(const Error &o); void operator=(const Error &o);
protected: protected:
/** @private @internal /** @private @internal
* @brief Constructor for use by constructors of derived classes. * @brief Constructor for use by constructors of derived classes.
*/ */
Error(const std::string &msg_, const std::string &context_, Error(const std::string &msg_, const std::string &context_,
const char * type_, const char * error_string_); const char * type_, const char * error_string_);
/** @private @internal /** @private @internal
* @brief Constructor for use by constructors of derived classes. * @brief Constructor for use by constructors of derived classes.
*/ */
Error(const std::string &msg_, const std::string &context_, Error(const std::string &msg_, const std::string &context_,
const char * type_, int errno_) const char * type_, int errno_)
: msg(msg_), context(context_), type(type_), my_errno(errno_), : msg(msg_), context(context_), error_string(), type(type_),
error_string(), already_handled(false) { } my_errno(errno_), already_handled(false) { }
public: public:
/// The type of this error (e.g. "DocNotFoundError".) /// The type of this error (e.g. "DocNotFoundError".)
const char * get_type() const { return type; } const char * get_type() const { return type + 1; }
/// Message giving details of the error, intended for human consumption . /// Message giving details of the error, intended for human consumption .
const std::string & get_msg() const { return msg; } const std::string & get_msg() const { return msg; }
/** Optional context information. /** Optional context information.
* *
* This context is intended for use by Xapian::ErrorHandler (for examp le * This context is intended for use by Xapian::ErrorHandler (for examp le
* so it can know which remote server is unreliable and report the pro blem * so it can know which remote server is unreliable and report the pro blem
* and remove that server from those being searched). But it's typica lly * and remove that server from those being searched). But it's typica lly
* a plain-text string, and so also fit for human consumption. * a plain-text string, and so also fit for human consumption.
skipping to change at line 186 skipping to change at line 185
* has been violated, or the assertion is incorrect!) * has been violated, or the assertion is incorrect!)
*/ */
class XAPIAN_VISIBILITY_DEFAULT AssertionError : public LogicError { class XAPIAN_VISIBILITY_DEFAULT AssertionError : public LogicError {
public: public:
/** @private @internal /** @private @internal
* @brief Private constructor for use by remote backend. * @brief Private constructor for use by remote backend.
* *
* @param error_string_ Optional string describing error. May be NU LL. * @param error_string_ Optional string describing error. May be NU LL.
*/ */
AssertionError(const std::string &msg_, const std::string &context_, co nst char * error_string_) AssertionError(const std::string &msg_, const std::string &context_, co nst char * error_string_)
: LogicError(msg_, context_, "AssertionError", error_string_) {} : LogicError(msg_, context_, "\000AssertionError", error_string_) {}
/** General purpose constructor. /** General purpose constructor.
* *
* @param msg_ Message giving details of the error, intende d * @param msg_ Message giving details of the error, intende d
* for human consumption. * for human consumption.
* @param context_ Optional context information for this error. * @param context_ Optional context information for this error.
* @param errno_ Optional errno value associated with this er ror. * @param errno_ Optional errno value associated with this er ror.
*/ */
explicit AssertionError(const std::string &msg_, const std::string &con text_ = std::string(), int errno_ = 0) explicit AssertionError(const std::string &msg_, const std::string &con text_ = std::string(), int errno_ = 0)
: LogicError(msg_, context_, "AssertionError", errno_) {} : LogicError(msg_, context_, "\000AssertionError", errno_) {}
/** Construct from message and errno value. /** Construct from message and errno value.
* *
* @param msg_ Message giving details of the error, intende d * @param msg_ Message giving details of the error, intende d
* for human consumption. * for human consumption.
* @param errno_ Optional errno value associated with this er ror. * @param errno_ Optional errno value associated with this er ror.
*/ */
AssertionError(const std::string &msg_, int errno_) AssertionError(const std::string &msg_, int errno_)
: LogicError(msg_, std::string(), "AssertionError", errno_) {} : LogicError(msg_, std::string(), "\000AssertionError", errno_) {}
protected: protected:
/** @private @internal /** @private @internal
* @brief Constructor for use by constructors of derived classes. * @brief Constructor for use by constructors of derived classes.
*/ */
AssertionError(const std::string &msg_, const std::string &context_, co nst char * type_, const char * error_string_) AssertionError(const std::string &msg_, const std::string &context_, co nst char * type_, const char * error_string_)
: LogicError(msg_, context_, type_, error_string_) {} : LogicError(msg_, context_, type_, error_string_) {}
/** @private @internal /** @private @internal
* @brief Constructor for use by constructors of derived classes. * @brief Constructor for use by constructors of derived classes.
*/ */
skipping to change at line 228 skipping to change at line 227
/** InvalidArgumentError indicates an invalid parameter value was passed to the API. /** InvalidArgumentError indicates an invalid parameter value was passed to the API.
*/ */
class XAPIAN_VISIBILITY_DEFAULT InvalidArgumentError : public LogicError { class XAPIAN_VISIBILITY_DEFAULT InvalidArgumentError : public LogicError {
public: public:
/** @private @internal /** @private @internal
* @brief Private constructor for use by remote backend. * @brief Private constructor for use by remote backend.
* *
* @param error_string_ Optional string describing error. May be NU LL. * @param error_string_ Optional string describing error. May be NU LL.
*/ */
InvalidArgumentError(const std::string &msg_, const std::string &contex t_, const char * error_string_) InvalidArgumentError(const std::string &msg_, const std::string &contex t_, const char * error_string_)
: LogicError(msg_, context_, "InvalidArgumentError", error_string_) {} : LogicError(msg_, context_, "\001InvalidArgumentError", error_strin g_) {}
/** General purpose constructor. /** General purpose constructor.
* *
* @param msg_ Message giving details of the error, intende d * @param msg_ Message giving details of the error, intende d
* for human consumption. * for human consumption.
* @param context_ Optional context information for this error. * @param context_ Optional context information for this error.
* @param errno_ Optional errno value associated with this er ror. * @param errno_ Optional errno value associated with this er ror.
*/ */
explicit InvalidArgumentError(const std::string &msg_, const std::strin g &context_ = std::string(), int errno_ = 0) explicit InvalidArgumentError(const std::string &msg_, const std::strin g &context_ = std::string(), int errno_ = 0)
: LogicError(msg_, context_, "InvalidArgumentError", errno_) {} : LogicError(msg_, context_, "\001InvalidArgumentError", errno_) {}
/** Construct from message and errno value. /** Construct from message and errno value.
* *
* @param msg_ Message giving details of the error, intende d * @param msg_ Message giving details of the error, intende d
* for human consumption. * for human consumption.
* @param errno_ Optional errno value associated with this er ror. * @param errno_ Optional errno value associated with this er ror.
*/ */
InvalidArgumentError(const std::string &msg_, int errno_) InvalidArgumentError(const std::string &msg_, int errno_)
: LogicError(msg_, std::string(), "InvalidArgumentError", errno_) {} : LogicError(msg_, std::string(), "\001InvalidArgumentError", errno_ ) {}
protected: protected:
/** @private @internal /** @private @internal
* @brief Constructor for use by constructors of derived classes. * @brief Constructor for use by constructors of derived classes.
*/ */
InvalidArgumentError(const std::string &msg_, const std::string &contex t_, const char * type_, const char * error_string_) InvalidArgumentError(const std::string &msg_, const std::string &contex t_, const char * type_, const char * error_string_)
: LogicError(msg_, context_, type_, error_string_) {} : LogicError(msg_, context_, type_, error_string_) {}
/** @private @internal /** @private @internal
* @brief Constructor for use by constructors of derived classes. * @brief Constructor for use by constructors of derived classes.
*/ */
skipping to change at line 270 skipping to change at line 269
/** InvalidOperationError indicates the API was used in an invalid way. /** InvalidOperationError indicates the API was used in an invalid way.
*/ */
class XAPIAN_VISIBILITY_DEFAULT InvalidOperationError : public LogicError { class XAPIAN_VISIBILITY_DEFAULT InvalidOperationError : public LogicError {
public: public:
/** @private @internal /** @private @internal
* @brief Private constructor for use by remote backend. * @brief Private constructor for use by remote backend.
* *
* @param error_string_ Optional string describing error. May be NU LL. * @param error_string_ Optional string describing error. May be NU LL.
*/ */
InvalidOperationError(const std::string &msg_, const std::string &conte xt_, const char * error_string_) InvalidOperationError(const std::string &msg_, const std::string &conte xt_, const char * error_string_)
: LogicError(msg_, context_, "InvalidOperationError", error_string_) {} : LogicError(msg_, context_, "\002InvalidOperationError", error_stri ng_) {}
/** General purpose constructor. /** General purpose constructor.
* *
* @param msg_ Message giving details of the error, intende d * @param msg_ Message giving details of the error, intende d
* for human consumption. * for human consumption.
* @param context_ Optional context information for this error. * @param context_ Optional context information for this error.
* @param errno_ Optional errno value associated with this er ror. * @param errno_ Optional errno value associated with this er ror.
*/ */
explicit InvalidOperationError(const std::string &msg_, const std::stri ng &context_ = std::string(), int errno_ = 0) explicit InvalidOperationError(const std::string &msg_, const std::stri ng &context_ = std::string(), int errno_ = 0)
: LogicError(msg_, context_, "InvalidOperationError", errno_) {} : LogicError(msg_, context_, "\002InvalidOperationError", errno_) {}
/** Construct from message and errno value. /** Construct from message and errno value.
* *
* @param msg_ Message giving details of the error, intende d * @param msg_ Message giving details of the error, intende d
* for human consumption. * for human consumption.
* @param errno_ Optional errno value associated with this er ror. * @param errno_ Optional errno value associated with this er ror.
*/ */
InvalidOperationError(const std::string &msg_, int errno_) InvalidOperationError(const std::string &msg_, int errno_)
: LogicError(msg_, std::string(), "InvalidOperationError", errno_) { } : LogicError(msg_, std::string(), "\002InvalidOperationError", errno _) {}
protected: protected:
/** @private @internal /** @private @internal
* @brief Constructor for use by constructors of derived classes. * @brief Constructor for use by constructors of derived classes.
*/ */
InvalidOperationError(const std::string &msg_, const std::string &conte xt_, const char * type_, const char * error_string_) InvalidOperationError(const std::string &msg_, const std::string &conte xt_, const char * type_, const char * error_string_)
: LogicError(msg_, context_, type_, error_string_) {} : LogicError(msg_, context_, type_, error_string_) {}
/** @private @internal /** @private @internal
* @brief Constructor for use by constructors of derived classes. * @brief Constructor for use by constructors of derived classes.
*/ */
skipping to change at line 311 skipping to change at line 310
/** UnimplementedError indicates an attempt to use an unimplemented feature . */ /** UnimplementedError indicates an attempt to use an unimplemented feature . */
class XAPIAN_VISIBILITY_DEFAULT UnimplementedError : public LogicError { class XAPIAN_VISIBILITY_DEFAULT UnimplementedError : public LogicError {
public: public:
/** @private @internal /** @private @internal
* @brief Private constructor for use by remote backend. * @brief Private constructor for use by remote backend.
* *
* @param error_string_ Optional string describing error. May be NU LL. * @param error_string_ Optional string describing error. May be NU LL.
*/ */
UnimplementedError(const std::string &msg_, const std::string &context_ , const char * error_string_) UnimplementedError(const std::string &msg_, const std::string &context_ , const char * error_string_)
: LogicError(msg_, context_, "UnimplementedError", error_string_) {} : LogicError(msg_, context_, "\003UnimplementedError", error_string_ ) {}
/** General purpose constructor. /** General purpose constructor.
* *
* @param msg_ Message giving details of the error, intende d * @param msg_ Message giving details of the error, intende d
* for human consumption. * for human consumption.
* @param context_ Optional context information for this error. * @param context_ Optional context information for this error.
* @param errno_ Optional errno value associated with this er ror. * @param errno_ Optional errno value associated with this er ror.
*/ */
explicit UnimplementedError(const std::string &msg_, const std::string &context_ = std::string(), int errno_ = 0) explicit UnimplementedError(const std::string &msg_, const std::string &context_ = std::string(), int errno_ = 0)
: LogicError(msg_, context_, "UnimplementedError", errno_) {} : LogicError(msg_, context_, "\003UnimplementedError", errno_) {}
/** Construct from message and errno value. /** Construct from message and errno value.
* *
* @param msg_ Message giving details of the error, intende d * @param msg_ Message giving details of the error, intende d
* for human consumption. * for human consumption.
* @param errno_ Optional errno value associated with this er ror. * @param errno_ Optional errno value associated with this er ror.
*/ */
UnimplementedError(const std::string &msg_, int errno_) UnimplementedError(const std::string &msg_, int errno_)
: LogicError(msg_, std::string(), "UnimplementedError", errno_) {} : LogicError(msg_, std::string(), "\003UnimplementedError", errno_) {}
protected: protected:
/** @private @internal /** @private @internal
* @brief Constructor for use by constructors of derived classes. * @brief Constructor for use by constructors of derived classes.
*/ */
UnimplementedError(const std::string &msg_, const std::string &context_ , const char * type_, const char * error_string_) UnimplementedError(const std::string &msg_, const std::string &context_ , const char * type_, const char * error_string_)
: LogicError(msg_, context_, type_, error_string_) {} : LogicError(msg_, context_, type_, error_string_) {}
/** @private @internal /** @private @internal
* @brief Constructor for use by constructors of derived classes. * @brief Constructor for use by constructors of derived classes.
*/ */
skipping to change at line 352 skipping to change at line 351
/** DatabaseError indicates some sort of database related error. */ /** DatabaseError indicates some sort of database related error. */
class XAPIAN_VISIBILITY_DEFAULT DatabaseError : public RuntimeError { class XAPIAN_VISIBILITY_DEFAULT DatabaseError : public RuntimeError {
public: public:
/** @private @internal /** @private @internal
* @brief Private constructor for use by remote backend. * @brief Private constructor for use by remote backend.
* *
* @param error_string_ Optional string describing error. May be NU LL. * @param error_string_ Optional string describing error. May be NU LL.
*/ */
DatabaseError(const std::string &msg_, const std::string &context_, con st char * error_string_) DatabaseError(const std::string &msg_, const std::string &context_, con st char * error_string_)
: RuntimeError(msg_, context_, "DatabaseError", error_string_) {} : RuntimeError(msg_, context_, "\004DatabaseError", error_string_) { }
/** General purpose constructor. /** General purpose constructor.
* *
* @param msg_ Message giving details of the error, intende d * @param msg_ Message giving details of the error, intende d
* for human consumption. * for human consumption.
* @param context_ Optional context information for this error. * @param context_ Optional context information for this error.
* @param errno_ Optional errno value associated with this er ror. * @param errno_ Optional errno value associated with this er ror.
*/ */
explicit DatabaseError(const std::string &msg_, const std::string &cont ext_ = std::string(), int errno_ = 0) explicit DatabaseError(const std::string &msg_, const std::string &cont ext_ = std::string(), int errno_ = 0)
: RuntimeError(msg_, context_, "DatabaseError", errno_) {} : RuntimeError(msg_, context_, "\004DatabaseError", errno_) {}
/** Construct from message and errno value. /** Construct from message and errno value.
* *
* @param msg_ Message giving details of the error, intende d * @param msg_ Message giving details of the error, intende d
* for human consumption. * for human consumption.
* @param errno_ Optional errno value associated with this er ror. * @param errno_ Optional errno value associated with this er ror.
*/ */
DatabaseError(const std::string &msg_, int errno_) DatabaseError(const std::string &msg_, int errno_)
: RuntimeError(msg_, std::string(), "DatabaseError", errno_) {} : RuntimeError(msg_, std::string(), "\004DatabaseError", errno_) {}
protected: protected:
/** @private @internal /** @private @internal
* @brief Constructor for use by constructors of derived classes. * @brief Constructor for use by constructors of derived classes.
*/ */
DatabaseError(const std::string &msg_, const std::string &context_, con st char * type_, const char * error_string_) DatabaseError(const std::string &msg_, const std::string &context_, con st char * type_, const char * error_string_)
: RuntimeError(msg_, context_, type_, error_string_) {} : RuntimeError(msg_, context_, type_, error_string_) {}
/** @private @internal /** @private @internal
* @brief Constructor for use by constructors of derived classes. * @brief Constructor for use by constructors of derived classes.
*/ */
skipping to change at line 393 skipping to change at line 392
/** DatabaseCorruptError indicates database corruption was detected. */ /** DatabaseCorruptError indicates database corruption was detected. */
class XAPIAN_VISIBILITY_DEFAULT DatabaseCorruptError : public DatabaseError { class XAPIAN_VISIBILITY_DEFAULT DatabaseCorruptError : public DatabaseError {
public: public:
/** @private @internal /** @private @internal
* @brief Private constructor for use by remote backend. * @brief Private constructor for use by remote backend.
* *
* @param error_string_ Optional string describing error. May be NU LL. * @param error_string_ Optional string describing error. May be NU LL.
*/ */
DatabaseCorruptError(const std::string &msg_, const std::string &contex t_, const char * error_string_) DatabaseCorruptError(const std::string &msg_, const std::string &contex t_, const char * error_string_)
: DatabaseError(msg_, context_, "DatabaseCorruptError", error_string _) {} : DatabaseError(msg_, context_, "\005DatabaseCorruptError", error_st ring_) {}
/** General purpose constructor. /** General purpose constructor.
* *
* @param msg_ Message giving details of the error, intende d * @param msg_ Message giving details of the error, intende d
* for human consumption. * for human consumption.
* @param context_ Optional context information for this error. * @param context_ Optional context information for this error.
* @param errno_ Optional errno value associated with this er ror. * @param errno_ Optional errno value associated with this er ror.
*/ */
explicit DatabaseCorruptError(const std::string &msg_, const std::strin g &context_ = std::string(), int errno_ = 0) explicit DatabaseCorruptError(const std::string &msg_, const std::strin g &context_ = std::string(), int errno_ = 0)
: DatabaseError(msg_, context_, "DatabaseCorruptError", errno_) {} : DatabaseError(msg_, context_, "\005DatabaseCorruptError", errno_) {}
/** Construct from message and errno value. /** Construct from message and errno value.
* *
* @param msg_ Message giving details of the error, intende d * @param msg_ Message giving details of the error, intende d
* for human consumption. * for human consumption.
* @param errno_ Optional errno value associated with this er ror. * @param errno_ Optional errno value associated with this er ror.
*/ */
DatabaseCorruptError(const std::string &msg_, int errno_) DatabaseCorruptError(const std::string &msg_, int errno_)
: DatabaseError(msg_, std::string(), "DatabaseCorruptError", errno_) {} : DatabaseError(msg_, std::string(), "\005DatabaseCorruptError", err no_) {}
protected: protected:
/** @private @internal /** @private @internal
* @brief Constructor for use by constructors of derived classes. * @brief Constructor for use by constructors of derived classes.
*/ */
DatabaseCorruptError(const std::string &msg_, const std::string &contex t_, const char * type_, const char * error_string_) DatabaseCorruptError(const std::string &msg_, const std::string &contex t_, const char * type_, const char * error_string_)
: DatabaseError(msg_, context_, type_, error_string_) {} : DatabaseError(msg_, context_, type_, error_string_) {}
/** @private @internal /** @private @internal
* @brief Constructor for use by constructors of derived classes. * @brief Constructor for use by constructors of derived classes.
*/ */
skipping to change at line 434 skipping to change at line 433
/** DatabaseCreateError indicates a failure to create a database. */ /** DatabaseCreateError indicates a failure to create a database. */
class XAPIAN_VISIBILITY_DEFAULT DatabaseCreateError : public DatabaseError { class XAPIAN_VISIBILITY_DEFAULT DatabaseCreateError : public DatabaseError {
public: public:
/** @private @internal /** @private @internal
* @brief Private constructor for use by remote backend. * @brief Private constructor for use by remote backend.
* *
* @param error_string_ Optional string describing error. May be NU LL. * @param error_string_ Optional string describing error. May be NU LL.
*/ */
DatabaseCreateError(const std::string &msg_, const std::string &context _, const char * error_string_) DatabaseCreateError(const std::string &msg_, const std::string &context _, const char * error_string_)
: DatabaseError(msg_, context_, "DatabaseCreateError", error_string_ ) {} : DatabaseError(msg_, context_, "\006DatabaseCreateError", error_str ing_) {}
/** General purpose constructor. /** General purpose constructor.
* *
* @param msg_ Message giving details of the error, intende d * @param msg_ Message giving details of the error, intende d
* for human consumption. * for human consumption.
* @param context_ Optional context information for this error. * @param context_ Optional context information for this error.
* @param errno_ Optional errno value associated with this er ror. * @param errno_ Optional errno value associated with this er ror.
*/ */
explicit DatabaseCreateError(const std::string &msg_, const std::string &context_ = std::string(), int errno_ = 0) explicit DatabaseCreateError(const std::string &msg_, const std::string &context_ = std::string(), int errno_ = 0)
: DatabaseError(msg_, context_, "DatabaseCreateError", errno_) {} : DatabaseError(msg_, context_, "\006DatabaseCreateError", errno_) { }
/** Construct from message and errno value. /** Construct from message and errno value.
* *
* @param msg_ Message giving details of the error, intende d * @param msg_ Message giving details of the error, intende d
* for human consumption. * for human consumption.
* @param errno_ Optional errno value associated with this er ror. * @param errno_ Optional errno value associated with this er ror.
*/ */
DatabaseCreateError(const std::string &msg_, int errno_) DatabaseCreateError(const std::string &msg_, int errno_)
: DatabaseError(msg_, std::string(), "DatabaseCreateError", errno_) {} : DatabaseError(msg_, std::string(), "\006DatabaseCreateError", errn o_) {}
protected: protected:
/** @private @internal /** @private @internal
* @brief Constructor for use by constructors of derived classes. * @brief Constructor for use by constructors of derived classes.
*/ */
DatabaseCreateError(const std::string &msg_, const std::string &context _, const char * type_, const char * error_string_) DatabaseCreateError(const std::string &msg_, const std::string &context _, const char * type_, const char * error_string_)
: DatabaseError(msg_, context_, type_, error_string_) {} : DatabaseError(msg_, context_, type_, error_string_) {}
/** @private @internal /** @private @internal
* @brief Constructor for use by constructors of derived classes. * @brief Constructor for use by constructors of derived classes.
*/ */
skipping to change at line 475 skipping to change at line 474
/** DatabaseLockError indicates failure to lock a database. */ /** DatabaseLockError indicates failure to lock a database. */
class XAPIAN_VISIBILITY_DEFAULT DatabaseLockError : public DatabaseError { class XAPIAN_VISIBILITY_DEFAULT DatabaseLockError : public DatabaseError {
public: public:
/** @private @internal /** @private @internal
* @brief Private constructor for use by remote backend. * @brief Private constructor for use by remote backend.
* *
* @param error_string_ Optional string describing error. May be NU LL. * @param error_string_ Optional string describing error. May be NU LL.
*/ */
DatabaseLockError(const std::string &msg_, const std::string &context_, const char * error_string_) DatabaseLockError(const std::string &msg_, const std::string &context_, const char * error_string_)
: DatabaseError(msg_, context_, "DatabaseLockError", error_string_) {} : DatabaseError(msg_, context_, "\007DatabaseLockError", error_strin g_) {}
/** General purpose constructor. /** General purpose constructor.
* *
* @param msg_ Message giving details of the error, intende d * @param msg_ Message giving details of the error, intende d
* for human consumption. * for human consumption.
* @param context_ Optional context information for this error. * @param context_ Optional context information for this error.
* @param errno_ Optional errno value associated with this er ror. * @param errno_ Optional errno value associated with this er ror.
*/ */
explicit DatabaseLockError(const std::string &msg_, const std::string & context_ = std::string(), int errno_ = 0) explicit DatabaseLockError(const std::string &msg_, const std::string & context_ = std::string(), int errno_ = 0)
: DatabaseError(msg_, context_, "DatabaseLockError", errno_) {} : DatabaseError(msg_, context_, "\007DatabaseLockError", errno_) {}
/** Construct from message and errno value. /** Construct from message and errno value.
* *
* @param msg_ Message giving details of the error, intende d * @param msg_ Message giving details of the error, intende d
* for human consumption. * for human consumption.
* @param errno_ Optional errno value associated with this er ror. * @param errno_ Optional errno value associated with this er ror.
*/ */
DatabaseLockError(const std::string &msg_, int errno_) DatabaseLockError(const std::string &msg_, int errno_)
: DatabaseError(msg_, std::string(), "DatabaseLockError", errno_) {} : DatabaseError(msg_, std::string(), "\007DatabaseLockError", errno_ ) {}
protected: protected:
/** @private @internal /** @private @internal
* @brief Constructor for use by constructors of derived classes. * @brief Constructor for use by constructors of derived classes.
*/ */
DatabaseLockError(const std::string &msg_, const std::string &context_, const char * type_, const char * error_string_) DatabaseLockError(const std::string &msg_, const std::string &context_, const char * type_, const char * error_string_)
: DatabaseError(msg_, context_, type_, error_string_) {} : DatabaseError(msg_, context_, type_, error_string_) {}
/** @private @internal /** @private @internal
* @brief Constructor for use by constructors of derived classes. * @brief Constructor for use by constructors of derived classes.
*/ */
skipping to change at line 521 skipping to change at line 520
* which failed. * which failed.
*/ */
class XAPIAN_VISIBILITY_DEFAULT DatabaseModifiedError : public DatabaseErro r { class XAPIAN_VISIBILITY_DEFAULT DatabaseModifiedError : public DatabaseErro r {
public: public:
/** @private @internal /** @private @internal
* @brief Private constructor for use by remote backend. * @brief Private constructor for use by remote backend.
* *
* @param error_string_ Optional string describing error. May be NU LL. * @param error_string_ Optional string describing error. May be NU LL.
*/ */
DatabaseModifiedError(const std::string &msg_, const std::string &conte xt_, const char * error_string_) DatabaseModifiedError(const std::string &msg_, const std::string &conte xt_, const char * error_string_)
: DatabaseError(msg_, context_, "DatabaseModifiedError", error_strin g_) {} : DatabaseError(msg_, context_, "\010DatabaseModifiedError", error_s tring_) {}
/** General purpose constructor. /** General purpose constructor.
* *
* @param msg_ Message giving details of the error, intende d * @param msg_ Message giving details of the error, intende d
* for human consumption. * for human consumption.
* @param context_ Optional context information for this error. * @param context_ Optional context information for this error.
* @param errno_ Optional errno value associated with this er ror. * @param errno_ Optional errno value associated with this er ror.
*/ */
explicit DatabaseModifiedError(const std::string &msg_, const std::stri ng &context_ = std::string(), int errno_ = 0) explicit DatabaseModifiedError(const std::string &msg_, const std::stri ng &context_ = std::string(), int errno_ = 0)
: DatabaseError(msg_, context_, "DatabaseModifiedError", errno_) {} : DatabaseError(msg_, context_, "\010DatabaseModifiedError", errno_) {}
/** Construct from message and errno value. /** Construct from message and errno value.
* *
* @param msg_ Message giving details of the error, intende d * @param msg_ Message giving details of the error, intende d
* for human consumption. * for human consumption.
* @param errno_ Optional errno value associated with this er ror. * @param errno_ Optional errno value associated with this er ror.
*/ */
DatabaseModifiedError(const std::string &msg_, int errno_) DatabaseModifiedError(const std::string &msg_, int errno_)
: DatabaseError(msg_, std::string(), "DatabaseModifiedError", errno_ ) {} : DatabaseError(msg_, std::string(), "\010DatabaseModifiedError", er rno_) {}
protected: protected:
/** @private @internal /** @private @internal
* @brief Constructor for use by constructors of derived classes. * @brief Constructor for use by constructors of derived classes.
*/ */
DatabaseModifiedError(const std::string &msg_, const std::string &conte xt_, const char * type_, const char * error_string_) DatabaseModifiedError(const std::string &msg_, const std::string &conte xt_, const char * type_, const char * error_string_)
: DatabaseError(msg_, context_, type_, error_string_) {} : DatabaseError(msg_, context_, type_, error_string_) {}
/** @private @internal /** @private @internal
* @brief Constructor for use by constructors of derived classes. * @brief Constructor for use by constructors of derived classes.
*/ */
skipping to change at line 562 skipping to change at line 561
/** DatabaseOpeningError indicates failure to open a database. */ /** DatabaseOpeningError indicates failure to open a database. */
class XAPIAN_VISIBILITY_DEFAULT DatabaseOpeningError : public DatabaseError { class XAPIAN_VISIBILITY_DEFAULT DatabaseOpeningError : public DatabaseError {
public: public:
/** @private @internal /** @private @internal
* @brief Private constructor for use by remote backend. * @brief Private constructor for use by remote backend.
* *
* @param error_string_ Optional string describing error. May be NU LL. * @param error_string_ Optional string describing error. May be NU LL.
*/ */
DatabaseOpeningError(const std::string &msg_, const std::string &contex t_, const char * error_string_) DatabaseOpeningError(const std::string &msg_, const std::string &contex t_, const char * error_string_)
: DatabaseError(msg_, context_, "DatabaseOpeningError", error_string _) {} : DatabaseError(msg_, context_, "\011DatabaseOpeningError", error_st ring_) {}
/** General purpose constructor. /** General purpose constructor.
* *
* @param msg_ Message giving details of the error, intende d * @param msg_ Message giving details of the error, intende d
* for human consumption. * for human consumption.
* @param context_ Optional context information for this error. * @param context_ Optional context information for this error.
* @param errno_ Optional errno value associated with this er ror. * @param errno_ Optional errno value associated with this er ror.
*/ */
explicit DatabaseOpeningError(const std::string &msg_, const std::strin g &context_ = std::string(), int errno_ = 0) explicit DatabaseOpeningError(const std::string &msg_, const std::strin g &context_ = std::string(), int errno_ = 0)
: DatabaseError(msg_, context_, "DatabaseOpeningError", errno_) {} : DatabaseError(msg_, context_, "\011DatabaseOpeningError", errno_) {}
/** Construct from message and errno value. /** Construct from message and errno value.
* *
* @param msg_ Message giving details of the error, intende d * @param msg_ Message giving details of the error, intende d
* for human consumption. * for human consumption.
* @param errno_ Optional errno value associated with this er ror. * @param errno_ Optional errno value associated with this er ror.
*/ */
DatabaseOpeningError(const std::string &msg_, int errno_) DatabaseOpeningError(const std::string &msg_, int errno_)
: DatabaseError(msg_, std::string(), "DatabaseOpeningError", errno_) {} : DatabaseError(msg_, std::string(), "\011DatabaseOpeningError", err no_) {}
protected: protected:
/** @private @internal /** @private @internal
* @brief Constructor for use by constructors of derived classes. * @brief Constructor for use by constructors of derived classes.
*/ */
DatabaseOpeningError(const std::string &msg_, const std::string &contex t_, const char * type_, const char * error_string_) DatabaseOpeningError(const std::string &msg_, const std::string &contex t_, const char * type_, const char * error_string_)
: DatabaseError(msg_, context_, type_, error_string_) {} : DatabaseError(msg_, context_, type_, error_string_) {}
/** @private @internal /** @private @internal
* @brief Constructor for use by constructors of derived classes. * @brief Constructor for use by constructors of derived classes.
*/ */
skipping to change at line 613 skipping to change at line 612
* the current version of Xapian. * the current version of Xapian.
*/ */
class XAPIAN_VISIBILITY_DEFAULT DatabaseVersionError : public DatabaseOpeni ngError { class XAPIAN_VISIBILITY_DEFAULT DatabaseVersionError : public DatabaseOpeni ngError {
public: public:
/** @private @internal /** @private @internal
* @brief Private constructor for use by remote backend. * @brief Private constructor for use by remote backend.
* *
* @param error_string_ Optional string describing error. May be NU LL. * @param error_string_ Optional string describing error. May be NU LL.
*/ */
DatabaseVersionError(const std::string &msg_, const std::string &contex t_, const char * error_string_) DatabaseVersionError(const std::string &msg_, const std::string &contex t_, const char * error_string_)
: DatabaseOpeningError(msg_, context_, "DatabaseVersionError", error _string_) {} : DatabaseOpeningError(msg_, context_, "\012DatabaseVersionError", e rror_string_) {}
/** General purpose constructor. /** General purpose constructor.
* *
* @param msg_ Message giving details of the error, intende d * @param msg_ Message giving details of the error, intende d
* for human consumption. * for human consumption.
* @param context_ Optional context information for this error. * @param context_ Optional context information for this error.
* @param errno_ Optional errno value associated with this er ror. * @param errno_ Optional errno value associated with this er ror.
*/ */
explicit DatabaseVersionError(const std::string &msg_, const std::strin g &context_ = std::string(), int errno_ = 0) explicit DatabaseVersionError(const std::string &msg_, const std::strin g &context_ = std::string(), int errno_ = 0)
: DatabaseOpeningError(msg_, context_, "DatabaseVersionError", errno _) {} : DatabaseOpeningError(msg_, context_, "\012DatabaseVersionError", e rrno_) {}
/** Construct from message and errno value. /** Construct from message and errno value.
* *
* @param msg_ Message giving details of the error, intende d * @param msg_ Message giving details of the error, intende d
* for human consumption. * for human consumption.
* @param errno_ Optional errno value associated with this er ror. * @param errno_ Optional errno value associated with this er ror.
*/ */
DatabaseVersionError(const std::string &msg_, int errno_) DatabaseVersionError(const std::string &msg_, int errno_)
: DatabaseOpeningError(msg_, std::string(), "DatabaseVersionError", errno_) {} : DatabaseOpeningError(msg_, std::string(), "\012DatabaseVersionErro r", errno_) {}
protected: protected:
/** @private @internal /** @private @internal
* @brief Constructor for use by constructors of derived classes. * @brief Constructor for use by constructors of derived classes.
*/ */
DatabaseVersionError(const std::string &msg_, const std::string &contex t_, const char * type_, const char * error_string_) DatabaseVersionError(const std::string &msg_, const std::string &contex t_, const char * type_, const char * error_string_)
: DatabaseOpeningError(msg_, context_, type_, error_string_) {} : DatabaseOpeningError(msg_, context_, type_, error_string_) {}
/** @private @internal /** @private @internal
* @brief Constructor for use by constructors of derived classes. * @brief Constructor for use by constructors of derived classes.
*/ */
skipping to change at line 654 skipping to change at line 653
/** Indicates an attempt to access a document not present in the database. */ /** Indicates an attempt to access a document not present in the database. */
class XAPIAN_VISIBILITY_DEFAULT DocNotFoundError : public RuntimeError { class XAPIAN_VISIBILITY_DEFAULT DocNotFoundError : public RuntimeError {
public: public:
/** @private @internal /** @private @internal
* @brief Private constructor for use by remote backend. * @brief Private constructor for use by remote backend.
* *
* @param error_string_ Optional string describing error. May be NU LL. * @param error_string_ Optional string describing error. May be NU LL.
*/ */
DocNotFoundError(const std::string &msg_, const std::string &context_, const char * error_string_) DocNotFoundError(const std::string &msg_, const std::string &context_, const char * error_string_)
: RuntimeError(msg_, context_, "DocNotFoundError", error_string_) {} : RuntimeError(msg_, context_, "\013DocNotFoundError", error_string_ ) {}
/** General purpose constructor. /** General purpose constructor.
* *
* @param msg_ Message giving details of the error, intende d * @param msg_ Message giving details of the error, intende d
* for human consumption. * for human consumption.
* @param context_ Optional context information for this error. * @param context_ Optional context information for this error.
* @param errno_ Optional errno value associated with this er ror. * @param errno_ Optional errno value associated with this er ror.
*/ */
explicit DocNotFoundError(const std::string &msg_, const std::string &c ontext_ = std::string(), int errno_ = 0) explicit DocNotFoundError(const std::string &msg_, const std::string &c ontext_ = std::string(), int errno_ = 0)
: RuntimeError(msg_, context_, "DocNotFoundError", errno_) {} : RuntimeError(msg_, context_, "\013DocNotFoundError", errno_) {}
/** Construct from message and errno value. /** Construct from message and errno value.
* *
* @param msg_ Message giving details of the error, intende d * @param msg_ Message giving details of the error, intende d
* for human consumption. * for human consumption.
* @param errno_ Optional errno value associated with this er ror. * @param errno_ Optional errno value associated with this er ror.
*/ */
DocNotFoundError(const std::string &msg_, int errno_) DocNotFoundError(const std::string &msg_, int errno_)
: RuntimeError(msg_, std::string(), "DocNotFoundError", errno_) {} : RuntimeError(msg_, std::string(), "\013DocNotFoundError", errno_) {}
protected: protected:
/** @private @internal /** @private @internal
* @brief Constructor for use by constructors of derived classes. * @brief Constructor for use by constructors of derived classes.
*/ */
DocNotFoundError(const std::string &msg_, const std::string &context_, const char * type_, const char * error_string_) DocNotFoundError(const std::string &msg_, const std::string &context_, const char * type_, const char * error_string_)
: RuntimeError(msg_, context_, type_, error_string_) {} : RuntimeError(msg_, context_, type_, error_string_) {}
/** @private @internal /** @private @internal
* @brief Constructor for use by constructors of derived classes. * @brief Constructor for use by constructors of derived classes.
*/ */
skipping to change at line 699 skipping to change at line 698
* because it requires other software or facilities which aren't available . * because it requires other software or facilities which aren't available .
*/ */
class XAPIAN_VISIBILITY_DEFAULT FeatureUnavailableError : public RuntimeErr or { class XAPIAN_VISIBILITY_DEFAULT FeatureUnavailableError : public RuntimeErr or {
public: public:
/** @private @internal /** @private @internal
* @brief Private constructor for use by remote backend. * @brief Private constructor for use by remote backend.
* *
* @param error_string_ Optional string describing error. May be NU LL. * @param error_string_ Optional string describing error. May be NU LL.
*/ */
FeatureUnavailableError(const std::string &msg_, const std::string &con text_, const char * error_string_) FeatureUnavailableError(const std::string &msg_, const std::string &con text_, const char * error_string_)
: RuntimeError(msg_, context_, "FeatureUnavailableError", error_stri ng_) {} : RuntimeError(msg_, context_, "\014FeatureUnavailableError", error_ string_) {}
/** General purpose constructor. /** General purpose constructor.
* *
* @param msg_ Message giving details of the error, intende d * @param msg_ Message giving details of the error, intende d
* for human consumption. * for human consumption.
* @param context_ Optional context information for this error. * @param context_ Optional context information for this error.
* @param errno_ Optional errno value associated with this er ror. * @param errno_ Optional errno value associated with this er ror.
*/ */
explicit FeatureUnavailableError(const std::string &msg_, const std::st ring &context_ = std::string(), int errno_ = 0) explicit FeatureUnavailableError(const std::string &msg_, const std::st ring &context_ = std::string(), int errno_ = 0)
: RuntimeError(msg_, context_, "FeatureUnavailableError", errno_) {} : RuntimeError(msg_, context_, "\014FeatureUnavailableError", errno_ ) {}
/** Construct from message and errno value. /** Construct from message and errno value.
* *
* @param msg_ Message giving details of the error, intende d * @param msg_ Message giving details of the error, intende d
* for human consumption. * for human consumption.
* @param errno_ Optional errno value associated with this er ror. * @param errno_ Optional errno value associated with this er ror.
*/ */
FeatureUnavailableError(const std::string &msg_, int errno_) FeatureUnavailableError(const std::string &msg_, int errno_)
: RuntimeError(msg_, std::string(), "FeatureUnavailableError", errno _) {} : RuntimeError(msg_, std::string(), "\014FeatureUnavailableError", e rrno_) {}
protected: protected:
/** @private @internal /** @private @internal
* @brief Constructor for use by constructors of derived classes. * @brief Constructor for use by constructors of derived classes.
*/ */
FeatureUnavailableError(const std::string &msg_, const std::string &con text_, const char * type_, const char * error_string_) FeatureUnavailableError(const std::string &msg_, const std::string &con text_, const char * type_, const char * error_string_)
: RuntimeError(msg_, context_, type_, error_string_) {} : RuntimeError(msg_, context_, type_, error_string_) {}
/** @private @internal /** @private @internal
* @brief Constructor for use by constructors of derived classes. * @brief Constructor for use by constructors of derived classes.
*/ */
skipping to change at line 740 skipping to change at line 739
/** InternalError indicates a runtime problem of some sort. */ /** InternalError indicates a runtime problem of some sort. */
class XAPIAN_VISIBILITY_DEFAULT InternalError : public RuntimeError { class XAPIAN_VISIBILITY_DEFAULT InternalError : public RuntimeError {
public: public:
/** @private @internal /** @private @internal
* @brief Private constructor for use by remote backend. * @brief Private constructor for use by remote backend.
* *
* @param error_string_ Optional string describing error. May be NU LL. * @param error_string_ Optional string describing error. May be NU LL.
*/ */
InternalError(const std::string &msg_, const std::string &context_, con st char * error_string_) InternalError(const std::string &msg_, const std::string &context_, con st char * error_string_)
: RuntimeError(msg_, context_, "InternalError", error_string_) {} : RuntimeError(msg_, context_, "\015InternalError", error_string_) { }
/** General purpose constructor. /** General purpose constructor.
* *
* @param msg_ Message giving details of the error, intende d * @param msg_ Message giving details of the error, intende d
* for human consumption. * for human consumption.
* @param context_ Optional context information for this error. * @param context_ Optional context information for this error.
* @param errno_ Optional errno value associated with this er ror. * @param errno_ Optional errno value associated with this er ror.
*/ */
explicit InternalError(const std::string &msg_, const std::string &cont ext_ = std::string(), int errno_ = 0) explicit InternalError(const std::string &msg_, const std::string &cont ext_ = std::string(), int errno_ = 0)
: RuntimeError(msg_, context_, "InternalError", errno_) {} : RuntimeError(msg_, context_, "\015InternalError", errno_) {}
/** Construct from message and errno value. /** Construct from message and errno value.
* *
* @param msg_ Message giving details of the error, intende d * @param msg_ Message giving details of the error, intende d
* for human consumption. * for human consumption.
* @param errno_ Optional errno value associated with this er ror. * @param errno_ Optional errno value associated with this er ror.
*/ */
InternalError(const std::string &msg_, int errno_) InternalError(const std::string &msg_, int errno_)
: RuntimeError(msg_, std::string(), "InternalError", errno_) {} : RuntimeError(msg_, std::string(), "\015InternalError", errno_) {}
protected: protected:
/** @private @internal /** @private @internal
* @brief Constructor for use by constructors of derived classes. * @brief Constructor for use by constructors of derived classes.
*/ */
InternalError(const std::string &msg_, const std::string &context_, con st char * type_, const char * error_string_) InternalError(const std::string &msg_, const std::string &context_, con st char * type_, const char * error_string_)
: RuntimeError(msg_, context_, type_, error_string_) {} : RuntimeError(msg_, context_, type_, error_string_) {}
/** @private @internal /** @private @internal
* @brief Constructor for use by constructors of derived classes. * @brief Constructor for use by constructors of derived classes.
*/ */
skipping to change at line 781 skipping to change at line 780
/** Indicates a problem communicating with a remote database. */ /** Indicates a problem communicating with a remote database. */
class XAPIAN_VISIBILITY_DEFAULT NetworkError : public RuntimeError { class XAPIAN_VISIBILITY_DEFAULT NetworkError : public RuntimeError {
public: public:
/** @private @internal /** @private @internal
* @brief Private constructor for use by remote backend. * @brief Private constructor for use by remote backend.
* *
* @param error_string_ Optional string describing error. May be NU LL. * @param error_string_ Optional string describing error. May be NU LL.
*/ */
NetworkError(const std::string &msg_, const std::string &context_, cons t char * error_string_) NetworkError(const std::string &msg_, const std::string &context_, cons t char * error_string_)
: RuntimeError(msg_, context_, "NetworkError", error_string_) {} : RuntimeError(msg_, context_, "\016NetworkError", error_string_) {}
/** General purpose constructor. /** General purpose constructor.
* *
* @param msg_ Message giving details of the error, intende d * @param msg_ Message giving details of the error, intende d
* for human consumption. * for human consumption.
* @param context_ Optional context information for this error. * @param context_ Optional context information for this error.
* @param errno_ Optional errno value associated with this er ror. * @param errno_ Optional errno value associated with this er ror.
*/ */
explicit NetworkError(const std::string &msg_, const std::string &conte xt_ = std::string(), int errno_ = 0) explicit NetworkError(const std::string &msg_, const std::string &conte xt_ = std::string(), int errno_ = 0)
: RuntimeError(msg_, context_, "NetworkError", errno_) {} : RuntimeError(msg_, context_, "\016NetworkError", errno_) {}
/** Construct from message and errno value. /** Construct from message and errno value.
* *
* @param msg_ Message giving details of the error, intende d * @param msg_ Message giving details of the error, intende d
* for human consumption. * for human consumption.
* @param errno_ Optional errno value associated with this er ror. * @param errno_ Optional errno value associated with this er ror.
*/ */
NetworkError(const std::string &msg_, int errno_) NetworkError(const std::string &msg_, int errno_)
: RuntimeError(msg_, std::string(), "NetworkError", errno_) {} : RuntimeError(msg_, std::string(), "\016NetworkError", errno_) {}
protected: protected:
/** @private @internal /** @private @internal
* @brief Constructor for use by constructors of derived classes. * @brief Constructor for use by constructors of derived classes.
*/ */
NetworkError(const std::string &msg_, const std::string &context_, cons t char * type_, const char * error_string_) NetworkError(const std::string &msg_, const std::string &context_, cons t char * type_, const char * error_string_)
: RuntimeError(msg_, context_, type_, error_string_) {} : RuntimeError(msg_, context_, type_, error_string_) {}
/** @private @internal /** @private @internal
* @brief Constructor for use by constructors of derived classes. * @brief Constructor for use by constructors of derived classes.
*/ */
skipping to change at line 822 skipping to change at line 821
/** Indicates a timeout expired while communicating with a remote database. */ /** Indicates a timeout expired while communicating with a remote database. */
class XAPIAN_VISIBILITY_DEFAULT NetworkTimeoutError : public NetworkError { class XAPIAN_VISIBILITY_DEFAULT NetworkTimeoutError : public NetworkError {
public: public:
/** @private @internal /** @private @internal
* @brief Private constructor for use by remote backend. * @brief Private constructor for use by remote backend.
* *
* @param error_string_ Optional string describing error. May be NU LL. * @param error_string_ Optional string describing error. May be NU LL.
*/ */
NetworkTimeoutError(const std::string &msg_, const std::string &context _, const char * error_string_) NetworkTimeoutError(const std::string &msg_, const std::string &context _, const char * error_string_)
: NetworkError(msg_, context_, "NetworkTimeoutError", error_string_) {} : NetworkError(msg_, context_, "\017NetworkTimeoutError", error_stri ng_) {}
/** General purpose constructor. /** General purpose constructor.
* *
* @param msg_ Message giving details of the error, intende d * @param msg_ Message giving details of the error, intende d
* for human consumption. * for human consumption.
* @param context_ Optional context information for this error. * @param context_ Optional context information for this error.
* @param errno_ Optional errno value associated with this er ror. * @param errno_ Optional errno value associated with this er ror.
*/ */
explicit NetworkTimeoutError(const std::string &msg_, const std::string &context_ = std::string(), int errno_ = 0) explicit NetworkTimeoutError(const std::string &msg_, const std::string &context_ = std::string(), int errno_ = 0)
: NetworkError(msg_, context_, "NetworkTimeoutError", errno_) {} : NetworkError(msg_, context_, "\017NetworkTimeoutError", errno_) {}
/** Construct from message and errno value. /** Construct from message and errno value.
* *
* @param msg_ Message giving details of the error, intende d * @param msg_ Message giving details of the error, intende d
* for human consumption. * for human consumption.
* @param errno_ Optional errno value associated with this er ror. * @param errno_ Optional errno value associated with this er ror.
*/ */
NetworkTimeoutError(const std::string &msg_, int errno_) NetworkTimeoutError(const std::string &msg_, int errno_)
: NetworkError(msg_, std::string(), "NetworkTimeoutError", errno_) { } : NetworkError(msg_, std::string(), "\017NetworkTimeoutError", errno _) {}
protected: protected:
/** @private @internal /** @private @internal
* @brief Constructor for use by constructors of derived classes. * @brief Constructor for use by constructors of derived classes.
*/ */
NetworkTimeoutError(const std::string &msg_, const std::string &context _, const char * type_, const char * error_string_) NetworkTimeoutError(const std::string &msg_, const std::string &context _, const char * type_, const char * error_string_)
: NetworkError(msg_, context_, type_, error_string_) {} : NetworkError(msg_, context_, type_, error_string_) {}
/** @private @internal /** @private @internal
* @brief Constructor for use by constructors of derived classes. * @brief Constructor for use by constructors of derived classes.
*/ */
skipping to change at line 863 skipping to change at line 862
/** Indicates a query string can't be parsed. */ /** Indicates a query string can't be parsed. */
class XAPIAN_VISIBILITY_DEFAULT QueryParserError : public RuntimeError { class XAPIAN_VISIBILITY_DEFAULT QueryParserError : public RuntimeError {
public: public:
/** @private @internal /** @private @internal
* @brief Private constructor for use by remote backend. * @brief Private constructor for use by remote backend.
* *
* @param error_string_ Optional string describing error. May be NU LL. * @param error_string_ Optional string describing error. May be NU LL.
*/ */
QueryParserError(const std::string &msg_, const std::string &context_, const char * error_string_) QueryParserError(const std::string &msg_, const std::string &context_, const char * error_string_)
: RuntimeError(msg_, context_, "QueryParserError", error_string_) {} : RuntimeError(msg_, context_, "\020QueryParserError", error_string_ ) {}
/** General purpose constructor. /** General purpose constructor.
* *
* @param msg_ Message giving details of the error, intende d * @param msg_ Message giving details of the error, intende d
* for human consumption. * for human consumption.
* @param context_ Optional context information for this error. * @param context_ Optional context information for this error.
* @param errno_ Optional errno value associated with this er ror. * @param errno_ Optional errno value associated with this er ror.
*/ */
explicit QueryParserError(const std::string &msg_, const std::string &c ontext_ = std::string(), int errno_ = 0) explicit QueryParserError(const std::string &msg_, const std::string &c ontext_ = std::string(), int errno_ = 0)
: RuntimeError(msg_, context_, "QueryParserError", errno_) {} : RuntimeError(msg_, context_, "\020QueryParserError", errno_) {}
/** Construct from message and errno value. /** Construct from message and errno value.
* *
* @param msg_ Message giving details of the error, intende d * @param msg_ Message giving details of the error, intende d
* for human consumption. * for human consumption.
* @param errno_ Optional errno value associated with this er ror. * @param errno_ Optional errno value associated with this er ror.
*/ */
QueryParserError(const std::string &msg_, int errno_) QueryParserError(const std::string &msg_, int errno_)
: RuntimeError(msg_, std::string(), "QueryParserError", errno_) {} : RuntimeError(msg_, std::string(), "\020QueryParserError", errno_) {}
protected: protected:
/** @private @internal /** @private @internal
* @brief Constructor for use by constructors of derived classes. * @brief Constructor for use by constructors of derived classes.
*/ */
QueryParserError(const std::string &msg_, const std::string &context_, const char * type_, const char * error_string_) QueryParserError(const std::string &msg_, const std::string &context_, const char * type_, const char * error_string_)
: RuntimeError(msg_, context_, type_, error_string_) {} : RuntimeError(msg_, context_, type_, error_string_) {}
/** @private @internal /** @private @internal
* @brief Constructor for use by constructors of derived classes. * @brief Constructor for use by constructors of derived classes.
*/ */
skipping to change at line 904 skipping to change at line 903
/** Indicates an error in the std::string serialisation of an object. */ /** Indicates an error in the std::string serialisation of an object. */
class XAPIAN_VISIBILITY_DEFAULT SerialisationError : public RuntimeError { class XAPIAN_VISIBILITY_DEFAULT SerialisationError : public RuntimeError {
public: public:
/** @private @internal /** @private @internal
* @brief Private constructor for use by remote backend. * @brief Private constructor for use by remote backend.
* *
* @param error_string_ Optional string describing error. May be NU LL. * @param error_string_ Optional string describing error. May be NU LL.
*/ */
SerialisationError(const std::string &msg_, const std::string &context_ , const char * error_string_) SerialisationError(const std::string &msg_, const std::string &context_ , const char * error_string_)
: RuntimeError(msg_, context_, "SerialisationError", error_string_) {} : RuntimeError(msg_, context_, "\021SerialisationError", error_strin g_) {}
/** General purpose constructor. /** General purpose constructor.
* *
* @param msg_ Message giving details of the error, intende d * @param msg_ Message giving details of the error, intende d
* for human consumption. * for human consumption.
* @param context_ Optional context information for this error. * @param context_ Optional context information for this error.
* @param errno_ Optional errno value associated with this er ror. * @param errno_ Optional errno value associated with this er ror.
*/ */
explicit SerialisationError(const std::string &msg_, const std::string &context_ = std::string(), int errno_ = 0) explicit SerialisationError(const std::string &msg_, const std::string &context_ = std::string(), int errno_ = 0)
: RuntimeError(msg_, context_, "SerialisationError", errno_) {} : RuntimeError(msg_, context_, "\021SerialisationError", errno_) {}
/** Construct from message and errno value. /** Construct from message and errno value.
* *
* @param msg_ Message giving details of the error, intende d * @param msg_ Message giving details of the error, intende d
* for human consumption. * for human consumption.
* @param errno_ Optional errno value associated with this er ror. * @param errno_ Optional errno value associated with this er ror.
*/ */
SerialisationError(const std::string &msg_, int errno_) SerialisationError(const std::string &msg_, int errno_)
: RuntimeError(msg_, std::string(), "SerialisationError", errno_) {} : RuntimeError(msg_, std::string(), "\021SerialisationError", errno_ ) {}
protected: protected:
/** @private @internal /** @private @internal
* @brief Constructor for use by constructors of derived classes. * @brief Constructor for use by constructors of derived classes.
*/ */
SerialisationError(const std::string &msg_, const std::string &context_ , const char * type_, const char * error_string_) SerialisationError(const std::string &msg_, const std::string &context_ , const char * type_, const char * error_string_)
: RuntimeError(msg_, context_, type_, error_string_) {} : RuntimeError(msg_, context_, type_, error_string_) {}
/** @private @internal /** @private @internal
* @brief Constructor for use by constructors of derived classes. * @brief Constructor for use by constructors of derived classes.
*/ */
skipping to change at line 946 skipping to change at line 945
/** RangeError indicates an attempt to access outside the bounds of a conta iner. /** RangeError indicates an attempt to access outside the bounds of a conta iner.
*/ */
class XAPIAN_VISIBILITY_DEFAULT RangeError : public RuntimeError { class XAPIAN_VISIBILITY_DEFAULT RangeError : public RuntimeError {
public: public:
/** @private @internal /** @private @internal
* @brief Private constructor for use by remote backend. * @brief Private constructor for use by remote backend.
* *
* @param error_string_ Optional string describing error. May be NU LL. * @param error_string_ Optional string describing error. May be NU LL.
*/ */
RangeError(const std::string &msg_, const std::string &context_, const char * error_string_) RangeError(const std::string &msg_, const std::string &context_, const char * error_string_)
: RuntimeError(msg_, context_, "RangeError", error_string_) {} : RuntimeError(msg_, context_, "\022RangeError", error_string_) {}
/** General purpose constructor. /** General purpose constructor.
* *
* @param msg_ Message giving details of the error, intende d * @param msg_ Message giving details of the error, intende d
* for human consumption. * for human consumption.
* @param context_ Optional context information for this error. * @param context_ Optional context information for this error.
* @param errno_ Optional errno value associated with this er ror. * @param errno_ Optional errno value associated with this er ror.
*/ */
explicit RangeError(const std::string &msg_, const std::string &context _ = std::string(), int errno_ = 0) explicit RangeError(const std::string &msg_, const std::string &context _ = std::string(), int errno_ = 0)
: RuntimeError(msg_, context_, "RangeError", errno_) {} : RuntimeError(msg_, context_, "\022RangeError", errno_) {}
/** Construct from message and errno value. /** Construct from message and errno value.
* *
* @param msg_ Message giving details of the error, intende d * @param msg_ Message giving details of the error, intende d
* for human consumption. * for human consumption.
* @param errno_ Optional errno value associated with this er ror. * @param errno_ Optional errno value associated with this er ror.
*/ */
RangeError(const std::string &msg_, int errno_) RangeError(const std::string &msg_, int errno_)
: RuntimeError(msg_, std::string(), "RangeError", errno_) {} : RuntimeError(msg_, std::string(), "\022RangeError", errno_) {}
protected: protected:
/** @private @internal /** @private @internal
* @brief Constructor for use by constructors of derived classes. * @brief Constructor for use by constructors of derived classes.
*/ */
RangeError(const std::string &msg_, const std::string &context_, const char * type_, const char * error_string_) RangeError(const std::string &msg_, const std::string &context_, const char * type_, const char * error_string_)
: RuntimeError(msg_, context_, type_, error_string_) {} : RuntimeError(msg_, context_, type_, error_string_) {}
/** @private @internal /** @private @internal
* @brief Constructor for use by constructors of derived classes. * @brief Constructor for use by constructors of derived classes.
*/ */
 End of changes. 63 change blocks. 
75 lines changed or deleted 72 lines changed or added


 errorhandler.h   errorhandler.h 
/** \file errorhandler.h /** @file errorhandler.h
* \brief Decide if a Xapian::Error exception should be ignored. * @brief Decide if a Xapian::Error exception should be ignored.
*/ */
/* Copyright (C) 2003,2006,2007 Olly Betts /* Copyright (C) 2003,2006,2007 Olly Betts
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the * published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version. * License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
 End of changes. 1 change blocks. 
2 lines changed or deleted 2 lines changed or added


 keymaker.h   keymaker.h 
/** @file keymaker.h /** @file keymaker.h
* @brief Build key strings for MSet ordering or collapsing. * @brief Build key strings for MSet ordering or collapsing.
*/ */
/* Copyright (C) 2007,2009 Olly Betts /* Copyright (C) 2007,2009,2011 Olly Betts
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the * published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version. * License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
skipping to change at line 27 skipping to change at line 27
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 US A * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 US A
*/ */
#ifndef XAPIAN_INCLUDED_KEYMAKER_H #ifndef XAPIAN_INCLUDED_KEYMAKER_H
#define XAPIAN_INCLUDED_KEYMAKER_H #define XAPIAN_INCLUDED_KEYMAKER_H
#include <string> #include <string>
#include <vector> #include <vector>
#include <xapian/deprecated.h>
#include <xapian/types.h> #include <xapian/types.h>
#include <xapian/visibility.h> #include <xapian/visibility.h>
namespace Xapian { namespace Xapian {
class Document; class Document;
/** Virtual base class for key making functors. */ /** Virtual base class for key making functors. */
class XAPIAN_VISIBILITY_DEFAULT KeyMaker { class XAPIAN_VISIBILITY_DEFAULT KeyMaker {
public: public:
skipping to change at line 83 skipping to change at line 82
while (begin != end) add_value(*begin++); while (begin != end) add_value(*begin++);
} }
virtual std::string operator()(const Xapian::Document & doc) const; virtual std::string operator()(const Xapian::Document & doc) const;
void add_value(Xapian::valueno slot, bool reverse = false) { void add_value(Xapian::valueno slot, bool reverse = false) {
slots.push_back(std::make_pair(slot, reverse)); slots.push_back(std::make_pair(slot, reverse));
} }
}; };
/** Virtual base class for sorter functor. */
class XAPIAN_VISIBILITY_DEFAULT XAPIAN_DEPRECATED_CLASS Sorter : public Key
Maker { };
/** Sorter subclass which sorts by a several values.
*
* Results are ordered by the first value. In the event of a tie, the
* second is used. If this is the same for both, the third is used, and
* so on.
*
* @deprecated This class is deprecated - you should migrate to using
* MultiValueKeyMaker instead. Note that MultiValueSorter::add
() becomes
* MultiValueKeyMaker::add_value(), but the sense of the direct
ion flag
* is reversed (to be consistent with Enquire::set_sort_by_valu
e()).
*
* So:
* <pre>
* MultiValueSorter sorter;
* // Primary ordering is forwards on value 4.
* sorter.add(4);
* // Secondary ordering is reverse on value 5.
* sorter.add(5, false);
* </pre>
* becomes:
* <pre>
* MultiValueKeyMaker sorter;
* // Primary ordering is forwards on value 4.
* sorter.add_value(4);
* // Secondary ordering is reverse on value 5.
* sorter.add_value(5, true);
* </pre>
*/
class XAPIAN_VISIBILITY_DEFAULT XAPIAN_DEPRECATED_CLASS MultiValueSorter :
public Sorter {
std::vector<std::pair<Xapian::valueno, bool> > slots;
public:
MultiValueSorter() { }
template <class Iterator>
MultiValueSorter(Iterator begin, Iterator end) {
while (begin != end) add(*begin++);
}
virtual std::string operator()(const Xapian::Document & doc) const;
void add(Xapian::valueno slot, bool forward = true) {
slots.push_back(std::make_pair(slot, forward));
}
};
} }
#endif // XAPIAN_INCLUDED_KEYMAKER_H #endif // XAPIAN_INCLUDED_KEYMAKER_H
 End of changes. 3 change blocks. 
56 lines changed or deleted 1 lines changed or added


 matchspy.h   matchspy.h 
/** @file matchspy.h /** @file matchspy.h
* @brief MatchSpy implementation. * @brief MatchSpy implementation.
*/ */
/* Copyright (C) 2007,2008,2009,2010,2012 Olly Betts /* Copyright (C) 2007,2008,2009,2010,2011,2012 Olly Betts
* Copyright (C) 2007,2009 Lemur Consulting Ltd * Copyright (C) 2007,2009 Lemur Consulting Ltd
* Copyright (C) 2010 Richard Boulton * Copyright (C) 2010 Richard Boulton
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
skipping to change at line 26 skipping to change at line 26
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 US A * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 US A
*/ */
#ifndef XAPIAN_INCLUDED_MATCHSPY_H #ifndef XAPIAN_INCLUDED_MATCHSPY_H
#define XAPIAN_INCLUDED_MATCHSPY_H #define XAPIAN_INCLUDED_MATCHSPY_H
#include <xapian/base.h> #include <xapian/intrusive_ptr.h>
#include <xapian/enquire.h>
#include <xapian/termiterator.h> #include <xapian/termiterator.h>
#include <xapian/visibility.h> #include <xapian/visibility.h>
#include <string> #include <string>
#include <map> #include <map>
#include <set>
#include <string>
#include <vector>
namespace Xapian { namespace Xapian {
class Document; class Document;
class Registry; class Registry;
/** Abstract base class for match spies. /** Abstract base class for match spies.
* *
* The subclasses will generally accumulate information seen during the ma tch, * The subclasses will generally accumulate information seen during the ma tch,
* to calculate aggregate functions, or other profiles of the matching * to calculate aggregate functions, or other profiles of the matching
skipping to change at line 76 skipping to change at line 72
* This is called by the matcher once with each document seen by the * This is called by the matcher once with each document seen by the
* matcher during the match process. Note that the matcher will often not * matcher during the match process. Note that the matcher will often not
* see all the documents which match the query, due to optimisations w hich * see all the documents which match the query, due to optimisations w hich
* allow low-weighted documents to be skipped, and allow the match pro cess * allow low-weighted documents to be skipped, and allow the match pro cess
* to be terminated early. * to be terminated early.
* *
* @param doc The document seen by the match spy. * @param doc The document seen by the match spy.
* @param wt The weight of the document. * @param wt The weight of the document.
*/ */
virtual void operator()(const Xapian::Document &doc, virtual void operator()(const Xapian::Document &doc,
Xapian::weight wt) = 0; double wt) = 0;
/** Clone the match spy. /** Clone the match spy.
* *
* The clone should inherit the configuration of the parent, but need not * The clone should inherit the configuration of the parent, but need not
* inherit the state. ie, the clone does not need to be passed * inherit the state. ie, the clone does not need to be passed
* information about the results seen by the parent. * information about the results seen by the parent.
* *
* If you don't want to support the remote backend in your match spy, you * If you don't want to support the remote backend in your match spy, you
* can use the default implementation which simply throws * can use the default implementation which simply throws
* Xapian::UnimplementedError. * Xapian::UnimplementedError.
skipping to change at line 185 skipping to change at line 181
}; };
/** Class for counting the frequencies of values in the matching documents. /** Class for counting the frequencies of values in the matching documents.
*/ */
class XAPIAN_VISIBILITY_DEFAULT ValueCountMatchSpy : public MatchSpy { class XAPIAN_VISIBILITY_DEFAULT ValueCountMatchSpy : public MatchSpy {
public: public:
struct Internal; struct Internal;
#ifndef SWIG // SWIG doesn't need to know about the internal class #ifndef SWIG // SWIG doesn't need to know about the internal class
struct XAPIAN_VISIBILITY_DEFAULT Internal struct XAPIAN_VISIBILITY_DEFAULT Internal
: public Xapian::Internal::RefCntBase : public Xapian::Internal::intrusive_base
{ {
/// The slot to count. /// The slot to count.
Xapian::valueno slot; Xapian::valueno slot;
/// Total number of documents seen by the match spy. /// Total number of documents seen by the match spy.
Xapian::doccount total; Xapian::doccount total;
/// The values seen so far, together with their frequency. /// The values seen so far, together with their frequency.
std::map<std::string, Xapian::doccount> values; std::map<std::string, Xapian::doccount> values;
Internal() : slot(Xapian::BAD_VALUENO), total(0) {} Internal() : slot(Xapian::BAD_VALUENO), total(0) {}
Internal(Xapian::valueno slot_) : slot(slot_), total(0) {} Internal(Xapian::valueno slot_) : slot(slot_), total(0) {}
}; };
#endif #endif
protected: protected:
Xapian::Internal::RefCntPtr<Internal> internal; Xapian::Internal::intrusive_ptr<Internal> internal;
public: public:
/// Construct an empty ValueCountMatchSpy. /// Construct an empty ValueCountMatchSpy.
ValueCountMatchSpy() : internal() {} ValueCountMatchSpy() : internal() {}
/// Construct a MatchSpy which counts the values in a particular slot. /// Construct a MatchSpy which counts the values in a particular slot.
ValueCountMatchSpy(Xapian::valueno slot_) ValueCountMatchSpy(Xapian::valueno slot_)
: internal(new Internal(slot_)) {} : internal(new Internal(slot_)) {}
/** Return the total number of documents tallied. */ /** Return the total number of documents tallied. */
size_t get_total() const { size_t get_total() const {
return internal.get() ? internal->total : 0; return internal->total;
} }
/** Get an iterator over the values seen in the slot. /** Get an iterator over the values seen in the slot.
* *
* Items will be returned in ascending alphabetical order. * Items will be returned in ascending alphabetical order.
* *
* During the iteration, the frequency of the current value can be * During the iteration, the frequency of the current value can be
* obtained with the get_termfreq() method on the iterator. * obtained with the get_termfreq() method on the iterator.
*/ */
TermIterator values_begin() const; TermIterator values_begin() const;
skipping to change at line 255 skipping to change at line 251
return TermIterator(); return TermIterator();
} }
/** Implementation of virtual operator(). /** Implementation of virtual operator().
* *
* This implementation tallies values for a matching document. * This implementation tallies values for a matching document.
* *
* @param doc The document to tally values for. * @param doc The document to tally values for.
* @param wt The weight of the document (ignored by this class). * @param wt The weight of the document (ignored by this class).
*/ */
void operator()(const Xapian::Document &doc, Xapian::weight wt); void operator()(const Xapian::Document &doc, double wt);
virtual MatchSpy * clone() const; virtual MatchSpy * clone() const;
virtual std::string name() const; virtual std::string name() const;
virtual std::string serialise() const; virtual std::string serialise() const;
virtual MatchSpy * unserialise(const std::string & s, virtual MatchSpy * unserialise(const std::string & s,
const Registry & context) const; const Registry & context) const;
virtual std::string serialise_results() const; virtual std::string serialise_results() const;
virtual void merge_results(const std::string & s); virtual void merge_results(const std::string & s);
virtual std::string get_description() const; virtual std::string get_description() const;
}; };
 End of changes. 8 change blocks. 
11 lines changed or deleted 7 lines changed or added


 positioniterator.h   positioniterator.h 
/** \file positioniterator.h /** @file positioniterator.h
* \brief Classes for iterating through position lists * @brief Class for iterating over term positions.
*/ */
/* Copyright 1999,2000,2001 BrightStation PLC /* Copyright (C) 2008,2009,2010,2011 Olly Betts
* Copyright 2002 Ananova Ltd
* Copyright 2003,2004,2007,2009,2012 Olly Betts
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the * published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version. * License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
skipping to change at line 30 skipping to change at line 28
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
* USA * USA
*/ */
#ifndef XAPIAN_INCLUDED_POSITIONITERATOR_H #ifndef XAPIAN_INCLUDED_POSITIONITERATOR_H
#define XAPIAN_INCLUDED_POSITIONITERATOR_H #define XAPIAN_INCLUDED_POSITIONITERATOR_H
#include <iterator> #include <iterator>
#include <string> #include <string>
#include <xapian/base.h>
#include <xapian/derefwrapper.h> #include <xapian/derefwrapper.h>
#include <xapian/types.h> #include <xapian/types.h>
#include <xapian/visibility.h> #include <xapian/visibility.h>
namespace Xapian { namespace Xapian {
class Database; /// Class for iterating over term positions.
class PostingIterator;
class TermIterator;
/** An iterator pointing to items in a list of positions.
*/
class XAPIAN_VISIBILITY_DEFAULT PositionIterator { class XAPIAN_VISIBILITY_DEFAULT PositionIterator {
private: void decref();
// friend classes which need to be able to construct us
friend class PostingIterator; public:
friend class TermIterator; /// Class representing the PositionIterator internals.
friend class Database; class Internal;
/// @private @internal Reference counted internals.
public: Internal * internal;
class Internal;
/// @private @internal Reference counted internals. /// @private @internal Construct given internals.
Xapian::Internal::RefCntPtr<Internal> internal; explicit PositionIterator(Internal *internal_);
friend bool operator==(const PositionIterator &a, const PositionIte /// Copy constructor.
rator &b); PositionIterator(const PositionIterator & o);
// FIXME: ought to be private /// Assignment.
explicit PositionIterator(Internal *internal_); PositionIterator & operator=(const PositionIterator & o);
/// Default constructor - for declaring an uninitialised iterator /** Default constructor.
PositionIterator(); *
* Creates an uninitialised iterator, which can't be used before being
/// Destructor * assigned to, but is sometimes syntactically convenient.
~PositionIterator(); */
PositionIterator() : internal(0) { }
/** Copying is allowed. The internals are reference counted, so
* copying is also cheap. /// Destructor.
*/ ~PositionIterator() {
PositionIterator(const PositionIterator &o); if (internal) decref();
}
/** Assignment is allowed. The internals are reference counted,
* so assignment is also cheap. /// Return the term position at the current iterator position.
*/ Xapian::termpos operator*() const;
void operator=(const PositionIterator &o);
/// Advance the iterator to the next position.
/// Return the term position at the current iterator position. PositionIterator & operator++();
Xapian::termpos operator *() const;
/// Advance the iterator to the next position (postfix version).
/// Advance the iterator to the next position. DerefWrapper_<Xapian::termpos> operator++(int) {
PositionIterator & operator++(); Xapian::termpos pos(**this);
operator++();
/// Advance the iterator to the next position (postfix version). return DerefWrapper_<Xapian::termpos>(pos);
DerefWrapper_<termpos> operator++(int) { }
Xapian::termpos tmp = **this;
operator++(); /** Advance the iterator to term position @a termpos.
return DerefWrapper_<termpos>(tmp); *
} * @param termpos The position to advance to. If this position isn't
in
/** Advance the iterator to the specified termpos. * the stream being iterated, then the iterator is move
* d
* If the specified termpos isn't in the list, position ourselves o * to the next term position after it which is.
n the */
* first termpos after it (or at_end() if no greater term positions void skip_to(Xapian::termpos termpos);
are
* present). /// Return a string describing this object.
*/ std::string get_description() const;
void skip_to(Xapian::termpos pos);
/** @private @internal PositionIterator is what the C++ STL calls an
/// Return a string describing this object. * input_iterator.
std::string get_description() const; *
* The following typedefs allow std::iterator_traits<> to work so that
// Allow use as an STL iterator * this iterator can be used with the STL.
typedef std::input_iterator_tag iterator_category; *
typedef Xapian::termpos value_type; * These are deliberately hidden from the Doxygen-generated docs, as t
typedef Xapian::termpos_diff difference_type; // "om_termposcount" he
typedef Xapian::termpos * pointer; * machinery here isn't interesting to API users. They just need to k
typedef Xapian::termpos & reference; now
* that Xapian iterator classes are compatible with the STL.
*/
// @{
/// @private
typedef std::input_iterator_tag iterator_category;
/// @private
typedef Xapian::termpos value_type;
/// @private
typedef Xapian::termpos_diff difference_type;
/// @private
typedef Xapian::termpos * pointer;
/// @private
typedef Xapian::termpos & reference;
// @}
}; };
/// Test equality of two PositionIterators /// Equality test for PositionIterator objects.
inline bool inline bool
operator==(const PositionIterator &a, const PositionIterator &b) operator==(const PositionIterator &a, const PositionIterator &b)
{ {
return (a.internal.get() == b.internal.get()); // Use a pointer comparison - this ensures both that (a == a) and corre
ct
// handling of end iterators (which we ensure have NULL internals).
return a.internal == b.internal;
} }
/// Test inequality of two PositionIterators /// Inequality test for PositionIterator objects.
inline bool inline bool
operator!=(const PositionIterator &a, const PositionIterator &b) operator!=(const PositionIterator &a, const PositionIterator &b)
{ {
return !(a == b); return !(a == b);
} }
} }
#endif /* XAPIAN_INCLUDED_POSITIONITERATOR_H */ #endif // XAPIAN_INCLUDED_POSITIONITERATOR_H
 End of changes. 9 change blocks. 
80 lines changed or deleted 89 lines changed or added


 postingiterator.h   postingiterator.h 
/** \file postingiterator.h /** @file postingiterator.h
* \brief Classes for iterating through posting lists * @brief Class for iterating over a list of document ids
*/ */
/* Copyright 1999,2000,2001 BrightStation PLC /* Copyright (C) 2007,2008,2009,2010,2011 Olly Betts
* Copyright 2002 Ananova Ltd
* Copyright 2003,2004,2005,2007,2008,2009,2012 Olly Betts
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the * published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version. * License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
skipping to change at line 30 skipping to change at line 28
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
* USA * USA
*/ */
#ifndef XAPIAN_INCLUDED_POSTINGITERATOR_H #ifndef XAPIAN_INCLUDED_POSTINGITERATOR_H
#define XAPIAN_INCLUDED_POSTINGITERATOR_H #define XAPIAN_INCLUDED_POSTINGITERATOR_H
#include <iterator> #include <iterator>
#include <string> #include <string>
#include <xapian/base.h>
#include <xapian/derefwrapper.h> #include <xapian/derefwrapper.h>
#include <xapian/types.h>
#include <xapian/positioniterator.h> #include <xapian/positioniterator.h>
#include <xapian/types.h>
#include <xapian/visibility.h> #include <xapian/visibility.h>
namespace Xapian { namespace Xapian {
class Database; /// Class for iterating over a list of terms.
/** An iterator pointing to items in a list of postings.
*/
class XAPIAN_VISIBILITY_DEFAULT PostingIterator { class XAPIAN_VISIBILITY_DEFAULT PostingIterator {
public: public:
class Internal; /// Class representing the PostingIterator internals.
/// @private @internal Reference counted internals. class Internal;
Xapian::Internal::RefCntPtr<Internal> internal; /// @private @internal Reference counted internals.
Internal * internal;
private:
friend class Database; // So Database can construct us /// @private @internal Construct given internals.
explicit PostingIterator(Internal *internal_);
explicit PostingIterator(Internal *internal_);
/// Copy constructor.
public: PostingIterator(const PostingIterator & o);
friend bool operator==(const PostingIterator &a,
const PostingIterator &b); /// Assignment.
PostingIterator & operator=(const PostingIterator & o);
/// Default constructor - for declaring an uninitialised iterator
PostingIterator(); /** Default constructor.
*
/// Destructor * Creates an uninitialised iterator, which can't be used before being
~PostingIterator(); * assigned to, but is sometimes syntactically convenient.
*/
/** Copying is allowed. The internals are reference counted, so PostingIterator() : internal(0) { }
* copying is also cheap.
*/ /// Destructor.
PostingIterator(const PostingIterator &other); ~PostingIterator() {
if (internal) decref();
/** Assignment is allowed. The internals are reference counted, }
* so assignment is also cheap.
*/ /// Return the document id at the current position.
void operator=(const PostingIterator &other); Xapian::docid operator*() const;
/// Advance the iterator to the next position. /// Return the wdf for the document at the current position.
PostingIterator & operator++(); Xapian::termcount get_wdf() const;
/// Advance the iterator to the next position (postfix version). /// Return the length of the document at the current position.
DerefWrapper_<docid> operator++(int) { Xapian::termcount get_doclength() const;
Xapian::docid tmp = **this;
operator++(); #if 0 // FIXME: TermIterator supports this, so PostingIterator really ought
return DerefWrapper_<docid>(tmp); to.
} /// Return the length of the position list for the current position.
Xapian::termcount positionlist_count() const;
/** Advance the iterator to the specified docid. #endif
*
* If the specified docid isn't in the list, position ourselves on /// Return a PositionIterator for the current document.
the PositionIterator positionlist_begin() const;
* first document after it (or at_end() if no greater docids are
* present). /// Return an end PositionIterator for the current document.
*/ PositionIterator positionlist_end() const {
void skip_to(Xapian::docid did); return PositionIterator();
}
/// Get the document id at the current position in the postlist.
Xapian::docid operator *() const; /// Advance the iterator to the next position.
PostingIterator & operator++();
/** Get the length of the document at the current position in the
* postlist. /// Advance the iterator to the next position (postfix version).
* DerefWrapper_<Xapian::docid> operator++(int) {
* This information may be stored in the postlist, in which case Xapian::docid did(**this);
* this lookup should be extremely fast (indeed, not require furthe operator++();
r return DerefWrapper_<Xapian::docid>(did);
* disk access). If the information is not present in the postlist }
,
* it will be retrieved from the database, at a greater performance /** Advance the iterator to document @a did.
* cost. *
*/ * @param did The document id to advance to. If this document id
Xapian::termcount get_doclength() const; * isn't in the stream being iterated, then the iterato
r
/** Get the within document frequency of the document at the * is moved to the next document id after it which is.
* current position in the postlist. */
*/ void skip_to(Xapian::docid did);
Xapian::termcount get_wdf() const;
/// Return a string describing this object.
/** Return PositionIterator pointing to start of positionlist for std::string get_description() const;
* current document.
*/ /** @private @internal PostingIterator is what the C++ STL calls an
PositionIterator positionlist_begin() const; * input_iterator.
*
/** Return PositionIterator pointing to end of positionlist for * The following typedefs allow std::iterator_traits<> to work so that
* current document. * this iterator can be used with the STL.
*/ *
PositionIterator positionlist_end() const { * These are deliberately hidden from the Doxygen-generated docs, as t
return PositionIterator(); he
} * machinery here isn't interesting to API users. They just need to k
now
// Don't expose these methods here. A container iterator doesn't * that Xapian iterator classes are compatible with the STL.
// provide a method to find the size of the container... */
// Xapian::doccount get_termfreq() const; // @{
// Xapian::termcount get_collection_freq() const; /// @private
typedef std::input_iterator_tag iterator_category;
/// Return a string describing this object. /// @private
std::string get_description() const; typedef Xapian::docid value_type;
/// @private
/// Allow use as an STL iterator typedef Xapian::doccount_diff difference_type;
//@{ /// @private
typedef std::input_iterator_tag iterator_category; typedef Xapian::docid * pointer;
typedef Xapian::docid value_type; /// @private
typedef Xapian::doccount_diff difference_type; typedef Xapian::docid & reference;
typedef Xapian::docid * pointer; // @}
typedef Xapian::docid & reference;
//@} private:
void decref();
void post_advance(Internal * res);
}; };
/// Test equality of two PostingIterators /// Equality test for PostingIterator objects.
inline bool operator==(const PostingIterator &a, const PostingIterator &b) inline bool
operator==(const PostingIterator &a, const PostingIterator &b)
{ {
return (a.internal.get() == b.internal.get()); // Use a pointer comparison - this ensures both that (a == a) and corre
ct
// handling of end iterators (which we ensure have NULL internals).
return a.internal == b.internal;
} }
/// Test inequality of two PostingIterators /// Inequality test for PostingIterator objects.
inline bool operator!=(const PostingIterator &a, const PostingIterator &b) inline bool
operator!=(const PostingIterator &a, const PostingIterator &b)
{ {
return !(a == b); return !(a == b);
} }
} }
#endif /* XAPIAN_INCLUDED_POSTINGITERATOR_H */ #endif // XAPIAN_INCLUDED_POSTINGITERATOR_H
 End of changes. 11 change blocks. 
114 lines changed or deleted 116 lines changed or added


 postingsource.h   postingsource.h 
skipping to change at line 34 skipping to change at line 34
#include <xapian/database.h> #include <xapian/database.h>
#include <xapian/types.h> #include <xapian/types.h>
#include <xapian/visibility.h> #include <xapian/visibility.h>
#include <string> #include <string>
#include <map> #include <map>
namespace Xapian { namespace Xapian {
class Registry;
/** Base class which provides an "external" source of postings. /** Base class which provides an "external" source of postings.
*/ */
class XAPIAN_VISIBILITY_DEFAULT PostingSource { class XAPIAN_VISIBILITY_DEFAULT PostingSource {
/// Don't allow assignment. /// Don't allow assignment.
void operator=(const PostingSource &); void operator=(const PostingSource &);
/// Don't allow copying. /// Don't allow copying.
PostingSource(const PostingSource &); PostingSource(const PostingSource &);
/// The current upper bound on what get_weight() can return. /// The current upper bound on what get_weight() can return.
skipping to change at line 77 skipping to change at line 79
* get_weight() earlier in the iteration, but the posting source must not * get_weight() earlier in the iteration, but the posting source must not
* return a higher value from get_weight() than the currently set uppe r * return a higher value from get_weight() than the currently set uppe r
* bound, and the upper bound must not be increased (until init() has been * bound, and the upper bound must not be increased (until init() has been
* called). * called).
* *
* If you don't call this method, the upper bound will default to 0, f or * If you don't call this method, the upper bound will default to 0, f or
* convenience when implementing "weight-less" PostingSource subclasse s. * convenience when implementing "weight-less" PostingSource subclasse s.
* *
* @param max_weight The upper bound to set. * @param max_weight The upper bound to set.
*/ */
void set_maxweight(Xapian::weight max_weight); void set_maxweight(double max_weight);
public: public:
/** @private @internal Set the object to inform of maxweight changes. /** @private @internal Set the object to inform of maxweight changes.
* *
* This method is for internal use only - it would be private except t hat * This method is for internal use only - it would be private except t hat
* would force us to forward declare an internal class in an external API * would force us to forward declare an internal class in an external API
* header just to make it a friend. * header just to make it a friend.
*/ */
void register_matcher_(void * matcher) { matcher_ = matcher; } void register_matcher_(void * matcher) { matcher_ = matcher; }
skipping to change at line 117 skipping to change at line 119
virtual Xapian::doccount get_termfreq_est() const = 0; virtual Xapian::doccount get_termfreq_est() const = 0;
/** An upper bound on the number of documents this object can return. /** An upper bound on the number of documents this object can return.
* *
* Xapian will always call init() on a PostingSource before calling th is * Xapian will always call init() on a PostingSource before calling th is
* for the first time. * for the first time.
*/ */
virtual Xapian::doccount get_termfreq_max() const = 0; virtual Xapian::doccount get_termfreq_max() const = 0;
/// Return the currently set upper bound on what get_weight() can retur n. /// Return the currently set upper bound on what get_weight() can retur n.
Xapian::weight get_maxweight() const { return max_weight_; } double get_maxweight() const { return max_weight_; }
/** Return the weight contribution for the current document. /** Return the weight contribution for the current document.
* *
* This default implementation always returns 0, for convenience when * This default implementation always returns 0, for convenience when
* implementing "weight-less" PostingSource subclasses. * implementing "weight-less" PostingSource subclasses.
* *
* This method may assume that it will only be called when there is a * This method may assume that it will only be called when there is a
* "current document". In detail: Xapian will always call init() on a * "current document". In detail: Xapian will always call init() on a
* PostingSource before calling this for the first time. It will also * PostingSource before calling this for the first time. It will also
* only call this if the PostingSource reports that it is pointing to a * only call this if the PostingSource reports that it is pointing to a
* valid document (ie, it will not call it before calling at least one of * valid document (ie, it will not call it before calling at least one of
* next(), skip_to() or check(), and will ensure that the PostingSourc e is * next(), skip_to() or check(), and will ensure that the PostingSourc e is
* not at the end by calling at_end()). * not at the end by calling at_end()).
*/ */
virtual Xapian::weight get_weight() const; virtual double get_weight() const;
/** Return the current docid. /** Return the current docid.
* *
* This method may assume that it will only be called when there is a * This method may assume that it will only be called when there is a
* "current document". See @a get_weight() for details. * "current document". See @a get_weight() for details.
* *
* Note: in the case of a multi-database search, the returned docid sh ould * Note: in the case of a multi-database search, the returned docid sh ould
* be in the single subdatabase relevant to this posting source. See the * be in the single subdatabase relevant to this posting source. See the
* @a init() method for details. * @a init() method for details.
*/ */
skipping to change at line 157 skipping to change at line 159
* The PostingSource starts before the first entry in the list, so nex t() * The PostingSource starts before the first entry in the list, so nex t()
* must be called before any methods which need the context of * must be called before any methods which need the context of
* the current position. * the current position.
* *
* Xapian will always call init() on a PostingSource before calling th is * Xapian will always call init() on a PostingSource before calling th is
* for the first time. * for the first time.
* *
* @param min_wt The minimum weight contribution that is needed (this is * @param min_wt The minimum weight contribution that is needed (this is
* just a hint which subclasses may ignore). * just a hint which subclasses may ignore).
*/ */
virtual void next(Xapian::weight min_wt) = 0; virtual void next(double min_wt) = 0;
/** Advance to the specified docid. /** Advance to the specified docid.
* *
* If the specified docid isn't in the list, position ourselves on the * If the specified docid isn't in the list, position ourselves on the
* first document after it (or at_end() if no greater docids are prese nt). * first document after it (or at_end() if no greater docids are prese nt).
* *
* If the current position is already the specified docid, this method will * If the current position is already the specified docid, this method will
* leave the position unmodified. * leave the position unmodified.
* *
* If the specified docid is earlier than the current position, the * If the specified docid is earlier than the current position, the
skipping to change at line 186 skipping to change at line 188
* for the first time. * for the first time.
* *
* Note: in the case of a multi-database search, the docid specified i s * Note: in the case of a multi-database search, the docid specified i s
* the docid in the single subdatabase relevant to this posting source . * the docid in the single subdatabase relevant to this posting source .
* See the @a init() method for details. * See the @a init() method for details.
* *
* @param did The document id to advance to. * @param did The document id to advance to.
* @param min_wt The minimum weight contribution that is needed (this is * @param min_wt The minimum weight contribution that is needed (this is
* just a hint which subclasses may ignore). * just a hint which subclasses may ignore).
*/ */
virtual void skip_to(Xapian::docid did, Xapian::weight min_wt); virtual void skip_to(Xapian::docid did, double min_wt);
/** Check if the specified docid occurs. /** Check if the specified docid occurs.
* *
* The caller is required to ensure that the specified document id @a did * The caller is required to ensure that the specified document id @a did
* actually exists in the database. If it does, it must move to that * actually exists in the database. If it does, it must move to that
* document id, and return true. If it does not, it may either: * document id, and return true. If it does not, it may either:
* *
* - return true, having moved to a definite position (including * - return true, having moved to a definite position (including
* "at_end"), which must be the same position as skip_to() would have * "at_end"), which must be the same position as skip_to() would have
* moved to. * moved to.
skipping to change at line 223 skipping to change at line 225
* for the first time. * for the first time.
* *
* Note: in the case of a multi-database search, the docid specified i s * Note: in the case of a multi-database search, the docid specified i s
* the docid in the single subdatabase relevant to this posting source . * the docid in the single subdatabase relevant to this posting source .
* See the @a init() method for details. * See the @a init() method for details.
* *
* @param did The document id to check. * @param did The document id to check.
* @param min_wt The minimum weight contribution that is needed (this is * @param min_wt The minimum weight contribution that is needed (this is
* just a hint which subclasses may ignore). * just a hint which subclasses may ignore).
*/ */
virtual bool check(Xapian::docid did, Xapian::weight min_wt); virtual bool check(Xapian::docid did, double min_wt);
/** Return true if the current position is past the last entry in this list. /** Return true if the current position is past the last entry in this list.
* *
* At least one of @a next(), @a skip_to() or @a check() will be calle d * At least one of @a next(), @a skip_to() or @a check() will be calle d
* before this method is first called. * before this method is first called.
*/ */
virtual bool at_end() const = 0; virtual bool at_end() const = 0;
/** Clone the posting source. /** Clone the posting source.
* *
skipping to change at line 300 skipping to change at line 302
* method in your subclass as shown here: * method in your subclass as shown here:
* http://trac.xapian.org/ticket/554#comment:1 * http://trac.xapian.org/ticket/554#comment:1
* *
* If you don't want to support the remote backend, you can use the * If you don't want to support the remote backend, you can use the
* default implementation which simply throws Xapian::UnimplementedErr or. * default implementation which simply throws Xapian::UnimplementedErr or.
* *
* @param s A serialised instance of this PostingSource subclass. * @param s A serialised instance of this PostingSource subclass.
*/ */
virtual PostingSource * unserialise(const std::string &s) const; virtual PostingSource * unserialise(const std::string &s) const;
/** Create object given string serialisation returned by serialise().
*
* Note that the returned object will be deallocated by Xapian after u
se
* with "delete". If you want to handle the deletion in a special way
* (for example when wrapping the Xapian API for use from another
* language) then you can define a static <code>operator delete</code>
* method in your subclass as shown here:
* http://trac.xapian.org/ticket/554#comment:1
*
* This method is supplied with a Registry object, which can be used w
hen
* unserialising objects contained within the posting source. The def
ault
* implementation simply calls unserialise() which doesn't take the
* Registry object, so you do not need to implement this method unless
you
* want to take advantage of the Registry object when unserialising.
*
* @param s A serialised instance of this PostingSource subclass.
*/
virtual PostingSource * unserialise_with_registry(const std::string &s,
const Registry & registry) const;
/** Set this PostingSource to the start of the list of postings. /** Set this PostingSource to the start of the list of postings.
* *
* This is called automatically by the matcher prior to each query bei ng * This is called automatically by the matcher prior to each query bei ng
* processed. * processed.
* *
* If a PostingSource is used for multiple searches, @a init() will * If a PostingSource is used for multiple searches, @a init() will
* therefore be called multiple times, and must handle this by using t he * therefore be called multiple times, and must handle this by using t he
* database passed in the most recent call. * database passed in the most recent call.
* *
* @param db The database which the PostingSource should iterate throu gh. * @param db The database which the PostingSource should iterate throu gh.
skipping to change at line 390 skipping to change at line 412
/** Construct a ValuePostingSource. /** Construct a ValuePostingSource.
* *
* @param slot_ The value slot to read values from. * @param slot_ The value slot to read values from.
*/ */
ValuePostingSource(Xapian::valueno slot_); ValuePostingSource(Xapian::valueno slot_);
Xapian::doccount get_termfreq_min() const; Xapian::doccount get_termfreq_min() const;
Xapian::doccount get_termfreq_est() const; Xapian::doccount get_termfreq_est() const;
Xapian::doccount get_termfreq_max() const; Xapian::doccount get_termfreq_max() const;
void next(Xapian::weight min_wt); void next(double min_wt);
void skip_to(Xapian::docid min_docid, Xapian::weight min_wt); void skip_to(Xapian::docid min_docid, double min_wt);
bool check(Xapian::docid min_docid, Xapian::weight min_wt); bool check(Xapian::docid min_docid, double min_wt);
bool at_end() const; bool at_end() const;
Xapian::docid get_docid() const; Xapian::docid get_docid() const;
void init(const Database & db_); void init(const Database & db_);
}; };
/** A posting source which reads weights from a value slot. /** A posting source which reads weights from a value slot.
* *
skipping to change at line 428 skipping to change at line 450
*/ */
class XAPIAN_VISIBILITY_DEFAULT ValueWeightPostingSource class XAPIAN_VISIBILITY_DEFAULT ValueWeightPostingSource
: public ValuePostingSource { : public ValuePostingSource {
public: public:
/** Construct a ValueWeightPostingSource. /** Construct a ValueWeightPostingSource.
* *
* @param slot_ The value slot to read values from. * @param slot_ The value slot to read values from.
*/ */
ValueWeightPostingSource(Xapian::valueno slot_); ValueWeightPostingSource(Xapian::valueno slot_);
Xapian::weight get_weight() const; double get_weight() const;
ValueWeightPostingSource * clone() const; ValueWeightPostingSource * clone() const;
std::string name() const; std::string name() const;
std::string serialise() const; std::string serialise() const;
ValueWeightPostingSource * unserialise(const std::string &s) const; ValueWeightPostingSource * unserialise(const std::string &s) const;
void init(const Database & db_); void init(const Database & db_);
std::string get_description() const; std::string get_description() const;
}; };
/** Read weights from a value which is known to decrease as docid increases . /** Read weights from a value which is known to decrease as docid increases .
skipping to change at line 468 skipping to change at line 490
: public Xapian::ValueWeightPostingSource { : public Xapian::ValueWeightPostingSource {
protected: protected:
Xapian::docid range_start; Xapian::docid range_start;
Xapian::docid range_end; Xapian::docid range_end;
double curr_weight; double curr_weight;
/// Flag, set to true if there are docs after the end of the range. /// Flag, set to true if there are docs after the end of the range.
bool items_at_end; bool items_at_end;
/// Skip the iterator forward if in the decreasing range, and weight is low. /// Skip the iterator forward if in the decreasing range, and weight is low.
void skip_if_in_range(Xapian::weight min_wt); void skip_if_in_range(double min_wt);
public: public:
DecreasingValueWeightPostingSource(Xapian::valueno slot_, DecreasingValueWeightPostingSource(Xapian::valueno slot_,
Xapian::docid range_start_ = 0, Xapian::docid range_start_ = 0,
Xapian::docid range_end_ = 0); Xapian::docid range_end_ = 0);
Xapian::weight get_weight() const; double get_weight() const;
DecreasingValueWeightPostingSource * clone() const; DecreasingValueWeightPostingSource * clone() const;
std::string name() const; std::string name() const;
std::string serialise() const; std::string serialise() const;
DecreasingValueWeightPostingSource * unserialise(const std::string &s) const; DecreasingValueWeightPostingSource * unserialise(const std::string &s) const;
void init(const Xapian::Database & db_); void init(const Xapian::Database & db_);
void next(Xapian::weight min_wt); void next(double min_wt);
void skip_to(Xapian::docid min_docid, Xapian::weight min_wt); void skip_to(Xapian::docid min_docid, double min_wt);
bool check(Xapian::docid min_docid, Xapian::weight min_wt); bool check(Xapian::docid min_docid, double min_wt);
std::string get_description() const; std::string get_description() const;
}; };
/** A posting source which looks up weights in a map using values as the ke y. /** A posting source which looks up weights in a map using values as the ke y.
* *
* This allows will return entries for all documents in the given database * This allows will return entries for all documents in the given database
* which have a value in the slot specified. The values will be mapped to the * which have a value in the slot specified. The values will be mapped to the
* corresponding weight in the weight map. If there is no mapping for a * corresponding weight in the weight map. If there is no mapping for a
* particular value, the default weight will be returned (which itself * particular value, the default weight will be returned (which itself
skipping to change at line 531 skipping to change at line 553
/** Clear all mappings. */ /** Clear all mappings. */
void clear_mappings(); void clear_mappings();
/** Set a default weight for document values not in the map. /** Set a default weight for document values not in the map.
* *
* @param wt The weight to set as the default. * @param wt The weight to set as the default.
*/ */
void set_default_weight(double wt); void set_default_weight(double wt);
Xapian::weight get_weight() const; double get_weight() const;
ValueMapPostingSource * clone() const; ValueMapPostingSource * clone() const;
std::string name() const; std::string name() const;
std::string serialise() const; std::string serialise() const;
ValueMapPostingSource * unserialise(const std::string &s) const; ValueMapPostingSource * unserialise(const std::string &s) const;
void init(const Database & db_); void init(const Database & db_);
std::string get_description() const; std::string get_description() const;
}; };
/** A posting source which returns a fixed weight for all documents. /** A posting source which returns a fixed weight for all documents.
skipping to change at line 567 skipping to change at line 589
bool started; bool started;
/// The docid last passed to check() (0 if check() wasn't the last move ). /// The docid last passed to check() (0 if check() wasn't the last move ).
Xapian::docid check_docid; Xapian::docid check_docid;
public: public:
/** Construct a FixedWeightPostingSource. /** Construct a FixedWeightPostingSource.
* *
* @param wt The fixed weight to return. * @param wt The fixed weight to return.
*/ */
FixedWeightPostingSource(Xapian::weight wt); FixedWeightPostingSource(double wt);
Xapian::doccount get_termfreq_min() const; Xapian::doccount get_termfreq_min() const;
Xapian::doccount get_termfreq_est() const; Xapian::doccount get_termfreq_est() const;
Xapian::doccount get_termfreq_max() const; Xapian::doccount get_termfreq_max() const;
Xapian::weight get_weight() const; double get_weight() const;
void next(Xapian::weight min_wt); void next(double min_wt);
void skip_to(Xapian::docid min_docid, Xapian::weight min_wt); void skip_to(Xapian::docid min_docid, double min_wt);
bool check(Xapian::docid min_docid, Xapian::weight min_wt); bool check(Xapian::docid min_docid, double min_wt);
bool at_end() const; bool at_end() const;
Xapian::docid get_docid() const; Xapian::docid get_docid() const;
FixedWeightPostingSource * clone() const; FixedWeightPostingSource * clone() const;
std::string name() const; std::string name() const;
std::string serialise() const; std::string serialise() const;
FixedWeightPostingSource * unserialise(const std::string &s) const; FixedWeightPostingSource * unserialise(const std::string &s) const;
void init(const Database & db_); void init(const Database & db_);
 End of changes. 17 change blocks. 
21 lines changed or deleted 47 lines changed or added


 query.h   query.h 
/** \file query.h /** @file query.h
* \brief Classes for representing a query * @brief Xapian::Query API class
*/ */
/* Copyright 1999,2000,2001 BrightStation PLC /* Copyright (C) 2011,2012 Olly Betts
* Copyright 2002 Ananova Ltd * Copyright (C) 2008 Richard Boulton
* Copyright 2003,2004,2005,2006,2007,2008,2009,2012 Olly Betts
* Copyright 2006,2007,2008,2009 Lemur Consulting Ltd
* Copyright 2008 Richard Boulton
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the * published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version. * License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 US
* USA A
*/ */
#ifndef XAPIAN_INCLUDED_QUERY_H #ifndef XAPIAN_INCLUDED_QUERY_H
#define XAPIAN_INCLUDED_QUERY_H #define XAPIAN_INCLUDED_QUERY_H
#include <string> #include <string>
#include <vector> #include <vector>
#include <xapian/base.h> #include <xapian/intrusive_ptr.h>
#include <xapian/types.h> #include <xapian/postingiterator.h>
#include <xapian/registry.h>
#include <xapian/termiterator.h> #include <xapian/termiterator.h>
#include <xapian/types.h>
#include <xapian/visibility.h> #include <xapian/visibility.h>
// FIXME: sort this out so we avoid exposing Xapian::Query::Internal class QueryOptimiser; // FIXME
// - we need to at present so that the Xapian::Query's template ctors
// compile.
class LocalSubMatch;
class MultiMatch;
class QueryOptimiser;
struct SortPosName;
namespace Xapian { namespace Xapian {
class PostingSource; class PostingSource;
class Registry;
/** Class representing a query. /// Class representing a query.
*
* Queries are represented as a tree of objects.
*/
class XAPIAN_VISIBILITY_DEFAULT Query { class XAPIAN_VISIBILITY_DEFAULT Query {
public: public:
/// Class holding details of the query /// Class representing the query internals.
class Internal; class Internal;
/// @private @internal Reference counted internals. /// @private @internal Reference counted internals.
Xapian::Internal::RefCntPtr<Internal> internal; Xapian::Internal::intrusive_ptr<Internal> internal;
/// Enum of possible query operations static const Xapian::Query MatchNothing;
typedef enum { static const Xapian::Query MatchAll;
/// Return iff both subqueries are satisfied
OP_AND, /** Query operators. */
enum op {
/// Return if either subquery is satisfied OP_AND = 0,
OP_OR, OP_OR = 1,
OP_AND_NOT = 2,
/// Return if left but not right satisfied OP_XOR = 3,
OP_AND_NOT, OP_AND_MAYBE = 4,
OP_FILTER = 5,
/// Return if one query satisfied, but not both OP_NEAR = 6,
OP_XOR, OP_PHRASE = 7,
OP_VALUE_RANGE = 8,
/// Return iff left satisfied, but use weights from both OP_SCALE_WEIGHT = 9,
OP_AND_MAYBE,
/** Pick the best N subqueries and combine with OP_OR.
/// As AND, but use only weights from left subquery *
OP_FILTER, * If you want to implement a feature which finds documents similar
to
/** Find occurrences of a list of terms with all the terms * a piece of text, an obvious approach is to build an "OR" query f
* occurring within a specified window of positions. rom
* * all the terms in the text, and run this query against a database
* Each occurrence of a term must be at a different position, * containing the documents. However such a query can contain a lo
* but the order they appear in is irrelevant. ts
* * of terms and be quite slow to perform, yet many of these terms
* The window parameter should be specified for this operation, * don't contribute usefully to the results.
* but will default to the number of terms in the list. *
*/ * The OP_ELITE_SET operator can be used instead of OP_OR in this
OP_NEAR, * situation. OP_ELITE_SET selects the most important ''N'' terms
and
/** Find occurrences of a list of terms with all the terms * then acts as an OP_OR query with just these, ignoring any other
* occurring within a specified window of positions, and all * terms. This will usually return results just as good as the ful
* the terms appearing in the order specified. l
* * OP_OR query, but much faster.
* Each occurrence of a term must be at a different position. *
* * In general, the OP_ELITE_SET operator can be used when you have
* The window parameter should be specified for this operation, a
* but will default to the number of terms in the list. * large OR query, but it doesn't matter if the search completely
*/ * ignores some of the less important terms in the query.
OP_PHRASE, *
* The subqueries don't have to be terms, but if they aren't then
/** Filter by a range test on a document value. */ * OP_ELITE_SET will look at the estimated frequencies of the
OP_VALUE_RANGE, * subqueries and so could pick a subset which don't actually
* match any documents even if the full OR would match some.
/** Scale the weight of a subquery by the specified factor. *
* * You can specify a parameter to the query constructor which contr
* A factor of 0 means this subquery will contribute no weight ol
to * the number of terms which OP_ELITE_SET will pick. If not
* the query - it will act as a purely boolean subquery. * specified, this defaults to 10 (Xapian used to default to
* * <code>ceil(sqrt(number_of_subqueries))</code> if there are more
* If the factor is negative, Xapian::InvalidArgumentError will * than 100 subqueries, but this rather arbitrary special case was
* be thrown. * dropped in 1.3.0). For example, this will pick the best 7 terms
*/ :
OP_SCALE_WEIGHT, *
* <pre>
/** Pick the best N subqueries and combine with OP_OR. * Xapian::Query query(Xapian::Query::OP_ELITE_SET, subqs.begin(),
* subqs.end(), 7);
* If you want to implement a feature which finds documents * </pre>
* similar to a piece of text, an obvious approach is to build *
an * If the number of subqueries is less than this threshold,
* "OR" query from all the terms in the text, and run this quer * OP_ELITE_SET behaves identically to OP_OR.
y */
* against a database containing the documents. However such a OP_ELITE_SET = 10,
* query can contain a lots of terms and be quite slow to perfo OP_VALUE_GE = 11,
rm, OP_VALUE_LE = 12,
* yet many of these terms don't contribute usefully to the OP_SYNONYM = 13
* results. };
*
* The OP_ELITE_SET operator can be used instead of OP_OR in th /// Default constructor.
is Query() : internal(0) { }
* situation. OP_ELITE_SET selects the most important ''N'' te
rms /// Destructor.
* and then acts as an OP_OR query with just these, ignoring an ~Query() { }
y
* other terms. This will usually return results just as good /** Copying is allowed.
as *
* the full OP_OR query, but much faster. * The internals are reference counted, so copying is cheap.
* */
* In general, the OP_ELITE_SET operator can be used when you h Query(const Query & o) : internal(o.internal) { }
ave
* a large OR query, but it doesn't matter if the search /** Copying is allowed.
* completely ignores some of the less important terms in the *
* query. * The internals are reference counted, so assignment is cheap.
* */
* The subqueries don't have to be terms, but if they aren't th Query & operator=(const Query & o) { internal = o.internal; return *thi
en s; }
* OP_ELITE_SET will look at the estimated frequencies of the
* subqueries and so could pick a subset which don't actually /** Construct a Query object for a term. */
* match any documents even if the full OR would match some. Query(const std::string & term,
* Xapian::termcount wqf = 1,
* You can specify a parameter to the query constructor which Xapian::termpos pos = 0);
* control the number of terms which OP_ELITE_SET will pick. I
f /** Construct a Query object for a PostingSource. */
* not specified, this defaults to 10 (or Query(Xapian::PostingSource * source);
* <code>ceil(sqrt(number_of_subqueries))</code> if there are m
ore // FIXME: new form for OP_SCALE_WEIGHT - do we want this?
* than 100 subqueries, but this rather arbitrary special case Query(double factor, const Xapian::Query & subquery);
* will be dropped in 1.3.0). For example, this will pick the
* best 7 terms: // FIXME: legacy form of above (assuming we want to add that...)
* Query(op op_, const Xapian::Query & subquery, double factor);
* <pre>
* Xapian::Query query(Xapian::Query::OP_ELITE_SET, subqs.begin // Pairwise.
(), subqs.end(), 7); Query(op op_, const Xapian::Query & a, const Xapian::Query & b)
* </pre> {
* init(op_, 2);
* If the number of subqueries is less than this threshold, add_subquery(a);
* OP_ELITE_SET behaves identically to OP_OR. add_subquery(b);
*/ done();
OP_ELITE_SET, }
/** Filter by a greater-than-or-equal test on a document value.
*/
OP_VALUE_GE,
/** Filter by a less-than-or-equal test on a document value. */
OP_VALUE_LE,
/** Treat a set of queries as synonyms.
*
* This returns all results which match at least one of the
* queries, but weighting as if all the sub-queries are instanc
es
* of the same term: so multiple matching terms for a document
* increase the wdf value used, and the term frequency is based
on
* the number of documents which would match an OR of all the
* subqueries.
*
* The term frequency used will usually be an approximation,
* because calculating the precise combined term frequency woul
d
* be overly expensive.
*
* Identical to OP_OR, except for the weightings returned.
*/
OP_SYNONYM
} op;
/** Copy constructor. */ // Pairwise with std::string.
Query(const Query & copyme); Query(op op_, const std::string & a, const std::string & b)
{
init(op_, 2);
add_subquery(a);
add_subquery(b);
done();
}
/** Assignment. */ // OP_VALUE_GE/OP_VALUE_LE
Query & operator=(const Query & copyme); Query(op op_, Xapian::valueno slot, const std::string & limit);
/** Default constructor: makes an empty query which matches no // OP_VALUE_RANGE
* documents. Query(op op_, Xapian::valueno slot,
* const std::string & begin, const std::string & end);
* Also useful for defining a Query object to be assigned to later.
* template<typename I>
* An exception will be thrown if an attempt is made to use an Query(op op_, I begin, I end, Xapian::termcount window = 0)
* undefined query when building up a composite query. {
*/ if (begin != end) {
Query(); typedef typename std::iterator_traits<I>::iterator_category iter
ator_category;
init(op_, window, begin, end, iterator_category());
for (I i = begin; i != end; ++i) {
add_subquery(*i);
}
}
done();
}
/** Destructor. */ #ifdef SWIG
~Query(); // SWIG's %template doesn't seem to handle a templated ctor so we
// provide this fake specialised form of the above prototype.
Query::Query(op op_, XapianSWIGQueryItor qbegin, XapianSWIGQueryItor qe
nd,
Xapian::termcount parameter = 0);
#endif
/** A query consisting of a single term. */ const TermIterator get_terms_begin() const;
Query(const std::string & tname_, Xapian::termcount wqf_ = 1,
Xapian::termpos pos_ = 0);
/** A query consisting of two subqueries, opp-ed together. */ const TermIterator get_terms_end() const { return TermIterator(); }
Query(Query::op op_, const Query & left, const Query & right);
/** A query consisting of two termnames opp-ed together. */ Xapian::termcount get_length() const;
Query(Query::op op_,
const std::string & left, const std::string & right);
/** Combine a number of Xapian::Query-s with the specified operator. bool empty() const { return internal.get() == 0; }
*
* The Xapian::Query objects are specified with begin and end
* iterators.
*
* AND, OR, XOR, ELITE_SET, SYNONYM, NEAR and PHRASE can take any
* number of subqueries. Other operators take exactly two subqueri
es.
*
* The iterators may be to Xapian::Query objects, pointers to
* Xapian::Query objects, or termnames (std::string-s).
*
* For NEAR and PHRASE, a window size can be specified in parameter
.
*
* For ELITE_SET, the elite set size can be specified in parameter.
*/
template <class Iterator>
Query(Query::op op_, Iterator qbegin, Iterator qend,
Xapian::termcount parameter = 0);
/** Apply the specified operator to a single Xapian::Query object, w std::string serialise() const;
ith
* a double parameter.
*/
Query(Query::op op_, Xapian::Query q, double parameter);
/** Construct a value range query on a document value. static const Query unserialise(const std::string & s,
* const Registry & reg = Registry());
* A value range query matches those documents which have a value
* stored in the slot given by @a slot which is in the range
* specified by @a begin and @a end (in lexicographical
* order), including the endpoints.
*
* @param op_ The operator to use for the query. Currently, must
* be OP_VALUE_RANGE.
* @param slot The slot number to get the value from.
* @param begin The start of the range.
* @param end The end of the range.
*/
Query(Query::op op_, Xapian::valueno slot,
const std::string &begin, const std::string &end);
/** Construct a value comparison query on a document value. std::string get_description() const;
*
* This query matches those documents which have a value stored in
the
* slot given by @a slot which compares, as specified by the
* operator, to @a value.
*
* @param op_ The operator to use for the query. Currently, must
* be OP_VALUE_GE or OP_VALUE_LE.
* @param slot The slot number to get the value from.
* @param value The value to compare.
*/
Query(Query::op op_, Xapian::valueno slot, const std::string &value)
;
/** Construct an external source query. const Query operator&=(const Query & o) {
* return (*this = Query(OP_AND, *this, o));
* An attempt to clone the posting source will be made immediately, }
so
* if the posting source supports clone(), the source supplied may
be
* safely deallocated after this call. If the source does not supp
ort
* clone(), the caller must ensure that the posting source remains
* valid until the Query is deallocated.
*
* @param external_source The source to use in the query.
*/
explicit Query(Xapian::PostingSource * external_source);
/** A query which matches all documents in the database. */
static const Xapian::Query MatchAll;
/** A query which matches no documents. */ const Query operator|=(const Query & o) {
static const Xapian::Query MatchNothing; return (*this = Query(OP_OR, *this, o));
}
/** Get the length of the query, used by some ranking formulae. const Query operator^=(const Query & o) {
* This value is calculated automatically - if you want to override return (*this = Query(OP_XOR, *this, o));
* it you can pass a different value to Enquire::set_query(). }
*/
Xapian::termcount get_length() const;
/** Return a Xapian::TermIterator returning all the terms in the que const Query operator*=(double factor) {
ry, return (*this = Query(factor, *this));
* in order of termpos. If multiple terms have the same term }
* position, their order is unspecified. Duplicates (same term and
* termpos) will be removed.
*/
TermIterator get_terms_begin() const;
/** Return a Xapian::TermIterator to the end of the list of terms in const Query operator/=(double factor) {
the return (*this = Query(1.0 / factor, *this));
* query. }
*/
TermIterator get_terms_end() const {
return TermIterator();
}
/** Test if the query is empty (i.e. was constructed using private:
* the default ctor or with an empty iterator ctor). // Pass a reference to avoid ambiguity for Query(NULL) (not useful, but
*/ the
bool empty() const; // testsuite does it...) FIXME
Query(Query::Internal & internal_) : internal(&internal_) { }
void init(Query::op op_, size_t n_subqueries, Xapian::termcount window
= 0);
template<typename I>
void init(Query::op op_, Xapian::termcount window,
const I & begin, const I & end, std::random_access_iterator_ta
g)
{
init(op_, end - begin, window);
}
/** Serialise query into a string. template<typename I>
* void init(Query::op op_, Xapian::termcount window,
* The query representation may change between Xapian releases: const I &, const I &, std::input_iterator_tag)
* even between minor versions. However, it is guaranteed not to {
* change unless the remote database protocol has also changed betw init(op_, 0, window);
een }
* releases.
*/
std::string serialise() const;
/** Unserialise a query from a string produced by serialise(). void add_subquery(const Xapian::Query & subquery);
*
* This method will fail if the query contains any external
* PostingSource leaf nodes.
*
* @param s The string representing the serialised query.
*/
static Query unserialise(const std::string &s);
/** Unserialise a query from a string produced by serialise(). void add_subquery(const std::string & subquery) {
* add_subquery(Xapian::Query(subquery));
* The supplied registry will be used to attempt to unserialise any }
* external PostingSource leaf nodes. This method will fail if the
* query contains any external PostingSource leaf nodes which are n
ot
* registered in the registry.
*
* @param s The string representing the serialised query.
* @param registry Xapian::Registry to use.
*/
static Query unserialise(const std::string & s,
const Registry & registry);
/// Return a string describing this object. void add_subquery(const Xapian::Query * subquery) {
std::string get_description() const; // FIXME: subquery NULL?
add_subquery(*subquery);
}
private: void done();
void add_subquery(const Query & subq);
void add_subquery(const Query * subq);
void add_subquery(const std::string & tname);
void start_construction(Query::op op_, Xapian::termcount parameter);
void end_construction();
void abort_construction();
}; };
template <class Iterator> inline const Query
Query::Query(Query::op op_, Iterator qbegin, Iterator qend, termcount param operator&(const Query & a, const Query & b)
eter)
: internal(0)
{ {
try { return Query(Query::OP_AND, a, b);
start_construction(op_, parameter);
/* Add all the elements */
while (qbegin != qend) {
add_subquery(*qbegin);
++qbegin;
}
end_construction();
} catch (...) {
abort_construction();
throw;
}
} }
#ifndef SWIG // SWIG has no interest in the internal class, so hide it comp inline const Query
letely. operator|(const Query & a, const Query & b)
{
/// @private @internal Internal class, implementing most of Xapian::Query. return Query(Query::OP_OR, a, b);
class XAPIAN_VISIBILITY_DEFAULT Query::Internal : public Xapian::Internal:: }
RefCntBase {
friend class ::LocalSubMatch;
friend class ::MultiMatch;
friend class ::QueryOptimiser;
friend struct ::SortPosName;
friend class Query;
public:
static const int OP_LEAF = -1;
static const int OP_EXTERNAL_SOURCE = -2;
/// The container type for storing pointers to subqueries
typedef std::vector<Internal *> subquery_list;
/// Type storing the operation
typedef int op_t;
private:
/// Operation to be performed at this node
Xapian::Query::Internal::op_t op;
/// Sub queries on which to perform operation
subquery_list subqs;
/** For NEAR or PHRASE, how close terms must be to match: all terms
* within the operation must occur in a window of this size.
*
* For ELITE_SET, the number of terms to select from those specified
.
*
* For RANGE, the value number to apply the range test to.
*
* For a leaf node, this is the within query frequency of the term.
*/
Xapian::termcount parameter;
/** Term that this node represents, or start of a range query.
*
* For a leaf node, this holds the term name. For an OP_VALUE_RANG
E
* query this holds the start of the range. For an OP_VALUE_GE or
* OP_VALUE_LE query this holds the value to compare against.
*/
std::string tname;
/** Used to store the end of a range query. */
std::string str_parameter;
/// Position in query of this term - leaf node only
Xapian::termpos term_pos;
/// External posting source.
Xapian::PostingSource * external_source;
/// Flag, indicating whether the external source is owned by the que
ry.
bool external_source_owned;
/// Copy another Xapian::Query::Internal into self.
void initialise_from_copy(const Query::Internal & copyme);
void accumulate_terms(
std::vector<std::pair<std::string, Xapian::termpos> > &terms) co
nst;
/** Simplify the query.
* For example, an AND query with only one subquery would become th
e
* subquery itself.
*/
Internal * simplify_query();
/** Perform checks that query is valid. (e.g., has correct number of
* sub queries.) Throw an exception if not. This is initially cal
led
* on the query before any simplifications have been made, and afte
r
* simplifications.
*/
void validate_query() const;
/** Simplify any matchnothing subqueries, either eliminating them, inline const Query
* or setting this query to matchnothing, depending on the query operator^(const Query & a, const Query & b)
* operator. Returns true if simplification resulted in a {
* matchnothing query. return Query(Query::OP_XOR, a, b);
*/ }
bool simplify_matchnothing();
/** Get a string describing the given query type. inline const Query
*/ operator*(double factor, const Query & q)
static std::string get_op_name(Xapian::Query::Internal::op_t op); {
return Query(factor, q);
}
/** Collapse the subqueries together if appropriate. inline const Query
*/ operator*(const Query & q, double factor)
void collapse_subqs(); {
return Query(factor, q);
}
/** Flatten a query structure, by changing, for example, inline const Query
* "A NEAR (B AND C)" to "(A NEAR B) AND (A NEAR C)" operator/(const Query & q, double factor)
*/ {
Xapian::Query::Internal * flatten_subqs(); return Query(1.0 / factor, q);
}
/** Implementation of serialisation; called recursively. class InvertedQuery_ {
*/ const Query & query;
std::string serialise(Xapian::termpos & curpos) const;
public: void operator=(const InvertedQuery_ &);
/** Copy constructor. */
Internal(const Query::Internal & copyme);
/** Assignment. */ InvertedQuery_(const Query & query_) : query(query_) { }
void operator=(const Query::Internal & copyme);
/** A query consisting of a single term. */ public:
explicit Internal(const std::string & tname_, Xapian::termcount wqf_ // GCC 4.2 seems to needs a copy ctor.
= 1, InvertedQuery_(const InvertedQuery_ & o) : query(o.query) { }
Xapian::termpos term_pos_ = 0);
/** Create internals given only the operator and a parameter. */ operator Query() const {
Internal(op_t op_, Xapian::termcount parameter); return Query(Query::OP_AND_NOT, Query::MatchAll, query);
}
/** Construct a range query on a document value. */ friend const InvertedQuery_ operator~(const Query &q);
Internal(op_t op_, Xapian::valueno slot,
const std::string &begin, const std::string &end);
/** Construct a value greater-than-or-equal query on a document valu friend const Query operator&(const Query & a, const InvertedQuery_ & b)
e. ;
*/ };
Internal(op_t op_, Xapian::valueno slot, const std::string &value);
/// Construct an external source query. inline const Query
explicit Internal(Xapian::PostingSource * external_source_, bool own operator&(const Query & a, const InvertedQuery_ & b)
ed); {
return Query(Query::OP_AND_NOT, a, b.query);
}
/** Destructor. */ inline const InvertedQuery_
~Internal(); operator~(const Query &q)
{
return InvertedQuery_(q);
}
static Xapian::Query::Internal * unserialise(const std::string &s, namespace Internal {
const Registry & regist class AndContext;
ry); class OrContext;
class XorContext;
}
/** Add a subquery. */ class Query::Internal : public Xapian::Internal::intrusive_base {
void add_subquery(const Query::Internal * subq); public:
Internal() { }
/** Add a subquery without copying it. virtual ~Internal();
*
* subq is owned by the object this is called on after the call.
*/
void add_subquery_nocopy(Query::Internal * subq);
void set_dbl_parameter(double dbl_parameter_); virtual PostingIterator::Internal * postlist(QueryOptimiser * qopt, dou ble factor) const = 0;
double get_dbl_parameter() const; virtual void postlist_sub_and_like(Xapian::Internal::AndContext& ctx,
QueryOptimiser * qopt,
double factor) const;
/** Finish off the construction. virtual void postlist_sub_or_like(Xapian::Internal::OrContext& ctx,
*/ QueryOptimiser * qopt,
Query::Internal * end_construction(); double factor) const;
/** Return a string in an easily parsed form virtual void postlist_sub_xor(Xapian::Internal::XorContext& ctx,
* which contains all the information in a query. QueryOptimiser * qopt,
*/ double factor) const;
std::string serialise() const {
Xapian::termpos curpos = 1;
return serialise(curpos);
}
/// Return a string describing this object. virtual termcount get_length() const;
std::string get_description() const;
/** Get the numeric parameter used in this query. virtual void serialise(std::string & result) const = 0;
*
* This is used by the QueryParser to get the value number for
* VALUE_RANGE queries. It should be replaced by a public method o
n
* the Query class at some point, but the API which should be used
for
* that is unclear, so this is a temporary workaround.
*/
Xapian::termcount get_parameter() const { return parameter; }
Xapian::termcount get_wqf() const { return parameter; } static Query::Internal * unserialise(const char ** p, const char * end, const Registry & reg);
/** Get the length of the query, used by some ranking formulae. virtual std::string get_description() const = 0;
* This value is calculated automatically - if you want to override
* it you can pass a different value to Enquire::set_query().
*/
Xapian::termcount get_length() const;
/** Return an iterator over all the terms in the query, virtual void gather_terms(std::vector<std::pair<Xapian::termpos, std::s
* in order of termpos. If multiple terms have the same term tring> > &terms) const;
* position, their order is unspecified. Duplicates (same term and
* termpos) will be removed.
*/
TermIterator get_terms() const;
}; };
#endif // SWIG
} }
#endif /* XAPIAN_INCLUDED_QUERY_H */ #endif // XAPIAN_INCLUDED_QUERY_H
 End of changes. 61 change blocks. 
517 lines changed or deleted 293 lines changed or added


 queryparser.h   queryparser.h 
/** \file queryparser.h /** @file queryparser.h
* \brief parsing a user query string to build a Xapian::Query object * @brief parsing a user query string to build a Xapian::Query object
*/ */
/* Copyright (C) 2005,2006,2007,2008,2009,2010,2011,2014 Olly Betts /* Copyright (C) 2005,2006,2007,2008,2009,2010,2011,2012 Olly Betts
* Copyright (C) 2010 Adam Sjøgren * Copyright (C) 2010 Adam Sjøgren
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the * published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version. * License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
skipping to change at line 26 skipping to change at line 26
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
* USA * USA
*/ */
#ifndef XAPIAN_INCLUDED_QUERYPARSER_H #ifndef XAPIAN_INCLUDED_QUERYPARSER_H
#define XAPIAN_INCLUDED_QUERYPARSER_H #define XAPIAN_INCLUDED_QUERYPARSER_H
#include <xapian/base.h> #include <xapian/intrusive_ptr.h>
#include <xapian/query.h> #include <xapian/query.h>
#include <xapian/termiterator.h> #include <xapian/termiterator.h>
#include <xapian/visibility.h> #include <xapian/visibility.h>
#include <set> #include <set>
#include <string> #include <string>
namespace Xapian { namespace Xapian {
class Database; class Database;
skipping to change at line 63 skipping to change at line 63
}; };
/// Simple implementation of Stopper class - this will suit most users. /// Simple implementation of Stopper class - this will suit most users.
class XAPIAN_VISIBILITY_DEFAULT SimpleStopper : public Stopper { class XAPIAN_VISIBILITY_DEFAULT SimpleStopper : public Stopper {
std::set<std::string> stop_words; std::set<std::string> stop_words;
public: public:
/// Default constructor. /// Default constructor.
SimpleStopper() { } SimpleStopper() { }
/** Initialise from a pair of iterators. /// Initialise from a pair of iterators.
*
* Xapian includes stop list files for many languages. You can initiali
se from a file like that:
* @code
* ifstream inFile ("stopwords/english/stop.txt");
* Xapian::SimplerStopper stopper(istream_iterator<string>(inFile), ist
ream_iterator<string>());
* @endcode
*
*/
#if ! defined __SUNPRO_CC || __SUNPRO_CC - 0 >= 0x580 #if ! defined __SUNPRO_CC || __SUNPRO_CC - 0 >= 0x580
template <class Iterator> template <class Iterator>
SimpleStopper(Iterator begin, Iterator end) : stop_words(begin, end) { } SimpleStopper(Iterator begin, Iterator end) : stop_words(begin, end) { }
#else #else
// Older versions of Sun's C++ compiler don't cope with the Iterator // Older versions of Sun's C++ compiler don't cope with the Iterator
// pointing to const char *. // pointing to const char *.
template <class Iterator> template <class Iterator>
SimpleStopper(Iterator begin, Iterator end) { SimpleStopper(Iterator begin, Iterator end) {
while (begin != end) stop_words.insert(*begin++); while (begin != end) stop_words.insert(*begin++);
} }
skipping to change at line 232 skipping to change at line 224
* For example, if str_ is "created:" and prefix_ is true, and the ran ge * For example, if str_ is "created:" and prefix_ is true, and the ran ge
* processor has been added to the queryparser, the queryparser will * processor has been added to the queryparser, the queryparser will
* accept "created:1/1/2000..31/12/2001". * accept "created:1/1/2000..31/12/2001".
*/ */
DateValueRangeProcessor(Xapian::valueno slot_, const std::string &str_, DateValueRangeProcessor(Xapian::valueno slot_, const std::string &str_,
bool prefix_ = true, bool prefix_ = true,
bool prefer_mdy_ = false, int epoch_year_ = 1970 ) bool prefer_mdy_ = false, int epoch_year_ = 1970 )
: StringValueRangeProcessor(slot_, str_, prefix_), : StringValueRangeProcessor(slot_, str_, prefix_),
prefer_mdy(prefer_mdy_), epoch_year(epoch_year_) { } prefer_mdy(prefer_mdy_), epoch_year(epoch_year_) { }
#ifndef SWIG
/** Constructor.
*
* This is like the previous version, but with const char * instead of
* std::string - we need this overload as otherwise
* DateValueRangeProcessor(1, "date:") quietly interprets the second
* argument as a boolean in preference to std::string. If you want to
* be compatible with 1.2.12 and earlier, then explicitly convert to
* std::string, i.e.: DateValueRangeProcessor(1, std::string("date:"))
*
* @param slot_ The value number to return from operator().
*
* @param str_ A string to look for to recognise values as belongi
ng
* to this date range.
*
* @param prefix_ Whether to look for the string at the start or end
of
* the values. If true, the string is a prefix; if
* false, the string is a suffix (default: true).
*
* @param prefer_mdy_ Should ambiguous dates be interpreted as
* month/day/year rather than day/month/year?
* (default: false)
*
* @param epoch_year_ Year to use as the epoch for dates with 2 digit
* years (default: 1970, so 1/1/69 is 2069 while
* 1/1/70 is 1970).
*
* The string supplied in str_ is used by @a operator() to decide whet
her
* the pair of strings supplied to it constitute a valid range. If
* prefix_ is true, the first value in a range must begin with str_ (a
nd
* the second value may optionally begin with str_);
* if prefix_ is false, the second value in a range must end with str_
* (and the first value may optionally end with str_).
*
* If str_ is empty, the setting of prefix_ is irrelevant, and no spec
ial
* strings are required at the start or end of the strings defining th
e
* range.
*
* The remainder of both strings defining the endpoints must be valid
* dates.
*
* For example, if str_ is "created:" and prefix_ is true, and the ran
ge
* processor has been added to the queryparser, the queryparser will
* accept "created:1/1/2000..31/12/2001".
*/
DateValueRangeProcessor(Xapian::valueno slot_, const char * str_,
bool prefix_ = true,
bool prefer_mdy_ = false, int epoch_year_ = 1970
)
: StringValueRangeProcessor(slot_, str_, prefix_),
prefer_mdy(prefer_mdy_), epoch_year(epoch_year_) { }
#endif
/** Check for a valid date range. /** Check for a valid date range.
* *
* @param[in,out] begin The start of the range as specified in the * @param[in,out] begin The start of the range as specified in the
* query string by the user. This parameter is a * query string by the user. This parameter is a
* non-const reference so the ValueRangeProcess or * non-const reference so the ValueRangeProcess or
* can modify it to return the value to start t he * can modify it to return the value to start t he
* range with. * range with.
* @param[in,out] end The end of the range. This is also a non-co nst * @param[in,out] end The end of the range. This is also a non-co nst
* reference so it can be modified. * reference so it can be modified.
* *
skipping to change at line 380 skipping to change at line 320
*/ */
Xapian::valueno operator()(std::string &begin, std::string &end); Xapian::valueno operator()(std::string &begin, std::string &end);
}; };
/// Build a Xapian::Query object from a user query string. /// Build a Xapian::Query object from a user query string.
class XAPIAN_VISIBILITY_DEFAULT QueryParser { class XAPIAN_VISIBILITY_DEFAULT QueryParser {
public: public:
/// Class representing the queryparser internals. /// Class representing the queryparser internals.
class Internal; class Internal;
/// @private @internal Reference counted internals. /// @private @internal Reference counted internals.
Xapian::Internal::RefCntPtr<Internal> internal; Xapian::Internal::intrusive_ptr<Internal> internal;
/// Enum of feature flags. /// Enum of feature flags.
typedef enum { typedef enum {
/// Support AND, OR, etc and bracketed subexpressions. /// Support AND, OR, etc and bracketed subexpressions.
FLAG_BOOLEAN = 1, FLAG_BOOLEAN = 1,
/// Support quoted phrases. /// Support quoted phrases.
FLAG_PHRASE = 2, FLAG_PHRASE = 2,
/// Support + and -. /// Support + and -.
FLAG_LOVEHATE = 4, FLAG_LOVEHATE = 4,
/// Support AND, OR, etc even if they aren't in ALLCAPS. /// Support AND, OR, etc even if they aren't in ALLCAPS.
FLAG_BOOLEAN_ANY_CASE = 8, FLAG_BOOLEAN_ANY_CASE = 8,
/** Support wildcards. /** Support right truncation (e.g. Xap*).
*
* At present only right truncation (e.g. Xap*) is supported.
* *
* Currently you can't use wildcards with boolean filter prefixes, * Currently you can't use wildcards with boolean filter prefixes,
* or in a phrase (either an explicitly quoted one, or one implicit ly * or in a phrase (either an explicitly quoted one, or one implicit ly
* generated by hyphens or other punctuation). * generated by hyphens or other punctuation).
* *
* NB: You need to tell the QueryParser object which database to * NB: You need to tell the QueryParser object which database to
* expand wildcards from by calling set_database. * expand wildcards from by calling set_database.
*/ */
FLAG_WILDCARD = 16, FLAG_WILDCARD = 16,
/** Allow queries such as 'NOT apples'. /** Allow queries such as 'NOT apples'.
skipping to change at line 462 skipping to change at line 400
* *
* NB: You must also call set_database() for this to work. * NB: You must also call set_database() for this to work.
*/ */
FLAG_AUTO_SYNONYMS = 512, FLAG_AUTO_SYNONYMS = 512,
/** Enable automatic use of synonyms for single terms and groups of /** Enable automatic use of synonyms for single terms and groups of
* terms. * terms.
* *
* NB: You must also call set_database() for this to work. * NB: You must also call set_database() for this to work.
*/ */
FLAG_AUTO_MULTIWORD_SYNONYMS = 1024 | FLAG_AUTO_SYNONYMS, FLAG_AUTO_MULTIWORD_SYNONYMS = 1024,
/** The default flags. /** The default flags.
* *
* Used if you don't explicitly pass any to @a parse_query(). * Used if you don't explicitly pass any to @a parse_query().
* The default flags are FLAG_PHRASE|FLAG_BOOLEAN|FLAG_LOVEHATE. * The default flags are FLAG_PHRASE|FLAG_BOOLEAN|FLAG_LOVEHATE.
* *
* Added in Xapian 1.0.11. * Added in Xapian 1.0.11.
*/ */
FLAG_DEFAULT = FLAG_PHRASE|FLAG_BOOLEAN|FLAG_LOVEHATE FLAG_DEFAULT = FLAG_PHRASE|FLAG_BOOLEAN|FLAG_LOVEHATE
} feature_flag; } feature_flag;
/// Stemming strategies, for use with set_stemming_strategy(). typedef enum { STEM_NONE, STEM_SOME, STEM_ALL } stem_strategy;
typedef enum { STEM_NONE, STEM_SOME, STEM_ALL, STEM_ALL_Z } stem_strate
gy;
/// Copy constructor. /// Copy constructor.
QueryParser(const QueryParser & o); QueryParser(const QueryParser & o);
/// Assignment. /// Assignment.
QueryParser & operator=(const QueryParser & o); QueryParser & operator=(const QueryParser & o);
/// Default constructor. /// Default constructor.
QueryParser(); QueryParser();
skipping to change at line 508 skipping to change at line 445
*/ */
void set_stemmer(const Xapian::Stem & stemmer); void set_stemmer(const Xapian::Stem & stemmer);
/** Set the stemming strategy. /** Set the stemming strategy.
* *
* This controls how the query parser will apply the stemming algorith m. * This controls how the query parser will apply the stemming algorith m.
* Note that the stemming algorithm is only applied to words in * Note that the stemming algorithm is only applied to words in
* probabilistic fields - boolean filter terms are never stemmed. * probabilistic fields - boolean filter terms are never stemmed.
* *
* @param strategy The strategy to use - possible values are: * @param strategy The strategy to use - possible values are:
* - STEM_NONE: Don't perform any stemming. (default in Xapian <= * - STEM_NONE: Don't perform any stemming (the default).
* 1.3.0) * - STEM_SOME: Search for stemmed forms of terms except for those wh
* - STEM_SOME: Stem all terms except for those which start with a ich
* capital letter, or are followed by certain character * start with a capital letter, or are followed by certai
s n
* (currently: <code>(/\@<>=*[{"</code> ), or are used * characters (currently: (/\@<>=*[{" ), or are used with
* with operators which need positional information. * operators which need positional information. Stemmed
* Stemmed terms are prefixed with 'Z'. (default in * terms are prefixed with 'Z'.
* Xapian >= 1.3.1) * - STEM_ALL: Search for stemmed forms of all words (note: no 'Z'
* - STEM_ALL: Stem all terms (note: no 'Z' prefix is added). * prefix is added).
* - STEM_ALL_Z: Stem all terms (note: 'Z' prefix is added). (new in
* Xapian 1.2.11 and 1.3.1)
*/ */
void set_stemming_strategy(stem_strategy strategy); void set_stemming_strategy(stem_strategy strategy);
/** Set the stopper. /** Set the stopper.
* *
* @param stop The Stopper object to set (default NULL, which means no * @param stop The Stopper object to set (default NULL, which means no
* stopwords). * stopwords).
*/ */
void set_stopper(const Stopper *stop = NULL); void set_stopper(const Stopper *stop = NULL);
/** Set the default operator. /** Set the default operator.
* *
* @param default_op The operator to use to combine non-filter * @param default_op The operator to use to combine non-filter
* query items when no explicit operator is use d. * query items when no explicit operator is use d.
* *
* The most useful values for this are OP_OR (t
he
* default) and OP_AND. OP_NEAR and OP_PHRASE
can
* also be useful.
*
* So for example, 'weather forecast' is parsed as * So for example, 'weather forecast' is parsed as
* if it were 'weather OR forecast' by default. * if it were 'weather OR forecast' by default.
*
* The most useful values for this are OP_OR (t
he
* default) and OP_AND. OP_NEAR, OP_PHRASE,
* OP_ELITE_SET and OP_SYNONYM are also permitt
ed.
* Passing other values will result in
* InvalidArgumentError being thrown.
*/ */
void set_default_op(Query::op default_op); void set_default_op(Query::op default_op);
/** Get the current default operator. */ /** Get the current default operator. */
Query::op get_default_op() const; Query::op get_default_op() const;
/** Specify the database being searched. /** Specify the database being searched.
* *
* @param db The database to use for wildcard expansion * @param db The database to use for wildcard expansion
* (FLAG_WILDCARD and FLAG_PARTIAL), spelling correctio n * (FLAG_WILDCARD and FLAG_PARTIAL), spelling correctio n
skipping to change at line 579 skipping to change at line 515
* multiple values with bitwise-or (|) (default FLAG_DEFAULT). * multiple values with bitwise-or (|) (default FLAG_DEFAULT).
* @param default_prefix The default term prefix to use (default none) . * @param default_prefix The default term prefix to use (default none) .
* For example, you can pass "A" when parsing an "Author" field . * For example, you can pass "A" when parsing an "Author" field .
* *
* @exception If the query string can't be parsed, then * @exception If the query string can't be parsed, then
* Xapian::QueryParserError is thrown. You can get an Engli sh * Xapian::QueryParserError is thrown. You can get an Engli sh
* error message to report to the user by catching it and * error message to report to the user by catching it and
* calling get_msg() on the caught exception. The current * calling get_msg() on the caught exception. The current
* possible values (in case you want to translate them) are: * possible values (in case you want to translate them) are:
* *
* @li Unknown range operation * @li Unknown range operation
* @li parse error * @li parse error
* @li Syntax: &lt;expression&gt; AND &lt;expression&gt; * @li Syntax: &lt;expression&gt; AND &lt;expression&gt
* @li Syntax: &lt;expression&gt; AND NOT &lt;expression&gt; ;
* @li Syntax: &lt;expression&gt; NOT &lt;expression&gt; * @li Syntax: &lt;expression&gt; AND NOT &lt;expressio
* @li Syntax: &lt;expression&gt; OR &lt;expression&gt; n&gt;
* @li Syntax: &lt;expression&gt; XOR &lt;expression&gt; * @li Syntax: &lt;expression&gt; NOT &lt;expression&gt
;
* @li Syntax: &lt;expression&gt; OR &lt;expression&gt;
* @li Syntax: &lt;expression&gt; XOR &lt;expression&gt
;
*/ */
Query parse_query(const std::string &query_string, Query parse_query(const std::string &query_string,
unsigned flags = FLAG_DEFAULT, unsigned flags = FLAG_DEFAULT,
const std::string &default_prefix = std::string()); const std::string &default_prefix = std::string());
/** Add a probabilistic term prefix. /** Add a probabilistic term prefix.
* *
* For example: * For example:
* *
* @code * @code
skipping to change at line 685 skipping to change at line 621
* @param prefix The term prefix to map this to * @param prefix The term prefix to map this to
* @param exclusive If true, each document can have at most one term w ith * @param exclusive If true, each document can have at most one term w ith
* this prefix, so multiple filters with this prefix * this prefix, so multiple filters with this prefix
* should be combined with OP_OR. If false, each * should be combined with OP_OR. If false, each
* document can have multiple terms with this prefix, so * document can have multiple terms with this prefix, so
* multiple filters should be combined with OP_AND, li ke * multiple filters should be combined with OP_AND, li ke
* happens with filters with different prefixes. * happens with filters with different prefixes.
* [default: true] * [default: true]
*/ */
void add_boolean_prefix(const std::string &field, const std::string &pr efix, void add_boolean_prefix(const std::string &field, const std::string &pr efix,
bool exclusive); bool exclusive = true);
/* FIXME:1.3: Merge two versions into one with optional parameter
* "exclusive", default true. */
void add_boolean_prefix(const std::string &field, const std::string &pr
efix);
/// Iterate over terms omitted from the query as stopwords. /// Iterate over terms omitted from the query as stopwords.
TermIterator stoplist_begin() const; TermIterator stoplist_begin() const;
TermIterator stoplist_end() const { TermIterator stoplist_end() const {
return TermIterator(); return TermIterator();
} }
/// Iterate over unstemmed forms of the given (stemmed) term used in th e query. /// Iterate over unstemmed forms of the given (stemmed) term used in th e query.
TermIterator unstem_begin(const std::string &term) const; TermIterator unstem_begin(const std::string &term) const;
TermIterator unstem_end(const std::string &) const { TermIterator unstem_end(const std::string &) const {
 End of changes. 14 change blocks. 
114 lines changed or deleted 39 lines changed or added


 registry.h   registry.h 
skipping to change at line 26 skipping to change at line 26
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
* USA * USA
*/ */
#ifndef XAPIAN_INCLUDED_REGISTRY_H #ifndef XAPIAN_INCLUDED_REGISTRY_H
#define XAPIAN_INCLUDED_REGISTRY_H #define XAPIAN_INCLUDED_REGISTRY_H
#include <xapian/base.h> #include <xapian/intrusive_ptr.h>
#include <xapian/visibility.h> #include <xapian/visibility.h>
#include <string> #include <string>
namespace Xapian { namespace Xapian {
// Forward declarations. // Forward declarations.
class LatLongMetric;
class MatchSpy; class MatchSpy;
class PostingSource; class PostingSource;
class Weight; class Weight;
/** Registry for user subclasses. /** Registry for user subclasses.
* *
* This class provides a way for the remote server to look up user subclas ses * This class provides a way for the remote server to look up user subclas ses
* when unserialising. * when unserialising.
*/ */
class XAPIAN_VISIBILITY_DEFAULT Registry { class XAPIAN_VISIBILITY_DEFAULT Registry {
public: public:
/// Class holding details of the registry. /// Class holding details of the registry.
class Internal; class Internal;
private: private:
/// @internal Reference counted internals. /// @internal Reference counted internals.
Xapian::Internal::RefCntPtr<Internal> internal; Xapian::Internal::intrusive_ptr<Internal> internal;
public: public:
/** Copy constructor. /** Copy constructor.
* *
* The internals are reference counted, so copying is cheap. * The internals are reference counted, so copying is cheap.
* *
* @param other The object to copy. * @param other The object to copy.
*/ */
Registry(const Registry & other); Registry(const Registry & other);
skipping to change at line 127 skipping to change at line 128
/** Get a match spy given a name. /** Get a match spy given a name.
* *
* @param name The name of the match spy to find. * @param name The name of the match spy to find.
* @return An object with the requested name, or NULL i f the * @return An object with the requested name, or NULL i f the
* match spy could not be found. The returned * match spy could not be found. The returned
* object is owned by the registry and so must not be * object is owned by the registry and so must not be
* deleted by the caller. * deleted by the caller.
*/ */
const Xapian::MatchSpy * const Xapian::MatchSpy *
get_match_spy(const std::string & name) const; get_match_spy(const std::string & name) const;
/// Register a user-defined lat-long metric class.
void register_lat_long_metric(const Xapian::LatLongMetric &metric);
/** Get a lat-long metric given a name.
*
* The returned metric is owned by the registry object.
*
* Returns NULL if the metric could not be found.
*/
const Xapian::LatLongMetric *
get_lat_long_metric(const std::string & name) const;
}; };
} }
#endif /* XAPIAN_INCLUDED_REGISTRY_H */ #endif /* XAPIAN_INCLUDED_REGISTRY_H */
 End of changes. 4 change blocks. 
2 lines changed or deleted 16 lines changed or added


 stem.h   stem.h 
/** \file stem.h /** @file stem.h
* \brief stemming algorithms * @brief stemming algorithms
*/ */
/* Copyright (C) 2005,2007,2010 Olly Betts /* Copyright (C) 2005,2007,2010,2011 Olly Betts
* Copyright (C) 2010 Evgeny Sizikov * Copyright (C) 2010 Evgeny Sizikov
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the * published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version. * License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 US A * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 US A
*/ */
#ifndef XAPIAN_INCLUDED_STEM_H #ifndef XAPIAN_INCLUDED_STEM_H
#define XAPIAN_INCLUDED_STEM_H #define XAPIAN_INCLUDED_STEM_H
#include <xapian/base.h> #include <xapian/intrusive_ptr.h>
#include <xapian/visibility.h> #include <xapian/visibility.h>
#include <string> #include <string>
namespace Xapian { namespace Xapian {
/// Class representing a stemming algorithm implementation. /// Class representing a stemming algorithm implementation.
struct XAPIAN_VISIBILITY_DEFAULT StemImplementation struct XAPIAN_VISIBILITY_DEFAULT StemImplementation
: public Xapian::Internal::RefCntBase : public Xapian::Internal::intrusive_base
{ {
/// Virtual destructor. /// Virtual destructor.
virtual ~StemImplementation(); virtual ~StemImplementation();
/// Stem the specified word. /// Stem the specified word.
virtual std::string operator()(const std::string & word) = 0; virtual std::string operator()(const std::string & word) = 0;
/// Return a string describing this object. /// Return a string describing this object.
virtual std::string get_description() const = 0; virtual std::string get_description() const = 0;
}; };
/// Class representing a stemming algorithm. /// Class representing a stemming algorithm.
class XAPIAN_VISIBILITY_DEFAULT Stem { class XAPIAN_VISIBILITY_DEFAULT Stem {
public: public:
/// @private @internal Reference counted internals. /// @private @internal Reference counted internals.
Xapian::Internal::RefCntPtr<StemImplementation> internal; Xapian::Internal::intrusive_ptr<StemImplementation> internal;
/// Copy constructor. /// Copy constructor.
Stem(const Stem & o); Stem(const Stem & o);
/// Assignment. /// Assignment.
void operator=(const Stem & o); Stem & operator=(const Stem & o);
/** Construct a Xapian::Stem object which doesn't change terms. /** Construct a Xapian::Stem object which doesn't change terms.
* *
* Equivalent to Stem("none"). * Equivalent to Stem("none").
*/ */
Stem(); Stem();
/** Construct a Xapian::Stem object for a particular language. /** Construct a Xapian::Stem object for a particular language.
* *
* @param language Either the English name for the language * @param language Either the English name for the language
* or the two letter ISO639 code. * or the two letter ISO639 code.
* *
* The following language names are understood (aliases follow the * The following language names are understood (aliases follow the
* name): * name):
* *
* - none - don't stem terms * - none - don't stem terms
* - armenian (hy)
* - basque (eu)
* - catalan (ca)
* - danish (da) * - danish (da)
* - dutch (nl) * - dutch (nl)
* - english (en) - Martin Porter's 2002 revision of his stemmer * - english (en) - Martin Porter's 2002 revision of his stemmer
* - english_lovins (lovins) - Lovin's stemmer * - english_lovins (lovins) - Lovin's stemmer
* - english_porter (porter) - Porter's stemmer as described in * - english_porter (porter) - Porter's stemmer as described in
* his 1980 paper * his 1980 paper
* - finnish (fi) * - finnish (fi)
* - french (fr) * - french (fr)
* - german (de) * - german (de)
* - german2 - Normalises umlauts and &szlig; * - german2 - Normalises umlauts and &szlig;
 End of changes. 7 change blocks. 
7 lines changed or deleted 10 lines changed or added


 termgenerator.h   termgenerator.h 
/** @file termgenerator.h /** @file termgenerator.h
* @brief parse free text and generate terms * @brief parse free text and generate terms
*/ */
/* Copyright (C) 2007,2009,2011,2012 Olly Betts /* Copyright (C) 2007,2009,2011 Olly Betts
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 US A * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 US A
*/ */
#ifndef XAPIAN_INCLUDED_TERMGENERATOR_H #ifndef XAPIAN_INCLUDED_TERMGENERATOR_H
#define XAPIAN_INCLUDED_TERMGENERATOR_H #define XAPIAN_INCLUDED_TERMGENERATOR_H
#include <xapian/base.h> #include <xapian/intrusive_ptr.h>
#include <xapian/types.h> #include <xapian/types.h>
#include <xapian/unicode.h> #include <xapian/unicode.h>
#include <xapian/visibility.h> #include <xapian/visibility.h>
#include <string> #include <string>
namespace Xapian { namespace Xapian {
class Document; class Document;
class Stem; class Stem;
skipping to change at line 49 skipping to change at line 49
* *
* This module takes a piece of text and parses it to produce words which a re * This module takes a piece of text and parses it to produce words which a re
* then used to generate suitable terms for indexing. The terms generated are * then used to generate suitable terms for indexing. The terms generated are
* suitable for use with Query objects produced by the QueryParser class. * suitable for use with Query objects produced by the QueryParser class.
*/ */
class XAPIAN_VISIBILITY_DEFAULT TermGenerator { class XAPIAN_VISIBILITY_DEFAULT TermGenerator {
public: public:
/// @private @internal Class representing the TermGenerator internals. /// @private @internal Class representing the TermGenerator internals.
class Internal; class Internal;
/// @private @internal Reference counted internals. /// @private @internal Reference counted internals.
Xapian::Internal::RefCntPtr<Internal> internal; Xapian::Internal::intrusive_ptr<Internal> internal;
/// Copy constructor. /// Copy constructor.
TermGenerator(const TermGenerator & o); TermGenerator(const TermGenerator & o);
/// Assignment. /// Assignment.
TermGenerator & operator=(const TermGenerator & o); TermGenerator & operator=(const TermGenerator & o);
/// Default constructor. /// Default constructor.
TermGenerator(); TermGenerator();
skipping to change at line 91 skipping to change at line 91
/// Set the database to index spelling data to. /// Set the database to index spelling data to.
void set_database(const Xapian::WritableDatabase &db); void set_database(const Xapian::WritableDatabase &db);
/// Flags to OR together and pass to TermGenerator::set_flags(). /// Flags to OR together and pass to TermGenerator::set_flags().
enum flags { enum flags {
/// Index data required for spelling correction. /// Index data required for spelling correction.
FLAG_SPELLING = 128 // Value matches QueryParser flag. FLAG_SPELLING = 128 // Value matches QueryParser flag.
}; };
/// Stemming strategies, for use with set_stemming_strategy().
typedef enum { STEM_NONE, STEM_SOME, STEM_ALL, STEM_ALL_Z } stem_strate
gy;
/** Set flags. /** Set flags.
* *
* The new value of flags is: (flags & mask) ^ toggle * The new value of flags is: (flags & mask) ^ toggle
* *
* To just set the flags, pass the new flags in toggle and the * To just set the flags, pass the new flags in toggle and the
* default value for mask. * default value for mask.
* *
* @param toggle Flags to XOR. * @param toggle Flags to XOR.
* @param mask Flags to AND with first. * @param mask Flags to AND with first.
* *
* @return The old flags setting. * @return The old flags setting.
*/ */
flags set_flags(flags toggle, flags mask = flags(0)); flags set_flags(flags toggle, flags mask = flags(0));
/** Set the stemming strategy.
*
* This method controls how the stemming algorithm is applied. It was
* new in Xapian 1.3.1.
*
* @param strategy The strategy to use - possible values are:
* - STEM_NONE: Don't perform any stemming - only unstemmed terms
* are generated.
* - STEM_SOME: Generate both stemmed (with a "Z" prefix) and unstem
med
* terms. This is the default strategy.
* - STEM_ALL: Generate only stemmed terms (but without a "Z" prefi
x).
* - STEM_ALL_Z: Generate only stemmed terms (with a "Z" prefix).
*/
void set_stemming_strategy(stem_strategy strategy);
/** Set the maximum length word to index.
*
* The limit is on the length of a word prior to stemming and prior to
* adding any term prefix.
*
* The backends mostly impose a limit on the length of terms (often of
* about 240 bytes), but it's generally useful to have a lower limit t
o
* help prevent the index being bloated by useless junk terms from try
ing
* to indexing things like binary data, uuencoded data, ASCII art, etc
.
*
* This method was new in Xapian 1.3.1.
*
* @param max_word_length The maximum length word to index, in bytes i
n
* UTF-8 representation. Default is 64.
*/
void set_max_word_length(unsigned max_word_length);
/** Index some text. /** Index some text.
* *
* @param itor Utf8Iterator pointing to the text to index. * @param itor Utf8Iterator pointing to the text to index.
* @param wdf_inc The wdf increment (default 1). * @param wdf_inc The wdf increment (default 1).
* @param prefix The term prefix to use (default is no prefix). * @param prefix The term prefix to use (default is no prefix).
*/ */
void index_text(const Xapian::Utf8Iterator & itor, void index_text(const Xapian::Utf8Iterator & itor,
Xapian::termcount wdf_inc = 1, Xapian::termcount wdf_inc = 1,
const std::string & prefix = std::string()); const std::string & prefix = std::string());
 End of changes. 5 change blocks. 
45 lines changed or deleted 3 lines changed or added


 termiterator.h   termiterator.h 
/** \file termiterator.h /** @file termiterator.h
* \brief Classes for iterating through term lists * @brief Class for iterating over a list of terms
*/ */
/* Copyright 1999,2000,2001 BrightStation PLC /* Copyright (C) 2007,2008,2009,2010,2011 Olly Betts
* Copyright 2002 Ananova Ltd
* Copyright 2003,2004,2005,2006,2007,2008,2009,2012 Olly Betts
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the * published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version. * License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
skipping to change at line 30 skipping to change at line 28
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
* USA * USA
*/ */
#ifndef XAPIAN_INCLUDED_TERMITERATOR_H #ifndef XAPIAN_INCLUDED_TERMITERATOR_H
#define XAPIAN_INCLUDED_TERMITERATOR_H #define XAPIAN_INCLUDED_TERMITERATOR_H
#include <iterator> #include <iterator>
#include <string> #include <string>
#include <xapian/base.h>
#include <xapian/derefwrapper.h> #include <xapian/derefwrapper.h>
#include <xapian/types.h>
#include <xapian/positioniterator.h> #include <xapian/positioniterator.h>
#include <xapian/types.h>
#include <xapian/visibility.h> #include <xapian/visibility.h>
namespace Xapian { namespace Xapian {
class Database; /// Class for iterating over a list of terms.
/** An iterator pointing to items in a list of terms.
*/
class XAPIAN_VISIBILITY_DEFAULT TermIterator { class XAPIAN_VISIBILITY_DEFAULT TermIterator {
public: public:
class Internal; /// Class representing the TermIterator internals.
/// @internal Reference counted internals. class Internal;
Xapian::Internal::RefCntPtr<Internal> internal; /// @private @internal Reference counted internals.
Internal * internal;
/// @internal Reference counted internals.
explicit TermIterator(Internal *internal_); /// @private @internal Construct given internals.
explicit TermIterator(Internal *internal_);
/// Default constructor - for declaring an uninitialised iterator.
TermIterator(); /// Copy constructor.
TermIterator(const TermIterator & o);
/// Destructor.
~TermIterator(); /// Assignment.
TermIterator & operator=(const TermIterator & o);
/** Copying is allowed. The internals are reference counted, so
* copying is also cheap. /** Default constructor.
*/ *
TermIterator(const TermIterator &other); * Creates an uninitialised iterator, which can't be used before being
* assigned to, but is sometimes syntactically convenient.
/** Assignment is allowed. The internals are reference counted, */
* so assignment is also cheap. TermIterator() : internal(0) { }
*/
void operator=(const TermIterator &other); /// Destructor.
~TermIterator() {
/// Return the current term. if (internal) decref();
std::string operator *() const; }
/// Advance the iterator to the next position. /// Return the term at the current position.
TermIterator & operator++(); std::string operator*() const;
/// Advance the iterator to the next position (postfix version). /// Return the wdf for the term at the current position.
DerefWrapper_<std::string> operator++(int) { Xapian::termcount get_wdf() const;
const std::string & term(**this);
operator++(); /// Return the term frequency for the term at the current position.
return DerefWrapper_<std::string>(term); Xapian::doccount get_termfreq() const;
}
/// Return the length of the position list for the current position.
/** Advance the iterator to the specified term. Xapian::termcount positionlist_count() const;
*
* If the specified term isn't in the list, position ourselves on t /// Return a PositionIterator for the current term.
he PositionIterator positionlist_begin() const;
* first term after it (or at_end() if no greater terms are present
). /// Return an end PositionIterator for the current term.
*/ PositionIterator positionlist_end() const {
void skip_to(const std::string & tname); return PositionIterator();
}
/** Return the wdf of the current term (if meaningful).
* /// Advance the iterator to the next position.
* The wdf (within document frequency) is the number of occurrences TermIterator & operator++();
* of a term in a particular document.
*/ /// Advance the iterator to the next position (postfix version).
Xapian::termcount get_wdf() const; DerefWrapper_<std::string> operator++(int) {
const std::string & term(**this);
/** Return the term frequency of the current term (if meaningful). operator++();
* return DerefWrapper_<std::string>(term);
* The term frequency is the number of documents which a term index }
es.
*/ /** Advance the iterator to term @a term.
Xapian::doccount get_termfreq() const; *
* If the iteration is over an unsorted list of terms, then this metho
/** Return length of positionlist for current term. d
*/ * will throw Xapian::InvalidOperationError.
Xapian::termcount positionlist_count() const; *
* @param term The term to advance to. If this term isn't in
/** Return PositionIterator pointing to start of positionlist for * the stream being iterated, then the iterator is move
* current term. d
*/ * to the next term after it which is.
PositionIterator positionlist_begin() const; */
void skip_to(const std::string &term);
/** Return PositionIterator pointing to end of positionlist for
* current term. /// Return a string describing this object.
*/ std::string get_description() const;
PositionIterator positionlist_end() const {
return PositionIterator(); /** @private @internal TermIterator is what the C++ STL calls an
} * input_iterator.
*
/// Return a string describing this object. * The following typedefs allow std::iterator_traits<> to work so that
std::string get_description() const; * this iterator can be used with the STL.
*
/// Allow use as an STL iterator * These are deliberately hidden from the Doxygen-generated docs, as t
//@{ he
typedef std::input_iterator_tag iterator_category; * machinery here isn't interesting to API users. They just need to k
typedef std::string value_type; now
typedef Xapian::termcount_diff difference_type; * that Xapian iterator classes are compatible with the STL.
typedef std::string * pointer; */
typedef std::string & reference; // @{
//@} /// @private
typedef std::input_iterator_tag iterator_category;
/// @private
typedef std::string value_type;
/// @private
typedef Xapian::termcount_diff difference_type;
/// @private
typedef std::string * pointer;
/// @private
typedef std::string & reference;
// @}
private:
void decref();
void post_advance(Internal * res);
}; };
/// Equality test for TermIterator objects. /// Equality test for TermIterator objects.
inline bool inline bool
operator==(const TermIterator &a, const TermIterator &b) operator==(const TermIterator &a, const TermIterator &b)
{ {
return (a.internal.get() == b.internal.get()); // Use a pointer comparison - this ensures both that (a == a) and corre
ct
// handling of end iterators (which we ensure have NULL internals).
return a.internal == b.internal;
} }
/// Inequality test for TermIterator objects. /// Inequality test for TermIterator objects.
inline bool inline bool
operator!=(const TermIterator &a, const TermIterator &b) operator!=(const TermIterator &a, const TermIterator &b)
{ {
return !(a == b); return !(a == b);
} }
} }
#endif /* XAPIAN_INCLUDED_TERMITERATOR_H */ #endif // XAPIAN_INCLUDED_TERMITERATOR_H
 End of changes. 9 change blocks. 
99 lines changed or deleted 111 lines changed or added


 types.h   types.h 
/** @file xapian/types.h /** @file xapian/types.h
* @brief typedefs for Xapian * @brief typedefs for Xapian
*/ */
/* Copyright (C) 2007,2010 Olly Betts /* Copyright (C) 2007,2010,2011 Olly Betts
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the * published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version. * License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 US A * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 US A
*/ */
#ifndef XAPIAN_INCLUDED_TYPES_H #ifndef XAPIAN_INCLUDED_TYPES_H
#define XAPIAN_INCLUDED_TYPES_H #define XAPIAN_INCLUDED_TYPES_H
#include <xapian/deprecated.h>
namespace Xapian { namespace Xapian {
/** A count of documents. /** A count of documents.
* *
* This is used to hold values such as the number of documents in a databa se * This is used to hold values such as the number of documents in a databa se
* and the frequency of a term in the database. * and the frequency of a term in the database.
*/ */
typedef unsigned doccount; typedef unsigned doccount;
/** A signed difference between two counts of documents. /** A signed difference between two counts of documents.
skipping to change at line 54 skipping to change at line 56
*/ */
typedef unsigned docid; typedef unsigned docid;
/** A normalised document length. /** A normalised document length.
* *
* The normalised document length is the document length divided by the * The normalised document length is the document length divided by the
* average document length in the database. * average document length in the database.
*/ */
typedef double doclength; typedef double doclength;
/** The percentage score for a document in an MSet. */ /** The percentage score for a document in an MSet.
typedef int percent; *
* @deprecated This type is deprecated as of Xapian 1.3.0 - use the standa
rd
* type int instead, which should work with older Xapian too.
*/
XAPIAN_DEPRECATED(typedef int percent);
/** A counts of terms. /** A counts of terms.
* *
* This is used to hold values such as the Within Document Frequency (wdf) . * This is used to hold values such as the Within Document Frequency (wdf) .
*/ */
typedef unsigned termcount; typedef unsigned termcount;
/** A signed difference between two counts of terms. /** A signed difference between two counts of terms.
* *
* This is used by the Xapian classes which are STL containers of terms * This is used by the Xapian classes which are STL containers of terms
skipping to change at line 85 skipping to change at line 91
* *
* This is used by the Xapian classes which are STL containers of position s * This is used by the Xapian classes which are STL containers of position s
* for "difference_type". * for "difference_type".
*/ */
typedef int termpos_diff; /* FIXME: can overflow. */ typedef int termpos_diff; /* FIXME: can overflow. */
/** A timeout value in milliseconds. /** A timeout value in milliseconds.
* *
* There are 1000 milliseconds in a second, so for example, to set a * There are 1000 milliseconds in a second, so for example, to set a
* timeout of 5 seconds use 5000. * timeout of 5 seconds use 5000.
*
* @deprecated This type is deprecated as of Xapian 1.3.0 - use the standa
rd
* POSIX type useconds_t instead, which should work with older Xapian too.
*/ */
typedef unsigned timeout; XAPIAN_DEPRECATED(typedef unsigned timeout);
/** The number for a value slot in a document. /** The number for a value slot in a document.
* *
* Value slot numbers are unsigned and (currently) a 32-bit quantity, with * Value slot numbers are unsigned and (currently) a 32-bit quantity, with
* Xapian::BAD_VALUENO being represented by the largest possible value. * Xapian::BAD_VALUENO being represented by the largest possible value.
* Therefore value slots 0 to 0xFFFFFFFE are available for use. * Therefore value slots 0 to 0xFFFFFFFE are available for use.
*/ */
typedef unsigned valueno; typedef unsigned valueno;
/** A signed difference between two value slot numbers. /** A signed difference between two value slot numbers.
* *
* This is used by the Xapian classes which are STL containers of values * This is used by the Xapian classes which are STL containers of values
* for "difference_type". * for "difference_type".
*/ */
typedef int valueno_diff; /* FIXME: can overflow. */ typedef int valueno_diff; /* FIXME: can overflow. */
/** The weight of a document or term. */ /** The weight of a document or term.
typedef double weight; *
* @deprecated This type is deprecated as of Xapian 1.3.0 - use the standa
rd
* C++ type double instead, which should work with older Xapian too.
*/
XAPIAN_DEPRECATED(typedef double weight);
/** Reserved value to indicate "no valueno". */ /** Reserved value to indicate "no valueno". */
const valueno BAD_VALUENO = static_cast<valueno>(-1); const valueno BAD_VALUENO = 0xffffffff;
} }
#endif /* XAPIAN_INCLUDED_TYPES_H */ #endif /* XAPIAN_INCLUDED_TYPES_H */
 End of changes. 7 change blocks. 
7 lines changed or deleted 23 lines changed or added


 unicode.h   unicode.h 
skipping to change at line 129 skipping to change at line 129
/** Create an iterator which is at the end of its iteration. /** Create an iterator which is at the end of its iteration.
* *
* This can be compared to another iterator to check if the other iter ator * This can be compared to another iterator to check if the other iter ator
* has reached its end. * has reached its end.
*/ */
Utf8Iterator() : p(NULL), end(0), seqlen(0) { } Utf8Iterator() : p(NULL), end(0), seqlen(0) { }
/** Get the current Unicode character value pointed to by the iterator. /** Get the current Unicode character value pointed to by the iterator.
* *
* If an invalid UTF-8 sequence is encountered, then the byte values
* comprising it are returned until valid UTF-8 or the end of the inpu
t is
* reached.
*
* Returns unsigned(-1) if the iterator has reached the end of its buf fer. * Returns unsigned(-1) if the iterator has reached the end of its buf fer.
*/ */
unsigned operator*() const; unsigned operator*() const;
/** Move forward to the next Unicode character. /** Move forward to the next Unicode character.
* *
* @return An iterator pointing to the position before the move. * @return An iterator pointing to the position before the move.
*/ */
Utf8Iterator operator++(int) { Utf8Iterator operator++(int) {
// If we've not calculated seqlen yet, do so. // If we've not calculated seqlen yet, do so.
skipping to change at line 226 skipping to change at line 222
INITIAL_QUOTE_PUNCTUATION, INITIAL_QUOTE_PUNCTUATION,
FINAL_QUOTE_PUNCTUATION, FINAL_QUOTE_PUNCTUATION,
OTHER_PUNCTUATION, OTHER_PUNCTUATION,
MATH_SYMBOL, MATH_SYMBOL,
CURRENCY_SYMBOL, CURRENCY_SYMBOL,
MODIFIER_SYMBOL, MODIFIER_SYMBOL,
OTHER_SYMBOL OTHER_SYMBOL
} category; } category;
namespace Internal { namespace Internal {
/** @private @internal Extract the information about a character from t /** @internal Extract the information about a character from the Unicod
he e
* Unicode character tables. * character tables.
* *
* ch must be a valid Unicode character value (i.e. < 0x110000) * ch must be a valid Unicode character value (i.e. < 0x110000)
*/ */
XAPIAN_VISIBILITY_DEFAULT XAPIAN_VISIBILITY_DEFAULT
int get_character_info(unsigned ch); int get_character_info(unsigned ch);
/** @private @internal Extract how to convert the case of a Unicode /** @internal Extract how to convert the case of a Unicode character fr
* character from its info. om
* its info.
*/ */
inline int get_case_type(int info) { return ((info & 0xe0) >> 5); } inline int get_case_type(int info) { return ((info & 0xe0) >> 5); }
/** @private @internal Extract the category of a Unicode character from /// @internal Extract the category of a Unicode character from its info
its .
* info.
*/
inline category get_category(int info) { return static_cast<category>(i nfo & 0x1f); } inline category get_category(int info) { return static_cast<category>(i nfo & 0x1f); }
/** @private @internal Extract the delta to use for case conversion of /** @internal Extract the delta to use for case conversion of a charact
a er
* character from its info. * from its info.
*/ */
inline int get_delta(int info) { inline int get_delta(int info) {
/* It's implementation defined if sign extension happens on right sh ift /* It's implementation defined if sign extension happens on right sh ift
* of a signed int, hence the conditional (hopefully the compiler wi ll * of a signed int, hence the conditional (hopefully the compiler wi ll
* spot this and optimise it to a sign-extending shift on architectu res * spot this and optimise it to a sign-extending shift on architectu res
* with a suitable instruction). * with a suitable instruction).
*/ */
#ifdef __GNUC__
// GCC 4.7.1 doesn't optimise the more complex expression down
// (reported as http://gcc.gnu.org/PR55299), but the documented
// behaviour for GCC is that right shift of a signed integer perform
s
// sign extension:
// http://gcc.gnu.org/onlinedocs/gcc-4.7.2/gcc/Integers-implementati
on.html
return info >> 15;
#else
return (info >= 0) ? (info >> 15) : (~(~info >> 15)); return (info >= 0) ? (info >> 15) : (~(~info >> 15));
#endif
} }
} }
/** Convert a single non-ASCII Unicode character to UTF-8. /** Convert a single non-ASCII Unicode character to UTF-8.
* *
* This is intended mainly as a helper method for to_utf8(). * This is intended mainly as a helper method for to_utf8().
* *
* @param ch The character (which must be > 128) to write to @a buf. * @param ch The character (which must be > 128) to write to @a buf.
* @param buf The buffer to write the character to - it must have * @param buf The buffer to write the character to - it must have
* space for (at least) 4 bytes. * space for (at least) 4 bytes.
 End of changes. 7 change blocks. 
28 lines changed or deleted 11 lines changed or added


 valueiterator.h   valueiterator.h 
/** @file valueiterator.h /** @file valueiterator.h
* @brief Class for iterating over document values. * @brief Class for iterating over document values.
*/ */
/* Copyright (C) 2008,2009,2010,2014 Olly Betts /* Copyright (C) 2008,2009,2010,2011 Olly Betts
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the * published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version. * License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
skipping to change at line 28 skipping to change at line 28
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
* USA * USA
*/ */
#ifndef XAPIAN_INCLUDED_VALUEITERATOR_H #ifndef XAPIAN_INCLUDED_VALUEITERATOR_H
#define XAPIAN_INCLUDED_VALUEITERATOR_H #define XAPIAN_INCLUDED_VALUEITERATOR_H
#include <iterator> #include <iterator>
#include <string> #include <string>
#include <xapian/base.h>
#include <xapian/derefwrapper.h> #include <xapian/derefwrapper.h>
#include <xapian/types.h> #include <xapian/types.h>
#include <xapian/visibility.h> #include <xapian/visibility.h>
namespace Xapian { namespace Xapian {
/// @private @internal A proxy class for an end ValueIterator.
class ValueIteratorEnd_ { };
/// Class for iterating over document values. /// Class for iterating over document values.
class XAPIAN_VISIBILITY_DEFAULT ValueIterator { class XAPIAN_VISIBILITY_DEFAULT ValueIterator {
void decref();
public: public:
/// Class representing the ValueIterator internals. /// Class representing the ValueIterator internals.
class Internal; class Internal;
/// @private @internal Reference counted internals. /// @private @internal Reference counted internals.
Xapian::Internal::RefCntPtr<Internal> internal; Internal * internal;
/// @private @internal Construct given internals. /// @private @internal Construct given internals.
explicit ValueIterator(Internal *internal_); explicit ValueIterator(Internal *internal_);
/// Copy constructor. /// Copy constructor.
ValueIterator(const ValueIterator & o); ValueIterator(const ValueIterator & o);
/// @internal Copy from an end iterator proxy.
ValueIterator(const ValueIteratorEnd_ &);
/// Assignment. /// Assignment.
ValueIterator & operator=(const ValueIterator & o); ValueIterator & operator=(const ValueIterator & o);
/// @internal Assignment of an end iterator proxy.
ValueIterator & operator=(const ValueIteratorEnd_ &);
/** Default constructor. /** Default constructor.
* *
* Creates an uninitialised iterator, which can't be used before being * Creates an uninitialised iterator, which can't be used before being
* assigned to, but is sometimes syntactically convenient. * assigned to, but is sometimes syntactically convenient.
*/ */
ValueIterator(); ValueIterator() : internal(0) { }
/// Destructor. /// Destructor.
~ValueIterator(); ~ValueIterator() {
if (internal) decref();
}
/// Return the value at the current position. /// Return the value at the current position.
std::string operator*() const; std::string operator*() const;
/// Advance the iterator to the next position. /// Advance the iterator to the next position.
ValueIterator & operator++(); ValueIterator & operator++();
/// Advance the iterator to the next position (postfix version). /// Advance the iterator to the next position (postfix version).
DerefWrapper_<std::string> operator++(int) { DerefWrapper_<std::string> operator++(int) {
const std::string & value(**this); const std::string & value(**this);
skipping to change at line 137 skipping to change at line 131
* for an efficient implementation of skip_to(). * for an efficient implementation of skip_to().
* *
* Otherwise it simply checks if a particular docid is present. If it * Otherwise it simply checks if a particular docid is present. If it
* is, it returns true. If it isn't, it returns false, and leaves the * is, it returns true. If it isn't, it returns false, and leaves the
* position unspecified (and hence the result of calling methods which * position unspecified (and hence the result of calling methods which
* depends on the current position, such as get_docid(), are also * depends on the current position, such as get_docid(), are also
* unspecified). In this state, next() will advance to the first matc hing * unspecified). In this state, next() will advance to the first matc hing
* position after document @a did, and skip_to() will act as it would if * position after document @a did, and skip_to() will act as it would if
* the position was the first matching position after document @a did. * the position was the first matching position after document @a did.
* *
* Currently the inmemory, flint, and remote backends behave in the * Currently the inmemory and remote backends behave in the
* latter way because they don't support streamed values and so skip_t o() * latter way because they don't support streamed values and so skip_t o()
* must check each document it skips over which is significantly slowe r. * must check each document it skips over which is significantly slowe r.
* *
* @param docid The document id to check. * @param docid The document id to check.
*/ */
#ifndef check
bool check(Xapian::docid docid); bool check(Xapian::docid docid);
#else
// The AssertMacros.h header in the OS X SDK currently defines a check
// macro. Apple have deprecated check() in favour of __Check() and
// plan to remove check() in a "future release", but for now prevent
// expansion of check by adding parentheses in the method prototype:
// http://www.opensource.apple.com/source/CarbonHeaders/CarbonHeaders-1
8.1/AssertMacros.h
//
// We do this conditionally, as these parentheses trip up SWIG's
// parser:
// https://github.com/swig/swig/issues/45
bool (check)(Xapian::docid docid);
#endif
/// Return a string describing this object. /// Return a string describing this object.
std::string get_description() const; std::string get_description() const;
/** @private @internal ValueIterator is what the C++ STL calls an /** @private @internal ValueIterator is what the C++ STL calls an
* input_iterator. * input_iterator.
* *
* The following typedefs allow std::iterator_traits<> to work so that * The following typedefs allow std::iterator_traits<> to work so that
* this iterator can be used with with STL. * this iterator can be used with the STL.
* *
* These are deliberately hidden from the Doxygen-generated docs, as t he * These are deliberately hidden from the Doxygen-generated docs, as t he
* machinery here isn't interesting to API users. They just need to k now * machinery here isn't interesting to API users. They just need to k now
* that Xapian iterator classes are compatible with the STL. * that Xapian iterator classes are compatible with the STL.
*/ */
// @{ // @{
/// @private /// @private
typedef std::input_iterator_tag iterator_category; typedef std::input_iterator_tag iterator_category;
/// @private /// @private
typedef std::string value_type; typedef std::string value_type;
skipping to change at line 191 skipping to change at line 172
typedef std::string & reference; typedef std::string & reference;
// @} // @}
}; };
/// Equality test for ValueIterator objects. /// Equality test for ValueIterator objects.
inline bool inline bool
operator==(const ValueIterator &a, const ValueIterator &b) operator==(const ValueIterator &a, const ValueIterator &b)
{ {
// Use a pointer comparison - this ensures both that (a == a) and corre ct // Use a pointer comparison - this ensures both that (a == a) and corre ct
// handling of end iterators (which we ensure have NULL internals). // handling of end iterators (which we ensure have NULL internals).
return a.internal.get() == b.internal.get(); return a.internal == b.internal;
}
/// @internal Equality test for ValueIterator object and end iterator.
inline bool
operator==(const ValueIterator &a, const ValueIteratorEnd_ &)
{
return a.internal.get() == NULL;
}
/// @internal Equality test for ValueIterator object and end iterator.
inline bool
operator==(const ValueIteratorEnd_ &a, const ValueIterator &b)
{
return b == a;
}
/// @internal Equality test for end iterators.
inline bool
operator==(const ValueIteratorEnd_ &, const ValueIteratorEnd_ &)
{
return true;
} }
/// Inequality test for ValueIterator objects. /// Inequality test for ValueIterator objects.
inline bool inline bool
operator!=(const ValueIterator &a, const ValueIterator &b) operator!=(const ValueIterator &a, const ValueIterator &b)
{ {
return !(a == b); return !(a == b);
} }
/// @internal Inequality test for ValueIterator object and end iterator.
inline bool
operator!=(const ValueIterator &a, const ValueIteratorEnd_ &b)
{
return !(a == b);
}
/// @internal Inequality test for ValueIterator object and end iterator.
inline bool
operator!=(const ValueIteratorEnd_ &a, const ValueIterator &b)
{
return !(a == b);
}
/// @internal Inequality test for end iterators.
inline bool
operator!=(const ValueIteratorEnd_ &a, const ValueIteratorEnd_ &b)
{
return !(a == b);
}
} }
#endif // XAPIAN_INCLUDED_VALUEITERATOR_H #endif // XAPIAN_INCLUDED_VALUEITERATOR_H
 End of changes. 15 change blocks. 
73 lines changed or deleted 11 lines changed or added


 valuesetmatchdecider.h   valuesetmatchdecider.h 
/** \file valuesetmatchdecider.h /** @file valuesetmatchdecider.h
* \brief MatchDecider subclass for filtering results by value. * @brief MatchDecider subclass for filtering results by value.
*/ */
/* Copyright 2008 Lemur Consulting Limited /* Copyright 2008 Lemur Consulting Limited
* Copyright 2008,2009,2011 Olly Betts * Copyright 2008,2009,2011 Olly Betts
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the * published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version. * License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
 End of changes. 1 change blocks. 
2 lines changed or deleted 2 lines changed or added


 version.h   version.h 
/** @file version.h /** @file version.h
* @brief Define preprocessor symbols for the library version * @brief Define preprocesor symbols for the library version
*/ */
// Copyright (C) 2002,2004,2005,2006,2007,2008,2009,2010,2015 Olly Betts // Copyright (C) 2002,2004,2005,2006,2007,2008,2009,2010,2011 Olly Betts
// //
// This program is free software; you can redistribute it and/or // This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as // modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; either version 2 of the // published by the Free Software Foundation; either version 2 of the
// License, or (at your option) any later version. // License, or (at your option) any later version.
// //
// This program is distributed in the hope that it will be useful // This program is distributed in the hope that it will be useful
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
skipping to change at line 28 skipping to change at line 28
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#ifndef XAPIAN_INCLUDED_VERSION_H #ifndef XAPIAN_INCLUDED_VERSION_H
#define XAPIAN_INCLUDED_VERSION_H #define XAPIAN_INCLUDED_VERSION_H
#ifdef __GNUC__ #ifdef __GNUC__
#if __GNUC__ < 3 || (__GNUC__ == 3 && __GNUC_MINOR__ == 0) #if __GNUC__ < 3 || (__GNUC__ == 3 && __GNUC_MINOR__ == 0)
#error Xapian no longer supports GCC < 3.1 #error Xapian no longer supports GCC < 3.1
#else #else
#if !defined(__GXX_ABI_VERSION) || __GXX_ABI_VERSION != 1002 #if !defined(__GXX_ABI_VERSION) || __GXX_ABI_VERSION != 1002
#if defined __GXX_ABI_VERSION && __GXX_ABI_VERSION >= 1002
#warning The C++ ABI version of compiler you are using does not exactly mat
ch
#warning that of the compiler used to build the library. If linking fails
#warning due to missing symbols, this is probably the reason why.
#warning The Xapian library was built with g++ 4.6.1
#else
#error The C++ ABI version of compiler you are using does not match #error The C++ ABI version of compiler you are using does not match
#error that of the compiler used to build the library. The versions #error that of the compiler used to build the library. The versions
#error must match or your program will not work correctly. #error must match or your program will not work correctly.
#error The Xapian library was built with g++ 4.6.1 #error The Xapian library was built with g++ 4.6.1
#endif #endif
#endif
#ifdef _GLIBCXX_DEBUG #ifdef _GLIBCXX_DEBUG
#error You are compiling with _GLIBCXX_DEBUG defined, but the library #error You are compiling with _GLIBCXX_DEBUG defined, but the library
#error was not compiled with this flag. The settings must match or your #error was not compiled with this flag. The settings must match or your
#error program will not work correctly. #error program will not work correctly.
#endif #endif
#endif #endif
#endif #endif
/// The library was compiled with GCC's -fvisibility=hidden option. /// The library was compiled with GCC's -fvisibility=hidden option.
#define XAPIAN_ENABLE_VISIBILITY #define XAPIAN_ENABLE_VISIBILITY
/// The version of Xapian as a C string literal. /// The version of Xapian as a C string literal.
#define XAPIAN_VERSION "1.2.21" #define XAPIAN_VERSION "1.3.0"
/** The major component of the Xapian version. /** The major component of the Xapian version.
* E.g. for Xapian 1.0.14 this would be: 1 * E.g. for Xapian 1.0.14 this would be: 1
*/ */
#define XAPIAN_MAJOR_VERSION 1 #define XAPIAN_MAJOR_VERSION 1
/** The minor component of the Xapian version. /** The minor component of the Xapian version.
* E.g. for Xapian 1.0.14 this would be: 0 * E.g. for Xapian 1.0.14 this would be: 0
*/ */
#define XAPIAN_MINOR_VERSION 2 #define XAPIAN_MINOR_VERSION 3
/** The revision component of the Xapian version. /** The revision component of the Xapian version.
* E.g. for Xapian 1.0.14 this would be: 14 * E.g. for Xapian 1.0.14 this would be: 14
*/ */
#define XAPIAN_REVISION 21 #define XAPIAN_REVISION 0
/// XAPIAN_HAS_BRASS_BACKEND Defined if the brass backend is enabled. /// XAPIAN_HAS_BRASS_BACKEND Defined if the brass backend is enabled.
#define XAPIAN_HAS_BRASS_BACKEND 1 #define XAPIAN_HAS_BRASS_BACKEND 1
/// XAPIAN_HAS_CHERT_BACKEND Defined if the chert backend is enabled. /// XAPIAN_HAS_CHERT_BACKEND Defined if the chert backend is enabled.
#define XAPIAN_HAS_CHERT_BACKEND 1 #define XAPIAN_HAS_CHERT_BACKEND 1
/// XAPIAN_HAS_FLINT_BACKEND Defined if the flint backend is enabled.
#define XAPIAN_HAS_FLINT_BACKEND 1
/// XAPIAN_HAS_INMEMORY_BACKEND Defined if the inmemory backend is enabled. /// XAPIAN_HAS_INMEMORY_BACKEND Defined if the inmemory backend is enabled.
#define XAPIAN_HAS_INMEMORY_BACKEND 1 #define XAPIAN_HAS_INMEMORY_BACKEND 1
/// XAPIAN_HAS_REMOTE_BACKEND Defined if the remote backend is enabled. /// XAPIAN_HAS_REMOTE_BACKEND Defined if the remote backend is enabled.
#define XAPIAN_HAS_REMOTE_BACKEND 1 #define XAPIAN_HAS_REMOTE_BACKEND 1
#endif /* XAPIAN_INCLUDED_VERSION_H */ #endif /* XAPIAN_INCLUDED_VERSION_H */
 End of changes. 8 change blocks. 
16 lines changed or deleted 5 lines changed or added


 weight.h   weight.h 
/** @file weight.h /** @file weight.h
* @brief Weighting scheme API. * @brief Weighting scheme API.
*/ */
/* Copyright (C) 2007,2008,2009,2010,2011,2012,2014 Olly Betts /* Copyright (C) 2007,2008,2009,2010,2011,2012 Olly Betts
* Copyright (C) 2009 Lemur Consulting Ltd * Copyright (C) 2009 Lemur Consulting Ltd
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the * published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version. * License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
skipping to change at line 37 skipping to change at line 37
#include <xapian/types.h> #include <xapian/types.h>
#include <xapian/visibility.h> #include <xapian/visibility.h>
namespace Xapian { namespace Xapian {
/** Abstract base class for weighting schemes. */ /** Abstract base class for weighting schemes. */
class XAPIAN_VISIBILITY_DEFAULT Weight { class XAPIAN_VISIBILITY_DEFAULT Weight {
protected: protected:
/// Stats which the weighting scheme can use (see @a need_stat()). /// Stats which the weighting scheme can use (see @a need_stat()).
typedef enum { typedef enum {
/// Number of documents in the collection.
COLLECTION_SIZE = 1, COLLECTION_SIZE = 1,
/// Number of documents in the RSet.
RSET_SIZE = 2, RSET_SIZE = 2,
/// Average length of documents in the collection.
AVERAGE_LENGTH = 4, AVERAGE_LENGTH = 4,
/// How many documents the current term is in.
TERMFREQ = 8, TERMFREQ = 8,
/// How many documents in the RSet the current term is in.
RELTERMFREQ = 16, RELTERMFREQ = 16,
/// Sum of wqf for terms in the query.
QUERY_LENGTH = 32, QUERY_LENGTH = 32,
/// Within-query-frequency of the current term.
WQF = 64, WQF = 64,
/// Within-document-frequency of the current term in the current doc ument.
WDF = 128, WDF = 128,
/// Length of the current document (sum wdf).
DOC_LENGTH = 256, DOC_LENGTH = 256,
/// Lower bound on (non-zero) document lengths.
DOC_LENGTH_MIN = 512, DOC_LENGTH_MIN = 512,
/// Upper bound on document lengths.
DOC_LENGTH_MAX = 1024, DOC_LENGTH_MAX = 1024,
/// Upper bound on wdf.
WDF_MAX = 2048 WDF_MAX = 2048
} stat_flags; } stat_flags;
/** Tell Xapian that your subclass will want a particular statistic. /** Tell Xapian that your subclass will want a particular statistic.
* *
* Some of the statistics can be costly to fetch or calculate, so * Some of the statistics can be costly to fetch or calculate, so
* Xapian needs to know which are actually going to be used. You * Xapian needs to know which are actually going to be used. You
* should call need_stat() from your constructor for each such * should call need_stat() from your constructor for each such
* statistic. * statistic.
* *
* @param flag The stat_flags value for a required statistic. * @param flag The stat_flags value for a required statistic.
*/ */
void need_stat(stat_flags flag) { void need_stat(stat_flags flag) {
stats_needed = stat_flags(stats_needed | flag); stats_needed = stat_flags(stats_needed | flag);
} }
/** Allow the subclass to perform any initialisation it needs to. /** Allow the subclass to perform any initialisation it needs to.
* *
* @param factor Any scaling factor (e.g. from OP_SCALE_WEIGHT). * @param factor Any scaling factor (e.g. from OP_SCALE_WEIGHT).
* If the Weight object is for the term-independent
* weight supplied by get_sumextra()/get_maxextra(),
* then init(0.0) is called (starting from Xapian
* 1.2.11 and 1.3.1 - earlier versions failed to
* call init() for such Weight objects).
*/ */
virtual void init(double factor) = 0; virtual void init(double factor) = 0;
private: private:
/// Don't allow assignment. /// Don't allow assignment.
void operator=(const Weight &); void operator=(const Weight &);
/// A bitmask of the statistics this weighting scheme needs. /// A bitmask of the statistics this weighting scheme needs.
stat_flags stats_needed; stat_flags stats_needed;
skipping to change at line 115 skipping to change at line 98
/// The number of relevant documents which this term indexes. /// The number of relevant documents which this term indexes.
Xapian::doccount reltermfreq_; Xapian::doccount reltermfreq_;
/// The length of the query. /// The length of the query.
Xapian::termcount query_length_; Xapian::termcount query_length_;
/// The within-query-frequency of this term. /// The within-query-frequency of this term.
Xapian::termcount wqf_; Xapian::termcount wqf_;
/// A lower bound on the minimum length of any document in the database . /// An lower bound on the maximum length of any document in the databas e.
Xapian::termcount doclength_lower_bound_; Xapian::termcount doclength_lower_bound_;
/// An upper bound on the maximum length of any document in the databas e. /// An upper bound on the maximum length of any document in the databas e.
Xapian::termcount doclength_upper_bound_; Xapian::termcount doclength_upper_bound_;
/// An upper bound on the wdf of this term. /// An upper bound on the wdf of this term.
Xapian::termcount wdf_upper_bound_; Xapian::termcount wdf_upper_bound_;
public: public:
class Internal; class Internal;
skipping to change at line 197 skipping to change at line 180
virtual Weight * unserialise(const std::string & s) const; virtual Weight * unserialise(const std::string & s) const;
/** Calculate the weight contribution for this object's term to a docum ent. /** Calculate the weight contribution for this object's term to a docum ent.
* *
* The parameters give information about the document which may be use d * The parameters give information about the document which may be use d
* in the calculations: * in the calculations:
* *
* @param wdf The within document frequency of the term in the docu ment. * @param wdf The within document frequency of the term in the docu ment.
* @param doclen The document's length (unnormalised). * @param doclen The document's length (unnormalised).
*/ */
virtual Xapian::weight get_sumpart(Xapian::termcount wdf, virtual double get_sumpart(Xapian::termcount wdf,
Xapian::termcount doclen) const = 0; Xapian::termcount doclen) const = 0;
/** Return an upper bound on what get_sumpart() can return for any docu ment. /** Return an upper bound on what get_sumpart() can return for any docu ment.
* *
* This information is used by the matcher to perform various * This information is used by the matcher to perform various
* optimisations, so strive to make the bound as tight as possible. * optimisations, so strive to make the bound as tight as possible.
*/ */
virtual Xapian::weight get_maxpart() const = 0; virtual double get_maxpart() const = 0;
/** Calculate the term-independent weight component for a document. /** Calculate the term-independent weight component for a document.
* *
* The parameter gives information about the document which may be use d * The parameter gives information about the document which may be use d
* in the calculations: * in the calculations:
* *
* @param doclen The document's length (unnormalised). * @param doclen The document's length (unnormalised).
*/ */
virtual Xapian::weight get_sumextra(Xapian::termcount doclen) const = 0 ; virtual double get_sumextra(Xapian::termcount doclen) const = 0;
/** Return an upper bound on what get_sumextra() can return for any /** Return an upper bound on what get_sumextra() can return for any
* document. * document.
* *
* This information is used by the matcher to perform various * This information is used by the matcher to perform various
* optimisations, so strive to make the bound as tight as possible. * optimisations, so strive to make the bound as tight as possible.
*/ */
virtual Xapian::weight get_maxextra() const = 0; virtual double get_maxextra() const = 0;
/** @private @internal Initialise this object to calculate weights for term /** @private @internal Initialise this object to calculate weights for term
* @a term. * @a term.
* *
* @param stats Source of statistics. * @param stats Source of statistics.
* @param query_len_ Query length. * @param query_len_ Query length.
* @param term The term for the new object. * @param term The term for the new object.
* @param wqf_ The within-query-frequency of @a term. * @param wqf_ The within-query-frequency of @a term.
* @param factor Any scaling factor (e.g. from OP_SCALE_WEIGHT). * @param factor Any scaling factor (e.g. from OP_SCALE_WEIGHT).
*/ */
skipping to change at line 309 skipping to change at line 292
/// The number of relevant documents which this term indexes. /// The number of relevant documents which this term indexes.
Xapian::doccount get_reltermfreq() const { return reltermfreq_; } Xapian::doccount get_reltermfreq() const { return reltermfreq_; }
/// The length of the query. /// The length of the query.
Xapian::termcount get_query_length() const { return query_length_; } Xapian::termcount get_query_length() const { return query_length_; }
/// The within-query-frequency of this term. /// The within-query-frequency of this term.
Xapian::termcount get_wqf() const { return wqf_; } Xapian::termcount get_wqf() const { return wqf_; }
/** An upper bound on the maximum length of any document in the databas e. /** An lower bound on the maximum length of any document in the databas e.
* *
* This should only be used by get_maxpart() and get_maxextra(). * This should only be used by get_maxpart() and get_maxextra().
*/ */
Xapian::termcount get_doclength_upper_bound() const { Xapian::termcount get_doclength_upper_bound() const {
return doclength_upper_bound_; return doclength_upper_bound_;
} }
/** A lower bound on the minimum length of any document in the database /** An upper bound on the maximum length of any document in the databas
. e.
*
* This bound does not include any zero-length documents.
* *
* This should only be used by get_maxpart() and get_maxextra(). * This should only be used by get_maxpart() and get_maxextra().
*/ */
Xapian::termcount get_doclength_lower_bound() const { Xapian::termcount get_doclength_lower_bound() const {
return doclength_lower_bound_; return doclength_lower_bound_;
} }
/** An upper bound on the wdf of this term. /** An upper bound on the wdf of this term.
* *
* This should only be used by get_maxpart() and get_maxextra(). * This should only be used by get_maxpart() and get_maxextra().
skipping to change at line 354 skipping to change at line 335
public: public:
/** Construct a BoolWeight. */ /** Construct a BoolWeight. */
BoolWeight() { } BoolWeight() { }
std::string name() const; std::string name() const;
std::string serialise() const; std::string serialise() const;
BoolWeight * unserialise(const std::string & s) const; BoolWeight * unserialise(const std::string & s) const;
Xapian::weight get_sumpart(Xapian::termcount wdf, double get_sumpart(Xapian::termcount wdf,
Xapian::termcount doclen) const; Xapian::termcount doclen) const;
Xapian::weight get_maxpart() const; double get_maxpart() const;
Xapian::weight get_sumextra(Xapian::termcount doclen) const; double get_sumextra(Xapian::termcount doclen) const;
Xapian::weight get_maxextra() const; double get_maxextra() const;
}; };
/// Xapian::Weight subclass implementing the BM25 probabilistic formula. /// Xapian::Weight subclass implementing the BM25 probabilistic formula.
class XAPIAN_VISIBILITY_DEFAULT BM25Weight : public Weight { class XAPIAN_VISIBILITY_DEFAULT BM25Weight : public Weight {
/// Factor to multiply the document length by. /// Factor to multiply the document length by.
mutable Xapian::doclength len_factor; mutable Xapian::doclength len_factor;
/// Factor combining all the document independent factors. /// Factor combining all the document independent factors.
mutable Xapian::weight termweight; mutable double termweight;
/// The BM25 parameters. /// The BM25 parameters.
double param_k1, param_k2, param_k3, param_b; double param_k1, param_k2, param_k3, param_b;
/// The minimum normalised document length value. /// The minimum normalised document length value.
Xapian::doclength param_min_normlen; Xapian::doclength param_min_normlen;
BM25Weight * clone() const; BM25Weight * clone() const;
void init(double factor); void init(double factor);
skipping to change at line 426 skipping to change at line 407
param_b = 0; param_b = 0;
} else if (param_b > 1) { } else if (param_b > 1) {
param_b = 1; param_b = 1;
} }
need_stat(COLLECTION_SIZE); need_stat(COLLECTION_SIZE);
need_stat(RSET_SIZE); need_stat(RSET_SIZE);
need_stat(TERMFREQ); need_stat(TERMFREQ);
need_stat(RELTERMFREQ); need_stat(RELTERMFREQ);
need_stat(WDF); need_stat(WDF);
need_stat(WDF_MAX); need_stat(WDF_MAX);
need_stat(WDF);
if (param_k2 != 0 || (param_k1 != 0 && param_b != 0)) { if (param_k2 != 0 || (param_k1 != 0 && param_b != 0)) {
need_stat(DOC_LENGTH_MIN); need_stat(DOC_LENGTH_MIN);
need_stat(AVERAGE_LENGTH); need_stat(AVERAGE_LENGTH);
} }
if (param_k1 != 0 && param_b != 0) need_stat(DOC_LENGTH); if (param_k1 != 0 && param_b != 0) need_stat(DOC_LENGTH);
if (param_k2 != 0) need_stat(QUERY_LENGTH); if (param_k2 != 0) need_stat(QUERY_LENGTH);
if (param_k3 != 0) need_stat(WQF); if (param_k3 != 0) need_stat(WQF);
} }
BM25Weight() BM25Weight()
: param_k1(1), param_k2(0), param_k3(1), param_b(0.5), : param_k1(1), param_k2(0), param_k3(1), param_b(0.5),
param_min_normlen(0.5) param_min_normlen(0.5)
{ {
need_stat(COLLECTION_SIZE); need_stat(COLLECTION_SIZE);
need_stat(RSET_SIZE); need_stat(RSET_SIZE);
need_stat(TERMFREQ); need_stat(TERMFREQ);
need_stat(RELTERMFREQ); need_stat(RELTERMFREQ);
need_stat(WDF); need_stat(WDF);
need_stat(WDF_MAX); need_stat(WDF_MAX);
need_stat(WDF);
need_stat(DOC_LENGTH_MIN); need_stat(DOC_LENGTH_MIN);
need_stat(AVERAGE_LENGTH); need_stat(AVERAGE_LENGTH);
need_stat(DOC_LENGTH); need_stat(DOC_LENGTH);
need_stat(WQF); need_stat(WQF);
} }
std::string name() const; std::string name() const;
std::string serialise() const; std::string serialise() const;
BM25Weight * unserialise(const std::string & s) const; BM25Weight * unserialise(const std::string & s) const;
Xapian::weight get_sumpart(Xapian::termcount wdf, double get_sumpart(Xapian::termcount wdf,
Xapian::termcount doclen) const; Xapian::termcount doclen) const;
Xapian::weight get_maxpart() const; double get_maxpart() const;
Xapian::weight get_sumextra(Xapian::termcount doclen) const; double get_sumextra(Xapian::termcount doclen) const;
Xapian::weight get_maxextra() const; double get_maxextra() const;
}; };
/** Xapian::Weight subclass implementing the traditional probabilistic form ula. /** Xapian::Weight subclass implementing the traditional probabilistic form ula.
* *
* This class implements the "traditional" Probabilistic Weighting scheme, as * This class implements the "traditional" Probabilistic Weighting scheme, as
* described by the early papers on Probabilistic Retrieval. BM25 generall y * described by the early papers on Probabilistic Retrieval. BM25 generall y
* gives better results. * gives better results.
* *
* TradWeight(k) is equivalent to BM25Weight(k, 0, 0, 1, 0), except that * TradWeight(k) is equivalent to BM25Weight(k, 0, 0, 1, 0), except that
* the latter returns weights (k+1) times larger. * the latter returns weights (k+1) times larger.
*/ */
class XAPIAN_VISIBILITY_DEFAULT TradWeight : public Weight { class XAPIAN_VISIBILITY_DEFAULT TradWeight : public Weight {
/// Factor to multiply the document length by. /// Factor to multiply the document length by.
mutable Xapian::doclength len_factor; mutable Xapian::doclength len_factor;
/// Factor combining all the document independent factors. /// Factor combining all the document independent factors.
mutable Xapian::weight termweight; mutable double termweight;
/// The parameter in the formula. /// The parameter in the formula.
double param_k; double param_k;
TradWeight * clone() const; TradWeight * clone() const;
void init(double factor); void init(double factor);
public: public:
/** Construct a TradWeight. /** Construct a TradWeight.
* *
* @param k A non-negative parameter controlling how influential * @param k A non-negative parameter controlling how influential
* within-document-frequency (wdf) and document length are. * within-document-frequency (wdf) and document length are.
* k=0 means that wdf and document length don't affect the * k=0 means that wdf and document length don't affect the
* weights. The larger k is, the more they do. (default 1) * weights. The larger k1 is, the more they do. (default 1)
*/ */
explicit TradWeight(double k = 1.0) : param_k(k) { explicit TradWeight(double k = 1.0) : param_k(k) {
if (param_k < 0) param_k = 0; if (param_k < 0) param_k = 0;
if (param_k != 0.0) { if (param_k != 0.0) {
need_stat(AVERAGE_LENGTH); need_stat(AVERAGE_LENGTH);
need_stat(DOC_LENGTH); need_stat(DOC_LENGTH);
} }
need_stat(COLLECTION_SIZE); need_stat(COLLECTION_SIZE);
need_stat(RSET_SIZE); need_stat(RSET_SIZE);
need_stat(TERMFREQ); need_stat(TERMFREQ);
need_stat(RELTERMFREQ); need_stat(RELTERMFREQ);
need_stat(DOC_LENGTH_MIN); need_stat(DOC_LENGTH_MIN);
need_stat(WDF); need_stat(WDF);
need_stat(WDF_MAX); need_stat(WDF_MAX);
need_stat(WDF);
} }
std::string name() const; std::string name() const;
std::string serialise() const; std::string serialise() const;
TradWeight * unserialise(const std::string & s) const; TradWeight * unserialise(const std::string & s) const;
Xapian::weight get_sumpart(Xapian::termcount wdf, double get_sumpart(Xapian::termcount wdf,
Xapian::termcount doclen) const; Xapian::termcount doclen) const;
Xapian::weight get_maxpart() const; double get_maxpart() const;
Xapian::weight get_sumextra(Xapian::termcount doclen) const; double get_sumextra(Xapian::termcount doclen) const;
Xapian::weight get_maxextra() const; double get_maxextra() const;
}; };
} }
#endif // XAPIAN_INCLUDED_WEIGHT_H #endif // XAPIAN_INCLUDED_WEIGHT_H
 End of changes. 33 change blocks. 
47 lines changed or deleted 31 lines changed or added


 xapian.h   xapian.h 
/** @file xapian.h /** @file xapian.h
* @brief Public interfaces for the Xapian library. * @brief Public interfaces for the Xapian library.
*/ */
// Copyright (C) 2003,2004,2005,2007,2008,2009,2010,2012,2013 Olly Betts // Copyright (C) 2003,2004,2005,2007,2008,2009,2010 Olly Betts
// //
// This program is free software; you can redistribute it and/or modify // 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 // it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or // the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version. // (at your option) any later version.
// //
// This program is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software // along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 US A // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 US A
#ifndef XAPIAN_INCLUDED_XAPIAN_H #ifndef XAPIAN_INCLUDED_XAPIAN_H
#define XAPIAN_INCLUDED_XAPIAN_H #define XAPIAN_INCLUDED_XAPIAN_H
#ifdef slots
# ifdef Q_OBJECT
// Qt headers '#define slots' by default, which clashes with us using it as
a
// class member name. Including <xapian.h> first is a simple workaround, o
r
// you can use 'no_keywords' to stop Qt polluting the global macro namespac
e,
// as described here:
//
// http://qt-project.org/doc/qt-5.0/signalsandslots.html#using-qt-with-3rd-
party-signals-and-slots
# error "Include <xapian.h> before Qt headers, or put 'CONFIG += no_keywor
ds' in your .pro file and use Q_SLOTS instead of slots, etc"
# endif
# ifdef WT_API
// Argh, copycat polluters!
# error "Include <xapian.h> before Wt headers, or define WT_NO_SLOT_MACROS
to stop Wt from defining the macros 'slots' and 'SLOT()'"
# endif
#endif
// Set defines for library version and check C++ ABI versions match. // Set defines for library version and check C++ ABI versions match.
#include <xapian/version.h> #include <xapian/version.h>
// Types // Types
#include <xapian/types.h> #include <xapian/types.h>
// Exceptions // Exceptions
#include <xapian/error.h> #include <xapian/error.h>
#include <xapian/errorhandler.h> #include <xapian/errorhandler.h>
skipping to change at line 81 skipping to change at line 65
// Stemming // Stemming
#include <xapian/stem.h> #include <xapian/stem.h>
// Subclass registry // Subclass registry
#include <xapian/registry.h> #include <xapian/registry.h>
// Unicode support // Unicode support
#include <xapian/unicode.h> #include <xapian/unicode.h>
// Geospatial
#include <xapian/geospatial.h>
// Database compaction and merging // Database compaction and merging
#include <xapian/compactor.h> #include <xapian/compactor.h>
// ELF visibility annotations for GCC. // ELF visibility annotations for GCC.
#include <xapian/visibility.h> #include <xapian/visibility.h>
/// The Xapian namespace contains public interfaces for the Xapian library. /// The Xapian namespace contains public interfaces for the Xapian library.
namespace Xapian { namespace Xapian {
// Functions returning library version: // Functions returning library version:
 End of changes. 3 change blocks. 
23 lines changed or deleted 4 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/