ulxr_callparse_wb.cpp

Go to the documentation of this file.
00001 /**************************************************************************
00002                ulxr_callparse_wb.cpp  -  parse wbxml-rpc method call
00003                              -------------------
00004     begin                : Fri Jan 09 2004
00005     copyright            : (C) 2002-2007 by Ewald Arnold
00006     email                : ulxmlrpcpp@ewald-arnold.de
00007 
00008     $Id: ulxr_callparse_wb.cpp 940 2006-12-30 18:22:05Z ewald-arnold $
00009 
00010  ***************************************************************************/
00011 
00012 /**************************************************************************
00013  *
00014  * This program is free software; you can redistribute it and/or modify
00015  * it under the terms of the GNU Lesser General Public License as
00016  * published by the Free Software Foundation; either version 2 of the License,
00017  * or (at your option) any later version.
00018  *
00019  * This program is distributed in the hope that it will be useful,
00020  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00021  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00022  * GNU General Public License for more details.
00023  *
00024  * You should have received a copy of the GNU Lesser General Public License
00025  * along with this program; if not, write to the Free Software
00026  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00027  *
00028  ***************************************************************************/
00029 
00030 
00031 #define ULXR_NEED_EXPORTS
00032 #include <ulxmlrpcpp/ulxmlrpcpp.h>  // always first header
00033 
00034 #include <ulxmlrpcpp/ulxr_callparse_wb.h>
00035 #include <ulxmlrpcpp/ulxr_except.h>
00036 #include <ulxmlrpcpp/ulxr_htmlform_handler.h>
00037 
00038 
00039 namespace ulxr {
00040 
00041 
00042 ULXR_API_IMPL(void) MethodCallParserWb::startElement(unsigned token, const Attributes &attr)
00043 {
00044   if (!testStartElement(token, attr))
00045     ValueParserWb::testStartElement(token, attr);
00046 }
00047 
00048 
00049 ULXR_API_IMPL(bool)
00050   MethodCallParserWb::testStartElement(unsigned token, const Attributes &)
00051 {
00052   ULXR_TRACE(ULXR_PCHAR("MethodCallParserWb::testStartElement()")
00053              << ULXR_PCHAR("\n  token: ")+HtmlFormHandler::makeHexNumber(token)
00054             );
00055 
00056   switch(states.top()->getParserState() )
00057   {
00058     case eNone:
00059       if (wbToken_MethodCall == token)
00060       {
00061         setComplete(false);
00062         states.push(new ValueState(eMethodCall));
00063       }
00064       else
00065         return false;
00066     break;
00067 
00068     case eMethodCall:
00069       if (wbToken_MethodName == token)
00070         states.push(new ValueState(eMethodName));
00071 
00072       else if (wbToken_Params == token)
00073         states.push(new ValueState(eParams));
00074 
00075       else
00076         return false;
00077     break;
00078 
00079     case eParams:
00080       if (wbToken_Param == token)
00081         states.push(new ValueState(eParam));
00082       else
00083         return false;
00084     break;
00085 
00086     case eParam:
00087       if(wbToken_Value == token)
00088         states.push(new ValueState(eValue));
00089       else
00090         return false;
00091     break;
00092 
00093     default:
00094         return false;
00095   }
00096 
00097   return true;
00098 }
00099 
00100 
00101 ULXR_API_IMPL(void) MethodCallParserWb::endElement()
00102 {
00103   if (!testEndElement())
00104     ValueParserWb::testEndElement();
00105 }
00106 
00107 
00108 ULXR_API_IMPL(bool) MethodCallParserWb::testEndElement()
00109 {
00110   ULXR_TRACE(ULXR_PCHAR("MethodCallParserWb::testEndElement()"));
00111   if (states.size() <= 1)
00112     throw RuntimeException(ApplicationError, ulxr_i18n(ULXR_PCHAR("abnormal program behaviour: MethodCallParserWb::testEndElement() had no states left")));
00113 
00114   ValueState *curr = getTopValueState();
00115   states.pop();
00116 
00117   switch(curr->getParserState() )
00118   {
00119     case eMethodName:
00120       methodcall.setMethodName(curr->getCharData());
00121     break;
00122 
00123     case eMethodCall:
00124       setComplete(true);
00125     break;
00126 
00127     case eParams:
00128     break;
00129 
00130     case eParam:
00131       if (curr->getValue() != 0)
00132         methodcall.addParam(*curr->getValue());
00133       delete curr->getValue();
00134     break;
00135 
00136     default:
00137       states.push(curr);  // put back, someone else will process
00138       return false;
00139   }
00140   delete curr;
00141   return true;
00142 }
00143 
00144 
00145 }  // namespace ulxr
00146 

Generated on Sun Aug 19 20:08:57 2007 for ulxmlrpcpp by  doxygen 1.5.1