/* ----------------------------------------------------------------------------
 * This file was automatically generated by SWIG (http://www.swig.org).
 * Version 2.0.5
 *
 * Do not make changes to this file unless you know what you are doing--modify
 * the SWIG interface file instead.
 * ----------------------------------------------------------------------------- */

namespace Xapian {

using System;
using System.Runtime.InteropServices;

public class QueryParser : IDisposable {
  private HandleRef swigCPtr;
  protected bool swigCMemOwn;

  internal QueryParser(IntPtr cPtr, bool cMemoryOwn) {
    swigCMemOwn = cMemoryOwn;
    swigCPtr = new HandleRef(this, cPtr);
  }

  internal static HandleRef getCPtr(QueryParser obj) {
    return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
  }

  ~QueryParser() {
    Dispose();
  }

  public virtual void Dispose() {
    lock(this) {
      if (swigCPtr.Handle != IntPtr.Zero) {
        if (swigCMemOwn) {
          swigCMemOwn = false;
          XapianPINVOKE.delete_QueryParser(swigCPtr);
        }
        swigCPtr = new HandleRef(null, IntPtr.Zero);
      }
      GC.SuppressFinalize(this);
    }
  }

  public QueryParser() : this(XapianPINVOKE.new_QueryParser(), true) {
    if (XapianPINVOKE.SWIGPendingException.Pending) throw XapianPINVOKE.SWIGPendingException.Retrieve();
  }

  public void SetStemmer(Stem stemmer) {
    XapianPINVOKE.QueryParser_SetStemmer(swigCPtr, Stem.getCPtr(stemmer));
    if (XapianPINVOKE.SWIGPendingException.Pending) throw XapianPINVOKE.SWIGPendingException.Retrieve();
  }

  public void SetStemmingStrategy(QueryParser.stem_strategy strategy) {
    XapianPINVOKE.QueryParser_SetStemmingStrategy(swigCPtr, (int)strategy);
    if (XapianPINVOKE.SWIGPendingException.Pending) throw XapianPINVOKE.SWIGPendingException.Retrieve();
  }

  public void SetStopper(Stopper stop) {
    XapianPINVOKE.QueryParser_SetStopper__SWIG_0(swigCPtr, Stopper.getCPtr(stop));
    if (XapianPINVOKE.SWIGPendingException.Pending) throw XapianPINVOKE.SWIGPendingException.Retrieve();
  }

  public void SetStopper() {
    XapianPINVOKE.QueryParser_SetStopper__SWIG_1(swigCPtr);
    if (XapianPINVOKE.SWIGPendingException.Pending) throw XapianPINVOKE.SWIGPendingException.Retrieve();
  }

  public void SetDefaultOp(Query.op default_op) {
    XapianPINVOKE.QueryParser_SetDefaultOp(swigCPtr, (int)default_op);
    if (XapianPINVOKE.SWIGPendingException.Pending) throw XapianPINVOKE.SWIGPendingException.Retrieve();
  }

