/* ----------------------------------------------------------------------------
 * 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 WritableDatabase : Database {
  private HandleRef swigCPtr;

  internal WritableDatabase(IntPtr cPtr, bool cMemoryOwn) : base(XapianPINVOKE.WritableDatabase_SWIGUpcast(cPtr), cMemoryOwn) {
    swigCPtr = new HandleRef(this, cPtr);
  }

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

  ~WritableDatabase() {
    Dispose();
  }

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

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

  public WritableDatabase(string path, int action) : this(XapianPINVOKE.new_WritableDatabase__SWIG_1(path, action), true) {
    if (XapianPINVOKE.SWIGPendingException.Pending) throw XapianPINVOKE.SWIGPendingException.Retrieve();
  }

  public WritableDatabase(WritableDatabase other) : this(XapianPINVOKE.new_WritableDatabase__SWIG_2(WritableDatabase.getCPtr(other)), true) {
    if (XapianPINVOKE.SWIGPendingException.Pending) throw XapianPINVOKE.SWIGPendingException.Retrieve();
  }

  public void Commit() {
    XapianPINVOKE.WritableDatabase_Commit(swigCPtr);
    if (XapianPINVOKE.SWIGPendingException.Pending) throw XapianPINVOKE.SWIGPendingException.Retrieve();
  }

  public void Flush() {
    XapianPINVOKE.WritableDatabase_Flush(swigCPtr);
    if (XapianPINVOKE.SWIGPendingException.Pending) throw XapianPINVOKE.SWIGPendingException.Retrieve();
  }

  public void BeginTransaction(bool flushed) {
    XapianPINVOKE.WritableDatabase_BeginTransaction__SWIG_0(swigCPtr, flushed);
    if (XapianPINVOKE.SWIGPendingException.Pending) throw XapianPINVOKE.SWIGPendingException.Retrieve();
  }

  public void BeginTransaction() {
    XapianPINVOKE.WritableDatabase_BeginTransaction__SWIG_1(swigCPtr);
    if (XapianPINVOKE.SWIGPendingException.Pending) throw XapianPINVOKE.SWIGPendingException.Retrieve();
  }

  public void CommitTransaction() {
    XapianPINVOKE.WritableDatabase_CommitTransaction(swigCPtr);
    if (XapianPINVOKE.SWIGPendingException.Pending) throw XapianPINVOKE.SWIGPendingException.Retrieve();
  }

  public void CancelTransaction() {
    XapianPINVOKE.WritableDatabase_CancelTransaction(swigCPtr);
    if (XapianPINVOKE.SWIGPendingException.Pending) throw XapianPINVOKE.SWIGPendingException.Retrieve();
  }

  public uint AddDocument(Document document) {
    uint ret = XapianPINVOKE.WritableDatabase_AddDocument(swigCPtr, Document.getCPtr(document));
    if (XapianPINVOKE.SWIGPendingException.Pending) throw XapianPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public void DeleteDocument(uint did) {
    XapianPINVOKE.WritableDatabase_DeleteDocument__SWIG_0(swigCPtr, did);
    if (XapianPINVOKE.SWIGPendingException.Pending) throw XapianPINVOKE.SWIGPendingException.Retrieve();
  }

  public void ReplaceDocument(uint did, Document document) {
    XapianPINVOKE.WritableDatabase_ReplaceDocument__SWIG_0(swigCPtr, did, Document.getCPtr(document));
    if (XapianPINVOKE.SWIGPendingException.Pending) throw XapianPINVOKE.SWIGPendingException.Retrieve();
  }

  public void DeleteDocument(string unique_term) {
    XapianPINVOKE.WritableDatabase_DeleteDocument__SWIG_1(swigCPtr, unique_term);
    if (XapianPINVOKE.SWIGPendingException.Pending) throw XapianPINVOKE.SWIGPendingException.Retrieve();
  }

  public uint ReplaceDocument(string unique_term, Document document) {
    uint ret = XapianPINVOKE.WritableDatabase_ReplaceDocument__SWIG_1(swigCPtr, unique_term, Document.getCPtr(document));
    if (XapianPINVOKE.SWIGPendingException.Pending) throw XapianPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public void AddSpelling(string word, uint freqinc) {
    XapianPINVOKE.WritableDatabase_AddSpelling__SWIG_0(swigCPtr, word, freqinc);
    if (XapianPINVOKE.SWIGPendingException.Pending) throw XapianPINVOKE.SWIGPendingException.Retrieve();
  }

  public void AddSpelling(string word) {
    XapianPINVOKE.WritableDatabase_AddSpelling__SWIG_1(swigCPtr, word);
    if (XapianPINVOKE.SWIGPendingException.Pending) throw XapianPINVOKE.SWIGPendingException.Retrieve();
  }

  public void RemoveSpelling(string word, uint freqdec) {
    XapianPINVOKE.WritableDatabase_RemoveSpelling__SWIG_0(swigCPtr, word, freqdec);
    if (XapianPINVOKE.SWIGPendingException.Pending) throw XapianPINVOKE.SWIGPendingException.Retrieve();
  }

  public void RemoveSpelling(string word) {
    XapianPINVOKE.WritableDatabase_RemoveSpelling__SWIG_1(swigCPtr, word);
    if (XapianPINVOKE.SWIGPendingException.Pending) throw XapianPINVOKE.SWIGPendingException.Retrieve();
  }

  public void AddSynonym(string term, string synonym) {
    XapianPINVOKE.WritableDatabase_AddSynonym(swigCPtr, term, synonym);
    if (XapianPINVOKE.SWIGPendingException.Pending) throw XapianPINVOKE.SWIGPendingException.Retrieve();
  }

  public void RemoveSynonym(string term, string synonym) {
    XapianPINVOKE.WritableDatabase_RemoveSynonym(swigCPtr, term, synonym);
    if (XapianPINVOKE.SWIGPendingException.Pending) throw XapianPINVOKE.SWIGPendingException.Retrieve();
  }

  public void ClearSynonyms(string term) {
    XapianPINVOKE.WritableDatabase_ClearSynonyms(swigCPtr, term);
    if (XapianPINVOKE.SWIGPendingException.Pending) throw XapianPINVOKE.SWIGPendingException.Retrieve();
  }

  public void SetMetadata(string key, string value) {
    XapianPINVOKE.WritableDatabase_SetMetadata(swigCPtr, key, value);
    if (XapianPINVOKE.SWIGPendingException.Pending) throw XapianPINVOKE.SWIGPendingException.Retrieve();
  }

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

}

}
