Overview
Comment: | Rename of_options_parser_option_t |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | new-naming-convention |
Files: | files | file ages | folders |
SHA3-256: |
91daa4264934e8ebeea5cd69eb79b521 |
User & Date: | js on 2021-04-17 05:22:02 |
Other Links: | branch diff | manifest | tags |
Context
2021-04-17
| ||
05:28 | Rename all types in OFTarArchive(Entry).h check-in: 795618c69f user: js tags: new-naming-convention | |
05:22 | Rename of_options_parser_option_t check-in: 91daa42649 user: js tags: new-naming-convention | |
05:16 | Rename all types in OFFileManager.h check-in: c7bdb196d4 user: js tags: new-naming-convention | |
Changes
Modified src/OFOptionsParser.h from [c3700f4bd3] to [84a06358b9].
︙ | ︙ | |||
17 18 19 20 21 22 23 | #import "OFString.h" @class OFMapTable; OF_ASSUME_NONNULL_BEGIN /** | | | | 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | #import "OFString.h" @class OFMapTable; OF_ASSUME_NONNULL_BEGIN /** * @struct OFOptionsParserOption OFOptionsParser.h ObjFW/OFOptionsParser.h * * @brief An option which can be parsed by an @ref OFOptionsParser. */ struct OFOptionsParserOption { /** The short version (e.g. `-v`) of the option or `\0` for none. */ OFUnichar shortOption; /** * The long version (e.g. `--verbose`) of the option or `nil` for none. */ OFString *__unsafe_unretained _Nullable longOption; |
︙ | ︙ | |||
54 55 56 57 58 59 60 | /** * An optional pointer to an `OFString *` that is set to the * argument specified for the option or `nil` for no argument. */ OFString *__autoreleasing _Nullable *_Nullable argumentPtr; }; | | | | 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | /** * An optional pointer to an `OFString *` that is set to the * argument specified for the option or `nil` for no argument. */ OFString *__autoreleasing _Nullable *_Nullable argumentPtr; }; typedef struct OFOptionsParserOption OFOptionsParserOption; /** * @class OFOptionsParser OFOptionsParser.h ObjFW/OFOptionsParser.h * * @brief A class for parsing the program options specified on the command line. */ OF_SUBCLASSING_RESTRICTED @interface OFOptionsParser: OFObject { OFOptionsParserOption *_options; OFMapTable *_longOptions; OFArray OF_GENERIC(OFString *) *_arguments; size_t _index, _subIndex; OFUnichar _lastOption; OFString *_Nullable _lastLongOption, *_Nullable _argument; bool _done; } |
︙ | ︙ | |||
115 116 117 118 119 120 121 | */ @property (readonly, nonatomic) OFArray OF_GENERIC(OFString *) *remainingArguments; /** * @brief Creates a new OFOptionsParser which accepts the specified options. * | | | | | | 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 | */ @property (readonly, nonatomic) OFArray OF_GENERIC(OFString *) *remainingArguments; /** * @brief Creates a new OFOptionsParser which accepts the specified options. * * @param options An array of @ref OFOptionsParserOption specifying all * accepted options, terminated with an option whose short * option is `\0` and long option is `nil`. * * @return A new, autoreleased OFOptionsParser */ + (instancetype)parserWithOptions: (const OFOptionsParserOption *)options; - (instancetype)init OF_UNAVAILABLE; /** * @brief Initializes an already allocated OFOptionsParser so that it accepts * the specified options. * * @param options An array of @ref OFOptionsParserOption specifying all * accepted options, terminated with an option whose short * option is `\0` and long option is `nil`. * * @return An initialized OFOptionsParser */ - (instancetype)initWithOptions: (const OFOptionsParserOption *)options OF_DESIGNATED_INITIALIZER; /** * @brief Returns the next option. * * If the option is only available as a long option, `-` is returned. * Otherwise, the short option is returned, even if it was specified as a long |
︙ | ︙ |
Modified src/OFOptionsParser.m from [80d23d5595] to [f1ad10653b].
︙ | ︙ | |||
34 35 36 37 38 39 40 | return [(OFString *)object1 isEqual: (OFString *)object2]; } @implementation OFOptionsParser @synthesize lastOption = _lastOption, lastLongOption = _lastLongOption; @synthesize argument = _argument; | | | | | | 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | return [(OFString *)object1 isEqual: (OFString *)object2]; } @implementation OFOptionsParser @synthesize lastOption = _lastOption, lastLongOption = _lastLongOption; @synthesize argument = _argument; + (instancetype)parserWithOptions: (const OFOptionsParserOption *)options { return [[[self alloc] initWithOptions: options] autorelease]; } - (instancetype)init { OF_INVALID_INIT_METHOD } - (instancetype)initWithOptions: (const OFOptionsParserOption *)options { self = [super init]; @try { size_t count = 0; const OFOptionsParserOption *iter; OFOptionsParserOption *iter2; const of_map_table_functions_t keyFunctions = { .hash = stringHash, .equal = stringEqual }; const of_map_table_functions_t objectFunctions = { NULL }; /* Count, sanity check, initialize pointers */ |
︙ | ︙ | |||
137 138 139 140 141 142 143 | return self; } - (void)dealloc { if (_options != NULL) | | | | 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 | return self; } - (void)dealloc { if (_options != NULL) for (OFOptionsParserOption *iter = _options; iter->shortOption != '\0' || iter->longOption != nil; iter++) [iter->longOption release]; free(_options); [_longOptions release]; [_arguments release]; [_argument release]; [super dealloc]; } - (OFUnichar)nextOption { OFOptionsParserOption *iter; OFString *argument; if (_done || _index >= _arguments.count) return '\0'; [_lastLongOption release]; [_argument release]; |
︙ | ︙ | |||
182 183 184 185 186 187 188 | _index++; return '\0'; } if ([argument hasPrefix: @"--"]) { void *pool = objc_autoreleasePoolPush(); size_t pos; | | | 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 | _index++; return '\0'; } if ([argument hasPrefix: @"--"]) { void *pool = objc_autoreleasePoolPush(); size_t pos; OFOptionsParserOption *option; _lastOption = '-'; _index++; if ((pos = [argument rangeOfString: @"="].location) != OFNotFound) _argument = [[argument |
︙ | ︙ |
Modified utils/ofarc/OFArc.m from [13d11154e1] to [f6c3dc0d49].
︙ | ︙ | |||
145 146 147 148 149 150 151 | @"type", type)]; } @implementation OFArc - (void)applicationDidFinishLaunching { OFString *outputDir, *encodingString, *type; | | | 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 | @"type", type)]; } @implementation OFArc - (void)applicationDidFinishLaunching { OFString *outputDir, *encodingString, *type; const OFOptionsParserOption options[] = { { 'a', @"append", 0, NULL, NULL }, { 'c', @"create", 0, NULL, NULL }, { 'C', @"directory", 1, NULL, &outputDir }, { 'E', @"encoding", 1, NULL, &encodingString }, { 'f', @"force", 0, NULL, NULL }, { 'h', @"help", 0, NULL, NULL }, { 'l', @"list", 0, NULL, NULL }, |
︙ | ︙ |
Modified utils/ofdns/OFDNS.m from [2d8310fdb6] to [3d972b3bf5].
︙ | ︙ | |||
79 80 81 82 83 84 85 | if (_inFlight == 0) [OFApplication terminateWithStatus: _errors]; } - (void)applicationDidFinishLaunching { OFString *DNSClassString, *server; | | | 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | if (_inFlight == 0) [OFApplication terminateWithStatus: _errors]; } - (void)applicationDidFinishLaunching { OFString *DNSClassString, *server; const OFOptionsParserOption options[] = { { 'c', @"class", 1, NULL, &DNSClassString }, { 'h', @"help", 0, NULL, NULL }, { 's', @"server", 1, NULL, &server }, { 't', @"type", 1, NULL, NULL }, { '\0', nil, 0, NULL, NULL } }; OFMutableArray OF_GENERIC(OFString *) *recordTypes; |
︙ | ︙ |
Modified utils/ofhash/OFHash.m from [362fed811c] to [20916b6a0f].
︙ | ︙ | |||
66 67 68 69 70 71 72 | @implementation OFHash - (void)applicationDidFinishLaunching { int exitStatus = 0; bool calculateMD5, calculateRIPEMD160, calculateSHA1, calculateSHA224; bool calculateSHA256, calculateSHA384, calculateSHA512; | | | 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | @implementation OFHash - (void)applicationDidFinishLaunching { int exitStatus = 0; bool calculateMD5, calculateRIPEMD160, calculateSHA1, calculateSHA224; bool calculateSHA256, calculateSHA384, calculateSHA512; const OFOptionsParserOption options[] = { { '\0', @"md5", 0, &calculateMD5, NULL }, { '\0', @"ripemd160", 0, &calculateRIPEMD160, NULL }, { '\0', @"sha1", 0, &calculateSHA1, NULL }, { '\0', @"sha224", 0, &calculateSHA224, NULL }, { '\0', @"sha256", 0, &calculateSHA256, NULL }, { '\0', @"sha384", 0, &calculateSHA384, NULL }, { '\0', @"sha512", 0, &calculateSHA512, NULL }, |
︙ | ︙ |
Modified utils/ofhttp/OFHTTP.m from [ed48a4cbd1] to [b36faae7ff].
︙ | ︙ | |||
410 411 412 413 414 415 416 | [OFApplication terminateWithStatus: 1]; } } - (void)applicationDidFinishLaunching { OFString *outputPath; | | | 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 | [OFApplication terminateWithStatus: 1]; } } - (void)applicationDidFinishLaunching { OFString *outputPath; const OFOptionsParserOption options[] = { { 'b', @"body", 1, NULL, NULL }, { 'c', @"continue", 0, &_continue, NULL }, { 'f', @"force", 0, &_force, NULL }, { 'h', @"help", 0, NULL, NULL }, { 'H', @"header", 1, NULL, NULL }, { 'm', @"method", 1, NULL, NULL }, { 'o', @"output", 1, NULL, &outputPath }, |
︙ | ︙ |