// This file was generated by the Gtk# code generator.
// Any changes made will be lost if regenerated.

namespace GtkSource {

	using System;
	using System.Collections;
	using System.Collections.Generic;
	using System.Runtime.InteropServices;
	using static GLib.AbiStructExtension;

#region Autogenerated code
	public partial class SearchContext : GLib.Object {

		public SearchContext (IntPtr raw) : base(raw) {}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr d_gtk_source_search_context_new(IntPtr buffer, IntPtr settings);
		static d_gtk_source_search_context_new gtk_source_search_context_new = FuncLoader.LoadFunction<d_gtk_source_search_context_new>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GtkSource), "gtk_source_search_context_new"));

		public SearchContext (GtkSource.Buffer buffer, GtkSource.SearchSettings settings) : base (IntPtr.Zero)
		{
			if (GetType () != typeof (SearchContext)) {
				var vals = new List<GLib.Value> ();
				var names = new List<string> ();
				if (buffer != null) {
					names.Add ("buffer");
					vals.Add (new GLib.Value (buffer));
				}
				if (settings != null) {
					names.Add ("settings");
					vals.Add (new GLib.Value (settings));
				}
				CreateNativeObject (names.ToArray (), vals.ToArray ());
				return;
			}
			Raw = gtk_source_search_context_new(buffer == null ? IntPtr.Zero : buffer.Handle, settings == null ? IntPtr.Zero : settings.Handle);
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr d_gtk_source_search_context_get_buffer(IntPtr raw);
		static d_gtk_source_search_context_get_buffer gtk_source_search_context_get_buffer = FuncLoader.LoadFunction<d_gtk_source_search_context_get_buffer>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GtkSource), "gtk_source_search_context_get_buffer"));

		[GLib.Property ("buffer")]
		public GtkSource.Buffer Buffer {
			get  {
				IntPtr raw_ret = gtk_source_search_context_get_buffer(Handle);
				GtkSource.Buffer ret = GLib.Object.GetObject(raw_ret) as GtkSource.Buffer;
				return ret;
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr d_gtk_source_search_context_get_settings(IntPtr raw);
		static d_gtk_source_search_context_get_settings gtk_source_search_context_get_settings = FuncLoader.LoadFunction<d_gtk_source_search_context_get_settings>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GtkSource), "gtk_source_search_context_get_settings"));

		[GLib.Property ("settings")]
		public GtkSource.SearchSettings Settings {
			get  {
				IntPtr raw_ret = gtk_source_search_context_get_settings(Handle);
				GtkSource.SearchSettings ret = GLib.Object.GetObject(raw_ret) as GtkSource.SearchSettings;
				return ret;
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate bool d_gtk_source_search_context_get_highlight(IntPtr raw);
		static d_gtk_source_search_context_get_highlight gtk_source_search_context_get_highlight = FuncLoader.LoadFunction<d_gtk_source_search_context_get_highlight>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GtkSource), "gtk_source_search_context_get_highlight"));

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void d_gtk_source_search_context_set_highlight(IntPtr raw, bool highlight);
		static d_gtk_source_search_context_set_highlight gtk_source_search_context_set_highlight = FuncLoader.LoadFunction<d_gtk_source_search_context_set_highlight>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GtkSource), "gtk_source_search_context_set_highlight"));

		[GLib.Property ("highlight")]
		public bool Highlight {
			get  {
				bool raw_ret = gtk_source_search_context_get_highlight(Handle);
				bool ret = raw_ret;
				return ret;
			}
			set  {
				gtk_source_search_context_set_highlight(Handle, value);
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr d_gtk_source_search_context_get_match_style(IntPtr raw);
		static d_gtk_source_search_context_get_match_style gtk_source_search_context_get_match_style = FuncLoader.LoadFunction<d_gtk_source_search_context_get_match_style>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GtkSource), "gtk_source_search_context_get_match_style"));

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void d_gtk_source_search_context_set_match_style(IntPtr raw, IntPtr match_style);
		static d_gtk_source_search_context_set_match_style gtk_source_search_context_set_match_style = FuncLoader.LoadFunction<d_gtk_source_search_context_set_match_style>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GtkSource), "gtk_source_search_context_set_match_style"));

		[GLib.Property ("match-style")]
		public GtkSource.Style MatchStyle {
			get  {
				IntPtr raw_ret = gtk_source_search_context_get_match_style(Handle);
				GtkSource.Style ret = GLib.Object.GetObject(raw_ret) as GtkSource.Style;
				return ret;
			}
			set  {
				gtk_source_search_context_set_match_style(Handle, value == null ? IntPtr.Zero : value.Handle);
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate int d_gtk_source_search_context_get_occurrences_count(IntPtr raw);
		static d_gtk_source_search_context_get_occurrences_count gtk_source_search_context_get_occurrences_count = FuncLoader.LoadFunction<d_gtk_source_search_context_get_occurrences_count>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GtkSource), "gtk_source_search_context_get_occurrences_count"));

		[GLib.Property ("occurrences-count")]
		public int OccurrencesCount {
			get  {
				int raw_ret = gtk_source_search_context_get_occurrences_count(Handle);
				int ret = raw_ret;
				return ret;
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr d_gtk_source_search_context_get_regex_error(IntPtr raw);
		static d_gtk_source_search_context_get_regex_error gtk_source_search_context_get_regex_error = FuncLoader.LoadFunction<d_gtk_source_search_context_get_regex_error>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GtkSource), "gtk_source_search_context_get_regex_error"));

		[GLib.Property ("regex-error")]
		public IntPtr RegexError {
			get  {
				IntPtr raw_ret = gtk_source_search_context_get_regex_error(Handle);
				IntPtr ret = raw_ret;
				return ret;
			}
		}


		// Internal representation of the wrapped structure ABI.
		static GLib.AbiStruct _class_abi = null;
		static public unsafe new GLib.AbiStruct class_abi {
			get {
				if (_class_abi == null)
					_class_abi = new GLib.AbiStruct (new List<GLib.AbiField>{ 
						new GLib.AbiField("padding"
							, GLib.Object.class_abi.Fields
							, (uint) sizeof( IntPtr ) * 10 // padding
							, null
							, null
							, (uint) sizeof(IntPtr)
							, 0
							),
					});

				return _class_abi;
			}
		}


		// End of the ABI representation.

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate bool d_gtk_source_search_context_backward(IntPtr raw, IntPtr iter, IntPtr match_start, IntPtr match_end, out bool has_wrapped_around);
		static d_gtk_source_search_context_backward gtk_source_search_context_backward = FuncLoader.LoadFunction<d_gtk_source_search_context_backward>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GtkSource), "gtk_source_search_context_backward"));

		public bool Backward(Gtk.TextIter iter, out Gtk.TextIter match_start, out Gtk.TextIter match_end, out bool has_wrapped_around) {
			IntPtr native_iter = GLib.Marshaller.StructureToPtrAlloc (iter);
			IntPtr native_match_start = Marshal.AllocHGlobal (Marshal.SizeOf<Gtk.TextIter>());
			IntPtr native_match_end = Marshal.AllocHGlobal (Marshal.SizeOf<Gtk.TextIter>());
			bool raw_ret = gtk_source_search_context_backward(Handle, native_iter, native_match_start, native_match_end, out has_wrapped_around);
			bool ret = raw_ret;
			Marshal.FreeHGlobal (native_iter);
			match_start = Gtk.TextIter.New (native_match_start);
			Marshal.FreeHGlobal (native_match_start);
			match_end = Gtk.TextIter.New (native_match_end);
			Marshal.FreeHGlobal (native_match_end);
			return ret;
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void d_gtk_source_search_context_backward_async(IntPtr raw, IntPtr iter, IntPtr cancellable, GLibSharp.AsyncReadyCallbackNative cb, IntPtr user_data);
		static d_gtk_source_search_context_backward_async gtk_source_search_context_backward_async = FuncLoader.LoadFunction<d_gtk_source_search_context_backward_async>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GtkSource), "gtk_source_search_context_backward_async"));

		public void BackwardAsync(Gtk.TextIter iter, GLib.Cancellable cancellable, GLib.AsyncReadyCallback cb) {
			IntPtr native_iter = GLib.Marshaller.StructureToPtrAlloc (iter);
			GLibSharp.AsyncReadyCallbackWrapper cb_wrapper = new GLibSharp.AsyncReadyCallbackWrapper (cb);
			cb_wrapper.PersistUntilCalled ();
			gtk_source_search_context_backward_async(Handle, native_iter, cancellable == null ? IntPtr.Zero : cancellable.Handle, cb_wrapper.NativeDelegate, IntPtr.Zero);
			Marshal.FreeHGlobal (native_iter);
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate bool d_gtk_source_search_context_backward_finish(IntPtr raw, IntPtr result, IntPtr match_start, IntPtr match_end, out bool has_wrapped_around, out IntPtr error);
		static d_gtk_source_search_context_backward_finish gtk_source_search_context_backward_finish = FuncLoader.LoadFunction<d_gtk_source_search_context_backward_finish>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GtkSource), "gtk_source_search_context_backward_finish"));

		public unsafe bool BackwardFinish(GLib.IAsyncResult result, out Gtk.TextIter match_start, out Gtk.TextIter match_end, out bool has_wrapped_around) {
			IntPtr native_match_start = Marshal.AllocHGlobal (Marshal.SizeOf<Gtk.TextIter>());
			IntPtr native_match_end = Marshal.AllocHGlobal (Marshal.SizeOf<Gtk.TextIter>());
			IntPtr error = IntPtr.Zero;
			bool raw_ret = gtk_source_search_context_backward_finish(Handle, result == null ? IntPtr.Zero : ((result is GLib.Object) ? (result as GLib.Object).Handle : (result as GLib.AsyncResultAdapter).Handle), native_match_start, native_match_end, out has_wrapped_around, out error);
			bool ret = raw_ret;
			match_start = Gtk.TextIter.New (native_match_start);
			Marshal.FreeHGlobal (native_match_start);
			match_end = Gtk.TextIter.New (native_match_end);
			Marshal.FreeHGlobal (native_match_end);
			if (error != IntPtr.Zero) throw new GLib.GException (error);
			return ret;
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate bool d_gtk_source_search_context_forward(IntPtr raw, IntPtr iter, IntPtr match_start, IntPtr match_end, out bool has_wrapped_around);
		static d_gtk_source_search_context_forward gtk_source_search_context_forward = FuncLoader.LoadFunction<d_gtk_source_search_context_forward>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GtkSource), "gtk_source_search_context_forward"));

		public bool Forward(Gtk.TextIter iter, out Gtk.TextIter match_start, out Gtk.TextIter match_end, out bool has_wrapped_around) {
			IntPtr native_iter = GLib.Marshaller.StructureToPtrAlloc (iter);
			IntPtr native_match_start = Marshal.AllocHGlobal (Marshal.SizeOf<Gtk.TextIter>());
			IntPtr native_match_end = Marshal.AllocHGlobal (Marshal.SizeOf<Gtk.TextIter>());
			bool raw_ret = gtk_source_search_context_forward(Handle, native_iter, native_match_start, native_match_end, out has_wrapped_around);
			bool ret = raw_ret;
			Marshal.FreeHGlobal (native_iter);
			match_start = Gtk.TextIter.New (native_match_start);
			Marshal.FreeHGlobal (native_match_start);
			match_end = Gtk.TextIter.New (native_match_end);
			Marshal.FreeHGlobal (native_match_end);
			return ret;
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void d_gtk_source_search_context_forward_async(IntPtr raw, IntPtr iter, IntPtr cancellable, GLibSharp.AsyncReadyCallbackNative cb, IntPtr user_data);
		static d_gtk_source_search_context_forward_async gtk_source_search_context_forward_async = FuncLoader.LoadFunction<d_gtk_source_search_context_forward_async>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GtkSource), "gtk_source_search_context_forward_async"));

		public void ForwardAsync(Gtk.TextIter iter, GLib.Cancellable cancellable, GLib.AsyncReadyCallback cb) {
			IntPtr native_iter = GLib.Marshaller.StructureToPtrAlloc (iter);
			GLibSharp.AsyncReadyCallbackWrapper cb_wrapper = new GLibSharp.AsyncReadyCallbackWrapper (cb);
			cb_wrapper.PersistUntilCalled ();
			gtk_source_search_context_forward_async(Handle, native_iter, cancellable == null ? IntPtr.Zero : cancellable.Handle, cb_wrapper.NativeDelegate, IntPtr.Zero);
			Marshal.FreeHGlobal (native_iter);
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate bool d_gtk_source_search_context_forward_finish(IntPtr raw, IntPtr result, IntPtr match_start, IntPtr match_end, out bool has_wrapped_around, out IntPtr error);
		static d_gtk_source_search_context_forward_finish gtk_source_search_context_forward_finish = FuncLoader.LoadFunction<d_gtk_source_search_context_forward_finish>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GtkSource), "gtk_source_search_context_forward_finish"));

		public unsafe bool ForwardFinish(GLib.IAsyncResult result, out Gtk.TextIter match_start, out Gtk.TextIter match_end, out bool has_wrapped_around) {
			IntPtr native_match_start = Marshal.AllocHGlobal (Marshal.SizeOf<Gtk.TextIter>());
			IntPtr native_match_end = Marshal.AllocHGlobal (Marshal.SizeOf<Gtk.TextIter>());
			IntPtr error = IntPtr.Zero;
			bool raw_ret = gtk_source_search_context_forward_finish(Handle, result == null ? IntPtr.Zero : ((result is GLib.Object) ? (result as GLib.Object).Handle : (result as GLib.AsyncResultAdapter).Handle), native_match_start, native_match_end, out has_wrapped_around, out error);
			bool ret = raw_ret;
			match_start = Gtk.TextIter.New (native_match_start);
			Marshal.FreeHGlobal (native_match_start);
			match_end = Gtk.TextIter.New (native_match_end);
			Marshal.FreeHGlobal (native_match_end);
			if (error != IntPtr.Zero) throw new GLib.GException (error);
			return ret;
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate int d_gtk_source_search_context_get_occurrence_position(IntPtr raw, IntPtr match_start, IntPtr match_end);
		static d_gtk_source_search_context_get_occurrence_position gtk_source_search_context_get_occurrence_position = FuncLoader.LoadFunction<d_gtk_source_search_context_get_occurrence_position>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GtkSource), "gtk_source_search_context_get_occurrence_position"));

		public int GetOccurrencePosition(Gtk.TextIter match_start, Gtk.TextIter match_end) {
			IntPtr native_match_start = GLib.Marshaller.StructureToPtrAlloc (match_start);
			IntPtr native_match_end = GLib.Marshaller.StructureToPtrAlloc (match_end);
			int raw_ret = gtk_source_search_context_get_occurrence_position(Handle, native_match_start, native_match_end);
			int ret = raw_ret;
			Marshal.FreeHGlobal (native_match_start);
			Marshal.FreeHGlobal (native_match_end);
			return ret;
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr d_gtk_source_search_context_get_type();
		static d_gtk_source_search_context_get_type gtk_source_search_context_get_type = FuncLoader.LoadFunction<d_gtk_source_search_context_get_type>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GtkSource), "gtk_source_search_context_get_type"));

		public static new GLib.GType GType { 
			get {
				IntPtr raw_ret = gtk_source_search_context_get_type();
				GLib.GType ret = new GLib.GType(raw_ret);
				return ret;
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate bool d_gtk_source_search_context_replace(IntPtr raw, IntPtr match_start, IntPtr match_end, IntPtr replace, int replace_length, out IntPtr error);
		static d_gtk_source_search_context_replace gtk_source_search_context_replace = FuncLoader.LoadFunction<d_gtk_source_search_context_replace>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GtkSource), "gtk_source_search_context_replace"));

		public unsafe bool Replace(Gtk.TextIter match_start, Gtk.TextIter match_end, string replace) {
			IntPtr native_match_start = GLib.Marshaller.StructureToPtrAlloc (match_start);
			IntPtr native_match_end = GLib.Marshaller.StructureToPtrAlloc (match_end);
			IntPtr native_replace = GLib.Marshaller.StringToPtrGStrdup (replace);
			IntPtr error = IntPtr.Zero;
			bool raw_ret = gtk_source_search_context_replace(Handle, native_match_start, native_match_end, native_replace, System.Text.Encoding.UTF8.GetByteCount (replace), out error);
			bool ret = raw_ret;
			Marshal.FreeHGlobal (native_match_start);
			Marshal.FreeHGlobal (native_match_end);
			GLib.Marshaller.Free (native_replace);
			if (error != IntPtr.Zero) throw new GLib.GException (error);
			return ret;
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate uint d_gtk_source_search_context_replace_all(IntPtr raw, IntPtr replace, int replace_length, out IntPtr error);
		static d_gtk_source_search_context_replace_all gtk_source_search_context_replace_all = FuncLoader.LoadFunction<d_gtk_source_search_context_replace_all>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GtkSource), "gtk_source_search_context_replace_all"));

		public unsafe uint ReplaceAll(string replace) {
			IntPtr native_replace = GLib.Marshaller.StringToPtrGStrdup (replace);
			IntPtr error = IntPtr.Zero;
			uint raw_ret = gtk_source_search_context_replace_all(Handle, native_replace, System.Text.Encoding.UTF8.GetByteCount (replace), out error);
			uint ret = raw_ret;
			GLib.Marshaller.Free (native_replace);
			if (error != IntPtr.Zero) throw new GLib.GException (error);
			return ret;
		}


		static SearchContext ()
		{
			GtkSharp.GtkSourceSharp.ObjectManager.Initialize ();
		}

		// Internal representation of the wrapped structure ABI.
		static GLib.AbiStruct _abi_info = null;
		static public unsafe new GLib.AbiStruct abi_info {
			get {
				if (_abi_info == null)
					_abi_info = new GLib.AbiStruct (new List<GLib.AbiField>{ 
						new GLib.AbiField("priv"
							, GLib.Object.abi_info.Fields
							, (uint) sizeof( IntPtr ) // priv
							, null
							, null
							, (uint) sizeof(IntPtr)
							, 0
							),
					});

				return _abi_info;
			}
		}


		// End of the ABI representation.

#endregion
	}
}
