/* */ #include "XmlRpcRequestParserStateMachine.h" #include "XmlRpcRequestParserController.h" #include "XmlRpcRequestParserStateImpl.h" namespace aria2 { namespace rpc { namespace { InitialXmlRpcRequestParserState* initialState = new InitialXmlRpcRequestParserState(); UnknownElementXmlRpcRequestParserState* unknownElementState = new UnknownElementXmlRpcRequestParserState(); MethodCallXmlRpcRequestParserState* methodCallState = new MethodCallXmlRpcRequestParserState(); MethodNameXmlRpcRequestParserState* methodNameState = new MethodNameXmlRpcRequestParserState(); ParamsXmlRpcRequestParserState* paramsState = new ParamsXmlRpcRequestParserState(); ParamXmlRpcRequestParserState* paramState = new ParamXmlRpcRequestParserState(); ValueXmlRpcRequestParserState* valueState = new ValueXmlRpcRequestParserState(); IntXmlRpcRequestParserState* intState = new IntXmlRpcRequestParserState(); StringXmlRpcRequestParserState* stringState = new StringXmlRpcRequestParserState(); Base64XmlRpcRequestParserState* base64State = new Base64XmlRpcRequestParserState(); StructXmlRpcRequestParserState* structState = new StructXmlRpcRequestParserState(); MemberXmlRpcRequestParserState* memberState = new MemberXmlRpcRequestParserState(); NameXmlRpcRequestParserState* nameState = new NameXmlRpcRequestParserState(); ArrayXmlRpcRequestParserState* arrayState = new ArrayXmlRpcRequestParserState(); DataXmlRpcRequestParserState* dataState = new DataXmlRpcRequestParserState(); ArrayValueXmlRpcRequestParserState* arrayValueState = new ArrayValueXmlRpcRequestParserState(); } // namespace XmlRpcRequestParserStateMachine::XmlRpcRequestParserStateMachine(): controller_(new XmlRpcRequestParserController()) { stateStack_.push(initialState); } XmlRpcRequestParserStateMachine::~XmlRpcRequestParserStateMachine() { delete controller_; } void XmlRpcRequestParserStateMachine::reset() { controller_->reset(); while(!stateStack_.empty()) { stateStack_.pop(); } stateStack_.push(initialState); } bool XmlRpcRequestParserStateMachine::needsCharactersBuffering() const { return stateStack_.top()->needsCharactersBuffering(); } bool XmlRpcRequestParserStateMachine::finished() const { return stateStack_.top() == initialState; } void XmlRpcRequestParserStateMachine::beginElement (const char* localname, const char* prefix, const char* nsUri, const std::vector& attrs) { stateStack_.top()->beginElement(this, localname, attrs); } void XmlRpcRequestParserStateMachine::endElement (const char* localname, const char* prefix, const char* nsUri, const std::string& characters) { stateStack_.top()->endElement(this, localname, characters); stateStack_.pop(); } void XmlRpcRequestParserStateMachine::setMethodName (const std::string& methodName) { controller_->setMethodName(methodName); } const std::string& XmlRpcRequestParserStateMachine::getMethodName() const { return controller_->getMethodName(); } void XmlRpcRequestParserStateMachine::popArrayFrame() { controller_->popArrayFrame(); } void XmlRpcRequestParserStateMachine::popStructFrame() { controller_->popStructFrame(); } void XmlRpcRequestParserStateMachine::pushFrame() { controller_->pushFrame(); } void XmlRpcRequestParserStateMachine::setCurrentFrameValue (const std::shared_ptr& value) { controller_->setCurrentFrameValue(value); } const std::shared_ptr& XmlRpcRequestParserStateMachine::getCurrentFrameValue() const { return controller_->getCurrentFrameValue(); } void XmlRpcRequestParserStateMachine::setCurrentFrameName (const std::string& name) { controller_->setCurrentFrameName(name); } void XmlRpcRequestParserStateMachine::pushUnknownElementState() { stateStack_.push(unknownElementState); } void XmlRpcRequestParserStateMachine::pushMethodCallState() { stateStack_.push(methodCallState); } void XmlRpcRequestParserStateMachine::pushMethodNameState() { stateStack_.push(methodNameState); } void XmlRpcRequestParserStateMachine::pushParamsState() { stateStack_.push(paramsState); } void XmlRpcRequestParserStateMachine::pushParamState() { stateStack_.push(paramState); } void XmlRpcRequestParserStateMachine::pushValueState() { stateStack_.push(valueState); } void XmlRpcRequestParserStateMachine::pushIntState() { stateStack_.push(intState); } void XmlRpcRequestParserStateMachine::pushStringState() { stateStack_.push(stringState); } void XmlRpcRequestParserStateMachine::pushBase64State() { stateStack_.push(base64State); } void XmlRpcRequestParserStateMachine::pushStructState() { stateStack_.push(structState); } void XmlRpcRequestParserStateMachine::pushMemberState() { stateStack_.push(memberState); } void XmlRpcRequestParserStateMachine::pushNameState() { stateStack_.push(nameState); } void XmlRpcRequestParserStateMachine::pushArrayState() { stateStack_.push(arrayState); } void XmlRpcRequestParserStateMachine::pushDataState() { stateStack_.push(dataState); } void XmlRpcRequestParserStateMachine::pushArrayValueState() { stateStack_.push(arrayValueState); } } // namespace rpc } // namespace aria2