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

namespace OSGeo.OGR {

using System;
using System.Runtime.InteropServices;

public class Feature : IDisposable {
  private HandleRef swigCPtr;
  protected object swigCMemOwner;

  internal Feature(IntPtr cPtr, object cMemoryOwner) {
    swigCMemOwner = cMemoryOwner;
    swigCPtr = new HandleRef(this, cPtr);
  }

  internal static HandleRef getCPtr(Feature obj) {
    return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
  }
  internal static HandleRef getCPtrAndDisown(Feature obj, object cMemoryOwner) {
    obj.swigCMemOwner = cMemoryOwner;
    return getCPtr(obj);
  }

  ~Feature() {
    Dispose();
  }

  public virtual void Dispose() {
  lock(this) {
      if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwner == null) {
        swigCMemOwner = new object();
        ogrPINVOKE.delete_Feature(swigCPtr);
      }
      swigCPtr = new HandleRef(null, IntPtr.Zero);
      GC.SuppressFinalize(this);
    }
  }

  public Feature(FeatureDefn feature_def) : this(ogrPINVOKE.new_Feature(FeatureDefn.getCPtr(feature_def)), null) {
    if (ogrPINVOKE.SWIGPendingException.Pending) throw ogrPINVOKE.SWIGPendingException.Retrieve();
  }

