1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 2001 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, 59 Temple Place - Suite 330, Boston, --
20 -- MA 02111-1307, 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 when using project files.
29 with GNAT
.OS_Lib
; use GNAT
.OS_Lib
;
30 with Types
; use Types
;
35 (Variable
: Variable_Value
;
38 -- Get the value of a single string variable. If Variable is
39 -- Nil_Variable_Value, is a string list or is defaulted, return Default.
43 In_Array
: Array_Element_Id
)
45 -- Get a single string array component.
46 -- Returns No_Name if there is no component Index (case sensitive),
47 -- if In_Array is null, or if the component is a String list.
51 In_Array
: Array_Element_Id
)
52 return Variable_Value
;
53 -- Get a string array component (single String or String list).
54 -- Returns Nil_Variable_Value if there is no component Index
55 -- (case sensitive), or if In_Array is null.
59 Attribute_Or_Array_Name
: Name_Id
;
60 In_Package
: Package_Id
)
61 return Variable_Value
;
62 -- In a specific package,
63 -- - if there exists an array Variable_Or_Array_Name with an index
64 -- Name, returns the corresponding component,
65 -- - otherwise if there is a attribute Attribute_Or_Array_Name,
66 -- returns this attribute,
67 -- - otherwise, returns Nil_Variable_Value.
68 -- If In_Package is null, returns Nil_Variable_Value.
75 -- Get a string array component in an array of an array list.
76 -- Returns No_Name if there is no component Index (case sensitive),
77 -- if In_Arrays is null, if In_Array is not found in In_Arrays,
78 -- or if the component is a String list.
83 return Array_Element_Id
;
84 -- Returns a specified array in an array list. Returns No_Array_Element
85 -- if In_Arrays is null or if Name is not the name of an array in
86 -- In_Arrays. The caller must ensure that Name is in lower case.
90 In_Packages
: Package_Id
)
92 -- Returns a specified package in a package list. Returns No_Package
93 -- if In_Packages is null or if Name is not the name of a package in
94 -- Package_List. The caller must ensure that Name is in lower case.
97 (Variable_Name
: Name_Id
;
98 In_Variables
: Variable_Id
)
99 return Variable_Value
;
100 -- Returns a specified variable in a variable list. Returns null if
101 -- In_Variables is null or if Variable_Name is not the name of a
102 -- variable in In_Variables. Caller must ensure that Name is lower case.
106 Max_Length
: Positive;
107 Separator
: Character);
108 -- Output string S using Output.Write_Str. If S is too long to fit in
109 -- one line of Max_Length, cut it in several lines, using Separator as
110 -- the last character of each line, if possible.
112 type Text_File
is limited private;
113 -- Represents a text file. Default is invalid text file.
115 function Is_Valid
(File
: Text_File
) return Boolean;
116 -- Returns True if File designates an open text file that
117 -- has not yet been closed.
119 procedure Open
(File
: out Text_File
; Name
: String);
120 -- Open a text file. If this procedure fails, File is invalid.
122 function End_Of_File
(File
: Text_File
) return Boolean;
123 -- Returns True if the end of the text file File has been
124 -- reached. Fails if File is invalid.
130 -- Reads a line from an open text file. Fails if File is invalid.
132 procedure Close
(File
: in out Text_File
);
133 -- Close an open text file. File becomes invalid.
134 -- Fails if File is already invalid.
138 type Text_File_Data
is record
139 FD
: File_Descriptor
:= Invalid_FD
;
140 Buffer
: String (1 .. 1_000
);
141 Buffer_Len
: Natural;
142 Cursor
: Natural := 0;
143 End_Of_File_Reached
: Boolean := False;
146 type Text_File
is access Text_File_Data
;