rxada_0.1.1_dd9da799/src/priv/rx-impl-casts.ads

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
with Ada.Strings;	use Ada.Strings;
with Ada.Strings.Fixed; use Ada.Strings.Fixed;

package Rx.Impl.Casts is

   --  Casts between the standard Ada types for use in the Cast operator

   function To_Integer (V : Rx_Float)  return Rx_Integer is (Rx_Integer (V));
   function To_Integer (V : Rx_String) return Rx_Integer is (Rx_Integer'Value (V));

   function To_Float (V : Rx_Integer) return Rx_Float is (Rx_Float (V));
   function To_Float (V : Rx_String)  return Rx_Float is (Rx_Float'Value (V));

   function To_String (V : Rx_Integer) return String is (Trim (Rx_Integer'Image (V), Both));
   function To_String (V : Rx_Float)   return String is (Trim (Rx_Float'Image (V), Both));
   function To_String (V : Rx_String)  return String is (V);
   --  A default conversion with 4 decimal digits

end Rx.Impl.Casts;