ObjFW
OFSettings.h
1 /*
2  * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im>
3  *
4  * All rights reserved.
5  *
6  * This program is free software: you can redistribute it and/or modify it
7  * under the terms of the GNU Lesser General Public License version 3.0 only,
8  * as published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
13  * version 3.0 for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * version 3.0 along with this program. If not, see
17  * <https://www.gnu.org/licenses/>.
18  */
19 
20 #import "OFObject.h"
21 
22 OF_ASSUME_NONNULL_BEGIN
23 
24 @class OFString;
25 @class OFArray OF_GENERIC(ObjectType);
26 
38 @interface OFSettings: OFObject
39 {
40  OFString *_applicationName;
41  OF_RESERVE_IVARS(OFSettings, 4)
42 }
43 
48 @property (readonly, nonatomic) OFString *applicationName;
49 
58 + (instancetype)settingsWithApplicationName: (OFString *)applicationName;
59 
60 - (instancetype)init OF_UNAVAILABLE;
61 
70 - (instancetype)initWithApplicationName: (OFString *)applicationName
71  OF_DESIGNATED_INITIALIZER;
72 
79 - (void)setString: (OFString *)string forPath: (OFString *)path;
80 
87 - (void)setLongLong: (long long)longLong forPath: (OFString *)path;
88 
95 - (void)setBool: (bool)bool_ forPath: (OFString *)path;
96 
103 - (void)setFloat: (float)float_ forPath: (OFString *)path;
104 
111 - (void)setDouble: (double)double_ forPath: (OFString *)path;
112 
119 - (void)setStringArray: (OFArray OF_GENERIC(OFString *) *)array
120  forPath: (OFString *)path;
121 
129 - (nullable OFString *)stringForPath: (OFString *)path;
130 
139 - (nullable OFString *)stringForPath: (OFString *)path
140  defaultValue: (nullable OFString *)defaultValue;
141 
150 - (long long)longLongForPath: (OFString *)path
151  defaultValue: (long long)defaultValue;
152 
161 - (bool)boolForPath: (OFString *)path defaultValue: (bool)defaultValue;
162 
171 - (float)floatForPath: (OFString *)path defaultValue: (float)defaultValue;
172 
181 - (double)doubleForPath: (OFString *)path defaultValue: (double)defaultValue;
182 
190 - (OFArray OF_GENERIC(OFString *) *)stringArrayForPath: (OFString *)path;
191 
197 - (void)removeValueForPath: (OFString *)path;
198 
207 - (void)save;
208 @end
209 
210 OF_ASSUME_NONNULL_END
An abstract class for storing objects in an array.
Definition: OFArray.h:107
The root class for all other classes inside ObjFW.
Definition: OFObject.h:690
A class for handling strings.
Definition: OFString.h:142
A class for storing and retrieving settings.
Definition: OFSettings.h:38