1. -- 
  2. -- Copyright (c) 2012 Kevin Wellwood 
  3. -- All rights reserved. 
  4. -- 
  5. -- This source code is distributed under the Modified BSD License. For terms and 
  6. -- conditions, see license.txt. 
  7. -- 
  8.  
  9. private with Ada.Containers; 
  10. private with Ada.Strings.Hash_Case_Insensitive; 
  11.  
  12. package Statuses is 
  13.     pragma Elaborate_Body; 
  14.  
  15.     -- A Status is the hash value of a status string. 
  16.     type Status is private; 
  17.  
  18.     function "="( l, r : Status ) return Boolean; 
  19.  
  20.     -- Returns the Status value for a status id string; case insensitive. 
  21.     -- (Ex: To_Status("SUCCESS") = To_Status("success") Note that because a 
  22.     -- Status is a hash value, Status collisions are possible. 
  23.     function To_Status( id : String ) return Status; 
  24.     pragma Precondition( id'Length > 0 ); 
  25.  
  26.     ST_NONE      : constant Status;     -- "none" 
  27.     ST_FAILED    : constant Status;     -- "failed" 
  28.     ST_SUCCESS   : constant Status;     -- "success" 
  29.     ST_EXCEPTION : constant Status;     -- "exception" 
  30.  
  31. private 
  32.  
  33.     use Ada.Containers; 
  34.  
  35.     type Status is new Ada.Containers.Hash_Type; 
  36.  
  37.     ST_NONE      : constant Status := Status(Ada.Strings.Hash_Case_Insensitive( "none" )); 
  38.     ST_FAILED    : constant Status := Status(Ada.Strings.Hash_Case_Insensitive( "failed" )); 
  39.     ST_SUCCESS   : constant Status := Status(Ada.Strings.Hash_Case_Insensitive( "success" )); 
  40.     ST_EXCEPTION : constant Status := Status(Ada.Strings.Hash_Case_Insensitive( "exception" )); 
  41.  
  42. end Statuses;