Ada Programming/Libraries/Ada.Storage_IO
This language feature is available from Ada 95 on.
Ada.Storage_IO is a unit of the Predefined Language Environment since Ada 95.
Description
[edit | edit source]Ada.Storage_IO is not a general-purpose Input/Output package. According to A.9: The Generic Package Storage_IO [Annotated](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 [Annotated]), 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
[edit | edit source]-- 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_Typeis
private
;package
Ada.Storage_IOis
pragma
Preelaborate (Storage_IO); Buffer_Size :constant
System.Storage_Elements.Storage_Count := implementation_defined;subtype
Buffer_Typeis
System.Storage_Elements.Storage_Array (1 .. Buffer_Size); -- Input and output operationsprocedure
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_Exceptions.Data_Error;end
Ada.Storage_IO;
See also
[edit | edit source]Wikibook
[edit | edit source]- Ada Programming
- Ada Programming/Input Output
- Ada Programming/Libraries
- Ada Programming/Libraries/Ada
External examples
[edit source]- Search for examples of
Ada.Storage_IO
in: Rosetta Code, GitHub (gists), any Alire crate or this Wikibook. - Search for posts related to
Ada.Storage_IO
in: Stack Overflow, comp.lang.ada or any Ada related page.
Ada Reference Manual
[edit | edit source]Ada 95
[edit | edit source]Ada 2005
[edit | edit source]Ada 2012
[edit | edit source]Open-Source Implementations
[edit | edit source]FSF GNAT
- Specification: a-storio.ads
- Body: a-storio.adb
drake
- Specification: streams/a-storio.ads
- Body: streams/a-storio.adb