]> err.no Git - sope/blob - sope-appserver/NGXmlRpc/EOQualifier+XmlRpcCoding.m
removed some libFoundation dependencies, cleaned up
[sope] / sope-appserver / NGXmlRpc / EOQualifier+XmlRpcCoding.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 <EOControl/EOQualifier.h>
24 #include "common.h"
25 #include <XmlRpc/XmlRpcCoder.h>
26
27 #if APPLE_FOUNDATION_LIBRARY || NeXT_Foundation_LIBRARY
28 @interface NSObject(Miss)
29 - (void)subclassResponsibility:(SEL)cmd;
30 @end
31 #endif
32
33 @implementation EOQualifier(XmlRpcCoding)
34
35 - (id)initWithXmlRpcCoder:(XmlRpcDecoder *)_coder {
36   // TODO: hh asks: whats that ?
37   return [self init];
38 }
39 - (void)encodeWithXmlRpcCoder:(XmlRpcEncoder *)_coder {
40   [self subclassResponsibility:_cmd];
41 }
42
43 @end /* EOQualifier */
44
45 @implementation EOAndQualifier(XmlRpcCoding)
46 - (id)initWithXmlRpcCoder:(XmlRpcDecoder *)_coder {
47   NSArray *quals = [_coder decodeArrayForKey:@"qualifiers"];
48   
49   return [self initWithQualifierArray:quals];
50 }
51
52 - (void)encodeWithXmlRpcCoder:(XmlRpcEncoder *)_coder {
53   [_coder encodeArray:[self qualifiers] forKey:@"qualifiers"];
54 }
55
56 @end /* EOAndQualifier(XmlRpcCoding) */
57
58 @implementation EOOrQualifier(XmlRpcCoding)
59 - (id)initWithXmlRpcCoder:(XmlRpcDecoder *)_coder {
60   NSArray *quals = [_coder decodeArrayForKey:@"qualifiers"];
61   
62   return [self initWithQualifierArray:quals];
63 }
64
65 - (void)encodeWithXmlRpcCoder:(XmlRpcEncoder *)_coder {
66   [_coder encodeArray:[self qualifiers] forKey:@"qualifiers"];
67 }
68
69 @end /* EOOrQualifier(XmlRpcCoding) */
70
71 @implementation EONotQualifier(XmlRpcCoding)
72 - (id)initWithXmlRpcCoder:(XmlRpcDecoder *)_coder {
73   return [self initWithQualifier:[_coder decodeObject]];
74 }
75
76 - (void)encodeWithXmlRpcCoder:(XmlRpcEncoder *)_coder {
77   [_coder encodeObject:[self qualifier]];
78 }
79
80 @end /* EONotQualifier(XmlRpcCoding) */
81
82 @implementation EOKeyValueQualifier(XmlRpcCoding)
83 - (id)initWithXmlRpcCoder:(XmlRpcDecoder *)_coder {
84   NSString *k  = nil;
85   id       val = nil;
86   SEL      sel = NULL;
87
88   k = [_coder decodeStringForKey:@"selector"];
89   if (k) sel = NSSelectorFromString(k);
90   val = [_coder decodeObjectForKey:@"value"];
91   k   = [_coder decodeStringForKey:@"key"];
92   
93   return [self initWithKey:k operatorSelector:sel value:val];
94 }
95
96 - (void)encodeWithXmlRpcCoder:(XmlRpcEncoder *)_coder {
97   [_coder encodeString:[self key]   forKey:@"key"];
98   [_coder encodeObject:[self value] forKey:@"value"];
99   [_coder encodeString:NSStringFromSelector([self selector])
100           forKey:@"selector"];
101 }
102
103 @end /* EOKeyValueQualifier(XmlRpcCoding) */
104
105 @implementation EOKeyComparisonQualifier(XmlRpcCoding)
106
107 - (id)initWithXmlRpcCoder:(XmlRpcDecoder *)_coder {
108   NSString *lKey = nil;
109   NSString *rKey = nil;
110   SEL      sel   = NULL;
111
112   lKey = [_coder decodeStringForKey:@"selector"];
113   if (lKey) sel = NSSelectorFromString(lKey);
114   lKey = [_coder decodeObjectForKey:@"leftKey"];
115   rKey = [_coder decodeStringForKey:@"rightKey"];
116   
117   return [self initWithLeftKey:lKey operatorSelector:sel rightKey:rKey];
118 }
119
120 - (void)encodeWithXmlRpcCoder:(XmlRpcEncoder *)_coder {
121   [_coder encodeString:[self leftKey]  forKey:@"leftKey"];
122   [_coder encodeObject:[self rightKey] forKey:@"rightKey"];
123   [_coder encodeString:NSStringFromSelector([self selector])
124           forKey:@"selector"];
125 }
126
127 @end /* EOKeyComparisonQualifier(XmlRpcCoding) */
128
129 @implementation EOQualifierVariable(XmlRpcCoding)
130
131 - (id)initWithXmlRpcCoder:(XmlRpcDecoder *)_coder {
132   return [self initWithKey:[_coder decodeString]];
133 }
134
135 - (void)encodeWithXmlRpcCoder:(XmlRpcEncoder *)_coder {
136   [_coder encodeString:[self key]];
137 }
138
139 @end /* EOQualifierVariable(XmlRpcCoding) */