------------------------------------------------------------------------------
--                                                                          --
--                An Ada2005 binding to the Qt C++ framework                --
--                                                                          --
------------------------------------------------------------------------------
--                                                                          --
-- Copyright © 2009, 2010 Vadim Godunko <vgodunko@gmail.com>                --
--                                                                          --
-- QtAda is free software;  you can  redistribute it and/or modify it under --
-- terms of the  GNU General Public License as published  by the Free Soft- --
-- ware  Foundation;  either version 2,  or (at your option) any later ver- --
-- sion. QtAda is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
-- for  more details.  You should have  received  a copy of the GNU General --
-- Public License distributed with QtAda;  see file COPYING.  If not, write --
-- to  the  Free Software Foundation,  51  Franklin  Street,  Fifth  Floor, --
-- Boston, MA 02110-1301, USA.                                              --
--                                                                          --
-- As a special exception,  if other files  instantiate  generics from this --
-- unit, or you link  this unit with other files  to produce an executable, --
-- this  unit  does not  by itself cause  the resulting  executable  to  be --
-- covered  by the  GNU  General  Public  License.  This exception does not --
-- however invalidate  any other reasons why  the executable file  might be --
-- covered by the  GNU Public License.                                      --
--                                                                          --
------------------------------------------------------------------------------
--  $Revision: 3769 $ $Date: 2010-10-24 03:16:28 +0400 (Sun, 24 Oct 2010) $
------------------------------------------------------------------------------
with Ada.Unchecked_Conversion;
with System.Address_To_Access_Conversions;

