1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 2001-2005 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
;
36 Ada_Main
: Boolean := True) return Name_Id
;
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 (Variable
: Variable_Value
;
45 Default
: String) return String;
46 -- Get the value of a single string variable. If Variable is
47 -- Nil_Variable_Value, is a string list or is defaulted, return Default.
51 In_Array
: Array_Element_Id
;
52 In_Tree
: Project_Tree_Ref
) return Name_Id
;
53 -- Get a single string array component. Returns No_Name if there is no
54 -- component Index, if In_Array is null, or if the component is a String
55 -- list. Depending on the attribute (only attributes may be associative
56 -- arrays) the index may or may not be case sensitive. If the index is not
57 -- case sensitive, it is first set to lower case before the search in the
63 In_Array
: Array_Element_Id
;
64 In_Tree
: Project_Tree_Ref
) return Variable_Value
;
65 -- Get a string array component (single String or String list).
66 -- Returns Nil_Variable_Value if there is no component Index
67 -- or if In_Array is null.
69 -- Depending on the attribute (only attributes may be associative arrays)
70 -- the index may or may not be case sensitive. If the index is not
71 -- case sensitive, it is first set to lower case before the search
72 -- in the associative array.
77 Attribute_Or_Array_Name
: Name_Id
;
78 In_Package
: Package_Id
;
79 In_Tree
: Project_Tree_Ref
) return Variable_Value
;
80 -- In a specific package,
81 -- - if there exists an array Attribute_Or_Array_Name with an index
82 -- Name, returns the corresponding component (depending on the
83 -- attribute, the index may or may not be case sensitive, see previous
85 -- - otherwise if there is a single attribute Attribute_Or_Array_Name,
86 -- returns this attribute,
87 -- - otherwise, returns Nil_Variable_Value.
88 -- If In_Package is null, returns Nil_Variable_Value.
94 In_Tree
: Project_Tree_Ref
) return Name_Id
;
95 -- Get a string array component in an array of an array list.
96 -- Returns No_Name if there is no component Index, if In_Arrays is null, if
97 -- In_Array is not found in In_Arrays or if the component is a String list.
101 In_Arrays
: Array_Id
;
102 In_Tree
: Project_Tree_Ref
) return Array_Element_Id
;
103 -- Returns a specified array in an array list. Returns No_Array_Element
104 -- if In_Arrays is null or if Name is not the name of an array in
105 -- In_Arrays. The caller must ensure that Name is in lower case.
109 In_Packages
: Package_Id
;
110 In_Tree
: Project_Tree_Ref
) return Package_Id
;
111 -- Returns a specified package in a package list. Returns No_Package
112 -- if In_Packages is null or if Name is not the name of a package in
113 -- Package_List. The caller must ensure that Name is in lower case.
116 (Variable_Name
: Name_Id
;
117 In_Variables
: Variable_Id
;
118 In_Tree
: Project_Tree_Ref
) return Variable_Value
;
119 -- Returns a specified variable in a variable list. Returns null if
120 -- In_Variables is null or if Variable_Name is not the name of a
121 -- variable in In_Variables. Caller must ensure that Name is lower case.
125 Max_Length
: Positive;
126 Separator
: Character);
127 -- Output string S using Output.Write_Str. If S is too long to fit in
128 -- one line of Max_Length, cut it in several lines, using Separator as
129 -- the last character of each line, if possible.
131 type Text_File
is limited private;
132 -- Represents a text file. Default is invalid text file.
134 function Is_Valid
(File
: Text_File
) return Boolean;
135 -- Returns True if File designates an open text file that
136 -- has not yet been closed.
138 procedure Open
(File
: out Text_File
; Name
: String);
139 -- Open a text file. If this procedure fails, File is invalid.
141 function End_Of_File
(File
: Text_File
) return Boolean;
142 -- Returns True if the end of the text file File has been
143 -- reached. Fails if File is invalid.
149 -- Reads a line from an open text file. Fails if File is invalid.
151 procedure Close
(File
: in out Text_File
);
152 -- Close an open text file. File becomes invalid.
153 -- Fails if File is already invalid.
157 type Text_File_Data
is record
158 FD
: File_Descriptor
:= Invalid_FD
;
159 Buffer
: String (1 .. 1_000
);
160 Buffer_Len
: Natural;
161 Cursor
: Natural := 0;
162 End_Of_File_Reached
: Boolean := False;
165 type Text_File
is access Text_File_Data
;