gcc/
[official-gcc.git] / gcc / ada / a-tigeau.ads
blob4de4739dcbe0ff3664641689063548d4ac16e730
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT RUN-TIME COMPONENTS --
4 -- --
5 -- A D A . T E X T _ I O . G E N E R I C _ A U X --
6 -- --
7 -- S p e c --
8 -- --
9 -- Copyright (C) 1992-2009, Free Software Foundation, Inc. --
10 -- --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. --
17 -- --
18 -- As a special exception under Section 7 of GPL version 3, you are granted --
19 -- additional permissions described in the GCC Runtime Library Exception, --
20 -- version 3.1, as published by the Free Software Foundation. --
21 -- --
22 -- You should have received a copy of the GNU General Public License and --
23 -- a copy of the GCC Runtime Library Exception along with this program; --
24 -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
25 -- <http://www.gnu.org/licenses/>. --
26 -- --
27 -- GNAT was originally developed by the GNAT team at New York University. --
28 -- Extensive contributions were provided by Ada Core Technologies Inc. --
29 -- --
30 ------------------------------------------------------------------------------
32 -- This package contains a set of auxiliary routines used by the Text_IO
33 -- generic children, including for reading and writing numeric strings.
35 private package Ada.Text_IO.Generic_Aux is
37 -- Note: for all the Load routines, File indicates the file to be read,
38 -- Buf is the string into which data is stored, Ptr is the index of the
39 -- last character stored so far, and is updated if additional characters
40 -- are stored. Data_Error is raised if the input overflows Buf. The only
41 -- Load routines that do a file status check are Load_Skip and Load_Width
42 -- so one of these two routines must be called first.
44 procedure Check_End_Of_Field
45 (Buf : String;
46 Stop : Integer;
47 Ptr : Integer;
48 Width : Field);
49 -- This routine is used after doing a get operations on a numeric value.
50 -- Buf is the string being scanned, and Stop is the last character of
51 -- the field being scanned. Ptr is as set by the call to the scan routine
52 -- that scanned out the numeric value, i.e. it points one past the last
53 -- character scanned, and Width is the width parameter from the Get call.
55 -- There are two cases, if Width is non-zero, then a check is made that
56 -- the remainder of the field is all blanks. If Width is zero, then it
57 -- means that the scan routine scanned out only part of the field. We
58 -- have already scanned out the field that the ACVC tests seem to expect
59 -- us to read (even if it does not follow the syntax of the type being
60 -- scanned, e.g. allowing negative exponents in integers, and underscores
61 -- at the end of the string), so we just raise Data_Error.
63 procedure Check_On_One_Line (File : File_Type; Length : Integer);
64 -- Check to see if item of length Integer characters can fit on
65 -- current line. Call New_Line if not, first checking that the
66 -- line length can accommodate Length characters, raise Layout_Error
67 -- if item is too large for a single line.
69 function Getc (File : File_Type) return Integer;
70 -- Gets next character from file, which has already been checked for
71 -- being in read status, and returns the character read if no error
72 -- occurs. The result is EOF if the end of file was read. Note that
73 -- the Col value is not bumped, so it is the caller's responsibility
74 -- to bump it if necessary.
76 function Is_Blank (C : Character) return Boolean;
77 -- Determines if C is a blank (space or tab)
79 procedure Load_Width
80 (File : File_Type;
81 Width : Field;
82 Buf : out String;
83 Ptr : in out Integer);
84 -- Loads exactly Width characters, unless a line mark is encountered first
86 procedure Load_Skip (File : File_Type);
87 -- Skips leading blanks and line and page marks, if the end of file is
88 -- read without finding a non-blank character, then End_Error is raised.
89 -- Note: a blank is defined as a space or horizontal tab (RM A.10.6(5)).
91 procedure Load
92 (File : File_Type;
93 Buf : out String;
94 Ptr : in out Integer;
95 Char : Character;
96 Loaded : out Boolean);
97 -- If next character is Char, loads it, otherwise no characters are loaded
98 -- Loaded is set to indicate whether or not the character was found.
100 procedure Load
101 (File : File_Type;
102 Buf : out String;
103 Ptr : in out Integer;
104 Char : Character);
105 -- Same as above, but no indication if character is loaded
107 procedure Load
108 (File : File_Type;
109 Buf : out String;
110 Ptr : in out Integer;
111 Char1 : Character;
112 Char2 : Character;
113 Loaded : out Boolean);
114 -- If next character is Char1 or Char2, loads it, otherwise no characters
115 -- are loaded. Loaded is set to indicate whether or not one of the two
116 -- characters was found.
118 procedure Load
119 (File : File_Type;
120 Buf : out String;
121 Ptr : in out Integer;
122 Char1 : Character;
123 Char2 : Character);
124 -- Same as above, but no indication if character is loaded
126 procedure Load_Digits
127 (File : File_Type;
128 Buf : out String;
129 Ptr : in out Integer;
130 Loaded : out Boolean);
131 -- Loads a sequence of zero or more decimal digits. Loaded is set if
132 -- at least one digit is loaded.
134 procedure Load_Digits
135 (File : File_Type;
136 Buf : out String;
137 Ptr : in out Integer);
138 -- Same as above, but no indication if character is loaded
140 procedure Load_Extended_Digits
141 (File : File_Type;
142 Buf : out String;
143 Ptr : in out Integer;
144 Loaded : out Boolean);
145 -- Like Load_Digits, but also allows extended digits a-f and A-F
147 procedure Load_Extended_Digits
148 (File : File_Type;
149 Buf : out String;
150 Ptr : in out Integer);
151 -- Same as above, but no indication if character is loaded
153 function Nextc (File : File_Type) return Integer;
154 -- Like Getc, but includes a call to Ungetc, so that the file
155 -- pointer is not moved by the call.
157 procedure Put_Item (File : File_Type; Str : String);
158 -- This routine is like Text_IO.Put, except that it checks for overflow
159 -- of bounded lines, as described in (RM A.10.6(8)). It is used for
160 -- all output of numeric values and of enumeration values.
162 procedure Store_Char
163 (File : File_Type;
164 ch : Integer;
165 Buf : in out String;
166 Ptr : in out Integer);
167 -- Store a single character in buffer, checking for overflow and
168 -- adjusting the column number in the file to reflect the fact
169 -- that a character has been acquired from the input stream. If
170 -- the character will not fit in the buffer it is stored in the
171 -- last character position of the buffer and Ptr is unchanged.
172 -- No exception is raised in this case, it is the caller's job
173 -- to raise Data_Error if the buffer fills up, so typically the
174 -- caller will make the buffer one character longer than needed.
176 procedure String_Skip (Str : String; Ptr : out Integer);
177 -- Used in the Get from string procedures to skip leading blanks in the
178 -- string. Ptr is set to the index of the first non-blank. If the string
179 -- is all blanks, then the exception End_Error is raised, Note that blank
180 -- is defined as a space or horizontal tab (RM A.10.6(5)).
182 procedure Ungetc (ch : Integer; File : File_Type);
183 -- Pushes back character into stream, using ungetc. The caller has
184 -- checked that the file is in read status. Device_Error is raised
185 -- if the character cannot be pushed back. An attempt to push back
186 -- an end of file (EOF) is ignored.
188 private
189 pragma Inline (Is_Blank);
191 end Ada.Text_IO.Generic_Aux;