mirror of
https://github.com/bitcoin/bitcoin.git
synced 2024-05-17 23:56:39 +00:00
serialize: add SER_PARAMS_OPFUNC
This commit is contained in:
parent
33203f59b4
commit
5e5c8f86b6
@ -218,6 +218,7 @@ public:
|
|||||||
};
|
};
|
||||||
struct SerParams {
|
struct SerParams {
|
||||||
const Encoding enc;
|
const Encoding enc;
|
||||||
|
SER_PARAMS_OPFUNC
|
||||||
};
|
};
|
||||||
static constexpr SerParams V1{Encoding::V1};
|
static constexpr SerParams V1{Encoding::V1};
|
||||||
static constexpr SerParams V2{Encoding::V2};
|
static constexpr SerParams V2{Encoding::V2};
|
||||||
|
@ -396,6 +396,7 @@ public:
|
|||||||
};
|
};
|
||||||
struct SerParams : CNetAddr::SerParams {
|
struct SerParams : CNetAddr::SerParams {
|
||||||
const Format fmt;
|
const Format fmt;
|
||||||
|
SER_PARAMS_OPFUNC
|
||||||
};
|
};
|
||||||
static constexpr SerParams V1_NETWORK{{CNetAddr::Encoding::V1}, Format::Network};
|
static constexpr SerParams V1_NETWORK{{CNetAddr::Encoding::V1}, Format::Network};
|
||||||
static constexpr SerParams V2_NETWORK{{CNetAddr::Encoding::V2}, Format::Network};
|
static constexpr SerParams V2_NETWORK{{CNetAddr::Encoding::V2}, Format::Network};
|
||||||
|
@ -1192,4 +1192,17 @@ static auto WithParams(const Params& params, T&& t)
|
|||||||
return ParamsWrapper<Params, T>{params, t};
|
return ParamsWrapper<Params, T>{params, t};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper macro for SerParams structs
|
||||||
|
*
|
||||||
|
* Allows you define SerParams instances and then apply them directly
|
||||||
|
* to an object via function call syntax, eg:
|
||||||
|
*
|
||||||
|
* constexpr SerParams FOO{....};
|
||||||
|
* ss << FOO(obj);
|
||||||
|
*/
|
||||||
|
#define SER_PARAMS_OPFUNC \
|
||||||
|
template <typename T> \
|
||||||
|
auto operator()(T&& t) const { return WithParams(*this, t); }
|
||||||
|
|
||||||
#endif // BITCOIN_SERIALIZE_H
|
#endif // BITCOIN_SERIALIZE_H
|
||||||
|
Loading…
x
Reference in New Issue
Block a user