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

namespace SLNet {

using System;
using System.Runtime.InteropServices;

public class ByteQueue : IDisposable {
  private HandleRef swigCPtr;
  protected bool swigCMemOwn;

  internal ByteQueue(IntPtr cPtr, bool cMemoryOwn) {
    swigCMemOwn = cMemoryOwn;
    swigCPtr = new HandleRef(this, cPtr);
  }

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

  ~ByteQueue() {
    Dispose();
  }

  public virtual void Dispose() {
    lock(this) {
      if (swigCPtr.Handle != IntPtr.Zero) {
        if (swigCMemOwn) {
          swigCMemOwn = false;
          SLikeNetPINVOKE.delete_ByteQueue(swigCPtr);
        }
        swigCPtr = new HandleRef(null, IntPtr.Zero);
      }
      GC.SuppressFinalize(this);
    }
  }

	public byte[] PeekContiguousBytes(out uint outLength) 
	{
		return PeekContiguousBytesHelper(out outLength);
	}

  public ByteQueue() : this(SLikeNetPINVOKE.new_ByteQueue(), true) {
  }

  public uint GetBytesWritten() {
    uint ret = SLikeNetPINVOKE.ByteQueue_GetBytesWritten(swigCPtr);
    return ret;
  }

  public void IncrementReadOffset(uint length) {
    SLikeNetPINVOKE.ByteQueue_IncrementReadOffset(swigCPtr, length);
  }

  public void DecrementReadOffset(uint length) {
    SLikeNetPINVOKE.ByteQueue_DecrementReadOffset(swigCPtr, length);
  }

  public void Clear(string file, uint line) {
    SLikeNetPINVOKE.ByteQueue_Clear(swigCPtr, file, line);
  }

  public void Print() {
    SLikeNetPINVOKE.ByteQueue_Print(swigCPtr);
  }

  public void WriteBytes(byte[] inByteArray, uint length, string file, uint line) {
    SLikeNetPINVOKE.ByteQueue_WriteBytes(swigCPtr, inByteArray, length, file, line);
  }

  public bool ReadBytes(byte[] inOutByteArray, uint maxLengthToRead, bool peek) {
    bool ret = SLikeNetPINVOKE.ByteQueue_ReadBytes(swigCPtr, inOutByteArray, maxLengthToRead, peek);
    return ret;
  }

  private byte[] PeekContiguousBytesHelper(out uint outLength) {
      IntPtr cPtr = SLikeNetPINVOKE.ByteQueue_PeekContiguousBytesHelper(swigCPtr, out outLength);
      int len = (int)outLength;
      if (len <= 0)
      {
          return null;
      }
      byte[] returnBytes = new byte[len];
      Marshal.Copy(cPtr, returnBytes, 0, len);
      return returnBytes;
  }

}

}
