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
00039
00040
00046 #ifndef CCXX_XML_H_
00047 #define CCXX_XML_H_
00048
00049 #ifndef CCXX_MISSING_H_
00050 #include <cc++/missing.h>
00051 #endif
00052
00053 #ifndef CCXX_THREAD_H_
00054 #include <cc++/thread.h>
00055 #endif
00056
00057 #ifndef CCXX_SLOG_H_
00058 #include <cc++/slog.h>
00059 #endif
00060
00061 #ifdef CCXX_NAMESPACES
00062 namespace ost {
00063 #endif
00064
00075 class __EXPORT XMLStream
00076 {
00077 #ifndef HAVE_LIBXML
00078 private:
00079 int ecount, dcount;
00080 enum { TAG, CDATA, COMMENT, DTD, AMP, NONE} state;
00081 char dbuf[8192];
00082 unsigned dp;
00083 bool parseChunk(const char *chunk, unsigned len);
00084 void parseInit(void);
00085 bool parseTag(void);
00086 void putData(char c);
00087 void clrData(void);
00088
00089 #endif
00090 public:
00100 virtual bool open(const char *resource)
00101 {return true;};
00102
00107 virtual void close(void)
00108 {return;};
00109
00115 virtual Slog::Level getLogging(void)
00116 {return Slog::levelCritical;};
00117
00124 virtual void comment(const unsigned char *text, unsigned len)
00125 {return;};
00126
00134 virtual int read(unsigned char *buffer, int len) = 0;
00135
00143 virtual void characters(const unsigned char *text, unsigned len) = 0;
00144
00148 virtual void startDocument(void)
00149 {return;};
00150
00154 virtual void endDocument(void)
00155 {return;};
00156
00163 virtual void startElement(const unsigned char *name, const unsigned char **attr) = 0;
00164
00170 virtual void endElement(const unsigned char *name) = 0;
00171
00178 bool parse(const char *resource = NULL);
00179 };
00180
00190 class __EXPORT XMLRPC : public XMLStream
00191 {
00192 private:
00193 #ifdef HAVE_SSTREAM
00194 std::stringstream strBuf;
00195 #else
00196 char *buffer;
00197 std::strstream *oldStrBuf;
00198 size_t bufSize;
00199 #endif
00200 bool structFlag;
00201 bool reply, fault;
00202 unsigned array;
00203
00204 protected:
00214 virtual bool post(const char *resource, const char *msg) = 0;
00215
00219 void begStruct(void);
00220
00221 public:
00229 XMLRPC(size_t bufferSize = 512);
00230
00234 virtual ~XMLRPC();
00235
00239 void begArray(void);
00240
00244 void endArray(void);
00245
00251 void invoke(const char *method);
00252
00258 void response(bool fault);
00259
00265 void addParam(bool value);
00266
00273 void addMember(const char *name, bool value);
00274
00280 void addParam(long value);
00281
00288 void addMember(const char *name, long value);
00289
00295 void addParam(const char *string);
00296
00303 void addMember(const char *name, const char *value);
00304
00308 void endStruct(void);
00309
00316 bool send(const char *resource);
00317 };
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327 #ifdef CCXX_NAMESPACES
00328 };
00329 #endif
00330
00331 #endif
00332