]> err.no Git - sope/blob - sope-xml/XmlRpc/XmlRpcCoder.h
fixed a Tiger warning
[sope] / sope-xml / XmlRpc / XmlRpcCoder.h
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 #ifndef __XmlRpc_XmlRpcCoder_H__
23 #define __XmlRpc_XmlRpcCoder_H__
24
25 #import <Foundation/NSObject.h>
26
27 @class NSDictionary, NSArray, NSNumber, NSString, NSCalendarDate, NSData;
28 @class NSMutableArray, NSMutableString, NSTimeZone, NSDate;
29 @class XmlRpcValue, XmlRpcMethodCall, XmlRpcMethodResponse;
30
31 /*"
32   The XmlRpcEncoder is used to encode XML-RPC objects. It's pretty much like
33   NSArchiver, only for XML-RPC.
34   
35   Encoder example: 
36
37    NSMutableString *str;                 // asume that exists
38    XmlRpcMethodResponse *methodResponse; // asume that exists
39    XmlRpcMethodCall     *methodCall;     // asume that exists
40  
41    coder = [[XmlRpcEncoder alloc] initForWritingWithMutableString:str];
42    
43    [coder encodeMethodCall:methodCall];
44
45    // or
46
47    [coder encodeMethodResponse:methodResponse];
48 "*/
49 @interface XmlRpcEncoder : NSObject
50 {
51   NSMutableString *string;
52   
53   NSMutableArray  *objectStack;
54   NSMutableArray  *objectHasStructStack;
55   NSTimeZone      *timeZone;
56 }
57
58 - (id)initForWritingWithMutableString:(NSMutableString *)_string;
59
60 - (void)encodeMethodCall:(XmlRpcMethodCall *)_methodCall;
61 - (void)encodeMethodResponse:(XmlRpcMethodResponse *)_methodResponse;
62
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;
72
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;
82
83 - (void)setDefaultTimeZone:(NSTimeZone *)_timeZone;
84
85 - (NSTimeZone *)defaultTimeZone;
86
87 @end
88
89 @class NSMutableSet;
90
91 /*"
92   The XmlRpcDecoder is used to decode XML-RPC objects. It's pretty much like
93   NSUnarchiver, only for XML-RPC.
94   
95   Decoder example:
96
97    NSString             *xmlRpcString; // asume that exists
98    XmlRpcMethodCall     *methodCall     = nil;
99    XmlRpcMethodResponse *methodResponse = nil;
100
101    coder = [[XmlRpcDecoder alloc] initForReadingWithString:xmlRpcString];
102
103    methodCall = [coder decodeMethodCall];
104    
105    // or
106    
107    methodResponse = [coder decodeMethodResponse];
108 "*/
109 @interface XmlRpcDecoder : NSObject
110 {
111   NSData         *data;
112   NSMutableArray *valueStack;
113    unsigned       nesting;
114   NSMutableArray *unarchivedObjects;
115   NSMutableSet   *awakeObjects;
116   NSTimeZone     *timeZone;
117 }
118
119 - (id)initForReadingWithString:(NSString *)_string;
120 - (id)initForReadingWithData:(NSData *)_data;
121
122 - (XmlRpcMethodCall *)decodeMethodCall;
123 - (XmlRpcMethodResponse *)decodeMethodResponse;
124
125 /* decoding */
126 - (NSDictionary *)decodeStruct;
127 - (NSArray *)decodeArray;
128 - (NSData *)decodeBase64;
129 - (BOOL)decodeBoolean;
130 - (int)decodeInt;
131 - (double)decodeDouble;
132 - (NSString *)decodeString;
133 - (NSCalendarDate *)decodeDateTime;
134 - (id)decodeObject;
135
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;
145
146 - (void)setDefaultTimeZone:(NSTimeZone *)_timeZone;
147 - (NSTimeZone *)defaultTimeZone;
148
149 /* operations */
150 - (void)ensureObjectAwake:(id)_object;
151 - (void)finishInitializationOfObjects;
152 - (void)awakeObjects;
153
154 @end
155
156 @interface NSObject(XmlRpcCoder)
157
158 + (id)decodeObjectWithXmlRpcCoder:(XmlRpcDecoder *)_decoder;
159 - (void)encodeWithXmlRpcCoder:(XmlRpcEncoder *)_coder;
160
161 @end
162
163 @interface NSObject(XmlRpcDecoderAwakeMethods)
164
165 - (void)finishInitializationWithXmlRpcDecoder:(XmlRpcDecoder *)_decoder;
166 - (void)awakeFromXmlRpcDecoder:(XmlRpcDecoder *)_decoder;
167
168 @end
169
170
171 #endif /* __XmlRpc_XmlRpcCoder_H__ */