ObjFW  Check-in [457e0e82af]

Overview
Comment:Split OFUnboundNamespaceException.

OFUnboundNamespaceException is now only used when the namespace is not
bound. If the prefix is not bound, OFUnboundPrefixException is used now.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 457e0e82af6898e1ea057c80845fd74c47892a6c8e290e037439ab558b4fb1a5
User & Date: js on 2013-06-16 20:03:47
Other Links: manifest | tags
Context
2013-06-17
08:44
Rename -[OFDataArray readDataArrayWithSize:]. check-in: eceebefeab user: js tags: trunk
2013-06-16
20:03
Split OFUnboundNamespaceException. check-in: 457e0e82af user: js tags: trunk
19:35
Include line number in OFMalformedXMLException. check-in: a4fbb3dd1b user: js tags: trunk
Changes

Modified ObjFW.xcodeproj/project.pbxproj from [102bb9bbac] to [a2e0b67b83].

360
361
362
363
364
365
366


367
368
369
370
371
372
373
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375







+
+







		4BB524C1143D1E4E0085FBCC /* OFProcess.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BB524BF143D1E4E0085FBCC /* OFProcess.h */; settings = {ATTRIBUTES = (Public, ); }; };
		4BB524C2143D1E4E0085FBCC /* OFProcess.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BB524C0143D1E4E0085FBCC /* OFProcess.m */; settings = {ATTRIBUTES = (Public, ); }; };
		4BB61D4916DA2AB700986DE1 /* OFBinaryPackRepresentation.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BB61D4816DA2AB700986DE1 /* OFBinaryPackRepresentation.h */; settings = {ATTRIBUTES = (Public, ); }; };
		4BC090441584F6760040640F /* OFInvalidJSONException.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BC090421584F6760040640F /* OFInvalidJSONException.h */; settings = {ATTRIBUTES = (Public, ); }; };
		4BC090451584F6760040640F /* OFInvalidJSONException.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BC090431584F6760040640F /* OFInvalidJSONException.m */; };
		4BD653C5143B8489006182F0 /* OFTCPSocket+SOCKS5.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BD653C3143B8489006182F0 /* OFTCPSocket+SOCKS5.h */; settings = {ATTRIBUTES = (); }; };
		4BD653C6143B8489006182F0 /* OFTCPSocket+SOCKS5.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BD653C4143B8489006182F0 /* OFTCPSocket+SOCKS5.m */; };
		4BD77FDE176E4BC40031C497 /* OFUnboundPrefixException.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BD77FDC176E4BC40031C497 /* OFUnboundPrefixException.h */; settings = {ATTRIBUTES = (Public, ); }; };
		4BD77FDF176E4BC40031C497 /* OFUnboundPrefixException.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BD77FDD176E4BC40031C497 /* OFUnboundPrefixException.m */; };
		4BD98C03133814220048DD5B /* objfw-defs.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BD98C011338140B0048DD5B /* objfw-defs.h */; settings = {ATTRIBUTES = (Public, ); }; };
		4BDF37B51338055600F9A81A /* config.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BDF37B41338055600F9A81A /* config.h */; };
		4BF33AFB133807590059CEF7 /* ObjFW.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4B3D23761337FBC800DD29B8 /* ObjFW.framework */; };
		4BF33AFC133807A20059CEF7 /* OFArrayTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B6EF66E1235358D0076B512 /* OFArrayTests.m */; };
		4BF33AFD133807A20059CEF7 /* OFBlockTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BE5F0E412DF4259005C7A0C /* OFBlockTests.m */; };
		4BF33AFE133807A20059CEF7 /* OFDataArrayTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B6EF66F1235358D0076B512 /* OFDataArrayTests.m */; };
		4BF33AFF133807A20059CEF7 /* OFDateTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BE5F0E512DF4259005C7A0C /* OFDateTests.m */; };
786
787
788
789
790
791
792


793
794
795
796
797
798
799
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803







