Merge -r 127928:132243 from trunk
[official-gcc.git] / gcc / ada / prj-util.ads
blob24c90aab529edc758f9d88cae35419134b7bd7e6
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- P R J . U T I L --
6 -- --
7 -- S p e c --
8 -- --
9 -- Copyright (C) 2001-2007, 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. 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 COPYING3. If not, go to --
19 -- http://www.gnu.org/licenses for a complete copy of the license. --
20 -- --
21 -- GNAT was originally developed by the GNAT team at New York University. --
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
23 -- --
24 ------------------------------------------------------------------------------
26 -- Utilities for use in processing project files
28 package Prj.Util is
30 function Executable_Of
31 (Project : Project_Id;
32 In_Tree : Project_Tree_Ref;
33 Main : File_Name_Type;
34 Index : Int;
35 Ada_Main : Boolean := True) return File_Name_Type;
36 -- Return the value of the attribute Builder'Executable for file Main in
37 -- the project Project, if it exists. If there is no attribute Executable
38 -- for Main, remove the suffix from Main; then, if the attribute
39 -- Executable_Suffix is specified, add this suffix, otherwise add the
40 -- standard executable suffix for the platform.
42 procedure Put
43 (Into_List : in out Name_List_Index;
44 From_List : String_List_Id;
45 In_Tree : Project_Tree_Ref);
46 -- Append a name list to a string list
48 procedure Duplicate
49 (This : in out Name_List_Index;
50 In_Tree : Project_Tree_Ref);
51 -- Duplicate a name list
53 function Value_Of
54 (Variable : Variable_Value;
55 Default : String) return String;
56 -- Get the value of a single string variable. If Variable is
57 -- Nil_Variable_Value, is a string list or is defaulted, return Default.
59 function Value_Of
60 (Index : Name_Id;
61 In_Array : Array_Element_Id;
62 In_Tree : Project_Tree_Ref) return Name_Id;
63 -- Get a single string array component. Returns No_Name if there is no
64 -- component Index, if In_Array is null, or if the component is a String
65 -- list. Depending on the attribute (only attributes may be associative
66 -- arrays) the index may or may not be case sensitive. If the index is not
67 -- case sensitive, it is first set to lower case before the search in the
68 -- associative array.
70 function Value_Of
71 (Index : Name_Id;
72 Src_Index : Int := 0;
73 In_Array : Array_Element_Id;
74 In_Tree : Project_Tree_Ref;
75 Force_Lower_Case_Index : Boolean := False) return Variable_Value;
76 -- Get a string array component (single String or String list). Returns
77 -- Nil_Variable_Value if no component Index or if In_Array is null.
79 -- Depending on the attribute (only attributes may be associative arrays)
80 -- the index may or may not be case sensitive. If the index is not case
81 -- sensitive, it is first set to lower case before the search in the
82 -- associative array.
84 function Value_Of
85 (Name : Name_Id;
86 Index : Int := 0;
87 Attribute_Or_Array_Name : Name_Id;
88 In_Package : Package_Id;
89 In_Tree : Project_Tree_Ref;
90 Force_Lower_Case_Index : Boolean := False) return Variable_Value;
91 -- In a specific package,
92 -- - if there exists an array Attribute_Or_Array_Name with an index Name,
93 -- returns the corresponding component (depending on the attribute, the
94 -- index may or may not be case sensitive, see previous function),
95 -- - otherwise if there is a single attribute Attribute_Or_Array_Name,
96 -- returns this attribute,
97 -- - otherwise, returns Nil_Variable_Value.
98 -- If In_Package is null, returns Nil_Variable_Value.
100 function Value_Of
101 (Index : Name_Id;
102 In_Array : Name_Id;
103 In_Arrays : Array_Id;
104 In_Tree : Project_Tree_Ref) return Name_Id;
105 -- Get a string array component in an array of an array list. Returns
106 -- No_Name if there is no component Index, if In_Arrays is null, if
107 -- In_Array is not found in In_Arrays or if the component is a String list.
109 function Value_Of
110 (Name : Name_Id;
111 In_Arrays : Array_Id;
112 In_Tree : Project_Tree_Ref) return Array_Element_Id;
113 -- Returns a specified array in an array list. Returns No_Array_Element
114 -- if In_Arrays is null or if Name is not the name of an array in
115 -- In_Arrays. The caller must ensure that Name is in lower case.
117 function Value_Of
118 (Name : Name_Id;
119 In_Packages : Package_Id;
120 In_Tree : Project_Tree_Ref) return Package_Id;
121 -- Returns a specified package in a package list. Returns No_Package if
122 -- In_Packages is null or if Name is not the name of a package in
123 -- Package_List. The caller must ensure that Name is in lower case.
125 function Value_Of
126 (Variable_Name : Name_Id;
127 In_Variables : Variable_Id;
128 In_Tree : Project_Tree_Ref) return Variable_Value;
129 -- Returns a specified variable in a variable list. Returns null if
130 -- In_Variables is null or if Variable_Name is not the name of a
131 -- variable in In_Variables. Caller must ensure that Name is lower case.
133 procedure Write_Str
134 (S : String;
135 Max_Length : Positive;
136 Separator : Character);
137 -- Output string S using Output.Write_Str. If S is too long to fit in
138 -- one line of Max_Length, cut it in several lines, using Separator as
139 -- the last character of each line, if possible.
141 type Text_File is limited private;
142 -- Represents a text file. Default is invalid text file
144 function Is_Valid (File : Text_File) return Boolean;
145 -- Returns True if File designates an open text file that
146 -- has not yet been closed.
148 procedure Open (File : out Text_File; Name : String);
149 -- Open a text file. If this procedure fails, File is invalid
151 function End_Of_File (File : Text_File) return Boolean;
152 -- Returns True if the end of the text file File has been reached. Fails if
153 -- File is invalid.
155 procedure Get_Line
156 (File : Text_File;
157 Line : out String;
158 Last : out Natural);
159 -- Reads a line from an open text file. Fails if File is invalid
161 procedure Close (File : in out Text_File);
162 -- Close an open text file. File becomes invalid. Fails if File is already
163 -- invalid.
165 private
167 type Text_File_Data is record
168 FD : File_Descriptor := Invalid_FD;
169 Buffer : String (1 .. 1_000);
170 Buffer_Len : Natural;
171 Cursor : Natural := 0;
172 End_Of_File_Reached : Boolean := False;
173 end record;
175 type Text_File is access Text_File_Data;
177 end Prj.Util;