  public Query.op GetDefaultOp() {
    Query.op ret = (Query.op)XapianPINVOKE.QueryParser_GetDefaultOp(swigCPtr);
    if (XapianPINVOKE.SWIGPendingException.Pending) throw XapianPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public void SetDatabase(Database db) {
    XapianPINVOKE.QueryParser_SetDatabase(swigCPtr, Database.getCPtr(db));
    if (XapianPINVOKE.SWIGPendingException.Pending) throw XapianPINVOKE.SWIGPendingException.Retrieve();
  }

  public void SetMaxWildcardExpansion(uint limit) {
    XapianPINVOKE.QueryParser_SetMaxWildcardExpansion(swigCPtr, limit);
    if (XapianPINVOKE.SWIGPendingException.Pending) throw XapianPINVOKE.SWIGPendingException.Retrieve();
  }

  public Query ParseQuery(string query_string, uint flags, string default_prefix) {
    Query ret = new Query(XapianPINVOKE.QueryParser_ParseQuery__SWIG_0(swigCPtr, query_string, flags, default_prefix), true);
    if (XapianPINVOKE.SWIGPendingException.Pending) throw XapianPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public Query ParseQuery(string query_string, uint flags) {
    Query ret = new Query(XapianPINVOKE.QueryParser_ParseQuery__SWIG_1(swigCPtr, query_string, flags), true);
    if (XapianPINVOKE.SWIGPendingException.Pending) throw XapianPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public Query ParseQuery(string query_string) {
    Query ret = new Query(XapianPINVOKE.QueryParser_ParseQuery__SWIG_2(swigCPtr, query_string), true);
    if (XapianPINVOKE.SWIGPendingException.Pending) throw XapianPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public void AddPrefix(string field, string prefix) {
    XapianPINVOKE.QueryParser_AddPrefix(swigCPtr, field, prefix);
    if (XapianPINVOKE.SWIGPendingException.Pending) throw XapianPINVOKE.SWIGPendingException.Retrieve();
  }

  public void AddBooleanPrefix(string field, string prefix, bool exclusive) {
    XapianPINVOKE.QueryParser_AddBooleanPrefix__SWIG_0(swigCPtr, field, prefix, exclusive);
    if (XapianPINVOKE.SWIGPendingException.Pending) throw XapianPINVOKE.SWIGPendingException.Retrieve();
  }

  public void AddBooleanPrefix(string field, string prefix) {
    XapianPINVOKE.QueryParser_AddBooleanPrefix__SWIG_1(swigCPtr, field, prefix);
    if (XapianPINVOKE.SWIGPendingException.Pending) throw XapianPINVOKE.SWIGPendingException.Retrieve();
  }

  public TermIterator StopListBegin() {
    TermIterator ret = new TermIterator(XapianPINVOKE.QueryParser_StopListBegin(swigCPtr), true);
    if (XapianPINVOKE.SWIGPendingException.Pending) throw XapianPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public TermIterator StopListEnd() {
    TermIterator ret = new TermIterator(XapianPINVOKE.QueryParser_StopListEnd(swigCPtr), true);
    if (XapianPINVOKE.SWIGPendingException.Pending) throw XapianPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public TermIterator UnstemBegin(string term) {
    TermIterator ret = new TermIterator(XapianPINVOKE.QueryParser_UnstemBegin(swigCPtr, term), true);
    if (XapianPINVOKE.SWIGPendingException.Pending) throw XapianPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public TermIterator UnstemEnd(string arg0) {
    TermIterator ret = new TermIterator(XapianPINVOKE.QueryParser_UnstemEnd(swigCPtr, arg0), true);
    if (XapianPINVOKE.SWIGPendingException.Pending) throw XapianPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public void AddValuerangeprocessor(ValueRangeProcessor vrproc) {
    XapianPINVOKE.QueryParser_AddValuerangeprocessor(swigCPtr, ValueRangeProcessor.getCPtr(vrproc));
    if (XapianPINVOKE.SWIGPendingException.Pending) throw XapianPINVOKE.SWIGPendingException.Retrieve();
  }

  public string GetCorrectedQueryString() {
    string ret = XapianPINVOKE.QueryParser_GetCorrectedQueryString(swigCPtr);
    if (XapianPINVOKE.SWIGPendingException.Pending) throw XapianPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public string GetDescription() {
    string ret = XapianPINVOKE.QueryParser_GetDescription(swigCPtr);
    if (XapianPINVOKE.SWIGPendingException.Pending) throw XapianPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public enum feature_flag {
    FLAG_BOOLEAN = 1,
    FLAG_PHRASE = 2,
    FLAG_LOVEHATE = 4,
    FLAG_BOOLEAN_ANY_CASE = 8,
    FLAG_WILDCARD = 16,
    FLAG_PURE_NOT = 32,
    FLAG_PARTIAL = 64,
    FLAG_SPELLING_CORRECTION = 128,
    FLAG_SYNONYM = 256,
    FLAG_AUTO_SYNONYMS = 512,
    FLAG_AUTO_MULTIWORD_SYNONYMS = 1024|FLAG_AUTO_SYNONYMS,
    FLAG_DEFAULT = FLAG_PHRASE|FLAG_BOOLEAN|FLAG_LOVEHATE
  }

  public enum stem_strategy {
    STEM_NONE,
    STEM_SOME,
    STEM_ALL,
    STEM_ALL_Z
  }

}

}
