/* */ #ifndef D_RPC_RESPONSE_H #define D_RPC_RESPONSE_H #include "common.h" #include #include #include "ValueBase.h" namespace aria2 { namespace rpc { struct RpcResponse { enum authorization_t { NOTAUTHORIZED, AUTHORIZED }; // 0 for success, non-zero for error std::unique_ptr param; std::unique_ptr id; int code; authorization_t authorized; RpcResponse(int code, authorization_t authorized, std::unique_ptr param, std::unique_ptr id); }; inline bool not_authorized(const rpc::RpcResponse& res) { return res.authorized != rpc::RpcResponse::AUTHORIZED; } template bool any_not_authorized(const InputIterator begin, const InputIterator end) { return std::any_of(begin, end, not_authorized); } std::string toXml(const RpcResponse& response, bool gzip = false); // Encodes RPC response in JSON. If callback is not empty, the // resulting string is JSONP. std::string toJson(const RpcResponse& response, const std::string& callback, bool gzip = false); std::string toJsonBatch(const std::vector& results, const std::string& callback, bool gzip = false); } // namespace rpc } // namespace aria2 #endif // D_RPC_RESPONSE_H