decl.c (validate_size): Set minimum size for fat pointers same as access types.
[gcc.git] / gcc / ada / g-regist.ads
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- G N A T . R E G I S T R Y --
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 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. --
21 -- --
22 -- As a special exception, if other files instantiate generics from this --
23 -- unit, or you link this unit with other files to produce an executable, --
24 -- this unit does not by itself cause the resulting executable to be --
25 -- covered by the GNU General Public License. This exception does not --
26 -- however invalidate any other reasons why the executable file might be --
27 -- covered by the GNU Public License. --
28 -- --
29 -- Extensive contributions were provided by Ada Core Technologies Inc. --
30 -- --
31 ------------------------------------------------------------------------------
32
33 -- The registry is a Windows database to store key/value pair. It is used
34 -- to keep Windows operation system and applications configuration options.
35 -- The database is a hierarchal set of key and for each key a value can
36 -- be associated. This package provides high level routines to deal with
37 -- the Windows registry. For full registry API, but at a lower level of
38 -- abstraction, refer to the Win32.Winreg package provided with the
39 -- Win32Ada binding. For example this binding handle only key values of
40 -- type Standard.String.
41
42 -- This package is specific to the NT version of GNAT, and is not available
43 -- on any other platforms.
44
45 package GNAT.Registry is
46
47 type HKEY is private;
48 -- HKEY is a handle to a registry key, including standard registry keys:
49 -- HKEY_CLASSES_ROOT, HKEY_CURRENT_CONFIG, HKEY_CURRENT_USER,
50 -- HKEY_LOCAL_MACHINE, HKEY_USERS, HKEY_PERFORMANCE_DATA.
51
52 HKEY_CLASSES_ROOT : constant HKEY;
53 HKEY_CURRENT_USER : constant HKEY;
54 HKEY_CURRENT_CONFIG : constant HKEY;
55 HKEY_LOCAL_MACHINE : constant HKEY;
56 HKEY_USERS : constant HKEY;
57 HKEY_PERFORMANCE_DATA : constant HKEY;
58
59 type Key_Mode is (Read_Only, Read_Write);
60 -- Access mode for the registry key
61
62 Registry_Error : exception;
63 -- Registry_Error is raises by all routines below if a problem occurs
64 -- (key cannot be opened, key cannot be found etc).
65
66 function Create_Key
67 (From_Key : HKEY;
68 Sub_Key : String;
69 Mode : Key_Mode := Read_Write) return HKEY;
70 -- Open or create a key (named Sub_Key) in the Windows registry database.
71 -- The key will be created under key From_Key. It returns the key handle.
72 -- From_Key must be a valid handle to an already opened key or one of
73 -- the standard keys identified by HKEY declarations above.
74
75 function Open_Key
76 (From_Key : HKEY;
77 Sub_Key : String;
78 Mode : Key_Mode := Read_Only) return HKEY;
79 -- Return a registry key handle for key named Sub_Key opened under key
80 -- From_Key. It is possible to open a key at any level in the registry
81 -- tree in a single call to Open_Key.
82
83 procedure Close_Key (Key : HKEY);
84 -- Close registry key handle. All resources used by Key are released
85
86 function Key_Exists (From_Key : HKEY; Sub_Key : String) return Boolean;
87 -- Returns True if Sub_Key is defined under From_Key in the registry
88
89 function Query_Value
90 (From_Key : HKEY;
91 Sub_Key : String;
92 Expand : Boolean := False) return String;
93 -- Returns the registry key's value associated with Sub_Key in From_Key
94 -- registry key. If Expand is set to True and the Sub_Key is a
95 -- REG_EXPAND_SZ the returned value will have the %name% variables
96 -- replaced by the corresponding environment variable value.
97
98 procedure Set_Value
99 (From_Key : HKEY;
100 Sub_Key : String;
101 Value : String;
102 Expand : Boolean := False);
103 -- Add the pair (Sub_Key, Value) into From_Key registry key.
104 -- By default the value created is of type REG_SZ, unless
105 -- Expand is True in which case it is of type REG_EXPAND_SZ
106
107 procedure Delete_Key (From_Key : HKEY; Sub_Key : String);
108 -- Remove Sub_Key from the registry key From_Key
109
110 procedure Delete_Value (From_Key : HKEY; Sub_Key : String);
111 -- Remove the named value Sub_Key from the registry key From_Key
112
113 generic
114 with procedure Action
115 (Index : Positive;
116 Sub_Key : String;
117 Value : String;
118 Quit : in out Boolean);
119 procedure For_Every_Key_Value (From_Key : HKEY; Expand : Boolean := False);
120 -- Iterates over all the pairs (Sub_Key, Value) registered under
121 -- From_Key. Index will be set to 1 for the first key and will be
122 -- incremented by one in each iteration. Quit can be set to True to
123 -- stop iteration; its initial value is False.
124 --
125 -- Key value that are not of type string (i.e. not REG_SZ / REG_EXPAND_SZ)
126 -- are skipped. In this case, the iterator behaves exactly as if the key
127 -- were not present. Note that you must use the Win32.Winreg API to deal
128 -- with this case. Furthermore, if Expand is set to True and the Sub_Key
129 -- is a REG_EXPAND_SZ the returned value will have the %name% variables
130 -- replaced by the corresponding environment variable value.
131
132 private
133
134 type HKEY is mod 2 ** Integer'Size;
135
136 HKEY_CLASSES_ROOT : constant HKEY := 16#80000000#;
137 HKEY_CURRENT_USER : constant HKEY := 16#80000001#;
138 HKEY_LOCAL_MACHINE : constant HKEY := 16#80000002#;
139 HKEY_USERS : constant HKEY := 16#80000003#;
140 HKEY_PERFORMANCE_DATA : constant HKEY := 16#80000004#;
141 HKEY_CURRENT_CONFIG : constant HKEY := 16#80000005#;
142
143 end GNAT.Registry;