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