ObjFW
OFURL.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 "OFCharacterSet.h"
18 #import "OFSerialization.h"
19 
20 OF_ASSUME_NONNULL_BEGIN
21 
22 @class OFArray OF_GENERIC(ObjectType);
23 @class OFDictionary OF_GENERIC(KeyType, ObjectType);
24 @class OFNumber;
25 @class OFString;
26 
33 {
34  OFString *_Nullable _URLEncodedScheme, *_Nullable _URLEncodedHost;
35  OFNumber *_Nullable _port;
36  OFString *_Nullable _URLEncodedUser, *_Nullable _URLEncodedPassword;
37  OFString *_Nullable _URLEncodedPath;
38  OFString *_Nullable _URLEncodedQuery, *_Nullable _URLEncodedFragment;
39  OF_RESERVE_IVARS(OFURL, 4)
40 }
41 
45 @property OF_NULLABLE_PROPERTY (readonly, copy, nonatomic) OFString *scheme;
46 
50 @property OF_NULLABLE_PROPERTY (readonly, copy, nonatomic)
51  OFString *URLEncodedScheme;
52 
56 @property OF_NULLABLE_PROPERTY (readonly, copy, nonatomic) OFString *host;
57 
61 @property OF_NULLABLE_PROPERTY (readonly, copy, nonatomic)
62  OFString *URLEncodedHost;
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 *URLEncodedUser;
79 
83 @property OF_NULLABLE_PROPERTY (readonly, copy, nonatomic) OFString *password;
84 
88 @property OF_NULLABLE_PROPERTY (readonly, copy, nonatomic)
89  OFString *URLEncodedPassword;
90 
94 @property OF_NULLABLE_PROPERTY (readonly, copy, nonatomic) OFString *path;
95 
99 @property OF_NULLABLE_PROPERTY (readonly, copy, nonatomic)
100  OFString *URLEncodedPath;
101 
107 @property OF_NULLABLE_PROPERTY (readonly, copy, nonatomic)
108  OFArray OF_GENERIC(OFString *) *pathComponents;
109 
115 @property OF_NULLABLE_PROPERTY (readonly, copy, nonatomic)
116  OFString *lastPathComponent;
117 
121 @property OF_NULLABLE_PROPERTY (readonly, copy, nonatomic) OFString *query;
122 
126 @property OF_NULLABLE_PROPERTY (readonly, copy, nonatomic)
127  OFString *URLEncodedQuery;
128 
140 @property OF_NULLABLE_PROPERTY (readonly, copy, nonatomic)
141  OFDictionary OF_GENERIC(OFString *, OFString *) *queryDictionary;
142 
146 @property OF_NULLABLE_PROPERTY (readonly, copy, nonatomic) OFString *fragment;
147 
151 @property OF_NULLABLE_PROPERTY (readonly, copy, nonatomic)
152  OFString *URLEncodedFragment;
153 
157 @property (readonly, nonatomic) OFString *string;
158 
162 @property (readonly, nonatomic) OFURL *URLByStandardizingPath;
163 
164 #ifdef OF_HAVE_FILES
172 @property OF_NULLABLE_PROPERTY (readonly, nonatomic)
173  OFString *fileSystemRepresentation;
174 #endif
175 
182 + (instancetype)URLWithString: (OFString *)string;
183 
192 + (instancetype)URLWithString: (OFString *)string relativeToURL: (OFURL *)URL;
193 
194 #ifdef OF_HAVE_FILES
204 + (instancetype)fileURLWithPath: (OFString *)path;
205 
214 + (instancetype)fileURLWithPath: (OFString *)path
215  isDirectory: (bool)isDirectory;
216 #endif
217 
224 - (instancetype)initWithString: (OFString *)string;
225 
234 - (instancetype)initWithString: (OFString *)string relativeToURL: (OFURL *)URL;
235 
236 #ifdef OF_HAVE_FILES
247 - (instancetype)initFileURLWithPath: (OFString *)path;
248 
258 - (instancetype)initFileURLWithPath: (OFString *)path
259  isDirectory: (bool)isDirectory;
260 #endif
261 
273 - (OFURL *)URLByAppendingPathComponent: (OFString *)component;
274 
285 - (OFURL *)URLByAppendingPathComponent: (OFString *)component
286  isDirectory: (bool)isDirectory;
287 @end
288 
289 @interface OFCharacterSet (URLCharacterSets)
290 #ifdef OF_HAVE_CLASS_PROPERTIES
291 @property (class, readonly, nonatomic)
292  OFCharacterSet *URLSchemeAllowedCharacterSet;
293 @property (class, readonly, nonatomic)
294  OFCharacterSet *URLHostAllowedCharacterSet;
295 @property (class, readonly, nonatomic)
296  OFCharacterSet *URLUserAllowedCharacterSet;
297 @property (class, readonly, nonatomic)
298  OFCharacterSet *URLPasswordAllowedCharacterSet;
299 @property (class, readonly, nonatomic)
300  OFCharacterSet *URLPathAllowedCharacterSet;
301 @property (class, readonly, nonatomic)
302  OFCharacterSet *URLQueryAllowedCharacterSet;
303 @property (class, readonly, nonatomic)
304  OFCharacterSet *URLQueryKeyValueAllowedCharacterSet;
305 @property (class, readonly, nonatomic)
306  OFCharacterSet *URLFragmentAllowedCharacterSet;
307 #endif
308 
314 + (OFCharacterSet *)URLSchemeAllowedCharacterSet;
315 
321 + (OFCharacterSet *)URLHostAllowedCharacterSet;
322 
328 + (OFCharacterSet *)URLUserAllowedCharacterSet;
329 
335 + (OFCharacterSet *)URLPasswordAllowedCharacterSet;
336 
342 + (OFCharacterSet *)URLPathAllowedCharacterSet;
343 
349 + (OFCharacterSet *)URLQueryAllowedCharacterSet;
350 
357 + (OFCharacterSet *)URLQueryKeyValueAllowedCharacterSet;
358 
364 + (OFCharacterSet *)URLFragmentAllowedCharacterSet;
365 @end
366 
367 #ifdef __cplusplus
368 extern "C" {
369 #endif
370 extern bool of_url_is_ipv6_host(OFString *host);
371 #ifdef __cplusplus
372 }
373 #endif
374 
375 OF_ASSUME_NONNULL_END
376 
377 #import "OFMutableURL.h"
An abstract class for storing objects in an array.
Definition: OFArray.h:92
A class cluster representing a character set.
Definition: OFCharacterSet.h:29
An abstract class for storing objects in a dictionary.
Definition: OFDictionary.h:58
Provides a way to store a number in an object.
Definition: OFNumber.h:49
The root class for all other classes inside ObjFW.
Definition: OFObject.h:520
A class for handling strings.
Definition: OFString.h:132
A class for parsing URLs and accessing parts of it.
Definition: OFURL.h:34
A protocol for the creation of copies.
Definition: OFObject.h:1187
A protocol for the creation of mutable copies.
Definition: OFObject.h:1208
A protocol for serializing objects.
Definition: OFSerialization.h:29