跳轉至內容

Ada 程式設計/庫/Ada.Storage_IO

來自華夏公益教科書,開放的書籍,面向開放的世界

Ada. Time-tested, safe and secure.
Ada. 經得起時間考驗,安全可靠。

此語言功能從 Ada 95 開始可用。

Ada.Storage_IO預定義語言環境 自 Ada 95 以來的一部分。

Ada.Storage_IO 不是通用的 輸入/輸出 包。根據 A.9: 泛型包 Storage_IO [註釋](1),它被設計用於構建使用者定義的輸入輸出包,但也可用於將元素從一個 任務 傳輸到另一個任務。注意: 語言定義的任何 IO 包都不是任務安全的。

它允許您將 *一個* 元素儲存在記憶體緩衝區中。該元素需要是 確定子型別

小心: 當讀取的值無法解釋為子型別 Element_Type 的值時,不一定呼叫異常 Data_Error(您必須按照 RM 中給出的多個引用來遵循 A.13: 輸入輸出中的異常 [註釋]),這可能導致錯誤執行; 尤其是在從未寫入值的情況下可能會發生這種情況。在不確定時使用 'Valid 屬性

 --                     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 System.Storage_Elements.Storage_Count
     := implementation_defined;

   subtype Buffer_Type is
     System.Storage_Elements.Storage_Array (1 .. 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_Exceptions.Data_Error;

end Ada.Storage_IO;

華夏公益教科書

[編輯 | 編輯原始碼]

外部示例

[編輯原始碼]

Ada 參考手冊

[編輯 | 編輯原始碼]

開源實現

[編輯 | 編輯原始碼]

FSF GNAT

drake

華夏公益教科書