OSDN Git Service

* 41intnam.ads, 42intnam.ads, 4aintnam.ads, 4cintnam.ads,
[pf3gnuchains/gcc-fork.git] / gcc / ada / prj-util.ads
1 ------------------------------------------------------------------------------
2 --                                                                          --
3 --                         GNAT COMPILER COMPONENTS                         --
4 --                                                                          --
5 --                              P R J . U T I L                             --
6 --                                                                          --
7 --                                 S p e c                                  --
8 --                                                                          --
9 --                            $Revision$
10 --                                                                          --
11 --             Copyright (C) 2001 Free Software Foundation, Inc.            --
12 --                                                                          --
13 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
14 -- terms of the  GNU General Public License as published  by the Free Soft- --
15 -- ware  Foundation;  either version 2,  or (at your option) any later ver- --
16 -- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
17 -- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
18 -- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
19 -- for  more details.  You should have  received  a copy of the GNU General --
20 -- Public License  distributed with GNAT;  see file COPYING.  If not, write --
21 -- to  the Free Software Foundation,  59 Temple Place - Suite 330,  Boston, --
22 -- MA 02111-1307, USA.                                                      --
23 --                                                                          --
24 -- GNAT was originally developed  by the GNAT team at  New York University. --
25 -- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). --
26 --                                                                          --
27 ------------------------------------------------------------------------------
28 --
29 --  Utilities when using project files.
30
31 with GNAT.OS_Lib; use GNAT.OS_Lib;
32 with Types;       use Types;
33
34 package Prj.Util is
35
36    function Value_Of
37      (Variable : Variable_Value;
38       Default  : String)
39       return     String;
40    --  Get the value of a single string variable. If Variable is
41    --  Nil_Variable_Value, is a string list or is defaulted, return Default.
42
43    function Value_Of
44      (Index    : Name_Id;
45       In_Array : Array_Element_Id)
46       return     Name_Id;
47    --  Get a single string array component.
48    --  Returns No_Name if there is no component Index (case sensitive),
49    --  if In_Array is null, or if the component is a String list.
50
51    function Value_Of
52      (Index    : Name_Id;
53       In_Array : Array_Element_Id)
54       return     Variable_Value;
55    --  Get a string array component (single String or String list).
56    --  Returns Nil_Variable_Value if there is no component Index
57    --  (case sensitive), or if In_Array is null.
58
59    function Value_Of
60      (Name                    : Name_Id;
61       Attribute_Or_Array_Name : Name_Id;
62       In_Package              : Package_Id)
63       return                    Variable_Value;
64    --  In a specific package,
65    --   - if there exists an array Variable_Or_Array_Name with an index
66    --     Name, returns the corresponding component,
67    --   - otherwise if there is a attribute Attribute_Or_Array_Name,
68    --     returns this attribute,
69    --   - otherwise, returns Nil_Variable_Value.
70    --  If In_Package is null, returns Nil_Variable_Value.
71
72    function Value_Of
73      (Index     : Name_Id;
74       In_Array  : Name_Id;
75       In_Arrays : Array_Id)
76       return      Name_Id;
77    --  Get a string array component in an array of an array list.
78    --  Returns No_Name if there is no component Index (case sensitive),
79    --  if In_Arrays is null, if In_Array is not found in In_Arrays,
80    --  or if the component is a String list.
81
82    function Value_Of
83      (Name      : Name_Id;
84       In_Arrays : Array_Id)
85       return      Array_Element_Id;
86    --  Returns a specified array in an array list. Returns No_Array_Element
87    --  if In_Arrays is null or if Name is not the name of an array in
88    --  In_Arrays. The caller must ensure that Name is in lower case.
89
90    function Value_Of
91      (Name        : Name_Id;
92       In_Packages : Package_Id)
93       return        Package_Id;
94    --  Returns a specified package in a package list. Returns No_Package
95    --  if In_Packages is null or if Name is not the name of a package in
96    --  Package_List. The caller must ensure that Name is in lower case.
97
98    function Value_Of
99      (Variable_Name : Name_Id;
100       In_Variables  : Variable_Id)
101       return          Variable_Value;
102    --  Returns a specified variable in a variable list. Returns null if
103    --  In_Variables is null or if Variable_Name is not the name of a
104    --  variable in In_Variables. Caller must ensure that Name is lower case.
105
106    procedure Write_Str
107      (S          : String;
108       Max_Length : Positive;
109       Separator  : Character);
110    --  Output string S using Output.Write_Str. If S is too long to fit in
111    --  one line of Max_Length, cut it in several lines, using Separator as
112    --  the last character of each line, if possible.
113
114    type Text_File is limited private;
115    --  Represents a text file. Default is invalid text file.
116
117    function Is_Valid (File : Text_File) return Boolean;
118    --  Returns True if File designates an open text file that
119    --  has not yet been closed.
120
121    procedure Open (File : out Text_File; Name : String);
122    --  Open a text file. If this procedure fails, File is invalid.
123
124    function End_Of_File (File : Text_File) return Boolean;
125    --  Returns True if the end of the text file File has been
126    --  reached. Fails if File is invalid.
127
128    procedure Get_Line
129      (File : Text_File;
130       Line : out String;
131       Last : out Natural);
132    --  Reads a line from an open text file. Fails if File is invalid.
133
134    procedure Close (File : in out Text_File);
135    --  Close an open text file. File becomes invalid.
136    --  Fails if File is already invalid.
137
138 private
139
140    type Text_File_Data is record
141       FD                  : File_Descriptor := Invalid_FD;
142       Buffer              : String (1 .. 1_000);
143       Buffer_Len          : Natural;
144       Cursor              : Natural := 0;
145       End_Of_File_Reached : Boolean := False;
146    end record;
147
148    type Text_File is access Text_File_Data;
149
150 end Prj.Util;