ObjFW
Loading...
Searching...
No Matches
OFOptionsParser.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#import "OFString.h"
22
23@class OFMapTable;
24
25OF_ASSUME_NONNULL_BEGIN
26
32typedef struct {
34 OFUnichar shortOption;
35
39 OFString *__unsafe_unretained _Nullable longOption;
40
51 signed char hasArgument;
52
57 bool *_Nullable isSpecifiedPtr;
58
63 OFString *__autoreleasing _Nullable *_Nullable argumentPtr;
65
71OF_SUBCLASSING_RESTRICTED
73{
74 OFOptionsParserOption *_options;
75 OFMapTable *_longOptions;
76 OFArray OF_GENERIC(OFString *) *_arguments;
77 size_t _index, _subIndex;
78 OFUnichar _lastOption;
79 OFString *_Nullable _lastLongOption, *_Nullable _argument;
80 bool _done;
81}
82
91@property (readonly, nonatomic) OFUnichar lastOption;
92
108@property OF_NULLABLE_PROPERTY (readonly, nonatomic) OFString *lastLongOption;
109
114@property OF_NULLABLE_PROPERTY (readonly, nonatomic) OFString *argument;
115
119@property (readonly, nonatomic)
121
131+ (instancetype)parserWithOptions: (const OFOptionsParserOption *)options;
132
133- (instancetype)init OF_UNAVAILABLE;
134
145- (instancetype)initWithOptions: (const OFOptionsParserOption *)options
146 OF_DESIGNATED_INITIALIZER;
147
166- (OFUnichar)nextOption;
167@end
168
169OF_ASSUME_NONNULL_END
An abstract class for storing objects in an array.
Definition OFArray.h:109
A class similar to OFDictionary, but providing more options how keys and objects should be retained,...
Definition OFMapTable.h:78
The root class for all other classes inside ObjFW.
Definition OFObject.h:692
A class for parsing the program options specified on the command line.
Definition OFOptionsParser.h:73
OFString * lastLongOption
The long option for the last parsed option, or nil if the last parsed option was not passed as a long...
Definition OFOptionsParser.h:108
OFString * argument
The argument for the last parsed option, or nil if the last parsed option takes no argument.
Definition OFOptionsParser.h:114
OFArray * remainingArguments
The arguments following the last option.
Definition OFOptionsParser.h:120
A class for handling strings.
Definition OFString.h:139
An option which can be parsed by an OFOptionsParser.
Definition OFOptionsParser.h:32
OFString *__autoreleasing * argumentPtr
Definition OFOptionsParser.h:63
bool * isSpecifiedPtr
Definition OFOptionsParser.h:57
OFString *__unsafe_unretained longOption
Definition OFOptionsParser.h:39
signed char hasArgument
Definition OFOptionsParser.h:51
OFUnichar shortOption
Definition OFOptionsParser.h:34