2009-05-08 03:24:24 +00:00
|
|
|
/* <!-- copyright */
|
|
|
|
/*
|
|
|
|
* aria2 - The high speed download utility
|
|
|
|
*
|
|
|
|
* Copyright (C) 2009 Tatsuhiro Tsujikawa
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2010-01-05 16:01:46 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
2009-05-08 03:24:24 +00:00
|
|
|
*
|
|
|
|
* In addition, as a special exception, the copyright holders give
|
|
|
|
* permission to link the code of portions of this program with the
|
|
|
|
* OpenSSL library under certain conditions as described in each
|
|
|
|
* individual source file, and distribute linked combinations
|
|
|
|
* including the two.
|
|
|
|
* You must obey the GNU General Public License in all respects
|
|
|
|
* for all of the code used other than OpenSSL. If you modify
|
|
|
|
* file(s) with this exception, you may extend this exception to your
|
|
|
|
* version of the file(s), but you are not obligated to do so. If you
|
|
|
|
* do not wish to do so, delete this exception statement from your
|
|
|
|
* version. If you delete this exception statement from all source
|
|
|
|
* files in the program, then also delete it here.
|
|
|
|
*/
|
|
|
|
/* copyright --> */
|
2010-10-31 07:23:53 +00:00
|
|
|
#ifndef D_XML_RPC_REQUEST_PARSER_STATE_MACHINE_H
|
|
|
|
#define D_XML_RPC_REQUEST_PARSER_STATE_MACHINE_H
|
2009-05-08 03:24:24 +00:00
|
|
|
|
|
|
|
#include "common.h"
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <map>
|
|
|
|
#include <stack>
|
|
|
|
|
|
|
|
#include "XmlRpcRequestParserController.h"
|
|
|
|
#include "XmlRpcRequestParserStateImpl.h"
|
2010-06-19 17:54:54 +00:00
|
|
|
#include "ValueBase.h"
|
2009-05-08 03:24:24 +00:00
|
|
|
|
|
|
|
namespace aria2 {
|
|
|
|
|
|
|
|
namespace xmlrpc {
|
|
|
|
|
|
|
|
class XmlRpcRequestParserStateMachine {
|
|
|
|
private:
|
2010-06-21 13:51:56 +00:00
|
|
|
XmlRpcRequestParserController* controller_;
|
|
|
|
|
|
|
|
std::stack<XmlRpcRequestParserState*> stateStack_;
|
|
|
|
|
|
|
|
static InitialXmlRpcRequestParserState* initialState_;
|
|
|
|
static MethodCallXmlRpcRequestParserState* methodCallState_;
|
|
|
|
static MethodNameXmlRpcRequestParserState* methodNameState_;
|
|
|
|
static ParamsXmlRpcRequestParserState* paramsState_;
|
|
|
|
static ParamXmlRpcRequestParserState* paramState_;
|
|
|
|
static ValueXmlRpcRequestParserState* valueState_;
|
|
|
|
static IntXmlRpcRequestParserState* intState_;
|
|
|
|
static StringXmlRpcRequestParserState* stringState_;
|
|
|
|
static Base64XmlRpcRequestParserState* base64State_;
|
|
|
|
static StructXmlRpcRequestParserState* structState_;
|
|
|
|
static MemberXmlRpcRequestParserState* memberState_;
|
|
|
|
static NameXmlRpcRequestParserState* nameState_;
|
|
|
|
static ArrayXmlRpcRequestParserState* arrayState_;
|
|
|
|
static DataXmlRpcRequestParserState* dataState_;
|
|
|
|
static ArrayValueXmlRpcRequestParserState* arrayValueState_;
|
2009-05-08 03:24:24 +00:00
|
|
|
|
2010-06-21 13:51:56 +00:00
|
|
|
static UnknownElementXmlRpcRequestParserState* unknownElementState_;
|
2009-05-08 03:24:24 +00:00
|
|
|
public:
|
|
|
|
XmlRpcRequestParserStateMachine();
|
|
|
|
|
|
|
|
~XmlRpcRequestParserStateMachine();
|
|
|
|
|
|
|
|
void beginElement(const std::string& name,
|
2010-01-05 16:01:46 +00:00
|
|
|
const std::map<std::string, std::string>& attrs)
|
2009-05-08 03:24:24 +00:00
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
stateStack_.top()->beginElement(this, name, attrs);
|
2009-05-08 03:24:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void endElement(const std::string& name, const std::string& characters)
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
stateStack_.top()->endElement(this, name, characters);
|
|
|
|
stateStack_.pop();
|
2009-05-08 03:24:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void setMethodName(const std::string& methodName)
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
controller_->setMethodName(methodName);
|
2009-05-08 03:24:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const std::string& getMethodName() const
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
return controller_->getMethodName();
|
2009-05-08 03:24:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void popArrayFrame()
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
controller_->popArrayFrame();
|
2009-05-08 03:24:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void popStructFrame()
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
controller_->popStructFrame();
|
2009-05-08 03:24:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void pushFrame()
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
controller_->pushFrame();
|
2009-05-08 03:24:24 +00:00
|
|
|
}
|
|
|
|
|
2010-06-19 17:54:54 +00:00
|
|
|
void setCurrentFrameValue(const SharedHandle<ValueBase>& value)
|
2009-05-08 03:24:24 +00:00
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
controller_->setCurrentFrameValue(value);
|
2009-05-08 03:24:24 +00:00
|
|
|
}
|
|
|
|
|
2010-06-19 17:54:54 +00:00
|
|
|
const SharedHandle<ValueBase>& getCurrentFrameValue() const
|
2009-05-08 03:24:24 +00:00
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
return controller_->getCurrentFrameValue();
|
2009-05-08 03:24:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void setCurrentFrameName(const std::string& name)
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
controller_->setCurrentFrameName(name);
|
2009-05-08 03:24:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool needsCharactersBuffering() const
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
return stateStack_.top()->needsCharactersBuffering();
|
2009-05-08 03:24:24 +00:00
|
|
|
}
|
|
|
|
|
2010-06-21 13:51:56 +00:00
|
|
|
void pushUnknownElementState() { stateStack_.push(unknownElementState_); }
|
2009-05-08 03:24:24 +00:00
|
|
|
|
2010-06-21 13:51:56 +00:00
|
|
|
void pushMethodCallState() { stateStack_.push(methodCallState_); }
|
2009-05-08 03:24:24 +00:00
|
|
|
|
2010-06-21 13:51:56 +00:00
|
|
|
void pushMethodNameState() { stateStack_.push(methodNameState_); }
|
2009-05-08 03:24:24 +00:00
|
|
|
|
2010-06-21 13:51:56 +00:00
|
|
|
void pushParamsState() { stateStack_.push(paramsState_); }
|
2009-05-08 03:24:24 +00:00
|
|
|
|
2010-06-21 13:51:56 +00:00
|
|
|
void pushParamState() { stateStack_.push(paramState_); }
|
2009-05-08 03:24:24 +00:00
|
|
|
|
2010-06-21 13:51:56 +00:00
|
|
|
void pushValueState() { stateStack_.push(valueState_); }
|
2009-05-08 03:24:24 +00:00
|
|
|
|
2010-06-21 13:51:56 +00:00
|
|
|
void pushIntState() { stateStack_.push(intState_); }
|
2009-05-08 03:24:24 +00:00
|
|
|
|
2010-06-21 13:51:56 +00:00
|
|
|
void pushStringState() { stateStack_.push(stringState_); }
|
2009-05-08 03:24:24 +00:00
|
|
|
|
2010-06-21 13:51:56 +00:00
|
|
|
void pushBase64State() { stateStack_.push(base64State_); }
|
2009-05-08 03:24:24 +00:00
|
|
|
|
2010-06-21 13:51:56 +00:00
|
|
|
void pushStructState() { stateStack_.push(structState_); }
|
2009-05-08 03:24:24 +00:00
|
|
|
|
2010-06-21 13:51:56 +00:00
|
|
|
void pushMemberState() { stateStack_.push(memberState_); }
|
2009-05-08 03:24:24 +00:00
|
|
|
|
2010-06-21 13:51:56 +00:00
|
|
|
void pushNameState() { stateStack_.push(nameState_); }
|
2009-05-08 03:24:24 +00:00
|
|
|
|
2010-06-21 13:51:56 +00:00
|
|
|
void pushArrayState() { stateStack_.push(arrayState_); }
|
2009-05-08 03:24:24 +00:00
|
|
|
|
2010-06-21 13:51:56 +00:00
|
|
|
void pushDataState() { stateStack_.push(dataState_); }
|
2009-05-08 03:24:24 +00:00
|
|
|
|
2010-06-21 13:51:56 +00:00
|
|
|
void pushArrayValueState() { stateStack_.push(arrayValueState_); }
|
2009-05-08 03:24:24 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace xmlrpc
|
|
|
|
|
|
|
|
} // namespace aria2
|
|
|
|
|
2010-10-31 07:23:53 +00:00
|
|
|
#endif // D_XML_RPC_REQUEST_PARSER_STATE_MACHINE_H
|