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

namespace Xapian {

public class WritableDatabase : Database {
  private global::System.Runtime.InteropServices.HandleRef swigCPtr;

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

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

  ~WritableDatabase() {
    Dispose();
  }

  public override void Dispose() {
    lock(this) {
      if (swigCPtr.Handle != global::System.IntPtr.Zero) {
        if (swigCMemOwn) {
          swigCMemOwn = false;
          XapianPINVOKE.delete_WritableDatabase(swigCPtr);
        }
        swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
      }
      global::System.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 flags, int block_size) : this(XapianPINVOKE.new_WritableDatabase__SWIG_1(path, flags, block_size), true) {
    if (XapianPINVOKE.SWIGPendingException.Pending) throw XapianPINVOKE.SWIGPendingException.Retrieve();
  }

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

  public WritableDatabase(string path) : this(XapianPINVOKE.new_WritableDatabase__SWIG_3(path), 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 DeleteDocument(string unique_term) {
    XapianPINVOKE.WritableDatabase_DeleteDocument__SWIG_1(swigCPtr, unique_term);
    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 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 metadata) {
    XapianPINVOKE.WritableDatabase_SetMetadata(swigCPtr, key, metadata);
    if (XapianPINVOKE.SWIGPendingException.Pending) throw XapianPINVOKE.SWIGPendingException.Retrieve();
  }

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

}

}
