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

namespace libsbml {

using System;
using System.Runtime.InteropServices;

public class XMLNode : XMLToken {
	private HandleRef swigCPtr;
	
	internal XMLNode(IntPtr cPtr, bool cMemoryOwn) : base(libsbmlPINVOKE.XMLNodeUpcast(cPtr), cMemoryOwn)
	{
		//super(libsbmlPINVOKE.XMLNodeUpcast(cPtr), cMemoryOwn);
		swigCPtr = new HandleRef(this, cPtr);
	}
	
	internal static HandleRef getCPtr(XMLNode obj)
	{
		return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
	}
	
	internal static HandleRef getCPtrAndDisown (XMLNode obj)
	{
		HandleRef ptr = new HandleRef(null, IntPtr.Zero);
		
		if (obj != null)
		{
			ptr             = obj.swigCPtr;
			obj.swigCMemOwn = false;
		}
		
		return ptr;
	}

  ~XMLNode() {
    Dispose();
  }

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

  public static bool operator==(XMLNode lhs, XMLNode rhs)
  {
    if((Object)lhs == (Object)rhs)
    {
      return true;
    }

    if( ((Object)lhs == null) || ((Object)rhs == null) )
    {
      return false;
    }

    return (getCPtr(lhs).Handle.ToString() == getCPtr(rhs).Handle.ToString());
  }

  public static bool operator!=(XMLNode lhs, XMLNode rhs)
  {
    return !(lhs == rhs);
  }

  public override bool Equals(Object sb)
  {
    if ( ! (sb is XMLNode) )
    {
      return false;
    }

    return this == (XMLNode)sb;
  }

  public override int GetHashCode()
  {
    return swigCPtr.Handle.ToInt32();
  }

  public XMLNode() : this(libsbmlPINVOKE.new_XMLNode__SWIG_0(), true) {
  }

  public XMLNode(XMLToken token) : this(libsbmlPINVOKE.new_XMLNode__SWIG_1(XMLToken.getCPtr(token)), true) {
    if (libsbmlPINVOKE.SWIGPendingException.Pending) throw libsbmlPINVOKE.SWIGPendingException.Retrieve();
  }

  public XMLNode(XMLTriple triple, XMLAttributes attributes, XMLNamespaces namespaces, long line, long column) : this(libsbmlPINVOKE.new_XMLNode__SWIG_2(XMLTriple.getCPtr(triple), XMLAttributes.getCPtr(attributes), XMLNamespaces.getCPtr(namespaces), line, column), true) {
    if (libsbmlPINVOKE.SWIGPendingException.Pending) throw libsbmlPINVOKE.SWIGPendingException.Retrieve();
  }

  public XMLNode(XMLTriple triple, XMLAttributes attributes, XMLNamespaces namespaces, long line) : this(libsbmlPINVOKE.new_XMLNode__SWIG_3(XMLTriple.getCPtr(triple), XMLAttributes.getCPtr(attributes), XMLNamespaces.getCPtr(namespaces), line), true) {
    if (libsbmlPINVOKE.SWIGPendingException.Pending) throw libsbmlPINVOKE.SWIGPendingException.Retrieve();
  }

  public XMLNode(XMLTriple triple, XMLAttributes attributes, XMLNamespaces namespaces) : this(libsbmlPINVOKE.new_XMLNode__SWIG_4(XMLTriple.getCPtr(triple), XMLAttributes.getCPtr(attributes), XMLNamespaces.getCPtr(namespaces)), true) {
    if (libsbmlPINVOKE.SWIGPendingException.Pending) throw libsbmlPINVOKE.SWIGPendingException.Retrieve();
  }

  public XMLNode(XMLTriple triple, XMLAttributes attributes, long line, long column) : this(libsbmlPINVOKE.new_XMLNode__SWIG_5(XMLTriple.getCPtr(triple), XMLAttributes.getCPtr(attributes), line, column), true) {
    if (libsbmlPINVOKE.SWIGPendingException.Pending) throw libsbmlPINVOKE.SWIGPendingException.Retrieve();
  }

  public XMLNode(XMLTriple triple, XMLAttributes attributes, long line) : this(libsbmlPINVOKE.new_XMLNode__SWIG_6(XMLTriple.getCPtr(triple), XMLAttributes.getCPtr(attributes), line), true) {
    if (libsbmlPINVOKE.SWIGPendingException.Pending) throw libsbmlPINVOKE.SWIGPendingException.Retrieve();
  }

  public XMLNode(XMLTriple triple, XMLAttributes attributes) : this(libsbmlPINVOKE.new_XMLNode__SWIG_7(XMLTriple.getCPtr(triple), XMLAttributes.getCPtr(attributes)), true) {
    if (libsbmlPINVOKE.SWIGPendingException.Pending) throw libsbmlPINVOKE.SWIGPendingException.Retrieve();
  }

