ObjFW  Check-in [0952a96827]

Overview
Comment:Add -[{decimal,hexadecimal,float,double}Value] to OFXMLAttribute.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 0952a96827ba0476e898d09050ca7db98ba32d5b3df53b48917dbe6af357e77a
User & Date: js on 2011-06-26 23:54:31
Other Links: manifest | tags
Context
2011-06-27
00:10
Style improvements. check-in: d13ff5382a user: js tags: trunk
2011-06-26
23:54
Add -[{decimal,hexadecimal,float,double}Value] to OFXMLAttribute. check-in: 0952a96827 user: js tags: trunk
23:40
Check the item size of the passed data array in of_base64_decode(). check-in: be49630777 user: js tags: trunk
Changes

Modified src/OFDate.m from [88ef3a2c1c] to [914a225e3e].

265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
		    elementForName: @"microseconds"
			 namespace: OF_SERIALIZATION_NS];

		if (secondsElement == nil || microsecondsElement == nil)
			@throw [OFInvalidArgumentException newWithClass: isa
							       selector: _cmd];

		seconds = (int64_t)[[secondsElement stringValue] decimalValue];
		microseconds =
		    (uint32_t)[[microsecondsElement stringValue] decimalValue];

		[pool release];
	} @catch (id e) {
		[self release];
		@throw e;
	}








|
|
<







265
266
267
268
269
270
271
272
273

274
275
276
277
278
279
280
		    elementForName: @"microseconds"
			 namespace: OF_SERIALIZATION_NS];

		if (secondsElement == nil || microsecondsElement == nil)
			@throw [OFInvalidArgumentException newWithClass: isa
							       selector: _cmd];

		seconds = (int64_t)[secondsElement decimalValue];
		microseconds = (uint32_t)[microsecondsElement decimalValue];


		[pool release];
	} @catch (id e) {
		[self release];
		@throw e;
	}

Modified src/OFNumber.m from [b1a8643b2f] to [a47eecf9ee].

738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
					selector: _cmd];
		} else if ([typeString isEqual: @"unsigned"]) {
			/*
			 * FIXME: This will fail if the value is bigger than
			 *	  INTMAX_MAX!
			 */
			type = OF_NUMBER_UINTMAX;
			value.uintmax = [[element stringValue] decimalValue];
		} else if ([typeString isEqual: @"signed"]) {
			type = OF_NUMBER_INTMAX;
			value.intmax = [[element stringValue] decimalValue];
		} else if ([typeString isEqual: @"float"]) {
			union {
				float f;
				uint32_t i;
			} f;

			type = OF_NUMBER_FLOAT;







|


|







738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
					selector: _cmd];
		} else if ([typeString isEqual: @"unsigned"]) {
			/*
			 * FIXME: This will fail if the value is bigger than
			 *	  INTMAX_MAX!
			 */
			type = OF_NUMBER_UINTMAX;
			value.uintmax = [element decimalValue];
		} else if ([typeString isEqual: @"signed"]) {
			type = OF_NUMBER_INTMAX;
			value.intmax = [element decimalValue];
		} else if ([typeString isEqual: @"float"]) {
			union {
				float f;
				uint32_t i;
			} f;

			type = OF_NUMBER_FLOAT;

Modified src/OFXMLAttribute.h from [a80691a45f] to [1b135c3546].

68
69
70
71
72
73
74




















75
 */
- (OFString*)namespace;

/**
 * \return The string value of the attribute as an autoreleased OFString
 */
- (OFString*)stringValue;




















@end







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

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
 */
- (OFString*)namespace;

/**
 * \return The string value of the attribute as an autoreleased OFString
 */
- (OFString*)stringValue;

/**
 * \return An integer with the decimal value of the attribute
 */
- (intmax_t)decimalValue;

/**
 * \return An integer with the hexadecimal value of the attribute
 */
- (uintmax_t)hexadecimalValue;

/**
 * \return A float with the float value of the attribute
 */
- (float)floatValue;

/**
 * \return A double with the double value of the attribute
 */
- (double)doubleValue;
@end

Modified src/OFXMLAttribute.m from [259ae30ded] to [6b3b878926].

106
107
108
109
110
111
112




















113
114
115
116
117
118
119
	return [[ns copy] autorelease];
}

- (OFString*)stringValue
{
	return [[stringValue copy] autorelease];
}





















- (BOOL)isEqual: (id)object
{
	OFXMLAttribute *otherAttribute;

	if (![object isKindOfClass: [OFXMLAttribute class]])
		return NO;







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







106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
	return [[ns copy] autorelease];
}

- (OFString*)stringValue
{
	return [[stringValue copy] autorelease];
}

- (intmax_t)decimalValue
{
	return [stringValue decimalValue];
}

- (uintmax_t)hexadecimalValue
{
	return [stringValue hexadecimalValue];
}

- (float)floatValue
{
	return [stringValue floatValue];
}

- (double)doubleValue
{
	return [stringValue doubleValue];
}

- (BOOL)isEqual: (id)object
{
	OFXMLAttribute *otherAttribute;

	if (![object isKindOfClass: [OFXMLAttribute class]])
		return NO;