/* */ #ifndef D_VALUE_BASE_STRUCT_PARSER_STATE_MACHINE_H #define D_VALUE_BASE_STRUCT_PARSER_STATE_MACHINE_H #include "StructParserStateMachine.h" #include #include #include namespace aria2 { class ValueBase; namespace rpc { class XmlRpcRequestParserController; } // namespace rpc; class ValueBaseStructParserState; // Implementation of StructParserStateMachine, using ValueBase as // value holder. class ValueBaseStructParserStateMachine : public StructParserStateMachine { public: typedef std::unique_ptr ResultType; static std::unique_ptr noResult(); struct NumberData { int64_t number; int frac; int exp; }; struct SessionData { std::string str; NumberData number; bool bval; }; ValueBaseStructParserStateMachine(); virtual ~ValueBaseStructParserStateMachine(); virtual void beginElement(int elementType) CXX11_OVERRIDE; virtual void endElement(int elementType) CXX11_OVERRIDE; virtual void charactersCallback(const char* data, size_t len) CXX11_OVERRIDE; virtual void numberCallback(int64_t number, int frac, int exp) CXX11_OVERRIDE; virtual void boolCallback(bool bval) CXX11_OVERRIDE; std::unique_ptr getResult(); virtual void reset() CXX11_OVERRIDE; const std::string& getCharacters() const; const NumberData& getNumber() const; bool getBool() const; void popArrayFrame(); void popDictFrame(); void pushFrame(); void setCurrentFrameValue(std::unique_ptr value); const std::unique_ptr& getCurrentFrameValue() const; std::unique_ptr popCurrentFrameValue(); void setCurrentFrameName(std::string name); void pushDictState(); void pushDictKeyState(); void pushDictDataState(); void pushArrayState(); void pushArrayDataState(); void pushStringState(); void pushNumberState(); void pushBoolState(); void pushNullState(); private: std::unique_ptr ctrl_; std::stack stateStack_; SessionData sessionData_; }; } // namespace aria2 #endif // D_VALUE_BASE_STRUCT_PARSER_STATE_MACHINE_H