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

namespace Xapian {

public class RangeProcessor : global::System.IDisposable {
  private global::System.Runtime.InteropServices.HandleRef swigCPtr;
  protected bool swigCMemOwn;

  internal RangeProcessor(global::System.IntPtr cPtr, bool cMemoryOwn) {
    swigCMemOwn = cMemoryOwn;
    swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
  }

  internal static global::System.Runtime.InteropServices.HandleRef getCPtr(RangeProcessor obj) {
    return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
  }

  ~RangeProcessor() {
    Dispose();
  }

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

  public RangeProcessor() : this(XapianPINVOKE.new_RangeProcessor__SWIG_0(), true) {
    if (XapianPINVOKE.SWIGPendingException.Pending) throw XapianPINVOKE.SWIGPendingException.Retrieve();
    SwigDirectorConnect();
  }

  public RangeProcessor(uint slot_, string str_, uint flags_) : this(XapianPINVOKE.new_RangeProcessor__SWIG_1(slot_, str_, flags_), true) {
    if (XapianPINVOKE.SWIGPendingException.Pending) throw XapianPINVOKE.SWIGPendingException.Retrieve();
    SwigDirectorConnect();
  }

  public RangeProcessor(uint slot_, string str_) : this(XapianPINVOKE.new_RangeProcessor__SWIG_2(slot_, str_), true) {
    if (XapianPINVOKE.SWIGPendingException.Pending) throw XapianPINVOKE.SWIGPendingException.Retrieve();
    SwigDirectorConnect();
  }

  public RangeProcessor(uint slot_) : this(XapianPINVOKE.new_RangeProcessor__SWIG_3(slot_), true) {
    if (XapianPINVOKE.SWIGPendingException.Pending) throw XapianPINVOKE.SWIGPendingException.Retrieve();
    SwigDirectorConnect();
  }

  public Query CheckRange(string b, string e) {
    Query ret = new Query(XapianPINVOKE.RangeProcessor_CheckRange(swigCPtr, b, e), true);
    if (XapianPINVOKE.SWIGPendingException.Pending) throw XapianPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public virtual Query Apply(string begin, string end) {
    Query ret = new Query((SwigDerivedClassHasMethod("Apply", swigMethodTypes0) ? XapianPINVOKE.RangeProcessor_ApplySwigExplicitRangeProcessor(swigCPtr, begin, end) : XapianPINVOKE.RangeProcessor_Apply(swigCPtr, begin, end)), true);
    if (XapianPINVOKE.SWIGPendingException.Pending) throw XapianPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public RangeProcessor Release() {
    global::System.IntPtr cPtr = XapianPINVOKE.RangeProcessor_Release(swigCPtr);
    RangeProcessor ret = (cPtr == global::System.IntPtr.Zero) ? null : new RangeProcessor(cPtr, false);
    if (XapianPINVOKE.SWIGPendingException.Pending) throw XapianPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  private void SwigDirectorConnect() {
    if (SwigDerivedClassHasMethod("Apply", swigMethodTypes0))
      swigDelegate0 = new SwigDelegateRangeProcessor_0(SwigDirectorApply);
    XapianPINVOKE.RangeProcessor_director_connect(swigCPtr, swigDelegate0);
  }

  private bool SwigDerivedClassHasMethod(string methodName, global::System.Type[] methodTypes) {
    global::System.Reflection.MethodInfo methodInfo = this.GetType().GetMethod(methodName, global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, methodTypes, null);
    bool hasDerivedMethod = methodInfo.DeclaringType.IsSubclassOf(typeof(RangeProcessor));
    return hasDerivedMethod;
  }

  private global::System.IntPtr SwigDirectorApply(string begin, string end) {
    return Query.getCPtr(Apply(begin, end)).Handle;
  }

  public delegate global::System.IntPtr SwigDelegateRangeProcessor_0(string begin, string end);

  private SwigDelegateRangeProcessor_0 swigDelegate0;

  private static global::System.Type[] swigMethodTypes0 = new global::System.Type[] { typeof(string), typeof(string) };
}

}
