ObjFW  Diff

Differences From Artifact [0c961c5344]:

To Artifact [ce099ffcaa]:


1
2
3
4

5
6
7
8
9
10
11
1



2
3
4
5
6
7
8
9

-
-
-
+







/*
 * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
 *               2018, 2019, 2020
 *   Jonathan Schleifer <js@nil.im>
 * Copyright (c) 2008-2021 Jonathan Schleifer <js@nil.im>
 *
 * All rights reserved.
 *
 * This file is part of ObjFW. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
 * the packaging of this file.
 *
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
194
195
196
197


198
199

200
201
202

203
204
205
206
207
208
209
210
211
212

213
214
215
216
217
218


219
220
221
222
223
224


225
226
227
228
229
230
231
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

194
195
196
197
198
199
200
201

202
203
204
205
206


207
208
209
210
211
212


213
214
215
216
217
218
219
220
221







-
-
+
+

-
-
+
+

-
-
+
+




-
-
+
+

-
-
+
+

-
+

-
-
+
+





-
-
+
+

-
-
+
+

-
+

-
-
+
+

-
-
+
+


-
-
+
+

-
-
+
+

-
+

-
-
+
+

-
+
-


-
-
+
+

-
-
+
+

-
+

-
-
+
+

-
+
-


-
-
+
+

-
-
+
+

-
+

-
-
+
+

-
+
-


-
-
+
+








-
+




-
-
+
+

-
+


-
+
-


-
+

-
-
+
+

-
+


-
-
+




-
-
+
+

-
+


-
+
-




-
-
+
+

-
+


-
+
-




-
-
+
+

-
+


-
+
-








-
+




-
-
+
+




-
-
+
+







 * @brief The name of the INI category
 */
@property (copy, nonatomic) OFString *name;

- (instancetype)init OF_UNAVAILABLE;

/**
 * @brief Returns the string value for the specified key, or `nil` if it does
 *	  not exist.
 * @brief Returns the string for the specified key, or `nil` if it does not
 *	  exist.
 *
 * If the specified key is a multi-key (see @ref arrayForKey:), the value of
 * the first key/value pair found is returned.
 * If the specified key is a multi-key (see @ref stringArrayForKey:), the value
 * of the first key/value pair found is returned.
 *
 * @param key The key for which the string value should be returned
 * @return The string value for the specified key, or `nil` if it does not exist
 * @param key The key for which the string should be returned
 * @return The string for the specified key, or `nil` if it does not exist
 */
- (nullable OFString *)stringForKey: (OFString *)key;

/**
 * @brief Returns the string value for the specified key or the specified
 *	  default value if it does not exist.
 * @brief Returns the string for the specified key or the specified default
 *	  value if it does not exist.
 *
 * If the specified key is a multi-key (see @ref arrayForKey:), the value of
 * the first key/value pair found is returned.
 * If the specified key is a multi-key (see @ref stringArrayForKey:), the value
 * of the first key/value pair found is returned.
 *
 * @param key The key for which the string value should be returned
 * @param key The key for which the string should be returned
 * @param defaultValue The value to return if the key does not exist
 * @return The string value for the specified key or the specified default
 *	   value if it does not exist
 * @return The string for the specified key or the specified default value if
 *	   it does not exist
 */
- (nullable OFString *)stringForKey: (OFString *)key
		       defaultValue: (nullable OFString *)defaultValue;

/**
 * @brief Returns the integer value for the specified key or the specified
 *	  default value if it does not exist.
 * @brief Returns the long long for the specified key or the specified default
 *	  value if it does not exist.
 *
 * If the specified key is a multi-key (see @ref arrayForKey:), the value of
 * the first key/value pair found is returned.
 * If the specified key is a multi-key (see @ref stringArrayForKey:), the value
 * of the first key/value pair found is returned.
 *
 * @param key The key for which the integer value should be returned
 * @param key The key for which the long long should be returned
 * @param defaultValue The value to return if the key does not exist
 * @return The integer value for the specified key or the specified default
 *	   value if it does not exist
 * @return The long long for the specified key or the specified default value
 *	   if it does not exist
 */
