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 #ifndef __XmlRpc_XmlRpcCoder_H__
24 #define __XmlRpc_XmlRpcCoder_H__
26 #import <Foundation/NSObject.h>
28 @class NSDictionary, NSArray, NSNumber, NSString, NSCalendarDate, NSData;
29 @class NSMutableArray, NSMutableString, NSTimeZone, NSDate;
30 @class XmlRpcValue, XmlRpcMethodCall, XmlRpcMethodResponse;
33 The XmlRpcEncoder is used to encode XML-RPC objects. It's pretty much like
34 NSArchiver, only for XML-RPC.
38 NSMutableString *str; // asume that exists
39 XmlRpcMethodResponse *methodResponse; // asume that exists
40 XmlRpcMethodCall *methodCall; // asume that exists
42 coder = [[XmlRpcEncoder alloc] initForWritingWithMutableString:str];
44 [coder encodeMethodCall:methodCall];
48 [coder encodeMethodResponse:methodResponse];
50 @interface XmlRpcEncoder : NSObject
52 NSMutableString *string;
54 NSMutableArray *objectStack;
55 NSMutableArray *objectHasStructStack;
59 - (id)initForWritingWithMutableString:(NSMutableString *)_string;
61 - (void)encodeMethodCall:(XmlRpcMethodCall *)_methodCall;
62 - (void)encodeMethodResponse:(XmlRpcMethodResponse *)_methodResponse;
64 - (void)encodeStruct:(NSDictionary *)_struct;
65 - (void)encodeArray:(NSArray *)_array;
66 - (void)encodeBase64:(NSData *)_data;
67 - (void)encodeBoolean:(BOOL)_number;
68 - (void)encodeInt:(int)_number;
69 - (void)encodeDouble:(double)_number;
70 - (void)encodeString:(NSString *)_string;
71 - (void)encodeDateTime:(NSDate *)_date;
72 - (void)encodeObject:(id)_object;
74 - (void)encodeStruct:(NSDictionary *)_struct forKey:(NSString *)_key;
75 - (void)encodeArray:(NSArray *)_array forKey:(NSString *)_key;
76 - (void)encodeBase64:(NSData *)_data forKey:(NSString *)_key;
77 - (void)encodeBoolean:(BOOL)_number forKey:(NSString *)_key;
78 - (void)encodeInt:(int)_number forKey:(NSString *)_key;
79 - (void)encodeDouble:(double)_number forKey:(NSString *)_key;
80 - (void)encodeString:(NSString *)_string forKey:(NSString *)_key;
81 - (void)encodeDateTime:(NSDate *)_date forKey:(NSString *)_key;
82 - (void)encodeObject:(id)_object forKey:(NSString *)_key;
84 - (void)setDefaultTimeZone:(NSTimeZone *)_timeZone;
86 - (NSTimeZone *)defaultTimeZone;
93 The XmlRpcDecoder is used to decode XML-RPC objects. It's pretty much like
94 NSUnarchiver, only for XML-RPC.
98 NSString *xmlRpcString; // asume that exists
99 XmlRpcMethodCall *methodCall = nil;
100 XmlRpcMethodResponse *methodResponse = nil;
102 coder = [[XmlRpcDecoder alloc] initForReadingWithString:xmlRpcString];
104 methodCall = [coder decodeMethodCall];
108 methodResponse = [coder decodeMethodResponse];
110 @interface XmlRpcDecoder : NSObject
113 NSMutableArray *valueStack;
115 NSMutableArray *unarchivedObjects;
116 NSMutableSet *awakeObjects;
117 NSTimeZone *timeZone;
120 - (id)initForReadingWithString:(NSString *)_string;
121 - (id)initForReadingWithData:(NSData *)_data;
123 - (XmlRpcMethodCall *)decodeMethodCall;
124 - (XmlRpcMethodResponse *)decodeMethodResponse;
127 - (NSDictionary *)decodeStruct;
128 - (NSArray *)decodeArray;
129 - (NSData *)decodeBase64;
130 - (BOOL)decodeBoolean;
132 - (double)decodeDouble;
133 - (NSString *)decodeString;
134 - (NSCalendarDate *)decodeDateTime;
137 - (NSDictionary *)decodeStructForKey:(NSString *)_key;
138 - (NSArray *)decodeArrayForKey:(NSString *)_key;
139 - (NSData *)decodeBase64ForKey:(NSString *)_key;
140 - (BOOL)decodeBooleanForKey:(NSString *)_key;
141 - (int)decodeIntForKey:(NSString *)_key;
142 - (double)decodeDoubleForKey:(NSString *)_key;
143 - (NSString *)decodeStringForKey:(NSString *)_key;
144 - (NSCalendarDate *)decodeDateTimeForKey:(NSString *)_key;
145 - (id)decodeObjectForKey:(NSString *)_key;
147 - (void)setDefaultTimeZone:(NSTimeZone *)_timeZone;
148 - (NSTimeZone *)defaultTimeZone;
151 - (void)ensureObjectAwake:(id)_object;
152 - (void)finishInitializationOfObjects;
153 - (void)awakeObjects;
157 @interface NSObject(XmlRpcCoder)
159 + (id)decodeObjectWithXmlRpcCoder:(XmlRpcDecoder *)_decoder;
160 - (void)encodeWithXmlRpcCoder:(XmlRpcEncoder *)_coder;
164 @interface NSObject(XmlRpcDecoderAwakeMethods)
166 - (void)finishInitializationWithXmlRpcDecoder:(XmlRpcDecoder *)_decoder;
167 - (void)awakeFromXmlRpcDecoder:(XmlRpcDecoder *)_decoder;
172 #endif /* __XmlRpc_XmlRpcCoder_H__ */