+
+







		4BB61D4816DA2AB700986DE1 /* OFBinaryPackRepresentation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFBinaryPackRepresentation.h; path = src/OFBinaryPackRepresentation.h; sourceTree = "<group>"; };
		4BBA36C411406AB700CBA3AC /* atomic.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = atomic.h; path = src/atomic.h; sourceTree = "<group>"; };
		4BBA36C511406AB700CBA3AC /* macros.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = macros.h; path = src/macros.h; sourceTree = "<group>"; };
		4BC090421584F6760040640F /* OFInvalidJSONException.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFInvalidJSONException.h; path = src/exceptions/OFInvalidJSONException.h; sourceTree = "<group>"; };
		4BC090431584F6760040640F /* OFInvalidJSONException.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFInvalidJSONException.m; path = src/exceptions/OFInvalidJSONException.m; sourceTree = "<group>"; };
		4BD653C3143B8489006182F0 /* OFTCPSocket+SOCKS5.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "OFTCPSocket+SOCKS5.h"; path = "src/OFTCPSocket+SOCKS5.h"; sourceTree = "<group>"; };
		4BD653C4143B8489006182F0 /* OFTCPSocket+SOCKS5.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "OFTCPSocket+SOCKS5.m"; path = "src/OFTCPSocket+SOCKS5.m"; sourceTree = "<group>"; };
		4BD77FDC176E4BC40031C497 /* OFUnboundPrefixException.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFUnboundPrefixException.h; path = src/exceptions/OFUnboundPrefixException.h; sourceTree = "<group>"; };
		4BD77FDD176E4BC40031C497 /* OFUnboundPrefixException.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFUnboundPrefixException.m; path = src/exceptions/OFUnboundPrefixException.m; sourceTree = "<group>"; };
		4BD86D801237A6C600ED9912 /* OFBlock.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFBlock.h; path = src/OFBlock.h; sourceTree = SOURCE_ROOT; };
		4BD86D811237A6C600ED9912 /* OFBlock.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFBlock.m; path = src/OFBlock.m; sourceTree = SOURCE_ROOT; };
		4BD98C011338140B0048DD5B /* objfw-defs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "objfw-defs.h"; path = "src/objfw-defs.h"; sourceTree = SOURCE_ROOT; };
		4BDF37B41338055600F9A81A /* config.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = config.h; sourceTree = SOURCE_ROOT; };
		4BE17AD812FD744C002CEB0B /* foundation-compat.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "foundation-compat.m"; path = "src/foundation-compat.m"; sourceTree = SOURCE_ROOT; };
		4BE17AD912FD746D002CEB0B /* OFDataArray+Hashing.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "OFDataArray+Hashing.h"; path = "src/OFDataArray+Hashing.h"; sourceTree = SOURCE_ROOT; };
		4BE17ADA12FD746D002CEB0B /* OFDataArray+Hashing.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "OFDataArray+Hashing.m"; path = "src/OFDataArray+Hashing.m"; sourceTree = SOURCE_ROOT; };
973
974
975
976
977
978
979


980
981
982
983
984
985
986
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992







+
+







				4B55A0FC133ABEA900B58A93 /* OFThreadStartFailedException.m */,
				4B55A0FD133ABEA900B58A93 /* OFThreadStillRunningException.h */,
				4B55A0FE133ABEA900B58A93 /* OFThreadStillRunningException.m */,
				4B17FFA7133A34DF003E6DCD /* OFTruncatedDataException.h */,
				4B17FFA8133A34E1003E6DCD /* OFTruncatedDataException.m */,
				4B17FFB3133A374C003E6DCD /* OFUnboundNamespaceException.h */,
				4B17FFB4133A3750003E6DCD /* OFUnboundNamespaceException.m */,
				4BD77FDC176E4BC40031C497 /* OFUnboundPrefixException.h */,
				4BD77FDD176E4BC40031C497 /* OFUnboundPrefixException.m */,
				4B6743EF163C384A00EB1E59 /* OFUnlockFailedException.h */,
				4B6743F0163C384A00EB1E59 /* OFUnlockFailedException.m */,
				4B17FFAF133A3658003E6DCD /* OFUnsupportedProtocolException.h */,
				4B17FFB0133A365C003E6DCD /* OFUnsupportedProtocolException.m */,
				4BA4846015CC9F1E00D75360 /* OFUnsupportedVersionException.h */,
				4BA4846115CC9F1E00D75360 /* OFUnsupportedVersionException.m */,
				4B55A110133AC24500B58A93 /* OFWriteFailedException.h */,