  public FeatureDefn GetDefnRef() {
    IntPtr cPtr = ogrPINVOKE.Feature_GetDefnRef(swigCPtr);
    FeatureDefn ret = (cPtr == IntPtr.Zero) ? null : new FeatureDefn(cPtr, false? null : this);
    if (ogrPINVOKE.SWIGPendingException.Pending) throw ogrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public int SetGeometry(Geometry geom) {
    int ret = ogrPINVOKE.Feature_SetGeometry(swigCPtr, Geometry.getCPtr(geom));
    if (ogrPINVOKE.SWIGPendingException.Pending) throw ogrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public int SetGeometryDirectly(Geometry geom) {
    int ret = ogrPINVOKE.Feature_SetGeometryDirectly(swigCPtr, Geometry.getCPtrAndDisown(geom, this));
    if (ogrPINVOKE.SWIGPendingException.Pending) throw ogrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public Geometry GetGeometryRef() {
    IntPtr cPtr = ogrPINVOKE.Feature_GetGeometryRef(swigCPtr);
    Geometry ret = (cPtr == IntPtr.Zero) ? null : new Geometry(cPtr, false? null : this);
    if (ogrPINVOKE.SWIGPendingException.Pending) throw ogrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public Feature Clone() {
    IntPtr cPtr = ogrPINVOKE.Feature_Clone(swigCPtr);
    Feature ret = (cPtr == IntPtr.Zero) ? null : new Feature(cPtr, true? null : this);
    if (ogrPINVOKE.SWIGPendingException.Pending) throw ogrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public bool Equal(Feature feature) {
    bool ret = ogrPINVOKE.Feature_Equal(swigCPtr, Feature.getCPtr(feature));
    if (ogrPINVOKE.SWIGPendingException.Pending) throw ogrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public int GetFieldCount() {
    int ret = ogrPINVOKE.Feature_GetFieldCount(swigCPtr);
    if (ogrPINVOKE.SWIGPendingException.Pending) throw ogrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public FieldDefn GetFieldDefnRef(int id) {
    IntPtr cPtr = ogrPINVOKE.Feature_GetFieldDefnRef__SWIG_0(swigCPtr, id);
    FieldDefn ret = (cPtr == IntPtr.Zero) ? null : new FieldDefn(cPtr, false? null : this);
    if (ogrPINVOKE.SWIGPendingException.Pending) throw ogrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public FieldDefn GetFieldDefnRef(string name) {
    IntPtr cPtr = ogrPINVOKE.Feature_GetFieldDefnRef__SWIG_1(swigCPtr, name);
    FieldDefn ret = (cPtr == IntPtr.Zero) ? null : new FieldDefn(cPtr, false? null : this);
    if (ogrPINVOKE.SWIGPendingException.Pending) throw ogrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public string GetFieldAsString(int id) {
    string ret = ogrPINVOKE.Feature_GetFieldAsString__SWIG_0(swigCPtr, id);
    if (ogrPINVOKE.SWIGPendingException.Pending) throw ogrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public string GetFieldAsString(string name) {
    string ret = ogrPINVOKE.Feature_GetFieldAsString__SWIG_1(swigCPtr, name);
    if (ogrPINVOKE.SWIGPendingException.Pending) throw ogrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public int GetFieldAsInteger(int id) {
    int ret = ogrPINVOKE.Feature_GetFieldAsInteger__SWIG_0(swigCPtr, id);
    if (ogrPINVOKE.SWIGPendingException.Pending) throw ogrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public int GetFieldAsInteger(string name) {
    int ret = ogrPINVOKE.Feature_GetFieldAsInteger__SWIG_1(swigCPtr, name);
    if (ogrPINVOKE.SWIGPendingException.Pending) throw ogrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public double GetFieldAsDouble(int id) {
    double ret = ogrPINVOKE.Feature_GetFieldAsDouble__SWIG_0(swigCPtr, id);
    if (ogrPINVOKE.SWIGPendingException.Pending) throw ogrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public double GetFieldAsDouble(string name) {
    double ret = ogrPINVOKE.Feature_GetFieldAsDouble__SWIG_1(swigCPtr, name);
    if (ogrPINVOKE.SWIGPendingException.Pending) throw ogrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public bool IsFieldSet(int id) {
    bool ret = ogrPINVOKE.Feature_IsFieldSet__SWIG_0(swigCPtr, id);
    if (ogrPINVOKE.SWIGPendingException.Pending) throw ogrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public bool IsFieldSet(string name) {
    bool ret = ogrPINVOKE.Feature_IsFieldSet__SWIG_1(swigCPtr, name);
    if (ogrPINVOKE.SWIGPendingException.Pending) throw ogrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public int GetFieldIndex(string name) {
    int ret = ogrPINVOKE.Feature_GetFieldIndex(swigCPtr, name);
    if (ogrPINVOKE.SWIGPendingException.Pending) throw ogrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public int GetFID() {
    int ret = ogrPINVOKE.Feature_GetFID(swigCPtr);
    if (ogrPINVOKE.SWIGPendingException.Pending) throw ogrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public int SetFID(int fid) {
    int ret = ogrPINVOKE.Feature_SetFID(swigCPtr, fid);
    if (ogrPINVOKE.SWIGPendingException.Pending) throw ogrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public void DumpReadable() {
    ogrPINVOKE.Feature_DumpReadable(swigCPtr);
    if (ogrPINVOKE.SWIGPendingException.Pending) throw ogrPINVOKE.SWIGPendingException.Retrieve();
  }

  public void UnsetField(int id) {
    ogrPINVOKE.Feature_UnsetField__SWIG_0(swigCPtr, id);
    if (ogrPINVOKE.SWIGPendingException.Pending) throw ogrPINVOKE.SWIGPendingException.Retrieve();
  }

  public void UnsetField(string name) {
    ogrPINVOKE.Feature_UnsetField__SWIG_1(swigCPtr, name);
    if (ogrPINVOKE.SWIGPendingException.Pending) throw ogrPINVOKE.SWIGPendingException.Retrieve();
  }

  public void SetField(int id, string value) {
    ogrPINVOKE.Feature_SetField__SWIG_0(swigCPtr, id, value);
    if (ogrPINVOKE.SWIGPendingException.Pending) throw ogrPINVOKE.SWIGPendingException.Retrieve();
  }

  public void SetField(string name, string value) {
    ogrPINVOKE.Feature_SetField__SWIG_1(swigCPtr, name, value);
    if (ogrPINVOKE.SWIGPendingException.Pending) throw ogrPINVOKE.SWIGPendingException.Retrieve();
  }

  public int SetFrom(Feature other, int forgiving) {
    int ret = ogrPINVOKE.Feature_SetFrom(swigCPtr, Feature.getCPtr(other), forgiving);
    if (ogrPINVOKE.SWIGPendingException.Pending) throw ogrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public string GetStyleString() {
    string ret = ogrPINVOKE.Feature_GetStyleString(swigCPtr);
    if (ogrPINVOKE.SWIGPendingException.Pending) throw ogrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public void SetStyleString(string the_string) {
    ogrPINVOKE.Feature_SetStyleString(swigCPtr, the_string);
    if (ogrPINVOKE.SWIGPendingException.Pending) throw ogrPINVOKE.SWIGPendingException.Retrieve();
  }

  public int GetFieldType(int id) {
    int ret = ogrPINVOKE.Feature_GetFieldType__SWIG_0(swigCPtr, id);
    if (ogrPINVOKE.SWIGPendingException.Pending) throw ogrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public int GetFieldType(string name) {
    int ret = ogrPINVOKE.Feature_GetFieldType__SWIG_1(swigCPtr, name);
    if (ogrPINVOKE.SWIGPendingException.Pending) throw ogrPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

}

}
