00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00044 #ifndef CCXX_XML_H_
00045 #define CCXX_XML_H_
00046
00047 #ifndef CCXX_MISSING_H_
00048 #include <cc++/missing.h>
00049 #endif
00050
00051 #ifndef CCXX_THREAD_H_
00052 #include <cc++/thread.h>
00053 #endif
00054
00055 #ifndef CCXX_SLOG_H_
00056 #include <cc++/slog.h>
00057 #endif
00058
00059 #ifdef CCXX_NAMESPACES
00060 namespace ost {
00061 #endif
00062
00073 class __EXPORT XMLStream
00074 {
00075 private:
00076 int ecount, dcount;
00077 enum { TAG, CDATA, COMMENT, DTD, AMP, NONE} state;
00078 char dbuf[8192];
00079 unsigned dp;
00080 bool parseChunk(const char *chunk, size_t len);
00081 void parseInit(void);
00082 bool parseTag(void);
00083 void putData(char c);
00084 void clrData(void);
00085
00086 protected:
00087 virtual ~XMLStream();
00088
00089 public:
00099 virtual bool open(const char *resource);
00100
00105 virtual void close(void);
00106
00112 virtual Slog::Level getLogging(void);
00113
00121 virtual void comment(const unsigned char *text, size_t len);
00122
00130 virtual int read(unsigned char *buffer, size_t len) = 0;
00131
00139 virtual void characters(const unsigned char *text, size_t len) = 0;
00140
00144 virtual void startDocument(void);
00145
00149 virtual void endDocument(void);
00150
00157 virtual void startElement(const unsigned char *name, const unsigned char **attr) = 0;
00158
00164 virtual void endElement(const unsigned char *name) = 0;
00165
00172 bool parse(const char *resource = NULL);
00173 };
00174
00184 class __EXPORT XMLRPC : public XMLStream
00185 {
00186 private:
00187 #ifdef HAVE_SSTREAM
00188 std::stringstream strBuf;
00189 #else
00190 char *buffer;
00191 std::strstream *oldStrBuf;
00192 size_t bufSize;
00193 #endif
00194 bool structFlag;
00195 bool reply, fault;
00196 unsigned array;
00197
00198 protected:
00208 virtual bool post(const char *resource, const char *msg) = 0;
00209
00213 void begStruct(void);
00214
00215 public:
00223 XMLRPC(size_t bufferSize = 512);
00224
00228 virtual ~XMLRPC();
00229
00233 void begArray(void);
00234
00238 void endArray(void);
00239
00245 void invoke(const char *method);
00246
00252 void response(bool fault);
00253
00259 void addParam(bool value);
00260
00267 void addMember(const char *name, bool value);
00268
00274 void addParam(long value);
00275
00282 void addMember(const char *name, long value);
00283
00289 void addParam(const char *string);
00290
00297 void addMember(const char *name, const char *value);
00298
00302 void endStruct(void);
00303
00310 bool send(const char *resource);
00311 };
00312
00313
00314
00315
00316
00317
00318
00319
00320
00321 #ifdef CCXX_NAMESPACES
00322 }
00323 #endif
00324
00325 #endif
00326