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 #define ULXR_NEED_EXPORTS
00034 #include <ulxmlrpcpp/ulxmlrpcpp.h>
00035
00036 #include <ulxmlrpcpp/ulxr_responseparse.h>
00037 #include <ulxmlrpcpp/ulxr_except.h>
00038
00039
00040 namespace ulxr {
00041
00042
00043 ULXR_API_IMPL(void)
00044 MethodResponseParser::startElement(const XML_Char* name, const XML_Char** atts)
00045 {
00046 if (!testStartElement(name, atts))
00047 ValueParser::testStartElement(name, atts);
00048 }
00049
00050
00051 ULXR_API_IMPL(bool)
00052 MethodResponseParser::testStartElement(const XML_Char* name, const XML_Char** )
00053 {
00054 ULXR_TRACE(ULXR_PCHAR("MethodResponseParser::testStartElement(const XML_Char*, const char**)")
00055 << ULXR_PCHAR("\n name: ")
00056 << ULXR_GET_STRING(name)
00057 );
00058
00059 switch(states.top()->getParserState() )
00060 {
00061 case eNone:
00062 if(strcmp(name, "methodResponse") == 0)
00063 {
00064 setComplete (false);
00065 states.push(new ValueState(eMethodResponse));
00066 }
00067 else
00068 return false;
00069 break;
00070
00071 case eMethodResponse:
00072 if(strcmp(name, "fault") == 0)
00073 states.push(new ValueState(eFault));
00074
00075 else if(strcmp(name, "params") == 0)
00076 states.push(new ValueState(eParams));
00077
00078 else
00079 return false;
00080 break;
00081
00082 case eFault:
00083 if(strcmp(name, "value") == 0)
00084 states.push(new ValueState(eValue));
00085 else
00086 return false;
00087 break;
00088
00089 case eParams:
00090 if(strcmp(name, "param") == 0)
00091 states.push(new ValueState(eParam));
00092 else
00093 return false;
00094 break;
00095
00096 case eParam:
00097 if(strcmp(name, "value") == 0)
00098 states.push(new ValueState(eValue));
00099 else
00100 return false;
00101 break;
00102
00103 default:
00104 return false;
00105 }
00106
00107 return true;
00108 }
00109
00110
00111 ULXR_API_IMPL(void) MethodResponseParser::endElement(const XML_Char *name)
00112 {
00113 if (!testEndElement(name))
00114 ValueParser::testEndElement(name);
00115 }
00116
00117
00118 ULXR_API_IMPL(bool) MethodResponseParser::testEndElement(const XML_Char *name)
00119 {
00120 ULXR_TRACE(ULXR_PCHAR("MethodResponseParser::testEndElement(const XML_Char*)"));
00121
00122 if (states.size() <= 1)
00123 throw RuntimeException(ApplicationError, ulxr_i18n(ULXR_PCHAR("abnormal program behaviour: MethodResponseParser::testEndElement() had no states left")));
00124
00125 ValueState *curr = getTopValueState();
00126 states.pop();
00127 ValueState *on_top = getTopValueState();
00128
00129 switch(curr->getParserState() )
00130 {
00131 case eMethodResponse:
00132 setComplete(true);
00133 assertEndElement(name, "methodResponse");
00134 on_top->takeValue (curr->getValue());
00135 if (on_top->getValue() != 0)
00136 method_value = *on_top->getValue();
00137 break;
00138
00139 case eFault:
00140 assertEndElement(name, "fault");
00141 on_top->takeValue (curr->getValue());
00142 break;
00143
00144 case eParams:
00145 assertEndElement(name, "params");
00146 on_top->takeValue (curr->getValue());
00147 break;
00148
00149 case eParam:
00150 assertEndElement(name, "param");
00151 on_top->takeValue (curr->getValue());
00152 break;
00153
00154 default:
00155 states.push(curr);
00156 return false;
00157 }
00158
00159 delete curr;
00160 return true;
00161 }
00162
00163
00164 }