Natools

natools-s_expressions-conditionals-strings.ads at [8c5686ece7]
Login

File src/natools-s_expressions-conditionals-strings.ads artifact d357316879 part of check-in 8c5686ece7


------------------------------------------------------------------------------
-- Copyright (c) 2015, Natacha Porté                                        --
--                                                                          --
-- Permission to use, copy, modify, and distribute this software for any    --
-- purpose with or without fee is hereby granted, provided that the above   --
-- copyright notice and this permission notice appear in all copies.        --
--                                                                          --
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES --
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF         --
-- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR  --
-- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES   --
-- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN    --
-- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF  --
-- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.           --
------------------------------------------------------------------------------

------------------------------------------------------------------------------
-- Natools.S_Expressions.Conditionals.Strings provides primitives to        --
-- evaluate S-expression conditions about strings.                          --
------------------------------------------------------------------------------

with Natools.S_Expressions.Conditionals.Generic_Evaluate;
with Natools.S_Expressions.Lockable;

package Natools.S_Expressions.Conditionals.Strings is
   pragma Preelaborate;

   type Settings (Data : not null access constant String) is record
      Case_Sensitive : Boolean := True;
   end record;

   type Context
     (Data : not null access constant String;
      Parametric_Fallback : access function
        (Settings : in Strings.Settings;
         Name : in Atom;
         Arguments : in out Lockable.Descriptor'Class)
        return Boolean;
      Simple_Fallback : access function
        (Settings : in Strings.Settings;
         Name : in Atom)
        return Boolean)
   is record
      Settings : Strings.Settings (Data);
   end record;


   function Parametric_Evaluate
     (Context : in Strings.Context;
      Name : in Atom;
      Arguments : in out Lockable.Descriptor'Class)
     return Boolean;

   function Simple_Evaluate
     (Context : in Strings.Context;
      Name : in Atom)
     return Boolean;

   function Evaluate is new Generic_Evaluate
     (Context, Parametric_Evaluate, Simple_Evaluate);

   function Evaluate
     (Text : in String;
      Expression : in out Lockable.Descriptor'Class)
     return Boolean;

end Natools.S_Expressions.Conditionals.Strings;