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 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 "OFCharacterSet.h"
18
19OF_ASSUME_NONNULL_BEGIN
20
21@class OFArray OF_GENERIC(ObjectType);
22@class OFDictionary OF_GENERIC(KeyType, ObjectType);
23@class OFNumber;
24@class OFPair OF_GENERIC(FirstType, SecondType);
25@class OFString;
26
36{
37 OFString *_scheme;
38 OFString *_Nullable _percentEncodedHost;
39 OFNumber *_Nullable _port;
40 OFString *_Nullable _percentEncodedUser;
41 OFString *_Nullable _percentEncodedPassword;
42 OFString *_percentEncodedPath;
43 OFString *_Nullable _percentEncodedQuery;
44 OFString *_Nullable _percentEncodedFragment;
45 OF_RESERVE_IVARS(OFIRI, 4)
46}
47
51@property (readonly, copy, nonatomic) OFString *scheme;
56@property OF_NULLABLE_PROPERTY (readonly, copy, nonatomic) OFString *host;
61@property OF_NULLABLE_PROPERTY (readonly, copy, nonatomic)
62 OFString *percentEncodedHost;
67@property OF_NULLABLE_PROPERTY (readonly, copy, nonatomic) OFNumber *port;
72@property OF_NULLABLE_PROPERTY (readonly, copy, nonatomic) OFString *user;
77@property OF_NULLABLE_PROPERTY (readonly, copy, nonatomic)
78 OFString *percentEncodedUser;
83@property OF_NULLABLE_PROPERTY (readonly, copy, nonatomic) OFString *password;
88@property OF_NULLABLE_PROPERTY (readonly, copy, nonatomic)
89 OFString *percentEncodedPassword;
94@property (readonly, copy, nonatomic) OFString *path;
99@property (readonly, copy, nonatomic) OFString *percentEncodedPath;
106@property (readonly, copy, nonatomic)
107 OFArray OF_GENERIC(OFString *) *pathComponents;
114@property (readonly, copy, nonatomic) OFString *lastPathComponent;
119@property OF_NULLABLE_PROPERTY (readonly, copy, nonatomic) OFString *query;
124@property OF_NULLABLE_PROPERTY (readonly, copy, nonatomic)
125 OFString *percentEncodedQuery;
140@property OF_NULLABLE_PROPERTY (readonly, copy, nonatomic)
141 OFArray OF_GENERIC(OFPair OF_GENERIC(OFString *, OFString *) *) *queryItems;
146@property OF_NULLABLE_PROPERTY (readonly, copy, nonatomic) OFString *fragment;
151@property OF_NULLABLE_PROPERTY (readonly, copy, nonatomic)
152 OFString *percentEncodedFragment;
157@property (readonly, nonatomic) OFString *string;
162@property (readonly, nonatomic) OFIRI *IRIByStandardizingPath;
167@property (readonly, nonatomic)
168 OFIRI *IRIByAddingPercentEncodingForUnicodeCharacters;
170#ifdef OF_HAVE_FILES
177@property OF_NULLABLE_PROPERTY (readonly, nonatomic)
178 OFString *fileSystemRepresentation;
179#endif
180
189+ (instancetype)IRIWithString: (OFString *)string;
190
201+ (instancetype)IRIWithString: (OFString *)string relativeToIRI: (OFIRI *)IRI;
202
203#ifdef OF_HAVE_FILES
214+ (instancetype)fileIRIWithPath: (OFString *)path;
215
224+ (instancetype)fileIRIWithPath: (OFString *)path
225 isDirectory: (bool)isDirectory;
226#endif
227
236- (instancetype)initWithString: (OFString *)string;
237
248- (instancetype)initWithString: (OFString *)string relativeToIRI: (OFIRI *)IRI;
249
250#ifdef OF_HAVE_FILES
262- (instancetype)initFileIRIWithPath: (OFString *)path;
263
273- (instancetype)initFileIRIWithPath: (OFString *)path
274 isDirectory: (bool)isDirectory;
275#endif
276
277- (instancetype)init OF_UNAVAILABLE;
278
290- (OFIRI *)IRIByAppendingPathComponent: (OFString *)component;
291
302- (OFIRI *)IRIByAppendingPathComponent: (OFString *)component
303 isDirectory: (bool)isDirectory;
304@end
305
306@interface OFCharacterSet (IRICharacterSets)
307#ifdef OF_HAVE_CLASS_PROPERTIES
308@property (class, readonly, nonatomic)
309 OFCharacterSet *IRISchemeAllowedCharacterSet;
310@property (class, readonly, nonatomic)
311 OFCharacterSet *IRIHostAllowedCharacterSet;
312@property (class, readonly, nonatomic)
313 OFCharacterSet *IRIUserAllowedCharacterSet;
314@property (class, readonly, nonatomic)
315 OFCharacterSet *IRIPasswordAllowedCharacterSet;
316@property (class, readonly, nonatomic)
317 OFCharacterSet *IRIPathAllowedCharacterSet;
318@property (class, readonly, nonatomic)
319 OFCharacterSet *IRIQueryAllowedCharacterSet;
320@property (class, readonly, nonatomic)
321 OFCharacterSet *IRIQueryKeyValueAllowedCharacterSet;
322@property (class, readonly, nonatomic)
323 OFCharacterSet *IRIFragmentAllowedCharacterSet;
324#endif
325
331+ (OFCharacterSet *)IRISchemeAllowedCharacterSet;
332
338+ (OFCharacterSet *)IRIHostAllowedCharacterSet;
339
345+ (OFCharacterSet *)IRIUserAllowedCharacterSet;
346
352+ (OFCharacterSet *)IRIPasswordAllowedCharacterSet;
353
359+ (OFCharacterSet *)IRIPathAllowedCharacterSet;
360
366+ (OFCharacterSet *)IRIQueryAllowedCharacterSet;
367
374+ (OFCharacterSet *)IRIQueryKeyValueAllowedCharacterSet;
375
381+ (OFCharacterSet *)IRIFragmentAllowedCharacterSet;
382@end
383
384#ifdef __cplusplus
385extern "C" {
386#endif
387extern bool OFIRIIsIPv6Host(OFString *host);
388extern void OFIRIVerifyIsEscaped(OFString *, OFCharacterSet *, bool);
389#ifdef __cplusplus
390}
391#endif
392
393OF_ASSUME_NONNULL_END
394
395#import "OFMutableIRI.h"
An abstract class for storing objects in an array.
Definition OFArray.h:105
A class cluster representing a character set.
Definition OFCharacterSet.h:29
An abstract class for storing objects in a dictionary.
Definition OFDictionary.h:80
A class for representing IRIs, URIs, URLs and URNs, for parsing them as well as accessing parts of th...
Definition OFIRI.h:37
Provides a way to store a number in an object.
Definition OFNumber.h:43
The root class for all other classes inside ObjFW.
Definition OFObject.h:688
A class for storing a pair of two objects.
Definition OFPair.h:36
A class for handling strings.
Definition OFString.h:135
A protocol for the creation of copies.
Definition OFObject.h:1346
A protocol for the creation of mutable copies.
Definition OFObject.h:1367