------------------------------------------------------------------------------
--                                                                          --
--                An Ada2005 binding to the Qt C++ framework                --
--                                                                          --
------------------------------------------------------------------------------
--                                                                          --
-- Copyright © 2007 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 Qt_Ada.Internals.Boolean_Conversions;
with System;

package body Qt4.Reg_Exps is

   function initialize_QRegExp
    (Storage : in System.Address)
      return Internals.QRegExp_Access;
   pragma Import (C, initialize_QRegExp, "__QtAda_inititialize_QRegExp");

   function initialize_QRegExp_QStringCR_CaseSensitivity_PatternSyntax
    (Storage : in System.Address;
     Pattern : in Qt4.Strings.Internals.QString_Access;
     Cs : in Qt4.Case_Sensitivity;
     Syntax : in Reg_Exp_Pattern_Syntax)
      return Internals.QRegExp_Access;
   pragma Import (C, initialize_QRegExp_QStringCR_CaseSensitivity_PatternSyntax, "__QtAda_inititialize_QRegExp_QStringCR_CaseSensitivity_PatternSyntax");

   function adjust_QRegExp
    (Storage : in System.Address;
     From    : in Internals.QRegExp_Access)
       return Internals.QRegExp_Access;
   pragma Import (C, adjust_QRegExp, "__QtAda_adjust_QRegExp");

   procedure finalize_QRegExp (Object : in Internals.QRegExp_Access);
   pragma Import (C, finalize_QRegExp, "__QtAda_finalize_QRegExp");

   procedure QRegExp_cap_int
    (Returns : in Qt4.Strings.Internals.QString_Access;
     Self : in Internals.QRegExp_Access;
     Nth : in Qt4.Q_Integer);
   pragma Import (C, QRegExp_cap_int, "__QtAda_QRegExp_cap_int");

   procedure QRegExp_capturedTexts
    (Returns : in Qt4.String_Lists.Internals.QStringList_Access;
     Self : in Internals.QRegExp_Access);
   pragma Import (C, QRegExp_capturedTexts, "__QtAda_QRegExp_capturedTexts");

   function QRegExp_caseSensitivity
    (Self : in Internals.QRegExp_Access)
       return Qt4.Case_Sensitivity;
   pragma Import (C, QRegExp_caseSensitivity, "__QtAda_QRegExp_caseSensitivity_Q");

   procedure QRegExp_errorString
    (Returns : in Qt4.Strings.Internals.QString_Access;
     Self : in Internals.QRegExp_Access);
   pragma Import (C, QRegExp_errorString, "__QtAda_QRegExp_errorString");

   function QRegExp_exactMatch_QStringCR
    (Self : in Internals.QRegExp_Access;
     Str : in Qt4.Strings.Internals.QString_Access)
       return Interfaces.C.unsigned;
   pragma Import (C, QRegExp_exactMatch_QStringCR, "__QtAda_QRegExp_exactMatch_QStringCR_Q");

   function QRegExp_indexIn_QStringCR_int_CaretMode
    (Self : in Internals.QRegExp_Access;
     Str : in Qt4.Strings.Internals.QString_Access;
     Offset : in Qt4.Q_Integer;
     Mode : in Caret_Mode)
       return Qt4.Q_Integer;
   pragma Import (C, QRegExp_indexIn_QStringCR_int_CaretMode, "__QtAda_QRegExp_indexIn_QStringCR_int_CaretMode_Q");

   function QRegExp_isEmpty
    (Self : in Internals.QRegExp_Access)
       return Interfaces.C.unsigned;
   pragma Import (C, QRegExp_isEmpty, "__QtAda_QRegExp_isEmpty_Q");

   function QRegExp_isMinimal
    (Self : in Internals.QRegExp_Access)
       return Interfaces.C.unsigned;
   pragma Import (C, QRegExp_isMinimal, "__QtAda_QRegExp_isMinimal_Q");

   function QRegExp_isValid
    (Self : in Internals.QRegExp_Access)
       return Interfaces.C.unsigned;
   pragma Import (C, QRegExp_isValid, "__QtAda_QRegExp_isValid_Q");

   function QRegExp_lastIndexIn_QStringCR_int_CaretMode
    (Self : in Internals.QRegExp_Access;
     Str : in Qt4.Strings.Internals.QString_Access;
     Offset : in Qt4.Q_Integer;
     Mode : in Caret_Mode)
       return Qt4.Q_Integer;
   pragma Import (C, QRegExp_lastIndexIn_QStringCR_int_CaretMode, "__QtAda_QRegExp_lastIndexIn_QStringCR_int_CaretMode_Q");

   function QRegExp_matchedLength
    (Self : in Internals.QRegExp_Access)
       return Qt4.Q_Integer;
   pragma Import (C, QRegExp_matchedLength, "__QtAda_QRegExp_matchedLength_Q");

   function QRegExp_numCaptures
    (Self : in Internals.QRegExp_Access)
       return Qt4.Q_Integer;
   pragma Import (C, QRegExp_numCaptures, "__QtAda_QRegExp_numCaptures_Q");

   procedure QRegExp_pattern
    (Returns : in Qt4.Strings.Internals.QString_Access;
     Self : in Internals.QRegExp_Access);
   pragma Import (C, QRegExp_pattern, "__QtAda_QRegExp_pattern_Q");

   function QRegExp_patternSyntax
    (Self : in Internals.QRegExp_Access)
       return Reg_Exp_Pattern_Syntax;
   pragma Import (C, QRegExp_patternSyntax, "__QtAda_QRegExp_patternSyntax_Q");

   function QRegExp_pos_int
    (Self : in Internals.QRegExp_Access;
     Nth : in Qt4.Q_Integer)
       return Qt4.Q_Integer;
   pragma Import (C, QRegExp_pos_int, "__QtAda_QRegExp_pos_int");

   procedure QRegExp_setCaseSensitivity_CaseSensitivity
    (Self : in Internals.QRegExp_Access;
     Cs : in Qt4.Case_Sensitivity);
   pragma Import (C, QRegExp_setCaseSensitivity_CaseSensitivity, "__QtAda_QRegExp_setCaseSensitivity_CaseSensitivity");

   procedure QRegExp_setMinimal_bool
    (Self : in Internals.QRegExp_Access;
     Minimal : in Interfaces.C.unsigned);
   pragma Import (C, QRegExp_setMinimal_bool, "__QtAda_QRegExp_setMinimal_bool");

   procedure QRegExp_setPattern_QStringCR
    (Self : in Internals.QRegExp_Access;
     Pattern : in Qt4.Strings.Internals.QString_Access);
   pragma Import (C, QRegExp_setPattern_QStringCR, "__QtAda_QRegExp_setPattern_QStringCR");

   procedure QRegExp_setPatternSyntax_PatternSyntaxCR
    (Self : in Internals.QRegExp_Access;
     Syntax : in Reg_Exp_Pattern_Syntax);
   pragma Import (C, QRegExp_setPatternSyntax_PatternSyntaxCR, "__QtAda_QRegExp_setPatternSyntax_PatternSyntaxCR");

   procedure QRegExp_escape_QStringCR
    (Returns : in Qt4.Strings.Internals.QString_Access;
     Str : in Qt4.Strings.Internals.QString_Access);
   pragma Import (C, QRegExp_escape_QStringCR, "__QtAda_QRegExp_escape_QStringCR_S");

   function eq_QRegExpCR
    (Self : in Internals.QRegExp_Access;
     Rx : in Internals.QRegExp_Access)
       return Interfaces.C.unsigned;
   pragma Import (C, eq_QRegExpCR, "__QtAda_QRegExp_eq_QRegExpCR_Q");

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

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

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

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

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

   overriding
   procedure Initialize (Self : in out Q_Reg_Exp) is
      use type Internals.QRegExp_Access;

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

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

   function Create
    (Pattern : in Qt4.Strings.Q_String'Class;
     Cs : in Qt4.Case_Sensitivity
       := Case_Sensitive;
     Syntax : in Reg_Exp_Pattern_Syntax
       := Reg_Exp)
       return Q_Reg_Exp
   is
   begin
      return Self : Q_Reg_Exp
        := (Ada.Finalization.Controlled with others => <>)
      do
         Self.Object := initialize_QRegExp_QStringCR_CaseSensitivity_PatternSyntax (Self.Storage'Address, Qt4.Strings.Internals.QString_View (Pattern), Cs, Syntax);
      end return;
   end Create;

   ---------
   -- Cap --
   ---------

   function Cap
    (Self : not null access Q_Reg_Exp'Class;
     Nth : in Qt4.Q_Integer
       := 0)
       return Qt4.Strings.Q_String
   is
   begin
      return Returns : Qt4.Strings.Q_String do
         QRegExp_cap_int (Qt4.Strings.Internals.QString_View (Returns), Self.Object, Nth);
      end return;
   end Cap;

   --------------------
   -- Captured_Texts --
   --------------------

   function Captured_Texts
    (Self : not null access Q_Reg_Exp'Class)
       return Qt4.String_Lists.Q_String_List
   is
   begin
      return Returns : Qt4.String_Lists.Q_String_List do
         QRegExp_capturedTexts (Qt4.String_Lists.Internals.QStringList_View (Returns), Self.Object);
      end return;
   end Captured_Texts;

   ----------------------
   -- Case_Sensitivity --
   ----------------------

   function Case_Sensitivity
    (Self : in Q_Reg_Exp'Class)
       return Qt4.Case_Sensitivity
   is
   begin
      return QRegExp_caseSensitivity (Self.Object);
   end Case_Sensitivity;

   ------------------
   -- Error_String --
   ------------------

   function Error_String
    (Self : not null access Q_Reg_Exp'Class)
       return Qt4.Strings.Q_String
   is
   begin
      return Returns : Qt4.Strings.Q_String do
         QRegExp_errorString (Qt4.Strings.Internals.QString_View (Returns), Self.Object);
      end return;
   end Error_String;

   -----------------
   -- Exact_Match --
   -----------------

   function Exact_Match
    (Self : in Q_Reg_Exp'Class;
     Str : in Qt4.Strings.Q_String'Class)
       return Boolean
   is
   begin
      return Interfaces.C."/=" (QRegExp_exactMatch_QStringCR (Self.Object, Qt4.Strings.Internals.QString_View (Str)), 0);
   end Exact_Match;

   --------------
   -- Index_In --
   --------------

   function Index_In
    (Self : in Q_Reg_Exp'Class;
     Str : in Qt4.Strings.Q_String'Class;
     Offset : in Qt4.Q_Integer
       := 0;
     Mode : in Caret_Mode
       := Caret_At_Zero)
       return Qt4.Q_Integer
   is
   begin
      return QRegExp_indexIn_QStringCR_int_CaretMode (Self.Object, Qt4.Strings.Internals.QString_View (Str), Offset, Mode);
   end Index_In;

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

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

   ----------------
   -- Is_Minimal --
   ----------------

   function Is_Minimal
    (Self : in Q_Reg_Exp'Class)
       return Boolean
   is
   begin
      return Interfaces.C."/=" (QRegExp_isMinimal (Self.Object), 0);
   end Is_Minimal;

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

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

   -------------------
   -- Last_Index_In --
   -------------------

   function Last_Index_In
    (Self : in Q_Reg_Exp'Class;
     Str : in Qt4.Strings.Q_String'Class;
     Offset : in Qt4.Q_Integer
       := -1;
     Mode : in Caret_Mode
       := Caret_At_Zero)
       return Qt4.Q_Integer
   is
   begin
      return QRegExp_lastIndexIn_QStringCR_int_CaretMode (Self.Object, Qt4.Strings.Internals.QString_View (Str), Offset, Mode);
   end Last_Index_In;

   --------------------
   -- Matched_Length --
   --------------------

   function Matched_Length
    (Self : in Q_Reg_Exp'Class)
       return Qt4.Q_Integer
   is
   begin
      return QRegExp_matchedLength (Self.Object);
   end Matched_Length;

   ------------------
   -- Num_Captures --
   ------------------

   function Num_Captures
    (Self : in Q_Reg_Exp'Class)
       return Qt4.Q_Integer
   is
   begin
      return QRegExp_numCaptures (Self.Object);
   end Num_Captures;

   -------------
   -- Pattern --
   -------------

   function Pattern
    (Self : in Q_Reg_Exp'Class)
       return Qt4.Strings.Q_String
   is
   begin
      return Returns : Qt4.Strings.Q_String do
         QRegExp_pattern (Qt4.Strings.Internals.QString_View (Returns), Self.Object);
      end return;
   end Pattern;

   --------------------
   -- Pattern_Syntax --
   --------------------

   function Pattern_Syntax
    (Self : in Q_Reg_Exp'Class)
       return Reg_Exp_Pattern_Syntax
   is
   begin
      return QRegExp_patternSyntax (Self.Object);
   end Pattern_Syntax;

   ---------
   -- Pos --
   ---------

   function Pos
    (Self : not null access Q_Reg_Exp'Class;
     Nth : in Qt4.Q_Integer
       := 0)
       return Qt4.Q_Integer
   is
   begin
      return QRegExp_pos_int (Self.Object, Nth);
   end Pos;

   --------------------------
   -- Set_Case_Sensitivity --
   --------------------------

   procedure Set_Case_Sensitivity
    (Self : in out Q_Reg_Exp'Class;
     Cs : in Qt4.Case_Sensitivity)
   is
   begin
      QRegExp_setCaseSensitivity_CaseSensitivity (Self.Object, Cs);
   end Set_Case_Sensitivity;

   -----------------
   -- Set_Minimal --
   -----------------

   procedure Set_Minimal
    (Self : in out Q_Reg_Exp'Class;
     Minimal : in Boolean)
   is
   begin
      QRegExp_setMinimal_bool (Self.Object, Qt_Ada.Internals.Boolean_Conversions.To_unsigned (Minimal));
   end Set_Minimal;

   -----------------
   -- Set_Pattern --
   -----------------

   procedure Set_Pattern
    (Self : in out Q_Reg_Exp'Class;
     Pattern : in Qt4.Strings.Q_String'Class)
   is
   begin
      QRegExp_setPattern_QStringCR (Self.Object, Qt4.Strings.Internals.QString_View (Pattern));
   end Set_Pattern;

   ------------------------
   -- Set_Pattern_Syntax --
   ------------------------

   procedure Set_Pattern_Syntax
    (Self : in out Q_Reg_Exp'Class;
     Syntax : in Reg_Exp_Pattern_Syntax)
   is
   begin
      QRegExp_setPatternSyntax_PatternSyntaxCR (Self.Object, Syntax);
   end Set_Pattern_Syntax;

   ------------
   -- Escape --
   ------------

   function Escape
    (Str : in Qt4.Strings.Q_String'Class)
       return Qt4.Strings.Q_String
   is
   begin
      return Returns : Qt4.Strings.Q_String do
         QRegExp_escape_QStringCR (Qt4.Strings.Internals.QString_View (Returns), Qt4.Strings.Internals.QString_View (Str));
      end return;
   end Escape;

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

   function "="
    (Self : in Q_Reg_Exp;
     Rx : in Q_Reg_Exp)
       return Boolean
   is
   begin
      return Interfaces.C."/=" (eq_QRegExpCR (Self.Object, Rx.Object), 0);
   end "=";

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

   package body Internals is

   ------------------
   -- QRegExp_View --
   ------------------

      function QRegExp_View
       (Item : in Q_Reg_Exp'Class)
          return QRegExp_Access
      is
      begin
         return Item.Object;
      end QRegExp_View;

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

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

   end Internals;

end Qt4.Reg_Exps;
