4.2.51. GNATCOLL.Symbols

package GNATCOLL.Symbols is

   type Symbol_Table_Record (<>) is tagged private;
   type Symbol_Table_Access is access all Symbol_Table_Record'Class;
   --  A symbol table associating integers with strings.
   --  By default, this is not task safe, so you will need to extend this if
   --  the symbol is to be shared between multiple tasks.

   type Symbol is private;
   No_Symbol    : constant Symbol;
   Empty_String : constant Symbol;

   function Allocate return Symbol_Table_Access;
   --  Allocate a new symbol table

   function Find
     (Table : access Symbol_Table_Record;
      Str   : String) return Symbol;
   --  Return the internal version of Str.
   --  Comparing Symbol is the same as comparing the string itself, but much
   --  faster.

   function Get
      (Sym : Symbol; Empty_If_Null : Boolean := True)
      return Cst_String_Access;
   pragma Inline_Always (Get);
   --  The string associated with the symbol.
   --  The returned string must not be deallocated, it points to internal data.
   --  For No_Symbol, this returns null or the empty string, depending on
   --  Empty_If_Null.

   procedure Free (Table : in out Symbol_Table_Record);
   procedure Free (Table : in out Symbol_Table_Access);
   --  Free the table

   function Hash (S : Symbol) return Ada.Containers.Hash_Type;
   --  Returns a hash for the symbol, in case you need to create your own
   --  hash tables.

   function Debug_Print (S : Symbol) return String;
   --  Return a displaying version of symbol (debugging purposes only)

   procedure Display_Stats (Self : access Symbol_Table_Record);
   --  Display statistics about the table.
   --  This is meant for debug purposes only, and the output might change from
   --  one version to the next.

end GNATCOLL.Symbols;