1. with Ada.Strings.Unbounded;             use Ada.Strings.Unbounded; 
  2. with Interfaces;                        use Interfaces; 
  3.  
  4. package Support is 
  5.  
  6.     function "*"( i : Integer; f : Float ) return Float; 
  7.  
  8.     function "*"( f : Float; i : Integer ) return Float; 
  9.  
  10.     function "/"( i : Integer; f : Float ) return Float; 
  11.  
  12.     function "/"( f : Float; i : Integer ) return Float; 
  13.  
  14.     function "-"( f : Float; i : Integer ) return Float; 
  15.  
  16.     function "-"( i : Integer; f : Float ) return Float; 
  17.  
  18.     function "+"( f : Float; i : Integer ) return Float; 
  19.  
  20.     function "+"( i : Integer; f : Float ) return Float; 
  21.  
  22.     function "**"( l, r : Long_Float ) return Long_Float; 
  23.  
  24.     function Constrain( val, min, max : Float ) return Float; 
  25.  
  26.     function Constrain( val, min, max : Integer ) return Integer; 
  27.  
  28.     function Div_Ceil( a, b : Integer ) return Integer; 
  29.  
  30.     function Floor( x : Float ) return Integer; 
  31.  
  32.     function Max( a, b : Integer ) return Integer; 
  33.  
  34.     function Max( a, b : Float ) return Float; 
  35.  
  36.     function Min( a, b : Integer ) return Integer; 
  37.  
  38.     function Min( a, b : Float ) return Float; 
  39.  
  40.     ---------------------------------------------------------------------------- 
  41.  
  42.     function "&"( l : String; r : Unbounded_String ) return String; 
  43.  
  44.     function "&"( l : Unbounded_String; r : String ) return String; 
  45.  
  46.     -- Capitalizes the words in the string using a set of delimiters. 
  47.     function Capitalize( str : String ) return String; 
  48.     pragma Postcondition( Capitalize'Result'Length = str'Length ); 
  49.  
  50.     -- Compares two strings; case insensitive. 
  51.     function Case_Eq( l, r : String ) return Boolean; 
  52.  
  53.     -- Compares two strings; case insensitive. 
  54.     function Case_Eq( l, r : Unbounded_String ) return Boolean; 
  55.  
  56.     -- Compares two strings; case insensitive. 
  57.     function Case_Eq( l : Unbounded_String; r : String ) return Boolean; 
  58.  
  59.     -- Compares two strings; case insensitive. 
  60.     function Case_Eq( l : String; r : Unbounded_String ) return Boolean; 
  61.  
  62.     -- Returns True if 'str' ends with 'ending'. Comparison is case sensitive. 
  63.     function Ends_With( str : String; ending : String ) return Boolean; 
  64.  
  65.     -- Iterate over words in a string separated by whitespace. 
  66.     procedure Iterate_Words( phrase  : String; 
  67.                              examine : access procedure( word : String ) ); 
  68.  
  69.     -- Replaces all 'from' characters in a string with 'to' characters. 
  70.     function Replace( str : String; from, to : Character ) return String; 
  71.  
  72.     ---------------------------------------------------------------------------- 
  73.  
  74.     -- Returns -1 if the file does not exist. 
  75.     function File_Length( path : String ) return Long_Integer; 
  76.     pragma Postcondition( File_Length'Result >= -1 ); 
  77.  
  78.     ---------------------------------------------------------------------------- 
  79.  
  80.     -- Extracts a readable Ada unit name from a source reference line. If the 
  81.     -- source reference doesn't contain symbols then an empty string will be 
  82.     -- returned because the unit name can't be determined. 
  83.     function Source_Ref_To_Unit_Name( ref : String ) return String; 
  84.  
  85.     ---------------------------------------------------------------------------- 
  86.  
  87.     -- Returns True if rectangle A contains point B. 
  88.     function Contains( ax1, ay1, ax2, ay2, bx, by : Integer ) return Boolean; 
  89.  
  90.     -- Returns the value of 'point' as it would be snapped to a grid of size 
  91.     -- 'gridSize'. If 'centered' is True, the snap will occur in the middle of 
  92.     -- the grid lines instead of on them. 
  93.     function Grid_Snap( point    : Integer; 
  94.                         gridSize : Positive; 
  95.                         centered : Boolean := False ) return Integer; 
  96.  
  97.     -- Returns True if rectangles A and B intersect. 
  98.     function Intersect( ax1, ay1, ax2, ay2, bx1, by1, bx2, by2 : Integer ) return Boolean; 
  99.  
  100.     ---------------------------------------------------------------------------- 
  101.  
  102.     -- Returns a string representation of 'i' without whitespace. 
  103.     function Image( i : Integer ) return String; 
  104.     pragma Postcondition( Image'Result'Length > 0 ); 
  105.  
  106.     -- Returns a string representation of 'u' without whitespace. 
  107.     function Image( u : Unsigned_32 ) return String; 
  108.     pragma Postcondition( Image'Result'Length > 0 ); 
  109.  
  110.     -- Returns a string image of a floating point number, where 'precision' is 
  111.     -- the number of places after the decimal to render. 
  112.     function Image( f : Float; precision : Natural := 3 ) return String; 
  113.     pragma Postcondition( Image'Result'Length > 0 ); 
  114.  
  115.     ---------------------------------------------------------------------------- 
  116.  
  117.     -- Returns a random unsigned 32-bit number. 
  118.     function Random_32 return Unsigned_32; 
  119.  
  120. private 
  121.  
  122.     -- A package for functions with OS-specific implementations 
  123.     package OS is 
  124.  
  125.         -- Returns the path of the directory where system-wide 
  126.         -- application-specific data files can be read and written. 
  127.         function App_Data_Directory return String; 
  128.  
  129.         -- Returns the file extension for executable files, not including a dot. 
  130.         function Executable_Extension return String; 
  131.  
  132.         -- Returns the path of the application's executable file. 
  133.         function Executable_Path return String; 
  134.  
  135.         -- Returns the path of the user's home directory. 
  136.         function Home_Directory return String; 
  137.  
  138.         -- Opens 'path' in the OS GUI and selects it if it points to an 
  139.         -- existing file. Nothing happens if the directory of 'path' does not 
  140.         -- exist. 
  141.         procedure Reveal_Path( path : String ); 
  142.  
  143.         -- Returns the directory for system fonts on the local machine. 
  144.         function System_Font_Directory return String; 
  145.  
  146.     end OS; 
  147.  
  148.     pragma Import( C, "**", "pow" ); 
  149.  
  150. end Support;