package body Qt4.Byte_Arrays is

   function initialize_QByteArray
    (Storage : System.Address)
      return Internals.QByteArray_Access;
   pragma Import (C, initialize_QByteArray, "__QtAda_inititialize_QByteArray");

   function adjust_QByteArray
    (Storage : System.Address;
     From    : Internals.QByteArray_Access)
       return Internals.QByteArray_Access;
   pragma Import (C, adjust_QByteArray, "__QtAda_adjust_QByteArray");

   procedure finalize_QByteArray (Object : Internals.QByteArray_Access);
   pragma Import (C, finalize_QByteArray, "__QtAda_finalize_QByteArray");

   procedure QByteArray_append_QByteArrayCR
    (Self : Internals.QByteArray_Access;
     Ba : Internals.QByteArray_Access);
   pragma Import (C, QByteArray_append_QByteArrayCR, "__QtAda_QByteArray_append_QByteArrayCR");

   function QByteArray_at_int
    (Self : Internals.QByteArray_Access;
     N : Qt4.Q_Integer)
       return Interfaces.C.char;
   pragma Import (C, QByteArray_at_int, "__QtAda_QByteArray_at_int_Q");

   function QByteArray_capacity
    (Self : Internals.QByteArray_Access)
       return Qt4.Q_Integer;
   pragma Import (C, QByteArray_capacity, "__QtAda_QByteArray_capacity_Q");

   procedure QByteArray_chop_int
    (Self : Internals.QByteArray_Access;
     N : Qt4.Q_Integer);
   pragma Import (C, QByteArray_chop_int, "__QtAda_QByteArray_chop_int");

   procedure QByteArray_clear
    (Self : Internals.QByteArray_Access);
   pragma Import (C, QByteArray_clear, "__QtAda_QByteArray_clear");

   function QByteArray_contains_QByteArrayCR
    (Self : Internals.QByteArray_Access;
     Ba : Internals.QByteArray_Access)
       return Interfaces.C.unsigned;
   pragma Import (C, QByteArray_contains_QByteArrayCR, "__QtAda_QByteArray_contains_QByteArrayCR_Q");

   function QByteArray_count_QByteArrayCR
    (Self : Internals.QByteArray_Access;
     Ba : Internals.QByteArray_Access)
       return Qt4.Q_Integer;
   pragma Import (C, QByteArray_count_QByteArrayCR, "__QtAda_QByteArray_count_QByteArrayCR_Q");

   function QByteArray_count
    (Self : Internals.QByteArray_Access)
       return Qt4.Q_Integer;
   pragma Import (C, QByteArray_count, "__QtAda_QByteArray_count_Q");

   function QByteArray_endsWith_QByteArrayCR
    (Self : Internals.QByteArray_Access;
     Ba : Internals.QByteArray_Access)
       return Interfaces.C.unsigned;
   pragma Import (C, QByteArray_endsWith_QByteArrayCR, "__QtAda_QByteArray_endsWith_QByteArrayCR_Q");

   function QByteArray_indexOf_QByteArrayCR_int
    (Self : Internals.QByteArray_Access;
     Ba : Internals.QByteArray_Access;
     From : Qt4.Q_Integer)
       return Qt4.Q_Integer;
   pragma Import (C, QByteArray_indexOf_QByteArrayCR_int, "__QtAda_QByteArray_indexOf_QByteArrayCR_int_Q");

   procedure QByteArray_insert_int_QByteArrayCR
    (Self : Internals.QByteArray_Access;
     Index : Qt4.Q_Integer;
     Ba : Internals.QByteArray_Access);
   pragma Import (C, QByteArray_insert_int_QByteArrayCR, "__QtAda_QByteArray_insert_int_QByteArrayCR");

   function QByteArray_isEmpty
    (Self : Internals.QByteArray_Access)
       return Interfaces.C.unsigned;
   pragma Import (C, QByteArray_isEmpty, "__QtAda_QByteArray_isEmpty_Q");

   function QByteArray_isNull
    (Self : Internals.QByteArray_Access)
       return Interfaces.C.unsigned;
   pragma Import (C, QByteArray_isNull, "__QtAda_QByteArray_isNull_Q");

   function QByteArray_lastIndexOf_QByteArrayCR_int
    (Self : Internals.QByteArray_Access;
     Ba : Internals.QByteArray_Access;
     From : Qt4.Q_Integer)
       return Qt4.Q_Integer;
   pragma Import (C, QByteArray_lastIndexOf_QByteArrayCR_int, "__QtAda_QByteArray_lastIndexOf_QByteArrayCR_int_Q");

   procedure QByteArray_left_int
    (Returns : Internals.QByteArray_Access;
     Self : Internals.QByteArray_Access;
     Length : Qt4.Q_Integer);
   pragma Import (C, QByteArray_left_int, "__QtAda_QByteArray_left_int_Q");

   function QByteArray_length
    (Self : Internals.QByteArray_Access)
       return Qt4.Q_Integer;
   pragma Import (C, QByteArray_length, "__QtAda_QByteArray_length_Q");

   procedure QByteArray_mid_int_int
    (Returns : Internals.QByteArray_Access;
     Self : Internals.QByteArray_Access;
     Pos : Qt4.Q_Integer;
     Length : Qt4.Q_Integer);
   pragma Import (C, QByteArray_mid_int_int, "__QtAda_QByteArray_mid_int_int_Q");

   procedure QByteArray_prepend_QByteArrayCR
    (Self : Internals.QByteArray_Access;
     Ba : Internals.QByteArray_Access);
   pragma Import (C, QByteArray_prepend_QByteArrayCR, "__QtAda_QByteArray_prepend_QByteArrayCR");

   procedure QByteArray_remove_int_int
    (Self : Internals.QByteArray_Access;
     Pos : Qt4.Q_Integer;
     Len : Qt4.Q_Integer);
   pragma Import (C, QByteArray_remove_int_int, "__QtAda_QByteArray_remove_int_int");

   procedure QByteArray_repeated_int
    (Returns : Internals.QByteArray_Access;
     Self : Internals.QByteArray_Access;
     Times : Qt4.Q_Integer);
   pragma Import (C, QByteArray_repeated_int, "__QtAda_QByteArray_repeated_int_Q");

   procedure QByteArray_replace_int_int_QByteArrayCR
    (Self : Internals.QByteArray_Access;
     Pos : Qt4.Q_Integer;
     Len : Qt4.Q_Integer;
     After : Internals.QByteArray_Access);
   pragma Import (C, QByteArray_replace_int_int_QByteArrayCR, "__QtAda_QByteArray_replace_int_int_QByteArrayCR");

   procedure QByteArray_replace_QByteArrayCR_QByteArrayCR
    (Self : Internals.QByteArray_Access;
     Before : Internals.QByteArray_Access;
     After : Internals.QByteArray_Access);
   pragma Import (C, QByteArray_replace_QByteArrayCR_QByteArrayCR, "__QtAda_QByteArray_replace_QByteArrayCR_QByteArrayCR");

   procedure QByteArray_reserve_int
    (Self : Internals.QByteArray_Access;
     Size : Qt4.Q_Integer);
   pragma Import (C, QByteArray_reserve_int, "__QtAda_QByteArray_reserve_int");

   procedure QByteArray_resize_int
    (Self : Internals.QByteArray_Access;
     Size : Qt4.Q_Integer);
   pragma Import (C, QByteArray_resize_int, "__QtAda_QByteArray_resize_int");

   procedure QByteArray_right_int
    (Returns : Internals.QByteArray_Access;
     Self : Internals.QByteArray_Access;
     Length : Qt4.Q_Integer);
   pragma Import (C, QByteArray_right_int, "__QtAda_QByteArray_right_int_Q");

   procedure QByteArray_simplified
    (Returns : Internals.QByteArray_Access;
     Self : Internals.QByteArray_Access);
   pragma Import (C, QByteArray_simplified, "__QtAda_QByteArray_simplified_Q");

   function QByteArray_size
    (Self : Internals.QByteArray_Access)
       return Qt4.Q_Integer;
   pragma Import (C, QByteArray_size, "__QtAda_QByteArray_size_Q");

   procedure QByteArray_squeeze
    (Self : Internals.QByteArray_Access);
   pragma Import (C, QByteArray_squeeze, "__QtAda_QByteArray_squeeze");

   function QByteArray_startsWith_QByteArrayCR
    (Self : Internals.QByteArray_Access;
     Ba : Internals.QByteArray_Access)
       return Interfaces.C.unsigned;
   pragma Import (C, QByteArray_startsWith_QByteArrayCR, "__QtAda_QByteArray_startsWith_QByteArrayCR_Q");

   procedure QByteArray_toBase64
    (Returns : Internals.QByteArray_Access;
     Self : Internals.QByteArray_Access);
   pragma Import (C, QByteArray_toBase64, "__QtAda_QByteArray_toBase64_Q");

   procedure QByteArray_toHex
    (Returns : Internals.QByteArray_Access;
     Self : Internals.QByteArray_Access);
   pragma Import (C, QByteArray_toHex, "__QtAda_QByteArray_toHex_Q");

   procedure QByteArray_trimmed
    (Self : Internals.QByteArray_Access);
   pragma Import (C, QByteArray_trimmed, "__QtAda_QByteArray_trimmed");

   procedure QByteArray_truncate_int
    (Self : Internals.QByteArray_Access;
     Pos : Qt4.Q_Integer);
   pragma Import (C, QByteArray_truncate_int, "__QtAda_QByteArray_truncate_int");

   procedure QByteArray_fromBase64_QByteArrayCR
    (Returns : Internals.QByteArray_Access;
     Base_64 : Internals.QByteArray_Access);
   pragma Import (C, QByteArray_fromBase64_QByteArrayCR, "__QtAda_QByteArray_fromBase64_QByteArrayCR_S");

   procedure QByteArray_fromHex_QByteArrayCR
    (Returns : Internals.QByteArray_Access;
     Hex_Encoded : Internals.QByteArray_Access);
   pragma Import (C, QByteArray_fromHex_QByteArrayCR, "__QtAda_QByteArray_fromHex_QByteArrayCR_S");

   function eq_QByteArrayCR
    (Self : Internals.QByteArray_Access;
     S : Internals.QByteArray_Access)
       return Interfaces.C.unsigned;
   pragma Import (C, eq_QByteArrayCR, "__QtAda_QByteArray_eq_QByteArrayCR_Q");

   function lt_QByteArrayCR
    (Self : Internals.QByteArray_Access;
     S : Internals.QByteArray_Access)
       return Interfaces.C.unsigned;
   pragma Import (C, lt_QByteArrayCR, "__QtAda_QByteArray_lt_QByteArrayCR_Q");

   function gt_QByteArrayCR
    (Self : Internals.QByteArray_Access;
     S : Internals.QByteArray_Access)
       return Interfaces.C.unsigned;
   pragma Import (C, gt_QByteArrayCR, "__QtAda_QByteArray_gt_QByteArrayCR_Q");

   function le_QByteArrayCR
    (Self : Internals.QByteArray_Access;
     S : Internals.QByteArray_Access)
       return Interfaces.C.unsigned;
   pragma Import (C, le_QByteArrayCR, "__QtAda_QByteArray_le_QByteArrayCR_Q");

   function ge_QByteArrayCR
    (Self : Internals.QByteArray_Access;
     S : Internals.QByteArray_Access)
       return Interfaces.C.unsigned;
   pragma Import (C, ge_QByteArrayCR, "__QtAda_QByteArray_ge_QByteArrayCR_Q");

   ------------
   -- Adjust --
   ------------

   overriding
   procedure Adjust (Self : in out Q_Byte_Array) is
   begin
      Self.Object := adjust_QByteArray (Self.Storage'Address, Self.Object);
      Self.Wrapper := False;
   end Adjust;

   --------------
   -- Finalize --
   --------------

   overriding
   procedure Finalize (Self : in out Q_Byte_Array) is
   begin
      if not Self.Wrapper then
         finalize_QByteArray (Self.Object);
      end if;
   end Finalize;

   ----------------
   -- Initialize --
   ----------------

   overriding
   procedure Initialize (Self : in out Q_Byte_Array) is
      use type Internals.QByteArray_Access;

   begin
      if Self.Object = null then
         Self.Object := initialize_QByteArray (Self.Storage'Address);
      end if;
   end Initialize;

   ------------
   -- Append --
   ------------

   procedure Append
    (Self : in out Q_Byte_Array'Class;
     Ba : Q_Byte_Array'Class)
   is
   begin
      QByteArray_append_QByteArrayCR (Self.Object, Ba.Object);
   end Append;

   ----------------
   -- Element_At --
   ----------------

   function Element_At
    (Self : Q_Byte_Array'Class;
     I : Qt4.Q_Integer)
       return System.Storage_Elements.Storage_Element
   is
      function To_Storage_Element is
        new Ada.Unchecked_Conversion
             (Interfaces.C.char, System.Storage_Elements.Storage_Element);

   begin
      return To_Storage_Element (QByteArray_at_int (Self.Object, I));
   end Element_At;

   ------------
   -- Create --
   ------------

   function Create
     return Q_Byte_Array
   is
   begin
      return Self : Q_Byte_Array
        := Q_Byte_Array'(Ada.Finalization.Controlled with others => <>)
      do
         Self.Object := initialize_QByteArray (Self.Storage'Address);
      end return;
   end Create;

   --------------
   -- Capacity --
   --------------

   function Capacity
    (Self : Q_Byte_Array'Class)
       return Qt4.Q_Integer
   is
   begin
      return QByteArray_capacity (Self.Object);
   end Capacity;

   ----------
   -- Chop --
   ----------

   procedure Chop
    (Self : in out Q_Byte_Array'Class;
     N : Qt4.Q_Integer)
   is
   begin
      QByteArray_chop_int (Self.Object, N);
   end Chop;

   -----------
   -- Clear --
   -----------

   procedure Clear
    (Self : in out Q_Byte_Array'Class)
   is
   begin
      QByteArray_clear (Self.Object);
   end Clear;

   --------------
   -- Contains --
   --------------

   function Contains
    (Self : Q_Byte_Array'Class;
     Ba : Q_Byte_Array'Class)
       return Boolean
   is
   begin
      return Interfaces.C."/=" (QByteArray_contains_QByteArrayCR (Self.Object, Ba.Object), 0);
   end Contains;

   -----------
   -- Count --
   -----------

   function Count
    (Self : Q_Byte_Array'Class;
     Ba : Q_Byte_Array'Class)
       return Qt4.Q_Integer
   is
   begin
      return QByteArray_count_QByteArrayCR (Self.Object, Ba.Object);
   end Count;

   -----------
   -- Count --
   -----------

   function Count
    (Self : Q_Byte_Array'Class)
       return Qt4.Q_Integer
   is
   begin
      return QByteArray_count (Self.Object);
   end Count;

   ---------------
   -- Ends_With --
   ---------------

   function Ends_With
    (Self : Q_Byte_Array'Class;
     Ba : Q_Byte_Array'Class)
       return Boolean
   is
   begin
      return Interfaces.C."/=" (QByteArray_endsWith_QByteArrayCR (Self.Object, Ba.Object), 0);
   end Ends_With;

   --------------
   -- Index_Of --
   --------------

   function Index_Of
    (Self : Q_Byte_Array'Class;
     Ba : Q_Byte_Array'Class;
     From : Qt4.Q_Integer
       := 0)
       return Qt4.Q_Integer
   is
   begin
      return QByteArray_indexOf_QByteArrayCR_int (Self.Object, Ba.Object, From);
   end Index_Of;

   ------------
   -- Insert --
   ------------

   procedure Insert
    (Self : in out Q_Byte_Array'Class;
     Index : Qt4.Q_Integer;
     Ba : Q_Byte_Array'Class)
   is
   begin
      QByteArray_insert_int_QByteArrayCR (Self.Object, Index, Ba.Object);
   end Insert;

   --------------
   -- Is_Empty --
   --------------

   function Is_Empty
    (Self : Q_Byte_Array'Class)
       return Boolean
   is
   begin
      return Interfaces.C."/=" (QByteArray_isEmpty (Self.Object), 0);
   end Is_Empty;

   -------------
   -- Is_Null --
   -------------

   function Is_Null
    (Self : Q_Byte_Array'Class)
       return Boolean
   is
   begin
      return Interfaces.C."/=" (QByteArray_isNull (Self.Object), 0);
   end Is_Null;

   -------------------
   -- Last_Index_Of --
   -------------------

   function Last_Index_Of
    (Self : Q_Byte_Array'Class;
     Ba : Q_Byte_Array'Class;
     From : Qt4.Q_Integer
       := -1)
       return Qt4.Q_Integer
   is
   begin
      return QByteArray_lastIndexOf_QByteArrayCR_int (Self.Object, Ba.Object, From);
   end Last_Index_Of;

   ----------
   -- Left --
   ----------

   function Left
    (Self : Q_Byte_Array'Class;
     Length : Qt4.Q_Integer)
       return Q_Byte_Array
   is
   begin
      return Returns : Q_Byte_Array do
         QByteArray_left_int (Returns.Object, Self.Object, Length);
      end return;
   end Left;

   ------------
   -- Length --
   ------------

   function Length
    (Self : Q_Byte_Array'Class)
       return Qt4.Q_Integer
   is
   begin
      return QByteArray_length (Self.Object);
   end Length;

   ---------
   -- Mid --
   ---------

   function Mid
    (Self : Q_Byte_Array'Class;
     Pos : Qt4.Q_Integer;
     Length : Qt4.Q_Integer
       := -1)
       return Q_Byte_Array
   is
   begin
      return Returns : Q_Byte_Array do
         QByteArray_mid_int_int (Returns.Object, Self.Object, Pos, Length);
      end return;
   end Mid;

   -------------
   -- Prepend --
   -------------

   procedure Prepend
    (Self : in out Q_Byte_Array'Class;
     Ba : Q_Byte_Array'Class)
   is
   begin
      QByteArray_prepend_QByteArrayCR (Self.Object, Ba.Object);
   end Prepend;

   ------------
   -- Remove --
   ------------

   procedure Remove
    (Self : in out Q_Byte_Array'Class;
     Pos : Qt4.Q_Integer;
     Len : Qt4.Q_Integer)
   is
   begin
      QByteArray_remove_int_int (Self.Object, Pos, Len);
   end Remove;

   --------------
   -- Repeated --
   --------------

   function Repeated
    (Self : Q_Byte_Array'Class;
     Times : Qt4.Q_Integer)
       return Q_Byte_Array
   is
   begin
      return Returns : Q_Byte_Array do
         QByteArray_repeated_int (Returns.Object, Self.Object, Times);
      end return;
   end Repeated;

   -------------
   -- Replace --
   -------------

   procedure Replace
    (Self : in out Q_Byte_Array'Class;
     Pos : Qt4.Q_Integer;
     Len : Qt4.Q_Integer;
     After : Q_Byte_Array'Class)
   is
   begin
      QByteArray_replace_int_int_QByteArrayCR (Self.Object, Pos, Len, After.Object);
   end Replace;

   -------------
   -- Replace --
   -------------

   procedure Replace
    (Self : in out Q_Byte_Array'Class;
     Before : Q_Byte_Array'Class;
     After : Q_Byte_Array'Class)
   is
   begin
      QByteArray_replace_QByteArrayCR_QByteArrayCR (Self.Object, Before.Object, After.Object);
   end Replace;

   -------------
   -- Reserve --
   -------------

   procedure Reserve
    (Self : in out Q_Byte_Array'Class;
     Size : Qt4.Q_Integer)
   is
   begin
      QByteArray_reserve_int (Self.Object, Size);
   end Reserve;

   ------------
   -- Resize --
   ------------

   procedure Resize
    (Self : in out Q_Byte_Array'Class;
     Size : Qt4.Q_Integer)
   is
   begin
      QByteArray_resize_int (Self.Object, Size);
   end Resize;

   -----------
   -- Right --
   -----------

   function Right
    (Self : Q_Byte_Array'Class;
     Length : Qt4.Q_Integer)
       return Q_Byte_Array
   is
   begin
      return Returns : Q_Byte_Array do
         QByteArray_right_int (Returns.Object, Self.Object, Length);
      end return;
   end Right;

   ----------------
   -- Simplified --
   ----------------

   function Simplified
    (Self : Q_Byte_Array'Class)
       return Q_Byte_Array
   is
   begin
      return Returns : Q_Byte_Array do
         QByteArray_simplified (Returns.Object, Self.Object);
      end return;
   end Simplified;

   ----------
   -- Size --
   ----------

   function Size
    (Self : Q_Byte_Array'Class)
       return Qt4.Q_Integer
   is
   begin
      return QByteArray_size (Self.Object);
   end Size;

   -------------
   -- Squeeze --
   -------------

   procedure Squeeze
    (Self : in out Q_Byte_Array'Class)
   is
   begin
      QByteArray_squeeze (Self.Object);
   end Squeeze;

   -----------------
   -- Starts_With --
   -----------------

   function Starts_With
    (Self : Q_Byte_Array'Class;
     Ba : Q_Byte_Array'Class)
       return Boolean
   is
   begin
      return Interfaces.C."/=" (QByteArray_startsWith_QByteArrayCR (Self.Object, Ba.Object), 0);
   end Starts_With;

   ----------------
   -- To_Base_64 --
   ----------------

   function To_Base_64
    (Self : Q_Byte_Array'Class)
       return Q_Byte_Array
   is
   begin
      return Returns : Q_Byte_Array do
         QByteArray_toBase64 (Returns.Object, Self.Object);
      end return;
   end To_Base_64;

   ------------
   -- To_Hex --
   ------------

   function To_Hex
    (Self : Q_Byte_Array'Class)
       return Q_Byte_Array
   is
   begin
      return Returns : Q_Byte_Array do
         QByteArray_toHex (Returns.Object, Self.Object);
      end return;
   end To_Hex;

   -------------
   -- Trimmed --
   -------------

   procedure Trimmed
    (Self : in out Q_Byte_Array'Class)
   is
   begin
      QByteArray_trimmed (Self.Object);
   end Trimmed;

   --------------
   -- Truncate --
   --------------

   procedure Truncate
    (Self : in out Q_Byte_Array'Class;
     Pos : Qt4.Q_Integer)
   is
   begin
      QByteArray_truncate_int (Self.Object, Pos);
   end Truncate;

   ------------------
   -- From_Base_64 --
   ------------------

   function From_Base_64
    (Base_64 : Q_Byte_Array'Class)
       return Q_Byte_Array
   is
   begin
      return Returns : Q_Byte_Array do
         QByteArray_fromBase64_QByteArrayCR (Returns.Object, Base_64.Object);
      end return;
   end From_Base_64;

   --------------
   -- From_Hex --
   --------------

   function From_Hex
    (Hex_Encoded : Q_Byte_Array'Class)
       return Q_Byte_Array
   is
   begin
      return Returns : Q_Byte_Array do
         QByteArray_fromHex_QByteArrayCR (Returns.Object, Hex_Encoded.Object);
      end return;
   end From_Hex;

   ---------
   -- "=" --
   ---------

   overriding
   function "="
    (Self : Q_Byte_Array;
     S : Q_Byte_Array)
       return Boolean
   is
   begin
      return Interfaces.C."/=" (eq_QByteArrayCR (Self.Object, S.Object), 0);
   end "=";

   ---------
   -- "<" --
   ---------

   function "<"
    (Self : Q_Byte_Array;
     S : Q_Byte_Array)
       return Boolean
   is
   begin
      return Interfaces.C."/=" (lt_QByteArrayCR (Self.Object, S.Object), 0);
   end "<";

   ---------
   -- ">" --
   ---------

   function ">"
    (Self : Q_Byte_Array;
     S : Q_Byte_Array)
       return Boolean
   is
   begin
      return Interfaces.C."/=" (gt_QByteArrayCR (Self.Object, S.Object), 0);
   end ">";

   ----------
   -- "<=" --
   ----------

   function "<="
    (Self : Q_Byte_Array;
     S : Q_Byte_Array)
       return Boolean
   is
   begin
      return Interfaces.C."/=" (le_QByteArrayCR (Self.Object, S.Object), 0);
   end "<=";

   ----------
   -- ">=" --
   ----------

   function ">="
    (Self : Q_Byte_Array;
     S : Q_Byte_Array)
       return Boolean
   is
   begin
      return Interfaces.C."/=" (ge_QByteArrayCR (Self.Object, S.Object), 0);
   end ">=";

   ---------------
   -- Internals --
   ---------------

   package body Internals is

   ---------------------
   -- QByteArray_View --
   ---------------------

      function QByteArray_View
       (Item : Q_Byte_Array'Class)
          return QByteArray_Access
      is
      begin
         return Item.Object;
      end QByteArray_View;

      package QByteArray_Conversions is
        new System.Address_To_Access_Conversions
             (QByteArray);

   --------------------------
   -- QByteArrayTo_Pointer --
   --------------------------

      function To_Pointer
       (Address : System.Address)
          return QByteArray_Access
      is
      begin
         return
           QByteArray_Access
            (QByteArray_Conversions.To_Pointer
            (Address));
      end To_Pointer;

   --------------------------
   -- QByteArrayTo_Address --
   --------------------------

      function To_Address
       (Pointer : QByteArray_Access)
          return System.Address
      is
      begin
         return
           QByteArray_Conversions.To_Address
            (QByteArray_Conversions.Object_Pointer
              (Pointer));
      end To_Address;

   --------------------
   -- Create_Wrapper --
   --------------------

      function Create_Wrapper
       (Item : Internals.QByteArray_Access)
          return Q_Byte_Array
      is
      begin
         return Q_Byte_Array'
          (Ada.Finalization.Controlled with
             Object  => Item,
             Wrapper => True,
             others  => <>);
      end Create_Wrapper;

   end Internals;

end Qt4.Byte_Arrays;