1504
1505
1506
1507
1508
1509
1510

1511
1512
1513
1514
1515
1516
1517
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524







+







				4B6743F3163C384A00EB1E59 /* OFStillLockedException.h in Headers */,
				4B29BC63133AC9CB0004B236 /* OFSymlinkFailedException.h in Headers */,
				4B17FFA9133A34E7003E6DCD /* OFTruncatedDataException.h in Headers */,
				4B55A0FF133ABEA900B58A93 /* OFThreadJoinFailedException.h in Headers */,
				4B55A101133ABEA900B58A93 /* OFThreadStartFailedException.h in Headers */,
				4B55A103133ABEA900B58A93 /* OFThreadStillRunningException.h in Headers */,
				4B17FFB5133A375B003E6DCD /* OFUnboundNamespaceException.h in Headers */,
				4BD77FDE176E4BC40031C497 /* OFUnboundPrefixException.h in Headers */,
				4B6743F5163C384A00EB1E59 /* OFUnlockFailedException.h in Headers */,
				4B17FFB1133A3664003E6DCD /* OFUnsupportedProtocolException.h in Headers */,
				4BA4846215CC9F1E00D75360 /* OFUnsupportedVersionException.h in Headers */,
				4B55A116133AC24600B58A93 /* OFWriteFailedException.h in Headers */,
				4B55A109133AC05100B58A93 /* common.h in Headers */,
				4B2B3E7D140D430500EC2F7C /* OFArray_adjacent.h in Headers */,
				4B9BB7BD141CDE2D000AD1CC /* OFArray_adjacentSubarray.h in Headers */,
1836
1837
1838
1839
1840
1841
1842

1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854

1855
1856
1857
1858
1859
1860


1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874



1875
1876
1877
1878
1879
1880
1881







+












+






+
+



