ObjFW
OFIRI.h
1 /*
2  * Copyright (c) 2008-2023 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 
19 OF_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;
52 
56 @property OF_NULLABLE_PROPERTY (readonly, copy, nonatomic) OFString *host;
57 
61 @property OF_NULLABLE_PROPERTY (readonly, copy, nonatomic)
62  OFString *percentEncodedHost;
63 
67 @property OF_NULLABLE_PROPERTY (readonly, copy, nonatomic) OFNumber *port;
68 
72 @property OF_NULLABLE_PROPERTY (readonly, copy, nonatomic) OFString *user;
73 
77 @property OF_NULLABLE_PROPERTY (readonly, copy, nonatomic)
78  OFString *percentEncodedUser;
79 
83 @property OF_NULLABLE_PROPERTY (readonly, copy, nonatomic) OFString *password;
84 
88 @property OF_NULLABLE_PROPERTY (readonly, copy, nonatomic)
89  OFString *percentEncodedPassword;
90 
94 @property (readonly, copy, nonatomic) OFString *path;
95 
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
171 
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
204 
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
251 
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
385 extern "C" {
386 #endif
387 extern bool OFIRIIsIPv6Host(OFString *host);
388 extern void OFIRIVerifyIsEscaped(OFString *, OFCharacterSet *, bool);
389 #ifdef __cplusplus
390 }
391 #endif
392 
393 OF_ASSUME_NONNULL_END
394 
395 #import "OFMutableIRI.h"
An abstract class for storing objects in an array.
Definition: OFArray.h:103
The root class for all other classes inside ObjFW.
Definition: OFObject.h:686
A class cluster representing a character set.
Definition: OFCharacterSet.h:28
A class for storing a pair of two objects.
Definition: OFPair.h:25
A class for handling strings.
Definition: OFString.h:134
An abstract class for storing objects in a dictionary.
Definition: OFDictionary.h:78
Provides a way to store a number in an object.
Definition: OFNumber.h:42
A class for representing IRIs, URIs, URLs and URNs, for parsing them as well as accessing parts of th...
Definition: OFIRI.h:35
A protocol for the creation of mutable copies.
Definition: OFObject.h:1367
A protocol for the creation of copies.
Definition: OFObject.h:1346