mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Reformat code with clang-format-18
This commit is contained in:
@@ -22,7 +22,7 @@
|
||||
|
||||
#include <xrpl/protocol/tokens.h>
|
||||
// VFALCO Uncomment when the header issues are resolved
|
||||
//#include <ripple/protocol/PublicKey.h>
|
||||
// #include <ripple/protocol/PublicKey.h>
|
||||
#include <xrpl/basics/UnorderedContainers.h>
|
||||
#include <xrpl/basics/base_uint.h>
|
||||
#include <xrpl/json/json_value.h>
|
||||
|
||||
@@ -76,38 +76,35 @@ static_assert(apiMaximumValidVersion >= apiMaximumSupportedVersion);
|
||||
} // namespace RPC
|
||||
|
||||
template <unsigned minVer, unsigned maxVer, typename Fn, typename... Args>
|
||||
void
|
||||
forApiVersions(Fn const& fn, Args&&... args) requires //
|
||||
(maxVer >= minVer) && //
|
||||
(minVer >= RPC::apiMinimumSupportedVersion) && //
|
||||
(RPC::apiMaximumValidVersion >= maxVer) &&
|
||||
requires
|
||||
{
|
||||
fn(std::integral_constant<unsigned int, minVer>{},
|
||||
std::forward<Args>(args)...);
|
||||
fn(std::integral_constant<unsigned int, maxVer>{},
|
||||
std::forward<Args>(args)...);
|
||||
}
|
||||
void
|
||||
forApiVersions(Fn const& fn, Args&&... args)
|
||||
requires //
|
||||
(maxVer >= minVer) && //
|
||||
(minVer >= RPC::apiMinimumSupportedVersion) && //
|
||||
(RPC::apiMaximumValidVersion >= maxVer) && requires {
|
||||
fn(std::integral_constant<unsigned int, minVer>{},
|
||||
std::forward<Args>(args)...);
|
||||
fn(std::integral_constant<unsigned int, maxVer>{},
|
||||
std::forward<Args>(args)...);
|
||||
}
|
||||
{
|
||||
constexpr auto size = maxVer + 1 - minVer;
|
||||
[&]<std::size_t... offset>(std::index_sequence<offset...>)
|
||||
{
|
||||
[&]<std::size_t... offset>(std::index_sequence<offset...>) {
|
||||
(((void)fn(
|
||||
std::integral_constant<unsigned int, minVer + offset>{},
|
||||
std::forward<Args>(args)...)),
|
||||
...);
|
||||
}
|
||||
(std::make_index_sequence<size>{});
|
||||
}(std::make_index_sequence<size>{});
|
||||
}
|
||||
|
||||
template <typename Fn, typename... Args>
|
||||
void
|
||||
forAllApiVersions(Fn const& fn, Args&&... args) requires requires
|
||||
{
|
||||
forApiVersions<
|
||||
RPC::apiMinimumSupportedVersion,
|
||||
RPC::apiMaximumValidVersion>(fn, std::forward<Args>(args)...);
|
||||
}
|
||||
forAllApiVersions(Fn const& fn, Args&&... args)
|
||||
requires requires {
|
||||
forApiVersions<
|
||||
RPC::apiMinimumSupportedVersion,
|
||||
RPC::apiMaximumValidVersion>(fn, std::forward<Args>(args)...);
|
||||
}
|
||||
{
|
||||
forApiVersions<
|
||||
RPC::apiMinimumSupportedVersion,
|
||||
|
||||
@@ -80,9 +80,8 @@ struct MultiApiJson
|
||||
}
|
||||
|
||||
void
|
||||
set(const char* key,
|
||||
auto const&
|
||||
v) requires std::constructible_from<Json::Value, decltype(v)>
|
||||
set(const char* key, auto const& v)
|
||||
requires std::constructible_from<Json::Value, decltype(v)>
|
||||
{
|
||||
for (auto& a : this->val)
|
||||
a[key] = v;
|
||||
@@ -110,7 +109,8 @@ struct MultiApiJson
|
||||
unsigned int Version,
|
||||
typename... Args,
|
||||
typename Fn>
|
||||
requires std::same_as<std::remove_cvref_t<Json>, MultiApiJson> auto
|
||||
requires std::same_as<std::remove_cvref_t<Json>, MultiApiJson>
|
||||
auto
|
||||
operator()(
|
||||
Json& json,
|
||||
std::integral_constant<unsigned int, Version> const version,
|
||||
@@ -133,7 +133,8 @@ struct MultiApiJson
|
||||
|
||||
// integral_constant version, Json only
|
||||
template <typename Json, unsigned int Version, typename Fn>
|
||||
requires std::same_as<std::remove_cvref_t<Json>, MultiApiJson> auto
|
||||
requires std::same_as<std::remove_cvref_t<Json>, MultiApiJson>
|
||||
auto
|
||||
operator()(
|
||||
Json& json,
|
||||
std::integral_constant<unsigned int, Version> const,
|
||||
@@ -151,10 +152,10 @@ struct MultiApiJson
|
||||
typename... Args,
|
||||
typename Fn>
|
||||
requires(!some_integral_constant<Version>) &&
|
||||
std::convertible_to<Version, unsigned>&& std::same_as<
|
||||
std::remove_cvref_t<Json>,
|
||||
MultiApiJson> auto
|
||||
operator()(Json& json, Version version, Fn fn, Args&&... args) const
|
||||
std::convertible_to<Version, unsigned> &&
|
||||
std::same_as<std::remove_cvref_t<Json>, MultiApiJson>
|
||||
auto
|
||||
operator()(Json& json, Version version, Fn fn, Args&&... args) const
|
||||
-> std::
|
||||
invoke_result_t<Fn, decltype(json.val[0]), Version, Args&&...>
|
||||
{
|
||||
@@ -170,9 +171,10 @@ struct MultiApiJson
|
||||
// unsigned int version, Json only
|
||||
template <typename Json, typename Version, typename Fn>
|
||||
requires(!some_integral_constant<Version>) &&
|
||||
std::convertible_to<Version, unsigned>&& std::
|
||||
same_as<std::remove_cvref_t<Json>, MultiApiJson> auto
|
||||
operator()(Json& json, Version version, Fn fn) const
|
||||
std::convertible_to<Version, unsigned> &&
|
||||
std::same_as<std::remove_cvref_t<Json>, MultiApiJson>
|
||||
auto
|
||||
operator()(Json& json, Version version, Fn fn) const
|
||||
-> std::invoke_result_t<Fn, decltype(json.val[0])>
|
||||
{
|
||||
assert(
|
||||
@@ -184,53 +186,43 @@ struct MultiApiJson
|
||||
auto
|
||||
visit()
|
||||
{
|
||||
return [self = this](auto... args) requires requires
|
||||
{
|
||||
visitor(
|
||||
std::declval<MultiApiJson&>(),
|
||||
std::declval<decltype(args)>()...);
|
||||
}
|
||||
{
|
||||
return visitor(*self, std::forward<decltype(args)>(args)...);
|
||||
};
|
||||
return [self = this](auto... args)
|
||||
requires requires {
|
||||
visitor(
|
||||
std::declval<MultiApiJson&>(),
|
||||
std::declval<decltype(args)>()...);
|
||||
}
|
||||
{ return visitor(*self, std::forward<decltype(args)>(args)...); };
|
||||
}
|
||||
|
||||
auto
|
||||
visit() const
|
||||
{
|
||||
return [self = this](auto... args) requires requires
|
||||
{
|
||||
visitor(
|
||||
std::declval<MultiApiJson const&>(),
|
||||
std::declval<decltype(args)>()...);
|
||||
}
|
||||
{
|
||||
return visitor(*self, std::forward<decltype(args)>(args)...);
|
||||
};
|
||||
return [self = this](auto... args)
|
||||
requires requires {
|
||||
visitor(
|
||||
std::declval<MultiApiJson const&>(),
|
||||
std::declval<decltype(args)>()...);
|
||||
}
|
||||
{ return visitor(*self, std::forward<decltype(args)>(args)...); };
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
auto
|
||||
visit(Args... args)
|
||||
-> std::invoke_result_t<visitor_t, MultiApiJson&, Args...> requires(
|
||||
sizeof...(args) > 0) &&
|
||||
requires
|
||||
{
|
||||
visitor(*this, std::forward<decltype(args)>(args)...);
|
||||
}
|
||||
auto
|
||||
visit(Args... args)
|
||||
-> std::invoke_result_t<visitor_t, MultiApiJson&, Args...>
|
||||
requires(sizeof...(args) > 0) &&
|
||||
requires { visitor(*this, std::forward<decltype(args)>(args)...); }
|
||||
{
|
||||
return visitor(*this, std::forward<decltype(args)>(args)...);
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
auto
|
||||
visit(Args... args) const -> std::
|
||||
invoke_result_t<visitor_t, MultiApiJson const&, Args...> requires(
|
||||
sizeof...(args) > 0) &&
|
||||
requires
|
||||
{
|
||||
visitor(*this, std::forward<decltype(args)>(args)...);
|
||||
}
|
||||
auto
|
||||
visit(Args... args) const
|
||||
-> std::invoke_result_t<visitor_t, MultiApiJson const&, Args...>
|
||||
requires(sizeof...(args) > 0) &&
|
||||
requires { visitor(*this, std::forward<decltype(args)>(args)...); }
|
||||
{
|
||||
return visitor(*this, std::forward<decltype(args)>(args)...);
|
||||
}
|
||||
|
||||
@@ -197,7 +197,8 @@ public:
|
||||
//
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
explicit operator bool() const noexcept;
|
||||
explicit
|
||||
operator bool() const noexcept;
|
||||
|
||||
STAmount&
|
||||
operator+=(STAmount const&);
|
||||
@@ -388,7 +389,8 @@ inline STAmount::operator Number() const
|
||||
return iou();
|
||||
}
|
||||
|
||||
inline STAmount& STAmount::operator=(beast::Zero)
|
||||
inline STAmount&
|
||||
STAmount::operator=(beast::Zero)
|
||||
{
|
||||
clear();
|
||||
return *this;
|
||||
|
||||
@@ -52,11 +52,13 @@ struct JsonOptions
|
||||
{
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr explicit operator underlying_t() const noexcept
|
||||
[[nodiscard]] constexpr explicit
|
||||
operator underlying_t() const noexcept
|
||||
{
|
||||
return value;
|
||||
}
|
||||
[[nodiscard]] constexpr explicit operator bool() const noexcept
|
||||
[[nodiscard]] constexpr explicit
|
||||
operator bool() const noexcept
|
||||
{
|
||||
return value != 0u;
|
||||
}
|
||||
|
||||
@@ -539,7 +539,8 @@ public:
|
||||
Fields with soeDEFAULT and set to the
|
||||
default value will return `true`
|
||||
*/
|
||||
explicit operator bool() const noexcept;
|
||||
explicit
|
||||
operator bool() const noexcept;
|
||||
|
||||
/** Return the contained value
|
||||
|
||||
|
||||
@@ -65,7 +65,8 @@ public:
|
||||
setValue(const STVector256& v);
|
||||
|
||||
/** Retrieve a copy of the vector we contain */
|
||||
explicit operator std::vector<uint256>() const;
|
||||
explicit
|
||||
operator std::vector<uint256>() const;
|
||||
|
||||
std::size_t
|
||||
size() const;
|
||||
|
||||
@@ -434,7 +434,8 @@ public:
|
||||
}
|
||||
|
||||
// Conversion to bool.
|
||||
explicit operator bool() const
|
||||
explicit
|
||||
operator bool() const
|
||||
{
|
||||
return code_ != tesSUCCESS;
|
||||
}
|
||||
@@ -480,60 +481,66 @@ public:
|
||||
// Only enabled if both arguments return int if TERtiInt is called with them.
|
||||
template <typename L, typename R>
|
||||
constexpr auto
|
||||
operator==(L const& lhs, R const& rhs) -> std::enable_if_t<
|
||||
std::is_same<decltype(TERtoInt(lhs)), int>::value &&
|
||||
std::is_same<decltype(TERtoInt(rhs)), int>::value,
|
||||
bool>
|
||||
operator==(L const& lhs, R const& rhs)
|
||||
-> std::enable_if_t<
|
||||
std::is_same<decltype(TERtoInt(lhs)), int>::value &&
|
||||
std::is_same<decltype(TERtoInt(rhs)), int>::value,
|
||||
bool>
|
||||
{
|
||||
return TERtoInt(lhs) == TERtoInt(rhs);
|
||||
}
|
||||
|
||||
template <typename L, typename R>
|
||||
constexpr auto
|
||||
operator!=(L const& lhs, R const& rhs) -> std::enable_if_t<
|
||||
std::is_same<decltype(TERtoInt(lhs)), int>::value &&
|
||||
std::is_same<decltype(TERtoInt(rhs)), int>::value,
|
||||
bool>
|
||||
operator!=(L const& lhs, R const& rhs)
|
||||
-> std::enable_if_t<
|
||||
std::is_same<decltype(TERtoInt(lhs)), int>::value &&
|
||||
std::is_same<decltype(TERtoInt(rhs)), int>::value,
|
||||
bool>
|
||||
{
|
||||
return TERtoInt(lhs) != TERtoInt(rhs);
|
||||
}
|
||||
|
||||
template <typename L, typename R>
|
||||
constexpr auto
|
||||
operator<(L const& lhs, R const& rhs) -> std::enable_if_t<
|
||||
std::is_same<decltype(TERtoInt(lhs)), int>::value &&
|
||||
std::is_same<decltype(TERtoInt(rhs)), int>::value,
|
||||
bool>
|
||||
operator<(L const& lhs, R const& rhs)
|
||||
-> std::enable_if_t<
|
||||
std::is_same<decltype(TERtoInt(lhs)), int>::value &&
|
||||
std::is_same<decltype(TERtoInt(rhs)), int>::value,
|
||||
bool>
|
||||
{
|
||||
return TERtoInt(lhs) < TERtoInt(rhs);
|
||||
}
|
||||
|
||||
template <typename L, typename R>
|
||||
constexpr auto
|
||||
operator<=(L const& lhs, R const& rhs) -> std::enable_if_t<
|
||||
std::is_same<decltype(TERtoInt(lhs)), int>::value &&
|
||||
std::is_same<decltype(TERtoInt(rhs)), int>::value,
|
||||
bool>
|
||||
operator<=(L const& lhs, R const& rhs)
|
||||
-> std::enable_if_t<
|
||||
std::is_same<decltype(TERtoInt(lhs)), int>::value &&
|
||||
std::is_same<decltype(TERtoInt(rhs)), int>::value,
|
||||
bool>
|
||||
{
|
||||
return TERtoInt(lhs) <= TERtoInt(rhs);
|
||||
}
|
||||
|
||||
template <typename L, typename R>
|
||||
constexpr auto
|
||||
operator>(L const& lhs, R const& rhs) -> std::enable_if_t<
|
||||
std::is_same<decltype(TERtoInt(lhs)), int>::value &&
|
||||
std::is_same<decltype(TERtoInt(rhs)), int>::value,
|
||||
bool>
|
||||
operator>(L const& lhs, R const& rhs)
|
||||
-> std::enable_if_t<
|
||||
std::is_same<decltype(TERtoInt(lhs)), int>::value &&
|
||||
std::is_same<decltype(TERtoInt(rhs)), int>::value,
|
||||
bool>
|
||||
{
|
||||
return TERtoInt(lhs) > TERtoInt(rhs);
|
||||
}
|
||||
|
||||
template <typename L, typename R>
|
||||
constexpr auto
|
||||
operator>=(L const& lhs, R const& rhs) -> std::enable_if_t<
|
||||
std::is_same<decltype(TERtoInt(lhs)), int>::value &&
|
||||
std::is_same<decltype(TERtoInt(rhs)), int>::value,
|
||||
bool>
|
||||
operator>=(L const& lhs, R const& rhs)
|
||||
-> std::enable_if_t<
|
||||
std::is_same<decltype(TERtoInt(lhs)), int>::value &&
|
||||
std::is_same<decltype(TERtoInt(rhs)), int>::value,
|
||||
bool>
|
||||
{
|
||||
return TERtoInt(lhs) >= TERtoInt(rhs);
|
||||
}
|
||||
|
||||
@@ -55,7 +55,8 @@ public:
|
||||
void
|
||||
operator()(void const* data, std::size_t size) noexcept;
|
||||
|
||||
explicit operator result_type() noexcept;
|
||||
explicit
|
||||
operator result_type() noexcept;
|
||||
|
||||
private:
|
||||
char ctx_[96];
|
||||
@@ -77,7 +78,8 @@ public:
|
||||
void
|
||||
operator()(void const* data, std::size_t size) noexcept;
|
||||
|
||||
explicit operator result_type() noexcept;
|
||||
explicit
|
||||
operator result_type() noexcept;
|
||||
|
||||
private:
|
||||
char ctx_[216];
|
||||
@@ -99,7 +101,8 @@ public:
|
||||
void
|
||||
operator()(void const* data, std::size_t size) noexcept;
|
||||
|
||||
explicit operator result_type() noexcept;
|
||||
explicit
|
||||
operator result_type() noexcept;
|
||||
|
||||
private:
|
||||
char ctx_[112];
|
||||
@@ -144,7 +147,8 @@ public:
|
||||
h_(data, size);
|
||||
}
|
||||
|
||||
explicit operator result_type() noexcept
|
||||
explicit
|
||||
operator result_type() noexcept
|
||||
{
|
||||
auto const d0 = sha256_hasher::result_type(h_);
|
||||
ripemd160_hasher rh;
|
||||
@@ -184,18 +188,21 @@ public:
|
||||
h_(data, size);
|
||||
}
|
||||
|
||||
explicit operator result_type() noexcept
|
||||
explicit
|
||||
operator result_type() noexcept
|
||||
{
|
||||
auto const digest = sha512_hasher::result_type(h_);
|
||||
return result_type::fromVoid(digest.data());
|
||||
}
|
||||
|
||||
private:
|
||||
inline void erase(std::false_type)
|
||||
inline void
|
||||
erase(std::false_type)
|
||||
{
|
||||
}
|
||||
|
||||
inline void erase(std::true_type)
|
||||
inline void
|
||||
erase(std::true_type)
|
||||
{
|
||||
secure_erase(&h_, sizeof(h_));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user