-1
  7   Uˆl–ß=¿J Ja,je@
àž¸ÛªbÑ¿�þ\�Y¹Y[do€�ùÛ„¢eŸÚÌÁ× ?÷     U/** @file
 * @brief Xapian::Query API class
 */
/* Copyright (C) 2011,2012,2013,2014,2015,2016,2017,2018,2019 Olly Betts
 * Copyright (C) 2008 Richard Boulton
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
 */

#ifndef XAPIAN_INCLUDED_QUERY_H
#define XAPIAN_INCLUDED_QUERY_H

#if !defined XAPIAN_IN_XAPIAN_H && !defined XAPIAN_LIB_BUILD
# error Never use <xapian/query.h> directly; include <xapian.h> instead.
#endif

#include <string>

#include <xapian/attributes.h>
#include <xapian/intrusive_ptr.h>
#include <xapian/postingiterator.h>
#include <xapian/registry.h>
#include <xapian/termiterator.h>
#include <xapian/types.h>
#include <xapian/visibility.h>

class QueryOptimiser; // FIXME

namespace Xapian {

class PostingSource;

/// Class representing a query.
class XAPIAN_VISIBILITY_DEFAULT Query {
  public:
    /// Class representing the query internals.
    class Internal;
    /// @private @internal Reference counted internals.
    Xapian::Internal::intrusive_ptr<Internal> internal;

    /** A query matching no documents.
     *
     *  This is a static instance of a default-constructed Xapian::Query
     *  object.  It is safe to use concurrently from different threads,
     *  unlike @a MatchAll (this is because MatchNothing has a NULL
     *  internal object so there's no reference counting happening).
     *
     *  When combined with other Query objects using the various supported
     *  operators, MatchNothing works like @c false in boolean logic, so
     *  <code>MatchNothing & q</code> is @c MatchNothing, while
     *  <code>MatchNothing | q</code> is @c q.
     */
    static const Xapian::Query MatchNothing;

    /** A query matching all documents.
     *
     *  This is a static instance of <code>Xapian::Query(std::string())</code>.
     *  If you are constructing Query objects which use @a MatchAll in
     *  different threads then the reference counting of the static object can
     *  get messed up by concurrent access so you should instead use
     *  <code>Xapian::Query(std::string())</code> directly.
     */
    static const Xapian::Query MatchAll;

    /** Query operators. */
    enum op {
	/** Match only documents which all subqueries match.
	 *
	 *  When used in a weighted context, the weight is the sum of the
	 *  weights for all the subqueries.
	 */
	OP_AND = 0,

	/** Match documents which at least one subquery matches.
	 *
	 *  When used in a weighted context, the weight is the sum of the
	 *  weights for matching subqueries (so additional matching subqueries
	 *  will mean a higher weight).
	 */
	OP_OR = 1,

	/** Match documents which the first subquery matches but no others do.
	 *
	 *  When used in a weighted context, the weight is just the weight of
	 *  the first subquery.
	 */
	OP_AND_NOT = 2,

	/** Match documents which an odd number of subqueries match.
	 *
	 *  When used in a weighted context, the weight is the sum of the
	 *  weights for matching subqueries (so additional matching subqueries
	 *  will mean a higher weight).
	 */
	OP_XOR = 3,

	/** Match the first subquery taking extra weight from other subqueries.
	 *
	 *  When used in a weighted context, the weight is the sum of the
	 *  weights for matching subqueries (so additional matching subqueries
	 *  will mean a higher weight).
	 *
	 *  Because only the first subquery determines which documents are
	 * 