OO String Stack Package
MC logo
 

OO String Stack Package

Ada Code Examples


<<OO Integer Stack Body Download OO String Stack Body>>
--
-- Declarations for string stack.
--
with GenStack; use GenStack;

package SStack is
   -- Data type containing a string to push onto the stack.
   type StrStackData is new StackData with private;

   -- Create one.
   function SDat(S: String) return StrStackData;

   -- Extract the string value.
   function SValue(R: StrStackData) return String;

   -- Controls.  These handle allocation for creation, destruction, and
   -- assignment.
   procedure Initialize(SR: in out StrStackData);
   procedure Adjust(SR: in out StrStackData);
   procedure Finalize(SR: in out StrStackData);

   private
      -- The string data is really a record containing a pointer to the
      -- actual string.  Using a pointer lets the length of the actual
      -- strings vary.
      type SPtr is access String;
      type StrStackData is new StackData with record
         V: SPtr;
      end record;
end SStack;
<<OO Integer Stack Body OO String Stack Body>>