411 REFERENCE · Wikibooks
Ada Programming/Libraries/Ada.Storage IO
Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.
Ada.Storage_IO
__TOC__
Ada Storage_IO is a unit of the Predefined Language Environment since Ada 95.
Description
Ada.Storage_IO is not a general-purpose Input/Output package. According to A 9 The Generic Package Storage_IO(1), it is designed for the construction of user-defined input-output packages, but may also be used to transfer elements from one task to another. Note: None of the language defined IO packages is task-safe.
It allows you to store one element inside a memory buffer. The element needs to be of a definite subtype.
Be careful: The exception Data_Error need not be called when the value read cannot be interpreted as a value of the subtype Element_Type (you have to follow several references given in the RM to A 13 Exceptions in Input-Output), which may lead to erroneous execution; this may especially occur if a value has never been written. Use the 'Valid attribute when not sure.
Specification
Standard Ada library specification
For copyright, see
http://ada-auth.org/standards/rm12_w_tc1/html/RM-TTL.html
-------------------------------------------------------------------------
with Ada IO_Exceptions;
with System Storage_Elements;
generic
type Element_Type is private;
package Ada Storage_IO is
pragma Preelaborate (Storage_IO);
Buffer_Size : constant Systemdot .Storage_Elementsdot .Storage_Count
:= implementation_defined;
subtype Buffer_Type is
Systemdot .Storage_Elementsdot .Storage_Array (1 double_dot .. Buffer_Size);
Input and output operations
procedure Read (Buffer : in Buffer_Type; Item : out Element_Type);
procedure Write (Buffer : out Buffer_Type; Item : in Element_Type);
Exceptions
Data_Error : exception renames IO_Exceptionsdot .Data_Error;
end Adadot .Storage_IO;
See also
Wikibook
Ada Programming
Ada Programming/Input Output
Ada Programming/Libraries
Ada Programming/Libraries/Ada
Ada Reference Manual
Ada 95
A 9 The Generic Package Storage_IO
Ada 2005
A 9 The Generic Package Storage_IO
Ada 2012
A 9 The Generic Package Storage_IO
Open-Source Implementations
a-storio.ads a-storio.adb
streams/a-storio.ads streams/a-storio.adb