2 Copyright (C) 2000-2003 SKYRIX Software AG
4 This file is part of OGo
6 OGo 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 OGo 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 OGo; see the file COPYING. If not, write to the
18 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
23 #include "XmlRpcMethodResponse.h"
24 #include "NSObject+XmlRpc.h"
25 #include "XmlRpcCoder.h"
28 #if LIB_FOUNDATION_LIBRARY
29 # include <Foundation/NSConcreteNumber.h>
32 #define BOOLEAN_TYPE 0
33 #define INTEGER_TYPE 1
36 @implementation NSNumber(XmlRpcCoding)
38 - (unsigned int)_xmlRpcNumberType {
39 static Class BoolClass = Nil;
42 BoolClass = NSClassFromString(@"NSBoolNumber");
44 if ([self isKindOfClass:BoolClass])
47 switch (*[self objCType]) {
65 - (NSString *)xmlRpcType {
66 switch ([self _xmlRpcNumberType]) {
71 default: /* INTEGER_TYPE */
76 - (void)encodeWithXmlRpcCoder:(XmlRpcEncoder *)_coder {
77 switch ([self _xmlRpcNumberType]) {
79 [_coder encodeBoolean:[self boolValue]];
82 [_coder encodeDouble:[self doubleValue]];
84 default: /* INTEGER_TYPE */
85 [_coder encodeInt:[self intValue]];
89 + (id)decodeObjectWithXmlRpcCoder:(XmlRpcDecoder *)_coder {
90 return [NSNumber numberWithInt:[_coder decodeInt]];
93 @end /* NSNumber(XmlRpcCoding) */
95 #if LIB_FOUNDATION_LIBRARY
97 @implementation NSBoolNumber(XmlRpcCoding)
99 + (id)decodeObjectWithXmlRpcCoder:(XmlRpcDecoder *)_coder {
100 return [[[NSNumber alloc] initWithBool:[_coder decodeBoolean]] autorelease];
103 - (NSString *)xmlRpcType {
107 @end /* NSBoolNumber(XmlRpcCoding) */
109 // nicht notwendig, nur BOOL muss speziell abgefangen werden ??? :
110 @implementation NSFloatNumber(XmlRpcCoding)
111 + (id)decodeObjectWithXmlRpcCoder:(XmlRpcDecoder *)_coder {
112 return [[[NSNumber alloc] initWithDouble:[_coder decodeDouble]] autorelease];
115 - (NSString *)xmlRpcType {
119 @end /* NSFloatNumber(XmlRpcCoding) */
121 @implementation NSDoubleNumber(XmlRpcCoding)
122 + (id)decodeObjectWithXmlRpcCoder:(XmlRpcDecoder *)_coder {
123 return [[[NSNumber alloc] initWithDouble:[_coder decodeDouble]] autorelease];
126 - (NSString *)xmlRpcType {
130 @end /* NSDoubleNumber(XmlRpcCoding) */