ObjFW
OFSettings.h
1 /*
2  * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017
3  * Jonathan Schleifer <js@heap.zone>
4  *
5  * All rights reserved.
6  *
7  * This file is part of ObjFW. It may be distributed under the terms of the
8  * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
9  * the packaging of this file.
10  *
11  * Alternatively, it may be distributed under the terms of the GNU General
12  * Public License, either version 2 or 3, which can be found in the file
13  * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
14  * file.
15  */
16 
17 #import "OFObject.h"
18 
19 OF_ASSUME_NONNULL_BEGIN
20 
21 @class OFString;
22 @class OFArray OF_GENERIC(ObjectType);
23 
35 @interface OFSettings: OFObject
36 {
37  OFString *_applicationName;
38 }
39 
43 @property (readonly, nonatomic) OFString *applicationName;
44 
53 + (instancetype)settingsWithApplicationName: (OFString *)applicationName;
54 
55 - init OF_UNAVAILABLE;
56 
65 - initWithApplicationName: (OFString *)applicationName
66  OF_DESIGNATED_INITIALIZER;
67 
74 - (void)setString: (OFString *)string
75  forPath: (OFString *)path;
76 
83 - (void)setInteger: (intmax_t)integer
84  forPath: (OFString *)path;
85 
92 - (void)setBool: (bool)bool_
93  forPath: (OFString *)path;
94 
101 - (void)setFloat: (float)float_
102  forPath: (OFString *)path;
103 
110 - (void)setDouble: (double)double_
111  forPath: (OFString *)path;
112 
119 - (void)setArray: (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 - (intmax_t)integerForPath: (OFString *)path
151  defaultValue: (intmax_t)defaultValue;
152 
161 - (bool)boolForPath: (OFString *)path
162  defaultValue: (bool)defaultValue;
163 
172 - (float)floatForPath: (OFString *)path
173  defaultValue: (float)defaultValue;
174 
183 - (double)doubleForPath: (OFString *)path
184  defaultValue: (double)defaultValue;
185 
193 - (OFArray OF_GENERIC(OFString *) *)arrayForPath: (OFString *)path;
194 
200 - (void)removeValueForPath: (OFString *)path;
201 
210 - (void)save;
211 @end
212 
213 OF_ASSUME_NONNULL_END
OFString * applicationName
Definition: OFSettings.h:43
A class for handling strings.
Definition: OFString.h:114
id init()
Initializes an already allocated object.
Definition: OFObject.m:488
A class for storing and retrieving settings.
Definition: OFSettings.h:35
void save()
Saves the settings to disk.
Definition: OFSettings.m:148
The root class for all other classes inside ObjFW.
Definition: OFObject.h:379
An abstract class for storing objects in an array.
Definition: OFArray.h:89