ObjFW
Loading...
Searching...
No Matches
OFIRI.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 "OFCharacterSet.h"
22
23OF_ASSUME_NONNULL_BEGIN
24
25@class OFArray OF_GENERIC(ObjectType);
26@class OFDictionary OF_GENERIC(KeyType, ObjectType);
27@class OFNumber;
28@class OFPair OF_GENERIC(FirstType, SecondType);
29@class OFString;
30
40{
41 OFString *_scheme;
42 OFString *_Nullable _percentEncodedHost;
43 OFNumber *_Nullable _port;
44 OFString *_Nullable _percentEncodedUser;
45 OFString *_Nullable _percentEncodedPassword;
46 OFString *_percentEncodedPath;
47 OFString *_Nullable _percentEncodedQuery;
48 OFString *_Nullable _percentEncodedFragment;
49 OF_RESERVE_IVARS(OFIRI, 4)
50}
51
55@property (readonly, copy, nonatomic) OFString *scheme;
60@property OF_NULLABLE_PROPERTY (readonly, copy, nonatomic) OFString *host;
65@property OF_NULLABLE_PROPERTY (readonly, copy, nonatomic)
66 OFString *percentEncodedHost;
71@property OF_NULLABLE_PROPERTY (readonly, copy, nonatomic) OFNumber *port;
76@property OF_NULLABLE_PROPERTY (readonly, copy, nonatomic) OFString *user;
81@property OF_NULLABLE_PROPERTY (readonly, copy, nonatomic)
82 OFString *percentEncodedUser;
87@property OF_NULLABLE_PROPERTY (readonly, copy, nonatomic) OFString *password;
92@property OF_NULLABLE_PROPERTY (readonly, copy, nonatomic)
93 OFString *percentEncodedPassword;
98@property (readonly, copy, nonatomic) OFString *path;
103@property (readonly, copy, nonatomic) OFString *percentEncodedPath;
110@property (readonly, copy, nonatomic)
111 OFArray OF_GENERIC(OFString *) *pathComponents;
118@property (readonly, copy, nonatomic) OFString *lastPathComponent;
123@property (readonly, copy, nonatomic) OFString *pathExtension;
128@property OF_NULLABLE_PROPERTY (readonly, copy, nonatomic) OFString *query;
133@property OF_NULLABLE_PROPERTY (readonly, copy, nonatomic)
134 OFString *percentEncodedQuery;
149@property OF_NULLABLE_PROPERTY (readonly, copy, nonatomic)
150 OFArray OF_GENERIC(OFPair OF_GENERIC(OFString *, OFString *) *) *queryItems;
155@property OF_NULLABLE_PROPERTY (readonly, copy, nonatomic) OFString *fragment;
160@property OF_NULLABLE_PROPERTY (readonly, copy, nonatomic)
161 OFString *percentEncodedFragment;
166@property (readonly, nonatomic) OFString *string;
171@property (readonly, nonatomic) OFIRI *IRIByStandardizingPath;
176@property (readonly, nonatomic) OFIRI *IRIByDeletingLastPathComponent;
181@property (readonly, nonatomic) OFIRI *IRIByDeletingPathExtension;
186@property (readonly, nonatomic)
187 OFIRI *IRIByAddingPercentEncodingForUnicodeCharacters;
189#ifdef OF_HAVE_FILES
196@property OF_NULLABLE_PROPERTY (readonly, nonatomic)
197 OFString *fileSystemRepresentation;
198#endif
199
208+ (instancetype)IRIWithString: (OFString *)string;
209
220+ (instancetype)IRIWithString: (OFString *)string relativeToIRI: (OFIRI *)IRI;
221
222#ifdef OF_HAVE_FILES
233+ (instancetype)fileIRIWithPath: (OFString *)path;
234
243+ (instancetype)fileIRIWithPath: (OFString *)path
244 isDirectory: (bool)isDirectory;
245#endif
246
255- (instancetype)initWithString: (OFString *)string;
256
267- (instancetype)initWithString: (OFString *)string relativeToIRI: (OFIRI *)IRI;
268
269#ifdef OF_HAVE_FILES
281- (instancetype)initFileIRIWithPath: (OFString *)path;
282
292- (instancetype)initFileIRIWithPath: (OFString *)path
293 isDirectory: (bool)isDirectory;
294#endif
295
296- (instancetype)init OF_UNAVAILABLE;
297
309- (OFIRI *)IRIByAppendingPathComponent: (OFString *)component;
310
321- (OFIRI *)IRIByAppendingPathComponent: (OFString *)component
322 isDirectory: (bool)isDirectory;
323
330- (OFIRI *)IRIByAppendingPathExtension: (OFString *)extension;
331@end
332
333@interface OFCharacterSet (IRICharacterSets)
334#ifdef OF_HAVE_CLASS_PROPERTIES
335@property (class, readonly, nonatomic)
336 OFCharacterSet *IRISchemeAllowedCharacterSet;
337@property (class, readonly, nonatomic)
338 OFCharacterSet *IRIHostAllowedCharacterSet;
339@property (class, readonly, nonatomic)
340 OFCharacterSet *IRIUserAllowedCharacterSet;
341@property (class, readonly, nonatomic)
342 OFCharacterSet *IRIPasswordAllowedCharacterSet;
343@property (class, readonly, nonatomic)
344 OFCharacterSet *IRIPathAllowedCharacterSet;
345@property (class, readonly, nonatomic)
346 OFCharacterSet *IRIQueryAllowedCharacterSet;
347@property (class, readonly, nonatomic)
348 OFCharacterSet *IRIQueryKeyValueAllowedCharacterSet;
349@property (class, readonly, nonatomic)
350 OFCharacterSet *IRIFragmentAllowedCharacterSet;
351#endif
352
358+ (OFCharacterSet *)IRISchemeAllowedCharacterSet;
359
365+ (OFCharacterSet *)IRIHostAllowedCharacterSet;
366
372+ (OFCharacterSet *)IRIUserAllowedCharacterSet;
373
379+ (OFCharacterSet *)IRIPasswordAllowedCharacterSet;
380
386+ (OFCharacterSet *)IRIPathAllowedCharacterSet;
387
393+ (OFCharacterSet *)IRIQueryAllowedCharacterSet;
394
401+ (OFCharacterSet *)IRIQueryKeyValueAllowedCharacterSet;
402
408+ (OFCharacterSet *)IRIFragmentAllowedCharacterSet;
409@end
410
411OF_ASSUME_NONNULL_END
412
413#import "OFMutableIRI.h"
An abstract class for storing objects in an array.
Definition OFArray.h:109
A class cluster representing a character set.
Definition OFCharacterSet.h:33
An abstract class for storing objects in a dictionary.
Definition OFDictionary.h:84
A class for representing IRIs, URIs, URLs and URNs, for parsing them as well as accessing parts of th...
Definition OFIRI.h:41
Provides a way to store a number in an object.
Definition OFNumber.h:47
The root class for all other classes inside ObjFW.
Definition OFObject.h:692
A class for storing a pair of two objects.
Definition OFPair.h:40
A class for handling strings.
Definition OFString.h:143
A protocol for the creation of copies.
Definition OFObject.h:1350
A protocol for the creation of mutable copies.
Definition OFObject.h:1371