1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
|
// **********************************************************************
//
// Copyright (c) 2003-2004 ZeroC, Inc. All rights reserved.
//
// This copy of Ice is licensed to you under the terms described in the
// ICE_LICENSE file included in this distribution.
//
// **********************************************************************
#ifndef ICE_PROPERTIES_ICE
#define ICE_PROPERTIES_ICE
#include <Ice/BuiltinSequences.ice>
module Ice
{
/**
*
* A simple collection of properties, represented as a dictionary of
* key/value pairs. Both key and value are [string]s.
*
* @see Properties::getPropertiesForPrefix
*
**/
local dictionary<string, string> PropertyDict;
/**
*
* A property set used to configure &Ice; and &Ice; applications.
* Properties are key/value pairs, with both keys and values
* being [string]s. By convention, property keys should have the form
* <replaceable>application-name</replaceable>\[.<replaceable>category</replaceable>\[.<replaceable>sub-category</replaceable>]].<replaceable>name</replaceable>.
*
**/
local interface Properties
{
/**
*
* Get a property by key. If the property does not exist, an empty
* string is returned.
*
* @param key The property key.
*
* @return The property value.
*
* @see setProperty
*
**/
string getProperty(string key);
/**
*
* Get a property by key. If the property does not exist, the
* given default value is returned.
*
* @param key The property key.
*
* @param value The default value to use if the property does not
* exist.
*
* @return The property value or the default value.
*
* @see setProperty
*
**/
string getPropertyWithDefault(string key, string value);
/**
*
* Get a property as an integer. If the property does not exist, 0
* is returned.
*
* @param key The property key.
*
* @return The property value interpreted as an integer.
*
* @see setProperty
*
**/
int getPropertyAsInt(string key);
/**
*
* Get a property as an integer. If the property does not exist, the
* given default value is returned.
*
* @param key The property key.
*
* @param value The default value to use if the property does not
* exist.
*
* @return The property value interpreted as an integer, or the
* default value.
*
* @see setProperty
*
**/
int getPropertyAsIntWithDefault(string key, int value);
/**
*
* Get all properties whose keys begins with
* <replaceable>prefix</replaceable>. If
* <replaceable>prefix</replaceable> is an empty string,
* then all properties are returned.
*
* @return The matching property set.
*
**/
PropertyDict getPropertiesForPrefix(string prefix);
/**
*
* Set a property. To unset a property, set it to
* the empty string.
*
* @param key The property key.
* @param value The property value.
*
* @see getProperty
*
**/
void setProperty(string key, string value);
/**
*
* Get a sequence of command-line options that is equivalent to
* this property set. Each element of the returned sequence is
* a command-line option of the form
* [--<replaceable>key</replaceable>=<replaceable>value</replaceable>].
*
* @return The command line options for this property set.
*
**/
StringSeq getCommandLineOptions();
/**
*
* Convert a sequence of command-line options into properties.
* All options that begin with
* [--<replaceable>prefix</replaceable>.] are
* converted into properties. If the prefix is empty, all options
* that begin with [--] are converted to properties.
*
* @param prefix The property prefix, or an empty string to
* convert all options starting with [--].
*
* @param options The command-line options.
*
* @return The command-line options that do not start with the specified
* prefix, in their original order.
*
**/
StringSeq parseCommandLineOptions(string prefix, StringSeq options);
/**
*
* Convert a sequence of command-line options into properties.
* All options that begin with one of the following prefixes
* are converted into properties: [--Ice], [--IceBox], [--IcePack],
* [--IcePatch], [--IceSSL], [--IceStorm], [--Freeze], and [--Glacier].
*
* @param options The command-line options.
*
* @return The command-line options that do not start with one of
* the listed prefixes, in their original order.
*
**/
StringSeq parseIceCommandLineOptions(StringSeq options);
/**
*
* Load properties from a file.
*
* @param file The property file.
*
**/
void load(string file);
/**
*
* Create a copy of this property set.
*
* @return A copy of this property set.
*
**/
Properties clone();
};
};
#endif
|