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