-
-
-







				4B17FF94133A317C003E6DCD /* OFInvalidArgumentException.m in Sources */,
				4B17FF9A133A3245003E6DCD /* OFInvalidEncodingException.m in Sources */,
				4B17FF9E133A32BA003E6DCD /* OFInvalidFormatException.m in Sources */,
				4BC090451584F6760040640F /* OFInvalidJSONException.m in Sources */,
				4B17FFBA133A381D003E6DCD /* OFInvalidServerReplyException.m in Sources */,
				4B29BC62133AC9CB0004B236 /* OFLinkFailedException.m in Sources */,
				4B90B7A7133AD87D00BD33CB /* OFListenFailedException.m in Sources */,
				4B6743F2163C384A00EB1E59 /* OFLockFailedException.m in Sources */,
				4B17FFA2133A3335003E6DCD /* OFMalformedXMLException.m in Sources */,
				4B17FF90133A3036003E6DCD /* OFMemoryNotPartOfObjectException.m in Sources */,
				4B90B790133AD46700BD33CB /* OFNotConnectedException.m in Sources */,
				4B17FF78133A2B18003E6DCD /* OFNotImplementedException.m in Sources */,
				4B55A10B133AC05100B58A93 /* OFOpenFileFailedException.m in Sources */,
				4B17FF84133A2DFB003E6DCD /* OFOutOfMemoryException.m in Sources */,
				4B17FF7C133A2C15003E6DCD /* OFOutOfRangeException.m in Sources */,
				4B55A113133AC24600B58A93 /* OFReadFailedException.m in Sources */,
				4B55A115133AC24600B58A93 /* OFReadOrWriteFailedException.m in Sources */,
				4B29BC57133AC8420004B236 /* OFRenameFileFailedException.m in Sources */,
				4B29BC42133AC4E80004B236 /* OFSeekFailedException.m in Sources */,
				4B90B792133AD46700BD33CB /* OFSetOptionFailedException.m in Sources */,
				4B6743F4163C384A00EB1E59 /* OFStillLockedException.m in Sources */,
				4B29BC64133AC9CB0004B236 /* OFSymlinkFailedException.m in Sources */,
				4B55A100133ABEA900B58A93 /* OFThreadJoinFailedException.m in Sources */,
				4B55A102133ABEA900B58A93 /* OFThreadStartFailedException.m in Sources */,
				4B55A104133ABEA900B58A93 /* OFThreadStillRunningException.m in Sources */,
				4B17FFAA133A34E7003E6DCD /* OFTruncatedDataException.m in Sources */,
				4B17FFB6133A375B003E6DCD /* OFUnboundNamespaceException.m in Sources */,
				4BD77FDF176E4BC40031C497 /* OFUnboundPrefixException.m in Sources */,
				4B6743F6163C384A00EB1E59 /* OFUnlockFailedException.m in Sources */,
				4B17FFB2133A3664003E6DCD /* OFUnsupportedProtocolException.m in Sources */,
				4BA4846315CC9F1E00D75360 /* OFUnsupportedVersionException.m in Sources */,
				4B55A117133AC24600B58A93 /* OFWriteFailedException.m in Sources */,
				4B6743F2163C384A00EB1E59 /* OFLockFailedException.m in Sources */,
				4B6743F4163C384A00EB1E59 /* OFStillLockedException.m in Sources */,
				4B6743F6163C384A00EB1E59 /* OFUnlockFailedException.m in Sources */,
			);
			runOnlyForDeploymentPostprocessing = 0;
		};
		4BF33AEC133807310059CEF7 /* Sources */ = {
			isa = PBXSourcesBuildPhase;
			buildActionMask = 2147483647;
			files = (

Modified src/OFXMLElement.m from [a91eb986c2] to [5660c1a7c6].

583
584
585
586
587
588
589
590


591
592
593
594
595
596
597
583
584
585
586
587
588
589

590
591
592
593
594
595
596
597
598







-
+
+








		if ([attributesObjects[j] namespace] != nil &&
		    (attributePrefix = [allNamespaces objectForKey:
		    [attributesObjects[j] namespace]]) == nil)
			@throw [OFUnboundNamespaceException
			    exceptionWithClass: [self class]
				     namespace: [attributesObjects[j]
						    namespace]];
						    namespace]
				       element: self];

		length += [attributeName UTF8StringLength] +
		    (attributePrefix != nil ?
		    [attributePrefix UTF8StringLength] + 1 : 0) +
		    [tmp UTF8StringLength] + 4;

		@try {

Modified src/OFXMLParser.m from [bf41f38598] to [12e7c5b831].

28
29
30
31
32
33
34
35

36
37
38
39
40
41
42
28
29
30
31
32
33
34

35
36
37
38
39
40
41
42







-
+







#import "OFXMLAttribute.h"
#import "OFStream.h"
#import "OFFile.h"
#import "OFSystemInfo.h"

#import "OFInitializationFailedException.h"
#import "OFMalformedXMLException.h"
#import "OFUnboundNamespaceException.h"
#import "OFUnboundPrefixException.h"

#import "autorelease.h"
#import "macros.h"

typedef void (*state_function)(id, SEL);
static SEL selectors[OF_XMLPARSER_NUM_STATES];
static state_function lookupTable[OF_XMLPARSER_NUM_STATES];
122
123
124
125
126
127
128
129

130
131


132
133
134
135
136
137
138
122
123
124
125
126
127
128

129
130

131
132
133
134
135
136
137
138
139







-
+

-
+
+








	if (attributePrefix == nil)
		return;

	attributeNS = namespace_for_prefix(attributePrefix, namespaces);

	if ((attributePrefix != nil && attributeNS == nil))
		@throw [OFUnboundNamespaceException
		@throw [OFUnboundPrefixException
		    exceptionWithClass: [self class]
				prefix: attributePrefix];
				prefix: attributePrefix
				parser: self];

	[attribute->_namespace release];
	attribute->_namespace = [attributeNS retain];
}

@implementation OFXMLParser
+ (void)initialize
578
579
580
581
582
583
584
585

586
587


588
589
590
591
592
593
594
579
580
581
582
583
584
585

586
587

588
589
590
591
592
593
594
595
596







-
+

