ObjFW  Diff

Differences From Artifact [b76d8bb1be]:

To Artifact [114ec293ed]:


16
17
18
19
20
21
22

23
24
25
26
27
28
29
30
31
32
33
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
66
67
68
69
70
71

#include "config.h"

#include <stdlib.h>
#include <string.h>

#import "OFURL.h"

#import "OFString.h"
#import "OFArray.h"
#import "OFXMLElement.h"

#import "OFInvalidArgumentException.h"
#import "OFInvalidFormatException.h"
#import "OFOutOfMemoryException.h"

@implementation OFURL
@synthesize scheme = _scheme, host = _host, port = _port, user = _user;
@synthesize password = _password, path = _path, parameters = _parameters;
@synthesize query = _query, fragment = _fragment;

+ (instancetype)URL
{
	return [[[self alloc] init] autorelease];
}

+ (instancetype)URLWithString: (OFString *)string
{
	return [[[self alloc] initWithString: string] autorelease];
}

+ (instancetype)URLWithString: (OFString *)string
		relativeToURL: (OFURL *)URL
{
	return [[[self alloc] initWithString: string
			       relativeToURL: URL] autorelease];
}

+ (instancetype)fileURLWithPath: (OFString *)path
{
	OFURL *URL = [OFURL URL];
	void *pool = objc_autoreleasePoolPush();

	[URL setScheme: @"file"];
	[URL setPath: [[path pathComponents] componentsJoinedByString: @"/"]];



	objc_autoreleasePoolPop(pool);

	return URL;
}











- initWithString: (OFString *)string
{
	char *UTF8String, *UTF8String2 = NULL;

	self = [super init];








>









<
<
<
<



















|




>
>





>
>
>
>
>
>
>
>
>
>







16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32




33
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80

#include "config.h"

#include <stdlib.h>
#include <string.h>

#import "OFURL.h"
#import "OFURL+Private.h"
#import "OFString.h"
#import "OFArray.h"
#import "OFXMLElement.h"

#import "OFInvalidArgumentException.h"
#import "OFInvalidFormatException.h"
#import "OFOutOfMemoryException.h"

@implementation OFURL




+ (instancetype)URL
{
	return [[[self alloc] init] autorelease];
}

+ (instancetype)URLWithString: (OFString *)string
{
	return [[[self alloc] initWithString: string] autorelease];
}

+ (instancetype)URLWithString: (OFString *)string
		relativeToURL: (OFURL *)URL
{
	return [[[self alloc] initWithString: string
			       relativeToURL: URL] autorelease];
}

+ (instancetype)fileURLWithPath: (OFString *)path
{
	OFMutableURL *URL = [OFMutableURL URL];
	void *pool = objc_autoreleasePoolPush();

	[URL setScheme: @"file"];
	[URL setPath: [[path pathComponents] componentsJoinedByString: @"/"]];

	[URL makeImmutable];

	objc_autoreleasePoolPop(pool);

	return URL;
}

- init
{
	OF_INVALID_INIT_METHOD
}

- (instancetype)of_init
{
	return [super init];
}

- initWithString: (OFString *)string
{
	char *UTF8String, *UTF8String2 = NULL;

	self = [super init];

357
358
359
360
361
362
363
364













































365
366


367

368


369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
	OF_HASH_ADD_HASH(hash, [_query hash]);
	OF_HASH_ADD_HASH(hash, [_fragment hash]);

	OF_HASH_FINALIZE(hash);

	return hash;
}














































- copy
{


	OFURL *copy = [[[self class] alloc] init];




	@try {
		copy->_scheme = [_scheme copy];
		copy->_host = [_host copy];
		copy->_port = _port;
		copy->_user = [_user copy];
		copy->_password = [_password copy];
		copy->_path = [_path copy];
		copy->_parameters = [_parameters copy];
		copy->_query = [_query copy];
		copy->_fragment = [_fragment copy];
	} @catch (id e) {
		[copy release];
		@throw e;
	}

	return copy;
}








>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>


>
>
|
>
|
>
>

|
|
|
|
|
|
|
|
|







366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
	OF_HASH_ADD_HASH(hash, [_query hash]);
	OF_HASH_ADD_HASH(hash, [_fragment hash]);

	OF_HASH_FINALIZE(hash);

	return hash;
}

- (OFString *)scheme
{
	return _scheme;
}

- (OFString *)host
{
	return _host;
}

- (uint16_t)port
{
	return _port;
}

- (OFString *)user
{
	return _user;
}

- (OFString *)password
{
	return _password;
}

- (OFString *)path
{
	return _path;
}

- (OFString *)parameters
{
	return _parameters;
}

- (OFString *)query
{
	return _query;
}

- (OFString *)fragment
{
	return _fragment;
}

- copy
{
	return [self retain];
}

- mutableCopy
{
	OFMutableURL *copy = [[OFMutableURL alloc] init];

	@try {
		[copy setScheme: _scheme];
		[copy setHost: _host];
		[copy setPort: _port];
		[copy setUser: _user];
		[copy setPassword: _password];
		[copy setPath: _path];
		[copy setParameters: _parameters];
		[copy setQuery: _query];
		[copy setFragment: _fragment];
	} @catch (id e) {
		[copy release];
		@throw e;
	}

	return copy;
}