/* */ #ifndef D_XML_RPC_REQUEST_PARSER_CONTROLLER_H #define D_XML_RPC_REQUEST_PARSER_CONTROLLER_H #include "common.h" #include #include #include "ValueBase.h" namespace aria2 { namespace rpc { class XmlRpcRequestParserController { private: struct StateFrame { std::unique_ptr value_; std::string name_; bool validMember() const { return value_ && !name_.empty(); } void reset() { value_.reset(); name_.clear(); } }; std::stack frameStack_; StateFrame currentFrame_; std::string methodName_; public: void pushFrame(); // Pops StateFrame p from frameStack_ and set p[currentFrame_.name_] // = currentFrame_.value_ and currentFrame_ = p; void popStructFrame(); // Pops StateFrame p from frameStack_ and add currentFrame_.value_ // to p and currentFrame_ = p; void popArrayFrame(); void setCurrentFrameValue(std::unique_ptr value); void setCurrentFrameName(std::string name); const std::unique_ptr& getCurrentFrameValue() const; std::unique_ptr popCurrentFrameValue(); void setMethodName(std::string methodName); const std::string& getMethodName() const { return methodName_; } void reset(); }; } // namespace rpc } // namespace aria2 #endif // D_XML_RPC_REQUEST_PARSER_CONTROLLER_H