------------------------------------------------------------------------------
--                                                                          --
--                An Ada2005 binding to the Qt C++ framework                --
--                                                                          --
------------------------------------------------------------------------------
--                                                                          --
-- Copyright © 2007-2009  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.     --
------------------------------------------------------------------------------
pragma Style_Checks ("NM32766");
with System.Address_To_Access_Conversions;

with Qt4_Debug;

package body Qt4.Times is

   procedure Q_Time_Image (Item : Q_Time);
   pragma Export (Ada, Q_Time_Image, "q_time_image");

   function initialize_QTime
    (Storage : in System.Address)
      return Internals.QTime_Access;
   pragma Import (C, initialize_QTime, "__QtAda_inititialize_QTime");

   function initialize_QTime_int_int_int_int
    (Storage : in System.Address;
     H : in Qt4.Q_Integer;
     M : in Qt4.Q_Integer;
     S : in Qt4.Q_Integer;
     Ms : in Qt4.Q_Integer)
      return Internals.QTime_Access;
   pragma Import (C, initialize_QTime_int_int_int_int, "__QtAda_inititialize_QTime_int_int_int_int");

   function adjust_QTime
    (Storage : in System.Address;
     From    : in Internals.QTime_Access)
       return Internals.QTime_Access;
   pragma Import (C, adjust_QTime, "__QtAda_adjust_QTime");

   procedure finalize_QTime (Object : in Internals.QTime_Access);
   pragma Import (C, finalize_QTime, "__QtAda_finalize_QTime");

   procedure QTime_addMSecs_int
    (Returns : in Internals.QTime_Access;
     Self : in Internals.QTime_Access;
     Ms : in Qt4.Q_Integer);
   pragma Import (C, QTime_addMSecs_int, "__QtAda_QTime_addMSecs_int_Q");

   procedure QTime_addSecs_int
    (Returns : in Internals.QTime_Access;
     Self : in Internals.QTime_Access;
     Secs : in Qt4.Q_Integer);
   pragma Import (C, QTime_addSecs_int, "__QtAda_QTime_addSecs_int_Q");

   function QTime_elapsed
    (Self : in Internals.QTime_Access)
       return Qt4.Q_Integer;
   pragma Import (C, QTime_elapsed, "__QtAda_QTime_elapsed_Q");

   function QTime_hour
    (Self : in Internals.QTime_Access)
       return Qt4.Q_Integer;
   pragma Import (C, QTime_hour, "__QtAda_QTime_hour_Q");

   function QTime_isNull
    (Self : in Internals.QTime_Access)
       return Interfaces.C.unsigned;
   pragma Import (C, QTime_isNull, "__QtAda_QTime_isNull_Q");

   function QTime_isValid
    (Self : in Internals.QTime_Access)
       return Interfaces.C.unsigned;
   pragma Import (C, QTime_isValid, "__QtAda_QTime_isValid_Q");

   function QTime_minute
    (Self : in Internals.QTime_Access)
       return Qt4.Q_Integer;
   pragma Import (C, QTime_minute, "__QtAda_QTime_minute_Q");

   function QTime_msec
    (Self : in Internals.QTime_Access)
       return Qt4.Q_Integer;
   pragma Import (C, QTime_msec, "__QtAda_QTime_msec_Q");

   function QTime_msecsTo_QTimeCR
    (Self : in Internals.QTime_Access;
     T : in Internals.QTime_Access)
       return Qt4.Q_Integer;
   pragma Import (C, QTime_msecsTo_QTimeCR, "__QtAda_QTime_msecsTo_QTimeCR_Q");

   function QTime_second
    (Self : in Internals.QTime_Access)
       return Qt4.Q_Integer;
   pragma Import (C, QTime_second, "__QtAda_QTime_second_Q");

   function QTime_secsTo_QTimeCR
    (Self : in Internals.QTime_Access;
     T : in Internals.QTime_Access)
       return Qt4.Q_Integer;
   pragma Import (C, QTime_secsTo_QTimeCR, "__QtAda_QTime_secsTo_QTimeCR_Q");

   procedure QTime_start
    (Self : in Internals.QTime_Access);
   pragma Import (C, QTime_start, "__QtAda_QTime_start");

   procedure QTime_toString_QStringCR
    (Returns : in Qt4.Strings.Internals.QString_Access;
     Self : in Internals.QTime_Access;
     Format : in Qt4.Strings.Internals.QString_Access);
   pragma Import (C, QTime_toString_QStringCR, "__QtAda_QTime_toString_QStringCR_Q");

   procedure QTime_toString_DateFormat
    (Returns : in Qt4.Strings.Internals.QString_Access;
     Self : in Internals.QTime_Access;
     F : in Qt4.Date_Format);
   pragma Import (C, QTime_toString_DateFormat, "__QtAda_QTime_toString_DateFormat_Q");

   procedure QTime_currentTime
    (Returns : in Internals.QTime_Access);
   pragma Import (C, QTime_currentTime, "__QtAda_QTime_currentTime_S");

   procedure QTime_fromString_QStringCR_DateFormat
    (Returns : in Internals.QTime_Access;
     S : in Qt4.Strings.Internals.QString_Access;
     F : in Qt4.Date_Format);
   pragma Import (C, QTime_fromString_QStringCR_DateFormat, "__QtAda_QTime_fromString_QStringCR_DateFormat_S");

   procedure QTime_fromString_QStringCR_QStringCR
    (Returns : in Internals.QTime_Access;
     S : in Qt4.Strings.Internals.QString_Access;
     Format : in Qt4.Strings.Internals.QString_Access);
   pragma Import (C, QTime_fromString_QStringCR_QStringCR, "__QtAda_QTime_fromString_QStringCR_QStringCR_S");

   function QTime_isValid_int_int_int_int
    (H : in Qt4.Q_Integer;
     M : in Qt4.Q_Integer;
     S : in Qt4.Q_Integer;
     Ms : in Qt4.Q_Integer)
       return Interfaces.C.unsigned;
   pragma Import (C, QTime_isValid_int_int_int_int, "__QtAda_QTime_isValid_int_int_int_int_S");

   function eq_QTimeCR
    (Self : in Internals.QTime_Access;
     Other : in Internals.QTime_Access)
       return Interfaces.C.unsigned;
   pragma Import (C, eq_QTimeCR, "__QtAda_QTime_eq_QTimeCR_Q");

   function lt_QTimeCR
    (Self : in Internals.QTime_Access;
     Other : in Internals.QTime_Access)
       return Interfaces.C.unsigned;
   pragma Import (C, lt_QTimeCR, "__QtAda_QTime_lt_QTimeCR_Q");

   function le_QTimeCR
    (Self : in Internals.QTime_Access;
     Other : in Internals.QTime_Access)
       return Interfaces.C.unsigned;
   pragma Import (C, le_QTimeCR, "__QtAda_QTime_le_QTimeCR_Q");

   function gt_QTimeCR
    (Self : in Internals.QTime_Access;
     Other : in Internals.QTime_Access)
       return Interfaces.C.unsigned;
   pragma Import (C, gt_QTimeCR, "__QtAda_QTime_gt_QTimeCR_Q");

   function ge_QTimeCR
    (Self : in Internals.QTime_Access;
     Other : in Internals.QTime_Access)
       return Interfaces.C.unsigned;
   pragma Import (C, ge_QTimeCR, "__QtAda_QTime_ge_QTimeCR_Q");

   ------------------
   -- Q_Time_Image --
   ------------------

   procedure Q_Time_Image (Item : Q_Time) is
   begin
      Qt4_Debug.Output (Item.To_String.To_Local_8_Bit);
   end Q_Time_Image;

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

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

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

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

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

   overriding
   procedure Initialize (Self : in out Q_Time) is
      use type Internals.QTime_Access;

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

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

   function Create
    (H : in Qt4.Q_Hour_Number;
     M : in Qt4.Q_Minute_Number;
     S : in Qt4.Q_Second_Number
       := 0;
     Ms : in Qt4.Q_Second_Duration
       := 0.000000000)
       return Q_Time
   is
   begin
      return Self : Q_Time
        := (Ada.Finalization.Controlled with others => <>)
      do
         Self.Object := initialize_QTime_int_int_int_int (Self.Storage'Address, H, M, S, Qt4.Q_Integer (Ms * 1000.0));
      end return;
   end Create;

   ----------------
   -- Add_M_Secs --
   ----------------

   function Add_M_Secs
    (Self : in Q_Time'Class;
     Ms : in Duration)
       return Q_Time
   is
   begin
      return Returns : Q_Time do
         QTime_addMSecs_int (Returns.Object, Self.Object, Qt4.Q_Integer (Ms * 1000.0));
      end return;
   end Add_M_Secs;

   --------------
   -- Add_Secs --
   --------------

   function Add_Secs
    (Self : in Q_Time'Class;
     Secs : in Qt4.Q_Integer)
       return Q_Time
   is
   begin
      return Returns : Q_Time do
         QTime_addSecs_int (Returns.Object, Self.Object, Secs);
      end return;
   end Add_Secs;

   -------------
   -- Elapsed --
   -------------

   function Elapsed
    (Self : in Q_Time'Class)
       return Qt4.Q_Day_Duration
   is
   begin
      return Duration (QTime_elapsed (Self.Object)) / 1000.0;
   end Elapsed;

   ----------
   -- Hour --
   ----------

   function Hour
    (Self : in Q_Time'Class)
       return Qt4.Q_Hour_Number
   is
   begin
      return QTime_hour (Self.Object);
   end Hour;

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

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

   --------------
   -- Is_Valid --
   --------------

   function Is_Valid
    (Self : in Q_Time'Class)
       return Boolean
   is
   begin
      return Interfaces.C."/=" (QTime_isValid (Self.Object), 0);
   end Is_Valid;

   ------------
   -- Minute --
   ------------

   function Minute
    (Self : in Q_Time'Class)
       return Qt4.Q_Minute_Number
   is
   begin
      return QTime_minute (Self.Object);
   end Minute;

   ----------
   -- Msec --
   ----------

   function Msec
    (Self : in Q_Time'Class)
       return Qt4.Q_Second_Duration
   is
   begin
      return Duration (QTime_msec (Self.Object)) / 1000.0;
   end Msec;

   --------------
   -- Msecs_To --
   --------------

   function Msecs_To
    (Self : in Q_Time'Class;
     T : in Q_Time'Class)
       return Duration
   is
   begin
      return Duration (QTime_msecsTo_QTimeCR (Self.Object, T.Object)) / 1000.0;
   end Msecs_To;

   ------------
   -- Second --
   ------------

   function Second
    (Self : in Q_Time'Class)
       return Qt4.Q_Second_Number
   is
   begin
      return QTime_second (Self.Object);
   end Second;

   -------------
   -- Secs_To --
   -------------

   function Secs_To
    (Self : in Q_Time'Class;
     T : in Q_Time'Class)
       return Qt4.Q_Integer
   is
   begin
      return QTime_secsTo_QTimeCR (Self.Object, T.Object);
   end Secs_To;

   -----------
   -- Start --
   -----------

   procedure Start
    (Self : in out Q_Time'Class)
   is
   begin
      QTime_start (Self.Object);
   end Start;

   ---------------
   -- To_String --
   ---------------

   function To_String
    (Self : in Q_Time'Class;
     Format : in Qt4.Strings.Q_String'Class)
       return Qt4.Strings.Q_String
   is
   begin
      return Returns : Qt4.Strings.Q_String do
         QTime_toString_QStringCR (Qt4.Strings.Internals.QString_View (Returns), Self.Object, Qt4.Strings.Internals.QString_View (Format));
      end return;
   end To_String;

   ---------------
   -- To_String --
   ---------------

   function To_String
    (Self : in Q_Time'Class;
     F : in Qt4.Date_Format
       := Text_Date)
       return Qt4.Strings.Q_String
   is
   begin
      return Returns : Qt4.Strings.Q_String do
         QTime_toString_DateFormat (Qt4.Strings.Internals.QString_View (Returns), Self.Object, F);
      end return;
   end To_String;

   ------------------
   -- Current_Time --
   ------------------

   function Current_Time
     return Q_Time
   is
   begin
      return Returns : Q_Time do
         QTime_currentTime (Returns.Object);
      end return;
   end Current_Time;

   -----------------
   -- From_String --
   -----------------

   function From_String
    (S : in Qt4.Strings.Q_String'Class;
     F : in Qt4.Date_Format
       := Text_Date)
       return Q_Time
   is
   begin
      return Returns : Q_Time do
         QTime_fromString_QStringCR_DateFormat (Returns.Object, Qt4.Strings.Internals.QString_View (S), F);
      end return;
   end From_String;

   -----------------
   -- From_String --
   -----------------

   function From_String
    (S : in Qt4.Strings.Q_String'Class;
     Format : in Qt4.Strings.Q_String'Class)
       return Q_Time
   is
   begin
      return Returns : Q_Time do
         QTime_fromString_QStringCR_QStringCR (Returns.Object, Qt4.Strings.Internals.QString_View (S), Qt4.Strings.Internals.QString_View (Format));
      end return;
   end From_String;

   --------------
   -- Is_Valid --
   --------------

   function Is_Valid
    (H : in Qt4.Q_Hour_Number;
     M : in Qt4.Q_Minute_Number;
     S : in Qt4.Q_Second_Number;
     Ms : in Qt4.Q_Second_Duration
       := 0.000000000)
       return Boolean
   is
   begin
      return Interfaces.C."/=" (QTime_isValid_int_int_int_int (H, M, S, Qt4.Q_Integer (Ms * 1000.0)), 0);
   end Is_Valid;

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

   function "="
    (Self : in Q_Time;
     Other : in Q_Time)
       return Boolean
   is
   begin
      return Interfaces.C."/=" (eq_QTimeCR (Self.Object, Other.Object), 0);
   end "=";

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

   function "<"
    (Self : in Q_Time;
     Other : in Q_Time)
       return Boolean
   is
   begin
      return Interfaces.C."/=" (lt_QTimeCR (Self.Object, Other.Object), 0);
   end "<";

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

   function "<="
    (Self : in Q_Time;
     Other : in Q_Time)
       return Boolean
   is
   begin
      return Interfaces.C."/=" (le_QTimeCR (Self.Object, Other.Object), 0);
   end "<=";

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

   function ">"
    (Self : in Q_Time;
     Other : in Q_Time)
       return Boolean
   is
   begin
      return Interfaces.C."/=" (gt_QTimeCR (Self.Object, Other.Object), 0);
   end ">";

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

   function ">="
    (Self : in Q_Time;
     Other : in Q_Time)
       return Boolean
   is
   begin
      return Interfaces.C."/=" (ge_QTimeCR (Self.Object, Other.Object), 0);
   end ">=";

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

   package body Internals is

   ----------------
   -- QTime_View --
   ----------------

      function QTime_View
       (Item : in Q_Time'Class)
          return QTime_Access
      is
      begin
         return Item.Object;
      end QTime_View;

      package QTime_Conversions is
        new System.Address_To_Access_Conversions
             (QTime);

   ---------------------
   -- QTimeTo_Pointer --
   ---------------------

      function To_Pointer
       (Address : in System.Address)
          return QTime_Access
      is
      begin
         return
           QTime_Access
            (QTime_Conversions.To_Pointer
            (Address));
      end To_Pointer;

   ---------------------
   -- QTimeTo_Address --
   ---------------------

      function To_Address
       (Pointer : in QTime_Access)
          return System.Address
      is
      begin
         return
           QTime_Conversions.To_Address
            (QTime_Conversions.Object_Pointer
              (Pointer));
      end To_Address;

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

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

   end Internals;

end Qt4.Times;
