/* */ #ifndef D_XML_RPC_REQUEST_PARSER_STATE_MACHINE_H #define D_XML_RPC_REQUEST_PARSER_STATE_MACHINE_H #include "common.h" #include #include #include #include "XmlRpcRequestParserController.h" #include "XmlRpcRequestParserStateImpl.h" #include "ValueBase.h" namespace aria2 { namespace rpc { class XmlRpcRequestParserStateMachine { private: XmlRpcRequestParserController* controller_; std::stack 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_; static UnknownElementXmlRpcRequestParserState* unknownElementState_; public: XmlRpcRequestParserStateMachine(); ~XmlRpcRequestParserStateMachine(); void beginElement(const char* name, const std::map& attrs) { stateStack_.top()->beginElement(this, name, attrs); } void endElement(const char* name, const std::string& characters) { stateStack_.top()->endElement(this, name, characters); stateStack_.pop(); } void setMethodName(const std::string& methodName) { controller_->setMethodName(methodName); } const std::string& getMethodName() const { return controller_->getMethodName(); } void popArrayFrame() { controller_->popArrayFrame(); } void popStructFrame() { controller_->popStructFrame(); } void pushFrame() { controller_->pushFrame(); } void setCurrentFrameValue(const SharedHandle& value) { controller_->setCurrentFrameValue(value); } const SharedHandle& getCurrentFrameValue() const { return controller_->getCurrentFrameValue(); } void setCurrentFrameName(const std::string& name) { controller_->setCurrentFrameName(name); } bool needsCharactersBuffering() const { return stateStack_.top()->needsCharactersBuffering(); } void pushUnknownElementState() { stateStack_.push(unknownElementState_); } void pushMethodCallState() { stateStack_.push(methodCallState_); } void pushMethodNameState() { stateStack_.push(methodNameState_); } void pushParamsState() { stateStack_.push(paramsState_); } void pushParamState() { stateStack_.push(paramState_); } void pushValueState() { stateStack_.push(valueState_); } void pushIntState() { stateStack_.push(intState_); } void pushStringState() { stateStack_.push(stringState_); } void pushBase64State() { stateStack_.push(base64State_); } void pushStructState() { stateStack_.push(structState_); } void pushMemberState() { stateStack_.push(memberState_); } void pushNameState() { stateStack_.push(nameState_); } void pushArrayState() { stateStack_.push(arrayState_); } void pushDataState() { stateStack_.push(dataState_); } void pushArrayValueState() { stateStack_.push(arrayValueState_); } }; } // namespace rpc } // namespace aria2 #endif // D_XML_RPC_REQUEST_PARSER_STATE_MACHINE_H