ObjFW
OFOptionsParser.h
1 /*
2  * Copyright (c) 2008-2021 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 #import "OFString.h"
18 
19 @class OFMapTable;
20 
21 OF_ASSUME_NONNULL_BEGIN
22 
30  of_unichar_t shortOption;
31 
35  OFString *__unsafe_unretained _Nullable longOption;
36 
47  signed char hasArgument;
48 
53  bool *_Nullable isSpecifiedPtr;
54 
59  OFString *__autoreleasing _Nullable *_Nullable argumentPtr;
60 };
62 
68 OF_SUBCLASSING_RESTRICTED
70 {
72  OFMapTable *_longOptions;
73  OFArray OF_GENERIC(OFString *) *_arguments;
74  size_t _index, _subIndex;
75  of_unichar_t _lastOption;
76  OFString *_Nullable _lastLongOption, *_Nullable _argument;
77  bool _done;
78 }
79 
88 @property (readonly, nonatomic) of_unichar_t lastOption;
89 
105 @property OF_NULLABLE_PROPERTY (readonly, nonatomic) OFString *lastLongOption;
106 
111 @property OF_NULLABLE_PROPERTY (readonly, nonatomic) OFString *argument;
112 
116 @property (readonly, nonatomic)
118 
128 + (instancetype)parserWithOptions: (const of_options_parser_option_t *)options;
129 
130 - (instancetype)init OF_UNAVAILABLE;
131 
142 - (instancetype)initWithOptions: (const of_options_parser_option_t *)options
143  OF_DESIGNATED_INITIALIZER;
144 
163 - (of_unichar_t)nextOption;
164 @end
165 
166 OF_ASSUME_NONNULL_END
An abstract class for storing objects in an array.
Definition: OFArray.h:92
A class similar to OFDictionary, but providing more options how keys and objects should be retained,...
Definition: OFMapTable.h:75
The root class for all other classes inside ObjFW.
Definition: OFObject.h:520
A class for parsing the program options specified on the command line.
Definition: OFOptionsParser.h:70
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:105
OFString * argument
The argument for the last parsed option, or nil if the last parsed option takes no argument.
Definition: OFOptionsParser.h:111
OFArray * remainingArguments
The arguments following the last option.
Definition: OFOptionsParser.h:117
A class for handling strings.
Definition: OFString.h:132
An option which can be parsed by an OFOptionsParser.
Definition: OFOptionsParser.h:28
of_unichar_t shortOption
Definition: OFOptionsParser.h:30
signed char hasArgument
Definition: OFOptionsParser.h:47
OFString *__unsafe_unretained _Nullable longOption
Definition: OFOptionsParser.h:35
OFString *__autoreleasing _Nullable *_Nullable argumentPtr
Definition: OFOptionsParser.h:59
bool *_Nullable isSpecifiedPtr
Definition: OFOptionsParser.h:53