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

namespace GLib {

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

#region Autogenerated code
	public partial class CharsetConverter : GLib.Object, GLib.IConverter, GLib.IInitable {

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

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr d_g_charset_converter_new(IntPtr to_charset, IntPtr from_charset, out IntPtr error);
		static d_g_charset_converter_new g_charset_converter_new = FuncLoader.LoadFunction<d_g_charset_converter_new>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gio), "g_charset_converter_new"));

		public unsafe CharsetConverter (string to_charset, string from_charset) : base (IntPtr.Zero)
		{
			if (GetType () != typeof (CharsetConverter)) {
				var vals = new List<GLib.Value> ();
				var names = new List<string> ();
				names.Add ("to_charset");
				vals.Add (new GLib.Value (to_charset));
				names.Add ("from_charset");
				vals.Add (new GLib.Value (from_charset));
				CreateNativeObject (names.ToArray (), vals.ToArray ());
				return;
			}
			IntPtr native_to_charset = GLib.Marshaller.StringToPtrGStrdup (to_charset);
			IntPtr native_from_charset = GLib.Marshaller.StringToPtrGStrdup (from_charset);
			IntPtr error = IntPtr.Zero;
			Raw = g_charset_converter_new(native_to_charset, native_from_charset, out error);
			GLib.Marshaller.Free (native_to_charset);
			GLib.Marshaller.Free (native_from_charset);
			if (error != IntPtr.Zero) throw new GLib.GException (error);
		}

		[GLib.Property ("to-charset")]
		public string ToCharset {
			get {
				GLib.Value val = GetProperty ("to-charset");
				string ret = (string) val;
				val.Dispose ();
				return ret;
			}
		}

		[GLib.Property ("from-charset")]
		public string FromCharset {
			get {
				GLib.Value val = GetProperty ("from-charset");
				string ret = (string) val;
				val.Dispose ();
				return ret;
			}
		}

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

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void d_g_charset_converter_set_use_fallback(IntPtr raw, bool use_fallback);
		static d_g_charset_converter_set_use_fallback g_charset_converter_set_use_fallback = FuncLoader.LoadFunction<d_g_charset_converter_set_use_fallback>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gio), "g_charset_converter_set_use_fallback"));

		[GLib.Property ("use-fallback")]
		public bool UseFallback {
			get  {
				bool raw_ret = g_charset_converter_get_use_fallback(Handle);
				bool ret = raw_ret;
				return ret;
			}
			set  {
				g_charset_converter_set_use_fallback(Handle, value);
			}
		}


		// 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 (GLib.Object.class_abi.Fields);

				return _class_abi;
			}
		}


		// End of the ABI representation.

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate uint d_g_charset_converter_get_num_fallbacks(IntPtr raw);
		static d_g_charset_converter_get_num_fallbacks g_charset_converter_get_num_fallbacks = FuncLoader.LoadFunction<d_g_charset_converter_get_num_fallbacks>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gio), "g_charset_converter_get_num_fallbacks"));

		public uint NumFallbacks { 
			get {
				uint raw_ret = g_charset_converter_get_num_fallbacks(Handle);
				uint ret = raw_ret;
				return ret;
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr d_g_charset_converter_get_type();
		static d_g_charset_converter_get_type g_charset_converter_get_type = FuncLoader.LoadFunction<d_g_charset_converter_get_type>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gio), "g_charset_converter_get_type"));

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

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate int d_g_converter_convert(IntPtr raw, IntPtr inbuf, UIntPtr inbuf_size, IntPtr outbuf, UIntPtr outbuf_size, int flags, out UIntPtr bytes_read, out UIntPtr bytes_written, out IntPtr error);
		static d_g_converter_convert g_converter_convert = FuncLoader.LoadFunction<d_g_converter_convert>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gio), "g_converter_convert"));

		public GLib.ConverterResult Convert(IntPtr inbuf, ulong inbuf_size, IntPtr outbuf, ulong outbuf_size, GLib.ConverterFlags flags, out ulong bytes_read, out ulong bytes_written) {
			UIntPtr native_bytes_read;
			UIntPtr native_bytes_written;
			IntPtr error = IntPtr.Zero;
			int raw_ret = g_converter_convert(Handle, inbuf, new UIntPtr (inbuf_size), outbuf, new UIntPtr (outbuf_size), (int) flags, out native_bytes_read, out native_bytes_written, out error);
			GLib.ConverterResult ret = (GLib.ConverterResult) raw_ret;
			bytes_read = (ulong) native_bytes_read;
			bytes_written = (ulong) native_bytes_written;
			if (error != IntPtr.Zero) throw new GLib.GException (error);
			return ret;
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void d_g_converter_reset(IntPtr raw);
		static d_g_converter_reset g_converter_reset = FuncLoader.LoadFunction<d_g_converter_reset>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gio), "g_converter_reset"));

		public void Reset() {
			g_converter_reset(Handle);
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate bool d_g_initable_init(IntPtr raw, IntPtr cancellable, out IntPtr error);
		static d_g_initable_init g_initable_init = FuncLoader.LoadFunction<d_g_initable_init>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gio), "g_initable_init"));

		public bool Init(GLib.Cancellable cancellable) {
			IntPtr error = IntPtr.Zero;
			bool raw_ret = g_initable_init(Handle, cancellable == null ? IntPtr.Zero : cancellable.Handle, out error);
			bool ret = raw_ret;
			if (error != IntPtr.Zero) throw new GLib.GException (error);
			return ret;
		}


		// 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 (GLib.Object.abi_info.Fields);

				return _abi_info;
			}
		}


		// End of the ABI representation.

#endregion
	}
}