-
+
+








	if (_data[_i] == '>' || _data[_i] == '/') {
		OFString *namespace;

		namespace = namespace_for_prefix(_prefix, _namespaces);

		if (_prefix != nil && namespace == nil)
			@throw [OFUnboundNamespaceException
			@throw [OFUnboundPrefixException
			    exceptionWithClass: [self class]
					prefix: _prefix];
					prefix: _prefix
					parser: self];

		if ([_delegate respondsToSelector: @selector(parser:
		    didStartElement:prefix:namespace:attributes:)])
			[_delegate parser: self
			  didStartElement: _name
				   prefix: _prefix
				namespace: namespace
667
668
669
670
671
672
673
674

675
676


677
678
679
680
681
682
683
669
670
671
672
673
674
675

676
677

678
679
680
681
682
683
684
685
686







-
+

-
+
+








	[_previous removeLastObject];

	[_buffer removeAllItems];

	namespace = namespace_for_prefix(_prefix, _namespaces);
	if (_prefix != nil && namespace == nil)
		@throw [OFUnboundNamespaceException
		@throw [OFUnboundPrefixException
		    exceptionWithClass: [self class]
				prefix: _prefix];
				prefix: _prefix
				parser: self];

	if ([_delegate respondsToSelector:
	    @selector(parser:didEndElement:prefix:namespace:)])
		[_delegate parser: self
		    didEndElement: _name
			   prefix: _prefix
			namespace: namespace];
719
720
721
722
723
724
725
726

727
728


729
730
731
732
733
734
735
722
723
724
725
726
727
728

729
730

731
732
733
734
735
736
737
738
739







-
+

-
+
+








	attributesObjects = [_attributes objects];
	attributesCount = [_attributes count];

	namespace = namespace_for_prefix(_prefix, _namespaces);

	if (_prefix != nil && namespace == nil)
		@throw [OFUnboundNamespaceException
		@throw [OFUnboundPrefixException
		    exceptionWithClass: [self class]
				prefix: _prefix];
				prefix: _prefix
				parser: self];

	for (j = 0; j < attributesCount; j++)
		resolve_attribute_namespace(attributesObjects[j], _namespaces,
		    self);

	pool = objc_autoreleasePoolPush();

Modified src/exceptions/Makefile from [556668b48e] to [9c29bedc9a].

33
34
35
36
37
38
39

40
41
42
43
44
45
46
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47







+







       OFRenameFileFailedException.m		\
       OFSeekFailedException.m			\
       OFSetOptionFailedException.m		\
       OFStillLockedException.m			\
       OFSymlinkFailedException.m		\
       OFTruncatedDataException.m		\
       OFUnboundNamespaceException.m		\
       OFUnboundPrefixException.m		\
       OFUnlockFailedException.m		\
       OFUnsupportedProtocolException.m		\
       OFUnsupportedVersionException.m		\
       OFWriteFailedException.m			\
       ${USE_SRCS_SOCKETS}			\
       ${USE_SRCS_THREADS}
SRCS_SOCKETS = OFAcceptFailedException.m		\

Modified src/exceptions/OFUnboundNamespaceException.h from [ae816ab4d8] to [449c7bd059].

12
13
14
15
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
81
82
83
84

85
86

87
88

89
12
13
14
15
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







+
+





-
+
+








-
+







+



-
-
+
+
-
-
-
-
-
-
-
-
-






+



-
-
+
+
-
-
-
-
-
-
-
-
-









-
+

-
+

-
+

 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#import "OFException.h"

@class OFXMLElement;

/*!
 * @brief An exception indicating an attempt to use an unbound namespace.
 */
@interface OFUnboundNamespaceException: OFException
{
	OFString *_namespace, *_prefix;
	OFString *_namespace;
	OFXMLElement *_element;
}

#ifdef OF_HAVE_PROPERTIES
# ifdef __cplusplus
@property (readonly, copy, nonatomic, getter=namespace) OFString *namespace_;
# else
@property (readonly, copy, nonatomic) OFString *namespace;
# endif
@property (readonly, copy, nonatomic) OFString *prefix;
@property (readonly, retain, nonatomic) OFXMLElement *element;
#endif

/*!
 * @brief Creates a new, autoreleased unbound namespace exception.
 *
 * @param class_ The class of the object which caused the exception
 * @param namespace_ The namespace which is unbound
 * @param element The element in which the namespace was not bound
 * @return A new, autoreleased unbound namespace exception
 */
+ (instancetype)exceptionWithClass: (Class)class_
			 namespace: (OFString*)namespace_;

			 namespace: (OFString*)namespace_
			   element: (OFXMLElement*)element;
/*!
 * @brief Creates a new, autoreleased unbound namespace exception.
 *
 * @param class_ The class of the object which caused the exception
 * @param prefix The prefix which is unbound
 * @return A new, autoreleased unbound namespace exception
 */
+ (instancetype)exceptionWithClass: (Class)class_
			    prefix: (OFString*)prefix;

/*!
 * @brief Initializes an already allocated unbound namespace exception.
 *
 * @param class_ The class of the object which caused the exception
 * @param namespace_ The namespace which is unbound
 * @param element The element in which the namespace was not bound
 * @return An initialized unbound namespace exception
 */
- initWithClass: (Class)class_
      namespace: (OFString*)namespace_;

      namespace: (OFString*)namespace_
	element: (OFXMLElement*)element;
/*!
 * @brief Initializes an already allocated unbound namespace exception.
 *
 * @param class_ The class of the object which caused the exception
 * @param prefix The prefix which is unbound
 * @return An initialized unbound namespace exception
 */
- initWithClass: (Class)class_
	 prefix: (OFString*)prefix;

/*!
 * @brief Returns the unbound namespace.
 *
 * @return The unbound namespace
 */
- (OFString*)namespace;

/*!
 * @brief Returns the unbound prefix.
 * @brief Returns the element in which the namespace was not bound.
 *
 * @return The unbound prefix
 * @return The element in which the namespace was not bound
 */
- (OFString*)prefix;
- (OFXMLElement*)element;
@end

Modified src/exceptions/OFUnboundNamespaceException.m from [1510166b61] to [37f60bba81].

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
81
82
83
84
85
86

87
88
89
90
91
92
93
94
95


96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112

113
114

115
116
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
81
82
83
84

85
86

87
88
89







+






+


-
+
-
-
-
-
-
-
-
+
















+





-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-











-
+






-
-
-
+
+
-
-
-
-
-
-
-
-
-







-
+

-
+



#include "config.h"

#include <stdlib.h>

#import "OFUnboundNamespaceException.h"
#import "OFString.h"
#import "OFXMLElement.h"

#import "common.h"

@implementation OFUnboundNamespaceException
+ (instancetype)exceptionWithClass: (Class)class
			 namespace: (OFString*)namespace
			   element: (OFXMLElement*)element
{
	return [[[self alloc] initWithClass: class
				  namespace: namespace] autorelease];
				  namespace: namespace
}

+ (instancetype)exceptionWithClass: (Class)class
			    prefix: (OFString*)prefix
{
	return [[[self alloc] initWithClass: class
				     prefix: prefix] autorelease];
				    element: element] autorelease];
}