- (long long)integerForKey: (OFString *)key
	      defaultValue: (long long)defaultValue;
- (long long)longLongForKey: (OFString *)key
	       defaultValue: (long long)defaultValue;

/**
 * @brief Returns the bool value for the specified key or the specified default
 *	  value if it does not exist.
 * @brief Returns the bool for the specified key or the specified default value
 *	  if it does not exist.
 *
 * If the specified key is a multi-key (see @ref arrayForKey:), the value of
 * the first key/value pair found is returned.
 * If the specified key is a multi-key (see @ref stringArrayForKey:), the value
 * of the first key/value pair found is returned.
 *
 * @param key The key for which the bool value should be returned
 * @param key The key for which the bool should be returned
 * @param defaultValue The value to return if the key does not exist
 * @return The bool value for the specified key or the specified default value
 *	   if it does not exist
 * @return The bool for the specified key or the specified default value if it
 *	   does not exist
 */
- (bool)boolForKey: (OFString *)key
- (bool)boolForKey: (OFString *)key defaultValue: (bool)defaultValue;
      defaultValue: (bool)defaultValue;

/**
 * @brief Returns the float value for the specified key or the specified
 *	  default value if it does not exist.
 * @brief Returns the float for the specified key or the specified default
 *	  value if it does not exist.
 *
 * If the specified key is a multi-key (see @ref arrayForKey:), the value of
 * the first key/value pair found is returned.
 * If the specified key is a multi-key (see @ref stringArrayForKey:), the value
 * of the first key/value pair found is returned.
 *
 * @param key The key for which the float value should be returned
 * @param key The key for which the float should be returned
 * @param defaultValue The value to return if the key does not exist
 * @return The float value for the specified key or the specified default value
 *	   if it does not exist
 * @return The float for the specified key or the specified default value if it
 *	   does not exist
 */
- (float)floatForKey: (OFString *)key
- (float)floatForKey: (OFString *)key defaultValue: (float)defaultValue;
	defaultValue: (float)defaultValue;

/**
 * @brief Returns the double value for the specified key or the specified
 *	  default value if it does not exist.
 * @brief Returns the double for the specified key or the specified default
 *	  value if it does not exist.
 *
 * If the specified key is a multi-key (see @ref arrayForKey:), the value of
 * the first key/value pair found is returned.
 * If the specified key is a multi-key (see @ref stringArrayForKey:), the value
 * of the first key/value pair found is returned.
 *
 * @param key The key for which the double value should be returned
 * @param key The key for which the double should be returned
 * @param defaultValue The value to return if the key does not exist
 * @return The double value for the specified key or the specified default
 *	   value if it does not exist
 * @return The double for the specified key or the specified default value if
 *	   it does not exist
 */
- (double)doubleForKey: (OFString *)key
- (double)doubleForKey: (OFString *)key defaultValue: (double)defaultValue;
	  defaultValue: (double)defaultValue;

/**
 * @brief Returns an array of string values for the specified multi-key, or an
 *	  empty array if the key does not exist.
 * @brief Returns an array of strings for the specified multi-key, or an empty
 *	  array if the key does not exist.
 *
 * A multi-key is a key which exists several times in the same category. Each
 * occurrence of the key/value pair adds the respective value to the array.
 *
 * @param key The multi-key for which the array should be returned
 * @return The array for the specified key, or an empty array if it does not
 *	   exist
 */
- (OFArray OF_GENERIC(OFString *) *)arrayForKey: (OFString *)key;
- (OFArray OF_GENERIC(OFString *) *)stringArrayForKey: (OFString *)key;

/**
 * @brief Sets the value of the specified key to the specified string.
 *
 * If the specified key is a multi-key (see @ref arrayForKey:), the value of
 * the first key/value pair found is changed.
 * If the specified key is a multi-key (see @ref stringValuesForKey:), the
 * value of the first key/value pair found is changed.
 *
 * @param string The string to which the value of the key should be set
 * @param string The string to which the key should be set
 * @param key The key for which the new value should be set
 */
