OSDN Git Service

2001-12-11 David O'Brien <obrien@FreeBSD.org>
[pf3gnuchains/gcc-fork.git] / gcc / ada / a-sequio.ads
1 ------------------------------------------------------------------------------
2 --                                                                          --
3 --                         GNAT RUNTIME COMPONENTS                          --
4 --                                                                          --
5 --                    A D A . S E Q U E N T I A L _ I O                     --
6 --                                                                          --
7 --                                 S p e c                                  --
8 --                                                                          --
9 --                            $Revision: 1.10 $                             --
10 --                                                                          --
11 --          Copyright (C) 1992-1997 Free Software Foundation, Inc.          --
12 --                                                                          --
13 -- This specification is derived from the Ada Reference Manual for use with --
14 -- GNAT. The copyright notice above, and the license provisions that follow --
15 -- apply solely to the  contents of the part following the private keyword. --
16 --                                                                          --
17 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
18 -- terms of the  GNU General Public License as published  by the Free Soft- --
19 -- ware  Foundation;  either version 2,  or (at your option) any later ver- --
20 -- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
21 -- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
22 -- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
23 -- for  more details.  You should have  received  a copy of the GNU General --
24 -- Public License  distributed with GNAT;  see file COPYING.  If not, write --
25 -- to  the Free Software Foundation,  59 Temple Place - Suite 330,  Boston, --
26 -- MA 02111-1307, USA.                                                      --
27 --                                                                          --
28 -- As a special exception,  if other files  instantiate  generics from this --
29 -- unit, or you link  this unit with other files  to produce an executable, --
30 -- this  unit  does not  by itself cause  the resulting  executable  to  be --
31 -- covered  by the  GNU  General  Public  License.  This exception does not --
32 -- however invalidate  any other reasons why  the executable file  might be --
33 -- covered by the  GNU Public License.                                      --
34 --                                                                          --
35 -- GNAT was originally developed  by the GNAT team at  New York University. --
36 -- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). --
37 --                                                                          --
38 ------------------------------------------------------------------------------
39
40
41 with Ada.IO_Exceptions;
42 with System.Sequential_IO;
43
44 generic
45    type Element_Type (<>) is private;
46
47 package Ada.Sequential_IO is
48
49    type File_Type is limited private;
50
51    type File_Mode is (In_File, Out_File, Append_File);
52
53    --  The following representation clause allows the use of unchecked
54    --  conversion for rapid translation between the File_Mode type
55    --  used in this package and System.File_IO.
56
57    for File_Mode use
58      (In_File     => 0,  -- System.FIle_IO.File_Mode'Pos (In_File)
59       Out_File    => 2,  -- System.File_IO.File_Mode'Pos (Out_File)
60       Append_File => 3); -- System.File_IO.File_Mode'Pos (Append_File)
61
62    ---------------------
63    -- File management --
64    ---------------------
65
66    procedure Create
67      (File : in out File_Type;
68       Mode : in File_Mode := Out_File;
69       Name : in String := "";
70       Form : in String := "");
71
72    procedure Open
73      (File : in out File_Type;
74       Mode : in File_Mode;
75       Name : in String;
76       Form : in String := "");
77
78    procedure Close  (File : in out File_Type);
79    procedure Delete (File : in out File_Type);
80    procedure Reset  (File : in out File_Type; Mode : in File_Mode);
81    procedure Reset  (File : in out File_Type);
82
83    function Mode    (File : in File_Type) return File_Mode;
84    function Name    (File : in File_Type) return String;
85    function Form    (File : in File_Type) return String;
86
87    function Is_Open (File : in File_Type) return Boolean;
88
89    ---------------------------------
90    -- Input and output operations --
91    ---------------------------------
92
93    procedure Read  (File : in File_Type; Item : out Element_Type);
94    procedure Write (File : in File_Type; Item : in Element_Type);
95
96    function End_Of_File (File : in File_Type) return Boolean;
97
98    ----------------
99    -- Exceptions --
100    ----------------
101
102    Status_Error : exception renames IO_Exceptions.Status_Error;
103    Mode_Error   : exception renames IO_Exceptions.Mode_Error;
104    Name_Error   : exception renames IO_Exceptions.Name_Error;
105    Use_Error    : exception renames IO_Exceptions.Use_Error;
106    Device_Error : exception renames IO_Exceptions.Device_Error;
107    End_Error    : exception renames IO_Exceptions.End_Error;
108    Data_Error   : exception renames IO_Exceptions.Data_Error;
109
110 private
111    type File_Type is new System.Sequential_IO.File_Type;
112
113    --  All subprograms are inlined
114
115    pragma Inline (Close);
116    pragma Inline (Create);
117    pragma Inline (Delete);
118    pragma Inline (End_Of_File);
119    pragma Inline (Form);
120    pragma Inline (Is_Open);
121    pragma Inline (Mode);
122    pragma Inline (Name);
123    pragma Inline (Open);
124    pragma Inline (Read);
125    pragma Inline (Reset);
126    pragma Inline (Write);
127
128 end Ada.Sequential_IO;