------------------------------------------------------------------------------
--                                                                          --
--                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.                                      --
--                                                                          --
------------------------------------------------------------------------------
--    This file has been generated automatically. Please don't edit it.     --
------------------------------------------------------------------------------
with Qt_Ada.Internals.Boolean_Conversions;
with System.Address_To_Access_Conversions;

package body Qt4.Sql_Records is

   function initialize_QSqlRecord
    (Storage : System.Address)
      return Internals.QSqlRecord_Access;
   pragma Import (C, initialize_QSqlRecord, "__QtAda_inititialize_QSqlRecord");

   function adjust_QSqlRecord
    (Storage : System.Address;
     From    : Internals.QSqlRecord_Access)
       return Internals.QSqlRecord_Access;
   pragma Import (C, adjust_QSqlRecord, "__QtAda_adjust_QSqlRecord");

   procedure finalize_QSqlRecord (Object : Internals.QSqlRecord_Access);
   pragma Import (C, finalize_QSqlRecord, "__QtAda_finalize_QSqlRecord");

   procedure QSqlRecord_append_QSqlFieldCR
    (Self : Internals.QSqlRecord_Access;
     Field : Qt4.Sql_Fields.Internals.QSqlField_Access);
   pragma Import (C, QSqlRecord_append_QSqlFieldCR, "__QtAda_QSqlRecord_append_QSqlFieldCR");

   procedure QSqlRecord_clear
    (Self : Internals.QSqlRecord_Access);
   pragma Import (C, QSqlRecord_clear, "__QtAda_QSqlRecord_clear");

   procedure QSqlRecord_clearValues
    (Self : Internals.QSqlRecord_Access);
   pragma Import (C, QSqlRecord_clearValues, "__QtAda_QSqlRecord_clearValues");

   function QSqlRecord_contains_QStringCR
    (Self : Internals.QSqlRecord_Access;
     Name : Qt4.Strings.Internals.QString_Access)
       return Interfaces.C.unsigned;
   pragma Import (C, QSqlRecord_contains_QStringCR, "__QtAda_QSqlRecord_contains_QStringCR_Q");

   function QSqlRecord_count
    (Self : Internals.QSqlRecord_Access)
       return Qt4.Q_Integer;
   pragma Import (C, QSqlRecord_count, "__QtAda_QSqlRecord_count_Q");

   procedure QSqlRecord_field_int
    (Returns : Qt4.Sql_Fields.Internals.QSqlField_Access;
     Self : Internals.QSqlRecord_Access;
     Index : Qt4.Q_Integer);
   pragma Import (C, QSqlRecord_field_int, "__QtAda_QSqlRecord_field_int_Q");

   procedure QSqlRecord_field_QStringCR
    (Returns : Qt4.Sql_Fields.Internals.QSqlField_Access;
     Self : Internals.QSqlRecord_Access;
     Name : Qt4.Strings.Internals.QString_Access);
   pragma Import (C, QSqlRecord_field_QStringCR, "__QtAda_QSqlRecord_field_QStringCR_Q");

   procedure QSqlRecord_fieldName_int
    (Returns : Qt4.Strings.Internals.QString_Access;
     Self : Internals.QSqlRecord_Access;
     Index : Qt4.Q_Integer);
   pragma Import (C, QSqlRecord_fieldName_int, "__QtAda_QSqlRecord_fieldName_int_Q");

   function QSqlRecord_indexOf_QStringCR
    (Self : Internals.QSqlRecord_Access;
     Name : Qt4.Strings.Internals.QString_Access)
       return Qt4.Q_Integer;
   pragma Import (C, QSqlRecord_indexOf_QStringCR, "__QtAda_QSqlRecord_indexOf_QStringCR_Q");

   procedure QSqlRecord_insert_int_QSqlFieldCR
    (Self : Internals.QSqlRecord_Access;
     Pos : Qt4.Q_Integer;
     Field : Qt4.Sql_Fields.Internals.QSqlField_Access);
   pragma Import (C, QSqlRecord_insert_int_QSqlFieldCR, "__QtAda_QSqlRecord_insert_int_QSqlFieldCR");

   function QSqlRecord_isEmpty
    (Self : Internals.QSqlRecord_Access)
       return Interfaces.C.unsigned;
   pragma Import (C, QSqlRecord_isEmpty, "__QtAda_QSqlRecord_isEmpty_Q");

   function QSqlRecord_isGenerated_QStringCR
    (Self : Internals.QSqlRecord_Access;
     Name : Qt4.Strings.Internals.QString_Access)
       return Interfaces.C.unsigned;
   pragma Import (C, QSqlRecord_isGenerated_QStringCR, "__QtAda_QSqlRecord_isGenerated_QStringCR_Q");

   function QSqlRecord_isGenerated_int
    (Self : Internals.QSqlRecord_Access;
     Index : Qt4.Q_Integer)
       return Interfaces.C.unsigned;
   pragma Import (C, QSqlRecord_isGenerated_int, "__QtAda_QSqlRecord_isGenerated_int_Q");

   function QSqlRecord_isNull_QStringCR
    (Self : Internals.QSqlRecord_Access;
     Name : Qt4.Strings.Internals.QString_Access)
       return Interfaces.C.unsigned;
   pragma Import (C, QSqlRecord_isNull_QStringCR, "__QtAda_QSqlRecord_isNull_QStringCR_Q");

   function QSqlRecord_isNull_int
    (Self : Internals.QSqlRecord_Access;
     Index : Qt4.Q_Integer)
       return Interfaces.C.unsigned;
   pragma Import (C, QSqlRecord_isNull_int, "__QtAda_QSqlRecord_isNull_int_Q");

   procedure QSqlRecord_remove_int
    (Self : Internals.QSqlRecord_Access;
     Pos : Qt4.Q_Integer);
   pragma Import (C, QSqlRecord_remove_int, "__QtAda_QSqlRecord_remove_int");

   procedure QSqlRecord_replace_int_QSqlFieldCR
    (Self : Internals.QSqlRecord_Access;
     Pos : Qt4.Q_Integer;
     Field : Qt4.Sql_Fields.Internals.QSqlField_Access);
   pragma Import (C, QSqlRecord_replace_int_QSqlFieldCR, "__QtAda_QSqlRecord_replace_int_QSqlFieldCR");

   procedure QSqlRecord_setGenerated_QStringCR_bool
    (Self : Internals.QSqlRecord_Access;
     Name : Qt4.Strings.Internals.QString_Access;
     Generated : Interfaces.C.unsigned);
   pragma Import (C, QSqlRecord_setGenerated_QStringCR_bool, "__QtAda_QSqlRecord_setGenerated_QStringCR_bool");

   procedure QSqlRecord_setGenerated_int_bool
    (Self : Internals.QSqlRecord_Access;
     Index : Qt4.Q_Integer;
     Generated : Interfaces.C.unsigned);
   pragma Import (C, QSqlRecord_setGenerated_int_bool, "__QtAda_QSqlRecord_setGenerated_int_bool");

   procedure QSqlRecord_setNull_QStringCR
    (Self : Internals.QSqlRecord_Access;
     Name : Qt4.Strings.Internals.QString_Access);
   pragma Import (C, QSqlRecord_setNull_QStringCR, "__QtAda_QSqlRecord_setNull_QStringCR");

   procedure QSqlRecord_setNull_int
    (Self : Internals.QSqlRecord_Access;
     Index : Qt4.Q_Integer);
   pragma Import (C, QSqlRecord_setNull_int, "__QtAda_QSqlRecord_setNull_int");

   procedure QSqlRecord_setValue_QStringCR_QVariantCR
    (Self : Internals.QSqlRecord_Access;
     Name : Qt4.Strings.Internals.QString_Access;
     Value : Qt4.Variants.Internals.QVariant_Access);
   pragma Import (C, QSqlRecord_setValue_QStringCR_QVariantCR, "__QtAda_QSqlRecord_setValue_QStringCR_QVariantCR");

   procedure QSqlRecord_setValue_int_QVariantCR
    (Self : Internals.QSqlRecord_Access;
     Index : Qt4.Q_Integer;
     Value : Qt4.Variants.Internals.QVariant_Access);
   pragma Import (C, QSqlRecord_setValue_int_QVariantCR, "__QtAda_QSqlRecord_setValue_int_QVariantCR");

   procedure QSqlRecord_value_QStringCR
    (Returns : Qt4.Variants.Internals.QVariant_Access;
     Self : Internals.QSqlRecord_Access;
     Name : Qt4.Strings.Internals.QString_Access);
   pragma Import (C, QSqlRecord_value_QStringCR, "__QtAda_QSqlRecord_value_QStringCR_Q");

   procedure QSqlRecord_value_int
    (Returns : Qt4.Variants.Internals.QVariant_Access;
     Self : Internals.QSqlRecord_Access;
     Index : Qt4.Q_Integer);
   pragma Import (C, QSqlRecord_value_int, "__QtAda_QSqlRecord_value_int_Q");

   function eq_QSqlRecordCR
    (Self : Internals.QSqlRecord_Access;
     Other : Internals.QSqlRecord_Access)
       return Interfaces.C.unsigned;
   pragma Import (C, eq_QSqlRecordCR, "__QtAda_QSqlRecord_eq_QSqlRecordCR_Q");

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

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

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

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

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

   overriding
   procedure Initialize (Self : in out Q_Sql_Record) is
      use type Internals.QSqlRecord_Access;

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

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

   procedure Append
    (Self : in out Q_Sql_Record'Class;
     Field : Qt4.Sql_Fields.Q_Sql_Field'Class)
   is
   begin
      QSqlRecord_append_QSqlFieldCR (Self.Object, Qt4.Sql_Fields.Internals.QSqlField_View (Field));
   end Append;

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

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

   ------------------
   -- Clear_Values --
   ------------------

   procedure Clear_Values
    (Self : in out Q_Sql_Record'Class)
   is
   begin
      QSqlRecord_clearValues (Self.Object);
   end Clear_Values;

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

   function Contains
    (Self : Q_Sql_Record'Class;
     Name : Qt4.Strings.Q_String'Class)
       return Boolean
   is
   begin
      return Interfaces.C."/=" (QSqlRecord_contains_QStringCR (Self.Object, Qt4.Strings.Internals.QString_View (Name)), 0);
   end Contains;

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

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

   -----------
   -- Field --
   -----------

   function Field
    (Self : Q_Sql_Record'Class;
     Index : Qt4.Q_Integer)
       return Qt4.Sql_Fields.Q_Sql_Field
   is
   begin
      return Returns : Qt4.Sql_Fields.Q_Sql_Field do
         QSqlRecord_field_int (Qt4.Sql_Fields.Internals.QSqlField_View (Returns), Self.Object, Index);
      end return;
   end Field;

   -----------
   -- Field --
   -----------

   function Field
    (Self : Q_Sql_Record'Class;
     Name : Qt4.Strings.Q_String'Class)
       return Qt4.Sql_Fields.Q_Sql_Field
   is
   begin
      return Returns : Qt4.Sql_Fields.Q_Sql_Field do
         QSqlRecord_field_QStringCR (Qt4.Sql_Fields.Internals.QSqlField_View (Returns), Self.Object, Qt4.Strings.Internals.QString_View (Name));
      end return;
   end Field;

   ----------------
   -- Field_Name --
   ----------------

   function Field_Name
    (Self : Q_Sql_Record'Class;
     Index : Qt4.Q_Integer)
       return Qt4.Strings.Q_String
   is
   begin
      return Returns : Qt4.Strings.Q_String do
         QSqlRecord_fieldName_int (Qt4.Strings.Internals.QString_View (Returns), Self.Object, Index);
      end return;
   end Field_Name;

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

   function Index_Of
    (Self : Q_Sql_Record'Class;
     Name : Qt4.Strings.Q_String'Class)
       return Qt4.Q_Integer
   is
   begin
      return QSqlRecord_indexOf_QStringCR (Self.Object, Qt4.Strings.Internals.QString_View (Name));
   end Index_Of;

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

   procedure Insert
    (Self : in out Q_Sql_Record'Class;
     Pos : Qt4.Q_Integer;
     Field : Qt4.Sql_Fields.Q_Sql_Field'Class)
   is
   begin
      QSqlRecord_insert_int_QSqlFieldCR (Self.Object, Pos, Qt4.Sql_Fields.Internals.QSqlField_View (Field));
   end Insert;

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

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

   ------------------
   -- Is_Generated --
   ------------------

   function Is_Generated
    (Self : Q_Sql_Record'Class;
     Name : Qt4.Strings.Q_String'Class)
       return Boolean
   is
   begin
      return Interfaces.C."/=" (QSqlRecord_isGenerated_QStringCR (Self.Object, Qt4.Strings.Internals.QString_View (Name)), 0);
   end Is_Generated;

   ------------------
   -- Is_Generated --
   ------------------

   function Is_Generated
    (Self : Q_Sql_Record'Class;
     Index : Qt4.Q_Integer)
       return Boolean
   is
   begin
      return Interfaces.C."/=" (QSqlRecord_isGenerated_int (Self.Object, Index), 0);
   end Is_Generated;

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

   function Is_Null
    (Self : Q_Sql_Record'Class;
     Name : Qt4.Strings.Q_String'Class)
       return Boolean
   is
   begin
      return Interfaces.C."/=" (QSqlRecord_isNull_QStringCR (Self.Object, Qt4.Strings.Internals.QString_View (Name)), 0);
   end Is_Null;

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

   function Is_Null
    (Self : Q_Sql_Record'Class;
     Index : Qt4.Q_Integer)
       return Boolean
   is
   begin
      return Interfaces.C."/=" (QSqlRecord_isNull_int (Self.Object, Index), 0);
   end Is_Null;

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

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

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

   procedure Replace
    (Self : in out Q_Sql_Record'Class;
     Pos : Qt4.Q_Integer;
     Field : Qt4.Sql_Fields.Q_Sql_Field'Class)
   is
   begin
      QSqlRecord_replace_int_QSqlFieldCR (Self.Object, Pos, Qt4.Sql_Fields.Internals.QSqlField_View (Field));
   end Replace;

   -------------------
   -- Set_Generated --
   -------------------

   procedure Set_Generated
    (Self : in out Q_Sql_Record'Class;
     Name : Qt4.Strings.Q_String'Class;
     Generated : Boolean)
   is
   begin
      QSqlRecord_setGenerated_QStringCR_bool (Self.Object, Qt4.Strings.Internals.QString_View (Name), Qt_Ada.Internals.Boolean_Conversions.To_unsigned (Generated));
   end Set_Generated;

   -------------------
   -- Set_Generated --
   -------------------

   procedure Set_Generated
    (Self : in out Q_Sql_Record'Class;
     Index : Qt4.Q_Integer;
     Generated : Boolean)
   is
   begin
      QSqlRecord_setGenerated_int_bool (Self.Object, Index, Qt_Ada.Internals.Boolean_Conversions.To_unsigned (Generated));
   end Set_Generated;

   --------------
   -- Set_Null --
   --------------

   procedure Set_Null
    (Self : in out Q_Sql_Record'Class;
     Name : Qt4.Strings.Q_String'Class)
   is
   begin
      QSqlRecord_setNull_QStringCR (Self.Object, Qt4.Strings.Internals.QString_View (Name));
   end Set_Null;

   --------------
   -- Set_Null --
   --------------

   procedure Set_Null
    (Self : in out Q_Sql_Record'Class;
     Index : Qt4.Q_Integer)
   is
   begin
      QSqlRecord_setNull_int (Self.Object, Index);
   end Set_Null;

   ---------------
   -- Set_Value --
   ---------------

   procedure Set_Value
    (Self : in out Q_Sql_Record'Class;
     Name : Qt4.Strings.Q_String'Class;
     Value : Qt4.Variants.Q_Variant'Class)
   is
   begin
      QSqlRecord_setValue_QStringCR_QVariantCR (Self.Object, Qt4.Strings.Internals.QString_View (Name), Qt4.Variants.Internals.QVariant_View (Value));
   end Set_Value;

   ---------------
   -- Set_Value --
   ---------------

   procedure Set_Value
    (Self : in out Q_Sql_Record'Class;
     Index : Qt4.Q_Integer;
     Value : Qt4.Variants.Q_Variant'Class)
   is
   begin
      QSqlRecord_setValue_int_QVariantCR (Self.Object, Index, Qt4.Variants.Internals.QVariant_View (Value));
   end Set_Value;

   -----------
   -- Value --
   -----------

   function Value
    (Self : Q_Sql_Record'Class;
     Name : Qt4.Strings.Q_String'Class)
       return Qt4.Variants.Q_Variant
   is
   begin
      return Returns : Qt4.Variants.Q_Variant do
         QSqlRecord_value_QStringCR (Qt4.Variants.Internals.QVariant_View (Returns), Self.Object, Qt4.Strings.Internals.QString_View (Name));
      end return;
   end Value;

   -----------
   -- Value --
   -----------

   function Value
    (Self : Q_Sql_Record'Class;
     Index : Qt4.Q_Integer)
       return Qt4.Variants.Q_Variant
   is
   begin
      return Returns : Qt4.Variants.Q_Variant do
         QSqlRecord_value_int (Qt4.Variants.Internals.QVariant_View (Returns), Self.Object, Index);
      end return;
   end Value;

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

   overriding function "="
    (Self : Q_Sql_Record;
     Other : Q_Sql_Record)
       return Boolean
   is
   begin
      return Interfaces.C."/=" (eq_QSqlRecordCR (Self.Object, Other.Object), 0);
   end "=";

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

   package body Internals is

   ---------------------
   -- QSqlRecord_View --
   ---------------------

      function QSqlRecord_View
       (Item : Q_Sql_Record'Class)
          return QSqlRecord_Access
      is
      begin
         return Item.Object;
      end QSqlRecord_View;

      package QSqlRecord_Conversions is
        new System.Address_To_Access_Conversions
             (QSqlRecord);

   --------------------------
   -- QSqlRecordTo_Pointer --
   --------------------------

      function To_Pointer
       (Address : System.Address)
          return QSqlRecord_Access
      is
      begin
         return
           QSqlRecord_Access
            (QSqlRecord_Conversions.To_Pointer
            (Address));
      end To_Pointer;

   --------------------------
   -- QSqlRecordTo_Address --
   --------------------------

      function To_Address
       (Pointer : QSqlRecord_Access)
          return System.Address
      is
      begin
         return
           QSqlRecord_Conversions.To_Address
            (QSqlRecord_Conversions.Object_Pointer
              (Pointer));
      end To_Address;

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

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

   end Internals;

end Qt4.Sql_Records;
