1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
11 -- Copyright (C) 2001 Free Software Foundation, Inc. --
13 -- GNAT is free software; you can redistribute it and/or modify it under --
14 -- terms of the GNU General Public License as published by the Free Soft- --
15 -- ware Foundation; either version 2, or (at your option) any later ver- --
16 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
17 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
18 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
19 -- for more details. You should have received a copy of the GNU General --
20 -- Public License distributed with GNAT; see file COPYING. If not, write --
21 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
22 -- MA 02111-1307, USA. --
24 -- GNAT was originally developed by the GNAT team at New York University. --
25 -- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). --
27 ------------------------------------------------------------------------------
29 -- Utilities when using project files.
31 with GNAT.OS_Lib; use GNAT.OS_Lib;
32 with Types; use Types;
37 (Variable : Variable_Value;
40 -- Get the value of a single string variable. If Variable is
41 -- Nil_Variable_Value, is a string list or is defaulted, return Default.
45 In_Array : Array_Element_Id)
47 -- Get a single string array component.
48 -- Returns No_Name if there is no component Index (case sensitive),
49 -- if In_Array is null, or if the component is a String list.
53 In_Array : Array_Element_Id)
54 return Variable_Value;
55 -- Get a string array component (single String or String list).
56 -- Returns Nil_Variable_Value if there is no component Index
57 -- (case sensitive), or if In_Array is null.
61 Attribute_Or_Array_Name : Name_Id;
62 In_Package : Package_Id)
63 return Variable_Value;
64 -- In a specific package,
65 -- - if there exists an array Variable_Or_Array_Name with an index
66 -- Name, returns the corresponding component,
67 -- - otherwise if there is a attribute Attribute_Or_Array_Name,
68 -- returns this attribute,
69 -- - otherwise, returns Nil_Variable_Value.
70 -- If In_Package is null, returns Nil_Variable_Value.
77 -- Get a string array component in an array of an array list.
78 -- Returns No_Name if there is no component Index (case sensitive),
79 -- if In_Arrays is null, if In_Array is not found in In_Arrays,
80 -- or if the component is a String list.
85 return Array_Element_Id;
86 -- Returns a specified array in an array list. Returns No_Array_Element
87 -- if In_Arrays is null or if Name is not the name of an array in
88 -- In_Arrays. The caller must ensure that Name is in lower case.
92 In_Packages : Package_Id)
94 -- Returns a specified package in a package list. Returns No_Package
95 -- if In_Packages is null or if Name is not the name of a package in
96 -- Package_List. The caller must ensure that Name is in lower case.
99 (Variable_Name : Name_Id;
100 In_Variables : Variable_Id)
101 return Variable_Value;
102 -- Returns a specified variable in a variable list. Returns null if
103 -- In_Variables is null or if Variable_Name is not the name of a
104 -- variable in In_Variables. Caller must ensure that Name is lower case.
108 Max_Length : Positive;
109 Separator : Character);
110 -- Output string S using Output.Write_Str. If S is too long to fit in
111 -- one line of Max_Length, cut it in several lines, using Separator as
112 -- the last character of each line, if possible.
114 type Text_File is limited private;
115 -- Represents a text file. Default is invalid text file.
117 function Is_Valid (File : Text_File) return Boolean;
118 -- Returns True if File designates an open text file that
119 -- has not yet been closed.
121 procedure Open (File : out Text_File; Name : String);
122 -- Open a text file. If this procedure fails, File is invalid.
124 function End_Of_File (File : Text_File) return Boolean;
125 -- Returns True if the end of the text file File has been
126 -- reached. Fails if File is invalid.
132 -- Reads a line from an open text file. Fails if File is invalid.
134 procedure Close (File : in out Text_File);
135 -- Close an open text file. File becomes invalid.
136 -- Fails if File is already invalid.
140 type Text_File_Data is record
141 FD : File_Descriptor := Invalid_FD;
142 Buffer : String (1 .. 1_000);
143 Buffer_Len : Natural;
144 Cursor : Natural := 0;
145 End_Of_File_Reached : Boolean := False;
148 type Text_File is access Text_File_Data;