  public XMLNode(XMLTriple triple, long line, long column) : this(libsbmlPINVOKE.new_XMLNode__SWIG_8(XMLTriple.getCPtr(triple), line, column), true) {
    if (libsbmlPINVOKE.SWIGPendingException.Pending) throw libsbmlPINVOKE.SWIGPendingException.Retrieve();
  }

  public XMLNode(XMLTriple triple, long line) : this(libsbmlPINVOKE.new_XMLNode__SWIG_9(XMLTriple.getCPtr(triple), line), true) {
    if (libsbmlPINVOKE.SWIGPendingException.Pending) throw libsbmlPINVOKE.SWIGPendingException.Retrieve();
  }

  public XMLNode(XMLTriple triple) : this(libsbmlPINVOKE.new_XMLNode__SWIG_10(XMLTriple.getCPtr(triple)), true) {
    if (libsbmlPINVOKE.SWIGPendingException.Pending) throw libsbmlPINVOKE.SWIGPendingException.Retrieve();
  }

  public XMLNode(string chars, long line, long column) : this(libsbmlPINVOKE.new_XMLNode__SWIG_11(chars, line, column), true) {
  }

  public XMLNode(string chars, long line) : this(libsbmlPINVOKE.new_XMLNode__SWIG_12(chars, line), true) {
  }

  public XMLNode(string chars) : this(libsbmlPINVOKE.new_XMLNode__SWIG_13(chars), true) {
  }

  public XMLNode(XMLNode orig) : this(libsbmlPINVOKE.new_XMLNode__SWIG_14(XMLNode.getCPtr(orig)), true) {
    if (libsbmlPINVOKE.SWIGPendingException.Pending) throw libsbmlPINVOKE.SWIGPendingException.Retrieve();
  }

  public new XMLNode clone() {
    IntPtr cPtr = libsbmlPINVOKE.XMLNode_clone(swigCPtr);
    XMLNode ret = (cPtr == IntPtr.Zero) ? null : new XMLNode(cPtr, true);
    return ret;
  }

  public int addChild(XMLNode node) {
    int ret = libsbmlPINVOKE.XMLNode_addChild(swigCPtr, XMLNode.getCPtr(node));
    if (libsbmlPINVOKE.SWIGPendingException.Pending) throw libsbmlPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public XMLNode insertChild(long n, XMLNode node) {
    XMLNode ret = new XMLNode(libsbmlPINVOKE.XMLNode_insertChild(swigCPtr, n, XMLNode.getCPtr(node)), false);
    if (libsbmlPINVOKE.SWIGPendingException.Pending) throw libsbmlPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  public XMLNode removeChild(long n) {
    IntPtr cPtr = libsbmlPINVOKE.XMLNode_removeChild(swigCPtr, n);
    XMLNode ret = (cPtr == IntPtr.Zero) ? null : new XMLNode(cPtr, true);
    return ret;
  }

  public int removeChildren() {
    int ret = libsbmlPINVOKE.XMLNode_removeChildren(swigCPtr);
    return ret;
  }

  public XMLNode getChild(long n) {
    XMLNode ret = new XMLNode(libsbmlPINVOKE.XMLNode_getChild__SWIG_0(swigCPtr, n), false);
    return ret;
  }

  public long getNumChildren() { return (long)libsbmlPINVOKE.XMLNode_getNumChildren(swigCPtr); }

  public string toXMLString() {
    string ret = libsbmlPINVOKE.XMLNode_toXMLString(swigCPtr);
    return ret;
  }

  public static string convertXMLNodeToString(XMLNode node) {
    string ret = libsbmlPINVOKE.XMLNode_convertXMLNodeToString(XMLNode.getCPtr(node));
    return ret;
  }

  public static XMLNode convertStringToXMLNode(string xmlstr, XMLNamespaces xmlns) {
    IntPtr cPtr = libsbmlPINVOKE.XMLNode_convertStringToXMLNode__SWIG_0(xmlstr, XMLNamespaces.getCPtr(xmlns));
    XMLNode ret = (cPtr == IntPtr.Zero) ? null : new XMLNode(cPtr, true);
    return ret;
  }

  public static XMLNode convertStringToXMLNode(string xmlstr) {
    IntPtr cPtr = libsbmlPINVOKE.XMLNode_convertStringToXMLNode__SWIG_1(xmlstr);
    XMLNode ret = (cPtr == IntPtr.Zero) ? null : new XMLNode(cPtr, true);
    return ret;
  }

}

}
