Ada Programming/Libraries/Ada.Storage IO
This language feature is available from Ada 95 on.Category:Book:Ada Programming/Ada 95 feature#Ada.Storage IO Ada.Storage_IO is a unit of the Predefined Language Environment since Ada 95.
Category:Book:Ada Programming/Unfinished module#Ada.Storage%20IODescription
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
-- 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.Category:Book:Ada Programming/Pages containing deprecated templatesStorage_Elements.Category:Book:Ada Programming/Pages containing deprecated templatesStorage_Count := implementation_defined;subtype
Buffer_Typeis
System.Category:Book:Ada Programming/Pages containing deprecated templatesStorage_Elements.Category:Book:Ada Programming/Pages containing deprecated templatesStorage_Array (1 ..Category:Book:Ada Programming/Pages containing deprecated templates 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.Category:Book:Ada Programming/Pages containing deprecated templatesData_Error;end
Ada.Category:Book:Ada Programming/Pages containing deprecated templatesStorage_IO;
See also
Wikibook
External examples
- 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
Ada 95
Ada 2005
Ada 2012
Open-Source Implementations
FSF GNAT
- Specification: a-storio.ads
- Body: a-storio.adb
drake
- Specification: streams/a-storio.ads
- Body: streams/a-storio.adb