2 Copyright (C) 2000-2005 SKYRIX Software AG
4 This file is part of SOPE.
6 SOPE is free software; you can redistribute it and/or modify it under
7 the terms of the GNU Lesser General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
11 SOPE is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14 License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with SOPE; see the file COPYING. If not, write to the
18 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
22 #include "XmlRpcMethodResponse.h"
23 #include "NSObject+XmlRpc.h"
24 #include "XmlRpcCoder.h"
27 #if LIB_FOUNDATION_LIBRARY
28 # include <Foundation/NSConcreteNumber.h>
31 #define BOOLEAN_TYPE 0
32 #define INTEGER_TYPE 1
35 @implementation NSNumber(XmlRpcCoding)
37 - (unsigned int)_xmlRpcNumberType {
38 static Class BoolClass = Nil;
41 BoolClass = NSClassFromString(@"NSBoolNumber");
43 if ([self isKindOfClass:BoolClass])
46 switch (*[self objCType]) {
64 - (NSString *)xmlRpcType {
65 switch ([self _xmlRpcNumberType]) {
70 default: /* INTEGER_TYPE */
75 - (void)encodeWithXmlRpcCoder:(XmlRpcEncoder *)_coder {
76 switch ([self _xmlRpcNumberType]) {
78 [_coder encodeBoolean:[self boolValue]];
81 [_coder encodeDouble:[self doubleValue]];
83 default: /* INTEGER_TYPE */
84 [_coder encodeInt:[self intValue]];
88 + (id)decodeObjectWithXmlRpcCoder:(XmlRpcDecoder *)_coder {
89 return [NSNumber numberWithInt:[_coder decodeInt]];
92 @end /* NSNumber(XmlRpcCoding) */
94 #if LIB_FOUNDATION_LIBRARY
96 @implementation NSBoolNumber(XmlRpcCoding)
98 + (id)decodeObjectWithXmlRpcCoder:(XmlRpcDecoder *)_coder {
99 return [[[NSNumber alloc] initWithBool:[_coder decodeBoolean]] autorelease];
102 - (NSString *)xmlRpcType {
106 @end /* NSBoolNumber(XmlRpcCoding) */
108 // nicht notwendig, nur BOOL muss speziell abgefangen werden ??? :
109 @implementation NSFloatNumber(XmlRpcCoding)
110 + (id)decodeObjectWithXmlRpcCoder:(XmlRpcDecoder *)_coder {
111 return [[[NSNumber alloc] initWithDouble:[_coder decodeDouble]] autorelease];
114 - (NSString *)xmlRpcType {
118 @end /* NSFloatNumber(XmlRpcCoding) */
120 @implementation NSDoubleNumber(XmlRpcCoding)
121 + (id)decodeObjectWithXmlRpcCoder:(XmlRpcDecoder *)_coder {
122 return [[[NSNumber alloc] initWithDouble:[_coder decodeDouble]] autorelease];
125 - (NSString *)xmlRpcType {
129 @end /* NSDoubleNumber(XmlRpcCoding) */