refactor: replace util::Ref by std::any (C++17)

This commit is contained in:
Sebastian Falbesoner
2020-12-01 00:36:36 +01:00
parent 95cccf8a4b
commit 8dbb87a393
17 changed files with 77 additions and 82 deletions

View File

@@ -6,14 +6,11 @@
#ifndef BITCOIN_RPC_REQUEST_H
#define BITCOIN_RPC_REQUEST_H
#include <any>
#include <string>
#include <univalue.h>
namespace util {
class Ref;
} // namespace util
UniValue JSONRPCRequestObj(const std::string& strMethod, const UniValue& params, const UniValue& id);
UniValue JSONRPCReplyObj(const UniValue& result, const UniValue& error, const UniValue& id);
std::string JSONRPCReply(const UniValue& result, const UniValue& error, const UniValue& id);
@@ -38,14 +35,14 @@ public:
std::string URI;
std::string authUser;
std::string peerAddr;
const util::Ref& context;
const std::any& context;
explicit JSONRPCRequest(const util::Ref& context) : id(NullUniValue), params(NullUniValue), context(context) {}
explicit JSONRPCRequest(const std::any& context) : id(NullUniValue), params(NullUniValue), context(context) {}
//! Initializes request information from another request object and the
//! given context. The implementation should be updated if any members are
//! added or removed above.
JSONRPCRequest(const JSONRPCRequest& other, const util::Ref& context)
JSONRPCRequest(const JSONRPCRequest& other, const std::any& context)
: id(other.id), strMethod(other.strMethod), params(other.params), mode(other.mode), URI(other.URI),
authUser(other.authUser), peerAddr(other.peerAddr), context(context)
{