- (void)setString: (OFString *)string
- (void)setString: (OFString *)string forKey: (OFString *)key;
	   forKey: (OFString *)key;

/**
 * @brief Sets the value of the specified key to the specified integer.
 * @brief Sets the value of the specified key to the specified long long.
 *
 * If the specified key is a multi-key (see @ref arrayForKey:), the value of
 * the first key/value pair found is changed.
 * If the specified key is a multi-key (see @ref stringValuesForKey:), the value
 * of the first key/value pair found is changed.
 *
 * @param integer The integer to which the value of the key should be set
 * @param longLong The long long to which the key should be set
 * @param key The key for which the new value should be set
 */
- (void)setInteger: (long long)integer
	    forKey: (OFString *)key;
- (void)setLongLong: (long long)longLong forKey: (OFString *)key;

/**
 * @brief Sets the value of the specified key to the specified bool.
 *
 * If the specified key is a multi-key (see @ref arrayForKey:), the value of
 * the first key/value pair found is changed.
 * If the specified key is a multi-key (see @ref stringValuesForKey:), the
 * value of the first key/value pair found is changed.
 *
 * @param bool_ The bool to which the value of the key should be set
 * @param bool_ The bool to which the key should be set
 * @param key The key for which the new value should be set
 */
- (void)setBool: (bool)bool_
- (void)setBool: (bool)bool_ forKey: (OFString *)key;
	 forKey: (OFString *)key;

/**
 * @brief Sets the value of the specified key to the specified float.
 *
 * If the specified key is a multi-key (see @ref arrayForKey:), the value of
 * the first key/value pair found is changed.
 * If the specified key is a multi-key (see @ref stringValuesForKey:), the
 * value of the first key/value pair found is changed.
 *
 * @param float_ The float to which the value of the key should be set
 * @param float_ The float to which the key should be set
 * @param key The key for which the new value should be set
 */
- (void)setFloat: (float)float_
- (void)setFloat: (float)float_ forKey: (OFString *)key;
	  forKey: (OFString *)key;

/**
 * @brief Sets the value of the specified key to the specified double.
 *
 * If the specified key is a multi-key (see @ref arrayForKey:), the value of
 * the first key/value pair found is changed.
 * If the specified key is a multi-key (see @ref stringValuesForKey:), the value
 * of the first key/value pair found is changed.
 *
 * @param double_ The double to which the value of the key should be set
 * @param double_ The double to which the key should be set
 * @param key The key for which the new value should be set
 */
- (void)setDouble: (double)double_
- (void)setDouble: (double)double_ forKey: (OFString *)key;
	   forKey: (OFString *)key;

/**
 * @brief Sets the specified multi-key to the specified array of strings.
 *
 * It replaces the first occurrence of the multi-key with several key/value
 * pairs and removes all following occurrences. If the multi-key does not exist
 * yet, it is appended to the section.
 *
 * See also @ref arrayForKey: for more information about multi-keys.
 * See also @ref stringArrayForKey: for more information about multi-keys.
 *
 * @param array The array of strings to which the multi-key should be set
 * @param key The multi-key for which the new values should be set
 */
- (void)setArray: (OFArray OF_GENERIC(OFString *) *)array
	  forKey: (OFString *)key;
- (void)setStringArray: (OFArray OF_GENERIC(OFString *) *)array
		forKey: (OFString *)key;

/**
 * @brief Removes the value for the specified key
 *
 * If the specified key is a multi-key (see @ref arrayForKey:), all key/value
 * pairs matching the specified key are removed.
 * If the specified key is a multi-key (see @ref stringValuesForKey:), all
 * key/value pairs matching the specified key are removed.
 *
 * @param key The key of the value to remove
 */
- (void)removeValueForKey: (OFString *)key;
@end

OF_ASSUME_NONNULL_END