1------------------------------------------------------------------------------ 2-- -- 3-- GNAT RUN-TIME COMPONENTS -- 4-- -- 5-- A D A . W I D E _ 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-2018, 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------------------------------------------------------------------------------ 31 32-- This package contains a set of auxiliary routines used by Wide_Text_IO 33-- generic children, including for reading and writing numeric strings. 34 35-- Note: although this is the Wide version of the package, the interface 36-- here is still in terms of Character and String rather than Wide_Character 37-- and Wide_String, since all numeric strings are composed entirely of 38-- characters in the range of type Standard.Character, and the basic 39-- conversion routines work with Character rather than Wide_Character. 40 41package Ada.Wide_Text_IO.Generic_Aux is 42 43 -- Note: for all the Load routines, File indicates the file to be read, 44 -- Buf is the string into which data is stored, Ptr is the index of the 45 -- last character stored so far, and is updated if additional characters 46 -- are stored. Data_Error is raised if the input overflows Buf. The only 47 -- Load routines that do a file status check are Load_Skip and Load_Width 48 -- so one of these two routines must be called first. 49 50 procedure Check_End_Of_Field 51 (Buf : String; 52 Stop : Integer; 53 Ptr : Integer; 54 Width : Field); 55 -- This routine is used after doing a get operations on a numeric value. 56 -- Buf is the string being scanned, and Stop is the last character of 57 -- the field being scanned. Ptr is as set by the call to the scan routine 58 -- that scanned out the numeric value, i.e. it points one past the last 59 -- character scanned, and Width is the width parameter from the Get call. 60 -- 61 -- There are two cases, if Width is non-zero, then a check is made that 62 -- the remainder of the field is all blanks. If Width is zero, then it 63 -- means that the scan routine scanned out only part of the field. We 64 -- have already scanned out the field that the ACVC tests seem to expect 65 -- us to read (even if it does not follow the syntax of the type being 66 -- scanned, e.g. allowing negative exponents in integers, and underscores 67 -- at the end of the string), so we just raise Data_Error. 68 69 procedure Check_On_One_Line (File : File_Type; Length : Integer); 70 -- Check to see if item of length Integer characters can fit on 71 -- current line. Call New_Line if not, first checking that the 72 -- line length can accommodate Length characters, raise Layout_Error 73 -- if item is too large for a single line. 74 75 function Is_Blank (C : Character) return Boolean; 76 -- Determines if C is a blank (space or tab) 77 78 procedure Load_Width 79 (File : File_Type; 80 Width : Field; 81 Buf : out String; 82 Ptr : in out Integer); 83 -- Loads exactly Width characters, unless a line mark is encountered first 84 85 procedure Load_Skip (File : File_Type); 86 -- Skips leading blanks and line and page marks, if the end of file is 87 -- read without finding a non-blank character, then End_Error is raised. 88 -- Note: a blank is defined as a space or horizontal tab (RM A.10.6(5)). 89 90 procedure Load 91 (File : File_Type; 92 Buf : out String; 93 Ptr : in out Integer; 94 Char : Character; 95 Loaded : out Boolean); 96 -- If next character is Char, loads it, otherwise no characters are loaded 97 -- Loaded is set to indicate whether or not the character was found. 98 99 procedure Load 100 (File : File_Type; 101 Buf : out String; 102 Ptr : in out Integer; 103 Char : Character); 104 -- Same as above, but no indication if character is loaded 105 106 procedure Load 107 (File : File_Type; 108 Buf : out String; 109 Ptr : in out Integer; 110 Char1 : Character; 111 Char2 : Character; 112 Loaded : out Boolean); 113 -- If next character is Char1 or Char2, loads it, otherwise no characters 114 -- are loaded. Loaded is set to indicate whether or not one of the two 115 -- characters was found. 116 117 procedure Load 118 (File : File_Type; 119 Buf : out String; 120 Ptr : in out Integer; 121 Char1 : Character; 122 Char2 : Character); 123 -- Same as above, but no indication if character is loaded 124 125 procedure Load_Digits 126 (File : File_Type; 127 Buf : out String; 128 Ptr : in out Integer; 129 Loaded : out Boolean); 130 -- Loads a sequence of zero or more decimal digits. Loaded is set if 131 -- at least one digit is loaded. 132 133 procedure Load_Digits 134 (File : File_Type; 135 Buf : out String; 136 Ptr : in out Integer); 137 -- Same as above, but no indication if character is loaded 138 139 procedure Load_Extended_Digits 140 (File : File_Type; 141 Buf : out String; 142 Ptr : in out Integer; 143 Loaded : out Boolean); 144 -- Like Load_Digits, but also allows extended digits a-f and A-F 145 146 procedure Load_Extended_Digits 147 (File : File_Type; 148 Buf : out String; 149 Ptr : in out Integer); 150 -- Same as above, but no indication if character is loaded 151 152 procedure Put_Item (File : File_Type; Str : String); 153 -- This routine is like Wide_Text_IO.Put, except that it checks for 154 -- overflow of bounded lines, as described in (RM A.10.6(8)). It is used 155 -- for all output of numeric values and of enumeration values. Note that 156 -- the buffer is of type String. Put_Item deals with converting this to 157 -- Wide_Characters as required. 158 159 procedure Store_Char 160 (File : File_Type; 161 ch : Integer; 162 Buf : out String; 163 Ptr : in out Integer); 164 -- Store a single character in buffer, checking for overflow and 165 -- adjusting the column number in the file to reflect the fact 166 -- that a character has been acquired from the input stream. 167 -- The pos value of the character to store is in ch on entry. 168 169 procedure String_Skip (Str : String; Ptr : out Integer); 170 -- Used in the Get from string procedures to skip leading blanks in the 171 -- string. Ptr is set to the index of the first non-blank. If the string 172 -- is all blanks, then the excption End_Error is raised, Note that blank 173 -- is defined as a space or horizontal tab (RM A.10.6(5)). 174 175 procedure Ungetc (ch : Integer; File : File_Type); 176 -- Pushes back character into stream, using ungetc. The caller has 177 -- checked that the file is in read status. Device_Error is raised 178 -- if the character cannot be pushed back. An attempt to push back 179 -- an end of file (EOF) is ignored. 180 181private 182 pragma Inline (Is_Blank); 183 184end Ada.Wide_Text_IO.Generic_Aux; 185