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