------------------------------------------------------------------------------
--                                                                          --
--                            Matreshka Project                             --
--                                                                          --
--                           SQL Database Access                            --
--                                                                          --
--                        Runtime Library Component                         --
--                                                                          --
------------------------------------------------------------------------------
--                                                                          --
-- Copyright © 2011-2012, Vadim Godunko <vgodunko@gmail.com>                --
-- All rights reserved.                                                     --
--                                                                          --
-- Redistribution and use in source and binary forms, with or without       --
-- modification, are permitted provided that the following conditions       --
-- are met:                                                                 --
--                                                                          --
--  * Redistributions of source code must retain the above copyright        --
--    notice, this list of conditions and the following disclaimer.         --
--                                                                          --
--  * Redistributions in binary form must reproduce the above copyright     --
--    notice, this list of conditions and the following disclaimer in the   --
--    documentation and/or other materials provided with the distribution.  --
--                                                                          --
--  * Neither the name of the Vadim Godunko, IE nor the names of its        --
--    contributors may be used to endorse or promote products derived from  --
--    this software without specific prior written permission.              --
--                                                                          --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS      --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT        --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR    --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT     --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,   --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR   --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF   --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING     --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS       --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.             --
--                                                                          --
------------------------------------------------------------------------------
--  $Revision: 3533 $ $Date: 2012-12-05 13:25:25 +0400 (Wed, 05 Dec 2012) $
------------------------------------------------------------------------------
--  This package provides base implementation of SQL statement parameter
--  rewriter, which converts :name style parameter placeholders into database
--  specific representation.
------------------------------------------------------------------------------
with League.Strings;

with Matreshka.Internals.SQL_Parameter_Sets;

package Matreshka.Internals.SQL_Parameter_Rewriters is

   pragma Preelaborate;

   type Abstract_Parameter_Rewriter is abstract tagged limited null record;

   procedure Rewrite
    (Self       : Abstract_Parameter_Rewriter'Class;
     Source     : League.Strings.Universal_String;
     Rewritten  : out League.Strings.Universal_String;
     Parameters : out SQL_Parameter_Sets.Parameter_Set);
   --  Parses SQL statement Source, rewrites parameter placeholders to
   --  database specific format and prepare set of parameters object.

   not overriding procedure Database_Placeholder
    (Self        : Abstract_Parameter_Rewriter;
     Name        : League.Strings.Universal_String;
     Number      : Positive;
     Placeholder : out League.Strings.Universal_String;
     Parameters  : in out SQL_Parameter_Sets.Parameter_Set) is abstract;
   --  Sets Placeholder to database specific placeholder for parameter with
   --  Name and number Number. Implementation must modify Parameters
   --  accordingly.
   --
   --  Note: passed parameter's name is casefolded.

end Matreshka.Internals.SQL_Parameter_Rewriters;
