ObjFW
OFSettings.h
1 /*
2  * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im>
3  *
4  * All rights reserved.
5  *
6  * This file is part of ObjFW. It may be distributed under the terms of the
7  * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
8  * the packaging of this file.
9  *
10  * Alternatively, it may be distributed under the terms of the GNU General
11  * Public License, either version 2 or 3, which can be found in the file
12  * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
13  * file.
14  */
15 
16 #import "OFObject.h"
17 
18 OF_ASSUME_NONNULL_BEGIN
19 
20 @class OFString;
21 @class OFArray OF_GENERIC(ObjectType);
22 
34 @interface OFSettings: OFObject
35 {
36  OFString *_applicationName;
37  OF_RESERVE_IVARS(OFSettings, 4)
38 }
39 
44 @property (readonly, nonatomic) OFString *applicationName;
45 
54 + (instancetype)settingsWithApplicationName: (OFString *)applicationName;
55 
56 - (instancetype)init OF_UNAVAILABLE;
57 
66 - (instancetype)initWithApplicationName: (OFString *)applicationName
67  OF_DESIGNATED_INITIALIZER;
68 
75 - (void)setString: (OFString *)string forPath: (OFString *)path;
76 
83 - (void)setLongLong: (long long)longLong forPath: (OFString *)path;
84 
91 - (void)setBool: (bool)bool_ forPath: (OFString *)path;
92 
99 - (void)setFloat: (float)float_ forPath: (OFString *)path;
100 
107 - (void)setDouble: (double)double_ forPath: (OFString *)path;
108 
115 - (void)setStringArray: (OFArray OF_GENERIC(OFString *) *)array
116  forPath: (OFString *)path;
117 
125 - (nullable OFString *)stringForPath: (OFString *)path;
126 
135 - (nullable OFString *)stringForPath: (OFString *)path
136  defaultValue: (nullable OFString *)defaultValue;
137 
146 - (long long)longLongForPath: (OFString *)path
147  defaultValue: (long long)defaultValue;
148 
157 - (bool)boolForPath: (OFString *)path defaultValue: (bool)defaultValue;
158 
167 - (float)floatForPath: (OFString *)path defaultValue: (float)defaultValue;
168 
177 - (double)doubleForPath: (OFString *)path defaultValue: (double)defaultValue;
178 
186 - (OFArray OF_GENERIC(OFString *) *)stringArrayForPath: (OFString *)path;
187 
193 - (void)removeValueForPath: (OFString *)path;
194 
203 - (void)save;
204 @end
205 
206 OF_ASSUME_NONNULL_END
An abstract class for storing objects in an array.
Definition: OFArray.h:103
The root class for all other classes inside ObjFW.
Definition: OFObject.h:686
A class for handling strings.
Definition: OFString.h:134
A class for storing and retrieving settings.
Definition: OFSettings.h:34