]> err.no Git - sope/blob - sope-xml/XmlRpc/XmlRpcValue.m
fixes for Xcode project
[sope] / sope-xml / XmlRpc / XmlRpcValue.m
1 /*
2   Copyright (C) 2000-2003 SKYRIX Software AG
3
4   This file is part of OGo
5
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
9   later version.
10
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.
15
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
19   02111-1307, USA.
20 */
21 // $Id$
22
23 #include "XmlRpcValue.h"
24 #include "common.h"
25
26 @implementation XmlRpcValue
27 /*"
28   The XmlRpcValue class is used internally by the XML-RPC decoder to
29   represent any valid XML-RPC value. You should never need to use this class.
30 "*/
31
32 - (id)initWithValue:(id)_value className:(NSString *)_className {
33   if ((self = [super init])) {
34     NSString *cName;
35     
36     ASSIGN(self->value, _value);
37     cName = (_className != nil)
38       ? _className
39       : NSStringFromClass([_value class]);
40
41     ASSIGN(self->className, cName);
42   }
43   return self;
44 }
45
46 - (void)dealloc {
47   [self->className release];
48   [self->value     release];
49   [super dealloc];
50 }
51
52 - (id)value {
53   return self->value;
54 }
55
56 - (void)setClassName:(NSString *)_className {
57   if (_className != self->className) {
58     [self->className autorelease];
59     self->className = [_className copy];
60   }
61 }
62 - (NSString *)className {
63   return self->className;
64 }
65
66 - (Class)class {
67   return NSClassFromString([self className]);
68 }
69
70 - (BOOL)isException {
71   return [(id<NSObject>)[self class] isKindOfClass:[NSException class]];
72 }
73 - (BOOL)isDictionary {
74   return [(id<NSObject>)[self class] isKindOfClass:[NSDictionary class]];
75 }
76
77 /* description */
78
79 - (NSString *)description {
80   return [NSString stringWithFormat:@"XmlRpcValue: %@->%@",
81                    self->className,
82                    self->value];
83 }
84
85 /* NSCopying */
86
87 - (id)copyWithZone:(NSZone *)zone {
88   return [[[self class] alloc]
89                  initWithValue:self->value className:self->className];
90 }
91
92 @end /* XmlRpcValue */