Files
alire-index-community/src/alire-utils.ads
T
2018-03-03 13:52:26 +01:00

42 lines
1.3 KiB
Ada

with Ada.Containers.Indefinite_Vectors;
package Alire.Utils with Preelaborate is
function To_Lower_Case (S : String) return String;
function To_Mixed_Case (S : String) return String;
function Contains (Text : String; Sub : String) return Boolean;
function Head (Str : String; Separator : Character) return String;
-- if Str contains Separator, the lhs is returned
-- Otherwise Str is returned
function Tail (Str : String; Separator : Character) return String;
-- If Str contains Separator, the rhs is returned
-- Otherwise ""
--------------------
-- String_Vectors --
--------------------
-- To simplify somewhat managing lists of strigns
package String_Vectors is new Ada.Containers.Indefinite_Vectors (Positive, String);
type String_Vector is new String_Vectors.Vector with null record;
Empty_Vector : constant String_Vector;
function Count (V : String_Vector) return Natural;
-- FSM do I hate the Containers.Count_Type...
function Flatten (V : String_Vector; Separator : String := " ") return String;
-- Concatenate all elements
private
Empty_Vector : constant String_Vector := (String_Vectors.Empty_Vector with null record);
function Count (V : String_Vector) return Natural is (Natural (String_Vectors.Vector (V).Length));
end Alire.Utils;