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_CONFIG_H_
00050 #include <cc++/config.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 #include <fstream>
00062 #include <iostream>
00063 #ifdef HAVE_SSTREAM
00064 #include <sstream>
00065 #else
00066 #include <strstream>
00067 #endif
00068
00069 #ifdef CCXX_NAMESPACES
00070 namespace ost {
00071 #endif
00072
00073 #ifdef COMMON_XML_PARSING
00074
00075 #ifdef HAVE_LIBXML
00076
00087 class CCXX_CLASS_EXPORT XMLStream
00088 {
00089 public:
00099 virtual bool open(const char *resource)
00100 {return true;};
00101
00106 virtual void close(void)
00107 {return;};
00108
00114 virtual Slog::Level getLogging(void)
00115 {return Slog::levelCritical;};
00116
00123 virtual void comment(const unsigned char *text)
00124 {return;};
00125
00133 virtual int read(unsigned char *buffer, int len) = 0;
00134
00142 virtual void characters(const unsigned char *text, unsigned len) = 0;
00143
00147 virtual void startDocument(void)
00148 {return;};
00149
00153 virtual void endDocument(void)
00154 {return;};
00155
00162 virtual void startElement(const unsigned char *name, const unsigned char **attr) = 0;
00163
00169 virtual void endElement(const unsigned char *name) = 0;
00170
00177 bool parse(const char *resource = NULL);
00178 };
00179
00189 class CCXX_CLASS_EXPORT XMLRPC : public XMLStream
00190 {
00191 private:
00192 #ifdef HAVE_SSTREAM
00193 std::stringstream strBuf;
00194 #else
00195 char *buffer;
00196 std::strstream *oldStrBuf;
00197 size_t bufSize;
00198 #endif
00199 bool structFlag;
00200 bool reply, fault;
00201 unsigned array;
00202
00203 protected:
00213 virtual bool post(const char *resource, const char *msg) = 0;
00214
00218 void begStruct(void);
00219
00220 public:
00228 XMLRPC(size_t bufferSize = 512);
00229
00233 virtual ~XMLRPC();
00234
00238 void begArray(void);
00239
00243 void endArray(void);
00244
00250 void invoke(const char *method);
00251
00257 void response(bool fault);
00258
00264 void addParam(bool value);
00265
00272 void addMember(const char *name, bool value);
00273
00279 void addParam(long value);
00280
00287 void addMember(const char *name, long value);
00288
00294 void addParam(const char *string);
00295
00302 void addMember(const char *name, const char *value);
00303
00307 void endStruct(void);
00308
00315 bool send(const char *resource);
00316 };
00317
00318 #else
00319 #error "XML support has been selected, but libxml could not be found"
00320 #endif // ifdef HAVE_XML
00321
00322 #else
00323 #error "XML support is not available."
00324 #endif // ifdef COMMON_XML_PARSING
00325
00326 #ifdef CCXX_NAMESPACES
00327 };
00328 #endif
00329
00330 #endif
00331