- initWithClass: (Class)class
{
	@try {
		[self doesNotRecognizeSelector: _cmd];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	abort();
}

- initWithClass: (Class)class
      namespace: (OFString*)namespace
	element: (OFXMLElement*)element
{
	self = [super initWithClass: class];

	@try {
		_namespace = [namespace copy];
	} @catch (id e) {
		[self release];
		@throw e;
	}

		_element = [element retain];
	return self;
}

- initWithClass: (Class)class
	 prefix: (OFString*)prefix
{
	self = [super initWithClass: class];

	@try {
		_prefix = [prefix copy];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- (void)dealloc
{
	[_namespace release];
	[_prefix release];
	[_element release];

	[super dealloc];
}

- (OFString*)description
{
	if (_namespace != nil)
		return [OFString stringWithFormat:
		    @"The namespace %@ is not bound in class %@", _namespace,
	return [OFString stringWithFormat:
	    @"The namespace %@ is not bound in class %@", _namespace, _inClass];
		    _inClass];
	else if (_prefix != nil)
		return [OFString stringWithFormat:
		    @"The prefix %@ is not bound to any namespace in class %@",
		    _prefix, _inClass];
	else
		return [OFString stringWithFormat:
		    @"A namespace or prefix is not bound in class %@",
		    _inClass];
}

- (OFString*)namespace
{
	OF_GETTER(_namespace, false)
}

- (OFString*)prefix
- (OFXMLElement*)element
{
	OF_GETTER(_prefix, false)
	OF_GETTER(_element, false)
}
@end

Added src/exceptions/OFUnboundPrefixException.h version [b7951aa078].









































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
/*
 * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013
 *   Jonathan Schleifer <js@webkeks.org>
 *
 * All rights reserved.
 *
 * This file is part of ObjFW. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
 * the packaging of this file.
 *
 * Alternatively, it may be distributed under the terms of the GNU General
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#import "OFException.h"

@class OFXMLParser;

/*!
 * @brief An exception indicating an attempt to use an unbound prefix.
 */
@interface OFUnboundPrefixException: OFException
{
	OFString *_prefix;
	OFXMLParser *_parser;
}

#ifdef OF_HAVE_PROPERTIES
@property (readonly, copy, nonatomic) OFString *prefix;
@property (readonly, retain, nonatomic) OFXMLParser *parser;
#endif

/*!
 * @brief Creates a new, autoreleased unbound prefix exception.
 *
 * @param class_ The class of the object which caused the exception
 * @param prefix The prefix which is unbound
 * @param parser The parser which encountered the unbound prefix
 * @return A new, autoreleased unbound prefix exception
 */
+ (instancetype)exceptionWithClass: (Class)class_
			    prefix: (OFString*)prefix
			    parser: (OFXMLParser*)parser;

/*!
 * @brief Initializes an already allocated unbound prefix exception.
 *
 * @param class_ The class of the object which caused the exception
 * @param prefix The prefix which is unbound
 * @param parser The parser which encountered the unbound prefix
 * @return An initialized unbound prefix exception
 */
- initWithClass: (Class)class_
	 prefix: (OFString*)prefix
	 parser: (OFXMLParser*)parser;

/*!
 * @brief Returns the unbound prefix.
 *
 * @return The unbound prefix
 */
- (OFString*)prefix;

/*!
 * @brief Returns the parser which encountered the unbound prefix.
 *
 * @return The parser which encountered the unbound prefix
 */
- (OFXMLParser*)parser;
@end

Added src/exceptions/OFUnboundPrefixException.m version [ecddbe546f].



























































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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
81
82
83
84
85
86
87
88
89
90
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
/*
 * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013
 *   Jonathan Schleifer <js@webkeks.org>
 *
 * All rights reserved.
 *
 * This file is part of ObjFW. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
 * the packaging of this file.
 *
 * Alternatively, it may be distributed under the terms of the GNU General
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#include "config.h"

#include <stdlib.h>

#import "OFUnboundPrefixException.h"
#import "OFString.h"
#import "OFXMLParser.h"

#import "common.h"

@implementation OFUnboundPrefixException
+ (instancetype)exceptionWithClass: (Class)class
			    prefix: (OFString*)prefix
			    parser: (OFXMLParser*)parser
{
	return [[[self alloc] initWithClass: class
				     prefix: prefix
				     parser: parser] autorelease];
}

- initWithClass: (Class)class
{
	@try {
		[self doesNotRecognizeSelector: _cmd];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	abort();
}

- initWithClass: (Class)class
	 prefix: (OFString*)prefix
	 parser: (OFXMLParser*)parser
{
	self = [super initWithClass: class];

	@try {
		_prefix = [prefix copy];
		_parser = [parser retain];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- (void)dealloc
{
	[_prefix release];
	[_parser release];

	[super dealloc];
}

- (OFString*)description
{
	return [OFString stringWithFormat:
	    @"The XML parser in class %@ encountered the unbound prefix %@ in "
	    @"line %zd!", _inClass, _prefix, [_parser lineNumber]];
}

- (OFString*)prefix
{
	OF_GETTER(_prefix, false)
}

- (OFXMLParser*)parser
{
	OF_GETTER(_parser, false)
}
@end