1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 2001-2007, Free Software Foundation, Inc. --
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 2, 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. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNAT; see file COPYING. If not, write --
19 -- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
20 -- Boston, MA 02110-1301, USA. --
22 -- GNAT was originally developed by the GNAT team at New York University. --
23 -- Extensive contributions were provided by Ada Core Technologies Inc. --
25 ------------------------------------------------------------------------------
27 -- Utilities for use in processing project files
31 function Executable_Of
32 (Project : Project_Id;
33 In_Tree : Project_Tree_Ref;
34 Main : File_Name_Type;
36 Ada_Main : Boolean := True) return File_Name_Type;
37 -- Return the value of the attribute Builder'Executable for file Main in
38 -- the project Project, if it exists. If there is no attribute Executable
39 -- for Main, remove the suffix from Main; then, if the attribute
40 -- Executable_Suffix is specified, add this suffix, otherwise add the
41 -- standard executable suffix for the platform.
44 (Into_List : in out Name_List_Index;
45 From_List : String_List_Id;
46 In_Tree : Project_Tree_Ref);
47 -- Append a name list to a string list
50 (This : in out Name_List_Index;
51 In_Tree : Project_Tree_Ref);
52 -- Duplicate a name list
55 (Variable : Variable_Value;
56 Default : String) return String;
57 -- Get the value of a single string variable. If Variable is
58 -- Nil_Variable_Value, is a string list or is defaulted, return Default.
62 In_Array : Array_Element_Id;
63 In_Tree : Project_Tree_Ref) return Name_Id;
64 -- Get a single string array component. Returns No_Name if there is no
65 -- component Index, if In_Array is null, or if the component is a String
66 -- list. Depending on the attribute (only attributes may be associative
67 -- arrays) the index may or may not be case sensitive. If the index is not
68 -- case sensitive, it is first set to lower case before the search in the
74 In_Array : Array_Element_Id;
75 In_Tree : Project_Tree_Ref;
76 Force_Lower_Case_Index : Boolean := False) return Variable_Value;
77 -- Get a string array component (single String or String list). Returns
78 -- Nil_Variable_Value if no component Index or if In_Array is null.
80 -- Depending on the attribute (only attributes may be associative arrays)
81 -- the index may or may not be case sensitive. If the index is not case
82 -- sensitive, it is first set to lower case before the search in the
88 Attribute_Or_Array_Name : Name_Id;
89 In_Package : Package_Id;
90 In_Tree : Project_Tree_Ref;
91 Force_Lower_Case_Index : Boolean := False) return Variable_Value;
92 -- In a specific package,
93 -- - if there exists an array Attribute_Or_Array_Name with an index Name,
94 -- returns the corresponding component (depending on the attribute, the
95 -- index may or may not be case sensitive, see previous function),
96 -- - otherwise if there is a single attribute Attribute_Or_Array_Name,
97 -- returns this attribute,
98 -- - otherwise, returns Nil_Variable_Value.
99 -- If In_Package is null, returns Nil_Variable_Value.
104 In_Arrays : Array_Id;
105 In_Tree : Project_Tree_Ref) return Name_Id;
106 -- Get a string array component in an array of an array list. Returns
107 -- No_Name if there is no component Index, if In_Arrays is null, if
108 -- In_Array is not found in In_Arrays or if the component is a String list.
112 In_Arrays : Array_Id;
113 In_Tree : Project_Tree_Ref) return Array_Element_Id;
114 -- Returns a specified array in an array list. Returns No_Array_Element
115 -- if In_Arrays is null or if Name is not the name of an array in
116 -- In_Arrays. The caller must ensure that Name is in lower case.
120 In_Packages : Package_Id;
121 In_Tree : Project_Tree_Ref) return Package_Id;
122 -- Returns a specified package in a package list. Returns No_Package if
123 -- In_Packages is null or if Name is not the name of a package in
124 -- Package_List. The caller must ensure that Name is in lower case.
127 (Variable_Name : Name_Id;
128 In_Variables : Variable_Id;
129 In_Tree : Project_Tree_Ref) return Variable_Value;
130 -- Returns a specified variable in a variable list. Returns null if
131 -- In_Variables is null or if Variable_Name is not the name of a
132 -- variable in In_Variables. Caller must ensure that Name is lower case.
136 Max_Length : Positive;
137 Separator : Character);
138 -- Output string S using Output.Write_Str. If S is too long to fit in
139 -- one line of Max_Length, cut it in several lines, using Separator as
140 -- the last character of each line, if possible.
142 type Text_File is limited private;
143 -- Represents a text file. Default is invalid text file
145 function Is_Valid (File : Text_File) return Boolean;
146 -- Returns True if File designates an open text file that
147 -- has not yet been closed.
149 procedure Open (File : out Text_File; Name : String);
150 -- Open a text file. If this procedure fails, File is invalid
152 function End_Of_File (File : Text_File) return Boolean;
153 -- Returns True if the end of the text file File has been reached. Fails if
160 -- Reads a line from an open text file. Fails if File is invalid
162 procedure Close (File : in out Text_File);
163 -- Close an open text file. File becomes invalid. Fails if File is already
168 type Text_File_Data is record
169 FD : File_Descriptor := Invalid_FD;
170 Buffer : String (1 .. 1_000);
171 Buffer_Len : Natural;
172 Cursor : Natural := 0;
173 End_Of_File_Reached : Boolean := False;
176 type Text_File is access Text_File_Data;