// SPDX-License-Identifier: BSD-3-Clause #ifndef INVERTER_TOOLS_PROTOCOL_RESPONSE_H #define INVERTER_TOOLS_PROTOCOL_RESPONSE_H #include #include "../formatter/formatter.h" namespace protocol { typedef std::shared_ptr formattable_ptr; class BaseResponse { protected: std::shared_ptr raw_; size_t rawSize_; public: BaseResponse(std::shared_ptr raw, size_t rawSize); virtual ~BaseResponse() = default; virtual bool validate() = 0; virtual void unpack() = 0; virtual formattable_ptr format(formatter::Format format) = 0; }; class ErrorResponse : public BaseResponse { private: std::string error_; public: explicit ErrorResponse(std::string error) : BaseResponse(nullptr, 0), error_(std::move(error)) {} bool validate() override { return true; } void unpack() override {} formattable_ptr format(formatter::Format format) override; }; } #endif //INVERTER_TOOLS_PROTOCOL_RESPONSE_H