2 Copyright (C) 2000-2005 SKYRIX Software AG
4 This file is part of SOPE.
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
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.
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
22 #ifndef __XmlRpc_XmlRpcCoder_H__
23 #define __XmlRpc_XmlRpcCoder_H__
25 #import <Foundation/NSObject.h>
27 @class NSDictionary, NSArray, NSNumber, NSString, NSCalendarDate, NSData;
28 @class NSMutableArray, NSMutableString, NSTimeZone, NSDate;
29 @class XmlRpcValue, XmlRpcMethodCall, XmlRpcMethodResponse;
32 The XmlRpcEncoder is used to encode XML-RPC objects. It's pretty much like
33 NSArchiver, only for XML-RPC.
37 NSMutableString *str; // asume that exists
38 XmlRpcMethodResponse *methodResponse; // asume that exists
39 XmlRpcMethodCall *methodCall; // asume that exists
41 coder = [[XmlRpcEncoder alloc] initForWritingWithMutableString:str];
43 [coder encodeMethodCall:methodCall];
47 [coder encodeMethodResponse:methodResponse];
49 @interface XmlRpcEncoder : NSObject
51 NSMutableString *string;
53 NSMutableArray *objectStack;
54 NSMutableArray *objectHasStructStack;
58 - (id)initForWritingWithMutableString:(NSMutableString *)_string;
60 - (void)encodeMethodCall:(XmlRpcMethodCall *)_methodCall;
61 - (void)encodeMethodResponse:(XmlRpcMethodResponse *)_methodResponse;
63 - (void)encodeStruct:(NSDictionary *)_struct;
64 - (void)encodeArray:(NSArray *)_array;
65 - (void)encodeBase64:(NSData *)_data;
66 - (void)encodeBoolean:(BOOL)_number;
67 - (void)encodeInt:(int)_number;
68 - (void)encodeDouble:(double)_number;
69 - (void)encodeString:(NSString *)_string;
70 - (void)encodeDateTime:(NSDate *)_date;
71 - (void)encodeObject:(id)_object;
73 - (void)encodeStruct:(NSDictionary *)_struct forKey:(NSString *)_key;
74 - (void)encodeArray:(NSArray *)_array forKey:(NSString *)_key;
75 - (void)encodeBase64:(NSData *)_data forKey:(NSString *)_key;
76 - (void)encodeBoolean:(BOOL)_number forKey:(NSString *)_key;
77 - (void)encodeInt:(int)_number forKey:(NSString *)_key;
78 - (void)encodeDouble:(double)_number forKey:(NSString *)_key;
79 - (void)encodeString:(NSString *)_string forKey:(NSString *)_key;
80 - (void)encodeDateTime:(NSDate *)_date forKey:(NSString *)_key;
81 - (void)encodeObject:(id)_object forKey:(NSString *)_key;
83 - (void)setDefaultTimeZone:(NSTimeZone *)_timeZone;
85 - (NSTimeZone *)defaultTimeZone;
92 The XmlRpcDecoder is used to decode XML-RPC objects. It's pretty much like
93 NSUnarchiver, only for XML-RPC.
97 NSString *xmlRpcString; // asume that exists
98 XmlRpcMethodCall *methodCall = nil;
99 XmlRpcMethodResponse *methodResponse = nil;
101 coder = [[XmlRpcDecoder alloc] initForReadingWithString:xmlRpcString];
103 methodCall = [coder decodeMethodCall];
107 methodResponse = [coder decodeMethodResponse];
109 @interface XmlRpcDecoder : NSObject
112 NSMutableArray *valueStack;
114 NSMutableArray *unarchivedObjects;
115 NSMutableSet *awakeObjects;
116 NSTimeZone *timeZone;
119 - (id)initForReadingWithString:(NSString *)_string;
120 - (id)initForReadingWithData:(NSData *)_data;
122 - (XmlRpcMethodCall *)decodeMethodCall;
123 - (XmlRpcMethodResponse *)decodeMethodResponse;
126 - (NSDictionary *)decodeStruct;
127 - (NSArray *)decodeArray;
128 - (NSData *)decodeBase64;
129 - (BOOL)decodeBoolean;
131 - (double)decodeDouble;
132 - (NSString *)decodeString;
133 - (NSCalendarDate *)decodeDateTime;
136 - (NSDictionary *)decodeStructForKey:(NSString *)_key;
137 - (NSArray *)decodeArrayForKey:(NSString *)_key;
138 - (NSData *)decodeBase64ForKey:(NSString *)_key;
139 - (BOOL)decodeBooleanForKey:(NSString *)_key;
140 - (int)decodeIntForKey:(NSString *)_key;
141 - (double)decodeDoubleForKey:(NSString *)_key;
142 - (NSString *)decodeStringForKey:(NSString *)_key;
143 - (NSCalendarDate *)decodeDateTimeForKey:(NSString *)_key;
144 - (id)decodeObjectForKey:(NSString *)_key;
146 - (void)setDefaultTimeZone:(NSTimeZone *)_timeZone;
147 - (NSTimeZone *)defaultTimeZone;
150 - (void)ensureObjectAwake:(id)_object;
151 - (void)finishInitializationOfObjects;
152 - (void)awakeObjects;
156 @interface NSObject(XmlRpcCoder)
158 + (id)decodeObjectWithXmlRpcCoder:(XmlRpcDecoder *)_decoder;
159 - (void)encodeWithXmlRpcCoder:(XmlRpcEncoder *)_coder;
163 @interface NSObject(XmlRpcDecoderAwakeMethods)
165 - (void)finishInitializationWithXmlRpcDecoder:(XmlRpcDecoder *)_decoder;
166 - (void)awakeFromXmlRpcDecoder:(XmlRpcDecoder *)_decoder;
171 #endif /* __XmlRpc_XmlRpcCoder_H__ */