------------------------------------------------------------------------------
--                                                                          --
--                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.     --
------------------------------------------------------------------------------
private with Ada.Finalization;
with Interfaces.C;
with Qt4.Strings;
private with Qt_Ada.Internals.Value_Class_Sizes;
with System;

package Qt4.Sql_Errors is

   --  QSqlError::ErrorType

   type Sql_Error_Type is
    (No_Error,
     Connection_Error,
     Statement_Error,
     Transaction_Error,
     Unknown_Error);
   pragma Convention (C, Sql_Error_Type);
   for Sql_Error_Type'Size use Interfaces.C.unsigned'Size;

   type Q_Sql_Error is tagged private;

   function Create
    (Driver_Text : Qt4.Strings.Q_String'Class
       := Qt4.Strings.Create;
     Database_Text : Qt4.Strings.Q_String'Class
       := Qt4.Strings.Create;
     The_Type : Sql_Error_Type
       := No_Error;
     Number : Qt4.Q_Integer
       := -1)
       return Q_Sql_Error;

   function Database_Text
    (Self : Q_Sql_Error'Class)
       return Qt4.Strings.Q_String;

   function Driver_Text
    (Self : Q_Sql_Error'Class)
       return Qt4.Strings.Q_String;

   function Is_Valid
    (Self : Q_Sql_Error'Class)
       return Boolean;

   function Number
    (Self : Q_Sql_Error'Class)
       return Qt4.Q_Integer;

   procedure Set_Database_Text
    (Self : in out Q_Sql_Error'Class;
     Database_Text : Qt4.Strings.Q_String'Class);

   procedure Set_Driver_Text
    (Self : in out Q_Sql_Error'Class;
     Driver_Text : Qt4.Strings.Q_String'Class);

   procedure Set_Number
    (Self : in out Q_Sql_Error'Class;
     Number : Qt4.Q_Integer);

   procedure Set_Type
    (Self : in out Q_Sql_Error'Class;
     The_Type : Sql_Error_Type);

   function Text
    (Self : Q_Sql_Error'Class)
       return Qt4.Strings.Q_String;

   function Error_Type
    (Self : Q_Sql_Error'Class)
       return Sql_Error_Type;

   package Internals is

      type QSqlError is private;

      type QSqlError_Access is access all QSqlError;
      pragma Convention (C, QSqlError_Access);

      function QSqlError_View
       (Item : Q_Sql_Error'Class)
          return QSqlError_Access;
      pragma Inline (QSqlError_View);

      function To_Pointer
       (Address : System.Address)
          return QSqlError_Access;
      pragma Inline (To_Pointer);

      function To_Address
       (Pointer : QSqlError_Access)
          return System.Address;
      pragma Inline (To_Address);

      function Create_Wrapper
       (Item : Internals.QSqlError_Access)
          return Q_Sql_Error;

   private

      type QSqlError is record
         Placeholder : Interfaces.C.char_array (1 .. Qt_Ada.Internals.Value_Class_Sizes.QSqlError_C_Size_Of);
      end record;
      pragma Convention (C, QSqlError);

   end Internals;

private

   type Q_Sql_Error is new Ada.Finalization.Controlled with record
      Storage : aliased Internals.QSqlError;
      Object  : Internals.QSqlError_Access := null;
      Wrapper : Boolean := False;
   end record;

   overriding
   procedure Adjust (Self : in out Q_Sql_Error);

   overriding
   procedure Finalize (Self : in out Q_Sql_Error);

   overriding
   procedure Initialize (Self : in out Q_Sql_Error);

end Qt4.Sql_Errors;
