mirror of
https://github.com/XRPLF/rippled.git
synced 2026-04-22 20:02:25 +00:00
Compare commits
2 Commits
mvadari/bu
...
pratik/fix
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cd3aa51a4b | ||
|
|
bd632b59c2 |
27
.clang-tidy
27
.clang-tidy
@@ -97,21 +97,9 @@ Checks: "-*,
|
||||
misc-throw-by-value-catch-by-reference,
|
||||
misc-unused-alias-decls,
|
||||
misc-unused-using-decls,
|
||||
modernize-concat-nested-namespaces,
|
||||
modernize-deprecated-headers,
|
||||
modernize-make-shared,
|
||||
modernize-make-unique,
|
||||
modernize-pass-by-value,
|
||||
modernize-type-traits,
|
||||
modernize-use-designated-initializers,
|
||||
modernize-use-emplace,
|
||||
modernize-use-equals-default,
|
||||
modernize-use-equals-delete,
|
||||
modernize-use-override,
|
||||
modernize-use-ranges,
|
||||
modernize-use-starts-ends-with,
|
||||
modernize-use-std-numbers,
|
||||
modernize-use-using,
|
||||
modernize-deprecated-headers,
|
||||
llvm-namespace-comment,
|
||||
performance-faster-string-find,
|
||||
performance-for-range-copy,
|
||||
@@ -153,6 +141,19 @@ Checks: "-*,
|
||||
# readability-inconsistent-declaration-parameter-name, # in this codebase this check will break a lot of arg names
|
||||
# readability-static-accessed-through-instance, # this check is probably unnecessary. it makes the code less readable
|
||||
# readability-identifier-naming, # https://github.com/XRPLF/rippled/pull/6571
|
||||
#
|
||||
# modernize-concat-nested-namespaces,
|
||||
# modernize-pass-by-value,
|
||||
# modernize-type-traits,
|
||||
# modernize-use-designated-initializers,
|
||||
# modernize-use-emplace,
|
||||
# modernize-use-equals-default,
|
||||
# modernize-use-equals-delete,
|
||||
# modernize-use-override,
|
||||
# modernize-use-ranges,
|
||||
# modernize-use-starts-ends-with,
|
||||
# modernize-use-std-numbers,
|
||||
# modernize-use-using,
|
||||
# ---
|
||||
#
|
||||
CheckOptions:
|
||||
|
||||
10
.github/scripts/rename/binary.sh
vendored
10
.github/scripts/rename/binary.sh
vendored
@@ -6,11 +6,11 @@ set -e
|
||||
# On MacOS, ensure that GNU sed is installed and available as `gsed`.
|
||||
SED_COMMAND=sed
|
||||
if [[ "${OSTYPE}" == 'darwin'* ]]; then
|
||||
if ! command -v gsed &> /dev/null; then
|
||||
echo "Error: gsed is not installed. Please install it using 'brew install gnu-sed'."
|
||||
exit 1
|
||||
fi
|
||||
SED_COMMAND=gsed
|
||||
if ! command -v gsed &> /dev/null; then
|
||||
echo "Error: gsed is not installed. Please install it using 'brew install gnu-sed'."
|
||||
exit 1
|
||||
fi
|
||||
SED_COMMAND=gsed
|
||||
fi
|
||||
|
||||
# This script changes the binary name from `rippled` to `xrpld`, and reverses
|
||||
|
||||
38
.github/scripts/rename/cmake.sh
vendored
38
.github/scripts/rename/cmake.sh
vendored
@@ -8,16 +8,16 @@ set -e
|
||||
SED_COMMAND=sed
|
||||
HEAD_COMMAND=head
|
||||
if [[ "${OSTYPE}" == 'darwin'* ]]; then
|
||||
if ! command -v gsed &> /dev/null; then
|
||||
echo "Error: gsed is not installed. Please install it using 'brew install gnu-sed'."
|
||||
exit 1
|
||||
fi
|
||||
SED_COMMAND=gsed
|
||||
if ! command -v ghead &> /dev/null; then
|
||||
echo "Error: ghead is not installed. Please install it using 'brew install coreutils'."
|
||||
exit 1
|
||||
fi
|
||||
HEAD_COMMAND=ghead
|
||||
if ! command -v gsed &> /dev/null; then
|
||||
echo "Error: gsed is not installed. Please install it using 'brew install gnu-sed'."
|
||||
exit 1
|
||||
fi
|
||||
SED_COMMAND=gsed
|
||||
if ! command -v ghead &> /dev/null; then
|
||||
echo "Error: ghead is not installed. Please install it using 'brew install coreutils'."
|
||||
exit 1
|
||||
fi
|
||||
HEAD_COMMAND=ghead
|
||||
fi
|
||||
|
||||
# This script renames CMake files from `RippleXXX.cmake` or `RippledXXX.cmake`
|
||||
@@ -44,10 +44,10 @@ pushd "${DIRECTORY}"
|
||||
find cmake -type f -name 'Rippled*.cmake' -exec bash -c 'mv "${1}" "${1/Rippled/Xrpl}"' - {} \;
|
||||
find cmake -type f -name 'Ripple*.cmake' -exec bash -c 'mv "${1}" "${1/Ripple/Xrpl}"' - {} \;
|
||||
if [ -e cmake/xrpl_add_test.cmake ]; then
|
||||
mv cmake/xrpl_add_test.cmake cmake/XrplAddTest.cmake
|
||||
mv cmake/xrpl_add_test.cmake cmake/XrplAddTest.cmake
|
||||
fi
|
||||
if [ -e include/xrpl/proto/ripple.proto ]; then
|
||||
mv include/xrpl/proto/ripple.proto include/xrpl/proto/xrpl.proto
|
||||
mv include/xrpl/proto/ripple.proto include/xrpl/proto/xrpl.proto
|
||||
fi
|
||||
|
||||
# Rename inside the files.
|
||||
@@ -71,14 +71,14 @@ ${SED_COMMAND} -i 's@xrpl/validator-keys-tool@ripple/validator-keys-tool@' cmake
|
||||
# Ensure the name of the binary and config remain 'rippled' for now.
|
||||
${SED_COMMAND} -i -E 's/xrpld(-example)?\.cfg/rippled\1.cfg/g' cmake/XrplInstall.cmake
|
||||
if grep -q '"xrpld"' cmake/XrplCore.cmake; then
|
||||
# The script has been rerun, so just restore the name of the binary.
|
||||
${SED_COMMAND} -i 's/"xrpld"/"rippled"/' cmake/XrplCore.cmake
|
||||
# The script has been rerun, so just restore the name of the binary.
|
||||
${SED_COMMAND} -i 's/"xrpld"/"rippled"/' cmake/XrplCore.cmake
|
||||
elif ! grep -q '"rippled"' cmake/XrplCore.cmake; then
|
||||
${HEAD_COMMAND} -n -1 cmake/XrplCore.cmake > cmake.tmp
|
||||
echo ' # For the time being, we will keep the name of the binary as it was.' >> cmake.tmp
|
||||
echo ' set_target_properties(xrpld PROPERTIES OUTPUT_NAME "rippled")' >> cmake.tmp
|
||||
tail -1 cmake/XrplCore.cmake >> cmake.tmp
|
||||
mv cmake.tmp cmake/XrplCore.cmake
|
||||
${HEAD_COMMAND} -n -1 cmake/XrplCore.cmake > cmake.tmp
|
||||
echo ' # For the time being, we will keep the name of the binary as it was.' >> cmake.tmp
|
||||
echo ' set_target_properties(xrpld PROPERTIES OUTPUT_NAME "rippled")' >> cmake.tmp
|
||||
tail -1 cmake/XrplCore.cmake >> cmake.tmp
|
||||
mv cmake.tmp cmake/XrplCore.cmake
|
||||
fi
|
||||
|
||||
# Restore the symlink from 'xrpld' to 'rippled'.
|
||||
|
||||
28
.github/scripts/rename/config.sh
vendored
28
.github/scripts/rename/config.sh
vendored
@@ -6,11 +6,11 @@ set -e
|
||||
# On MacOS, ensure that GNU sed is installed and available as `gsed`.
|
||||
SED_COMMAND=sed
|
||||
if [[ "${OSTYPE}" == 'darwin'* ]]; then
|
||||
if ! command -v gsed &> /dev/null; then
|
||||
echo "Error: gsed is not installed. Please install it using 'brew install gnu-sed'."
|
||||
exit 1
|
||||
fi
|
||||
SED_COMMAND=gsed
|
||||
if ! command -v gsed &> /dev/null; then
|
||||
echo "Error: gsed is not installed. Please install it using 'brew install gnu-sed'."
|
||||
exit 1
|
||||
fi
|
||||
SED_COMMAND=gsed
|
||||
fi
|
||||
|
||||
# This script renames the config from `rippled.cfg` to `xrpld.cfg`, and updates
|
||||
@@ -32,28 +32,28 @@ pushd "${DIRECTORY}"
|
||||
|
||||
# Add the xrpld.cfg to the .gitignore.
|
||||
if ! grep -q 'xrpld.cfg' .gitignore; then
|
||||
${SED_COMMAND} -i '/rippled.cfg/a\
|
||||
${SED_COMMAND} -i '/rippled.cfg/a\
|
||||
/xrpld.cfg' .gitignore
|
||||
fi
|
||||
|
||||
# Rename the files.
|
||||
if [ -e rippled.cfg ]; then
|
||||
mv rippled.cfg xrpld.cfg
|
||||
mv rippled.cfg xrpld.cfg
|
||||
fi
|
||||
if [ -e cfg/rippled-example.cfg ]; then
|
||||
mv cfg/rippled-example.cfg cfg/xrpld-example.cfg
|
||||
mv cfg/rippled-example.cfg cfg/xrpld-example.cfg
|
||||
fi
|
||||
|
||||
# Rename inside the files.
|
||||
DIRECTORIES=("cfg" "cmake" "include" "src")
|
||||
for DIRECTORY in "${DIRECTORIES[@]}"; do
|
||||
echo "Processing directory: ${DIRECTORY}"
|
||||
echo "Processing directory: ${DIRECTORY}"
|
||||
|
||||
find "${DIRECTORY}" -type f \( -name "*.h" -o -name "*.hpp" -o -name "*.ipp" -o -name "*.cpp" -o -name "*.cmake" -o -name "*.txt" -o -name "*.cfg" -o -name "*.md" \) | while read -r FILE; do
|
||||
echo "Processing file: ${FILE}"
|
||||
${SED_COMMAND} -i -E 's/rippled(-example)?[ .]cfg/xrpld\1.cfg/g' "${FILE}"
|
||||
${SED_COMMAND} -i 's/rippleConfig/xrpldConfig/g' "${FILE}"
|
||||
done
|
||||
find "${DIRECTORY}" -type f \( -name "*.h" -o -name "*.hpp" -o -name "*.ipp" -o -name "*.cpp" -o -name "*.cmake" -o -name "*.txt" -o -name "*.cfg" -o -name "*.md" \) | while read -r FILE; do
|
||||
echo "Processing file: ${FILE}"
|
||||
${SED_COMMAND} -i -E 's/rippled(-example)?[ .]cfg/xrpld\1.cfg/g' "${FILE}"
|
||||
${SED_COMMAND} -i 's/rippleConfig/xrpldConfig/g' "${FILE}"
|
||||
done
|
||||
done
|
||||
${SED_COMMAND} -i 's/rippled/xrpld/g' cfg/xrpld-example.cfg
|
||||
${SED_COMMAND} -i 's/rippled/xrpld/g' src/test/core/Config_test.cpp
|
||||
|
||||
54
.github/scripts/rename/copyright.sh
vendored
54
.github/scripts/rename/copyright.sh
vendored
@@ -6,11 +6,11 @@ set -e
|
||||
# On MacOS, ensure that GNU sed is installed and available as `gsed`.
|
||||
SED_COMMAND=sed
|
||||
if [[ "${OSTYPE}" == 'darwin'* ]]; then
|
||||
if ! command -v gsed &> /dev/null; then
|
||||
echo "Error: gsed is not installed. Please install it using 'brew install gnu-sed'."
|
||||
exit 1
|
||||
fi
|
||||
SED_COMMAND=gsed
|
||||
if ! command -v gsed &> /dev/null; then
|
||||
echo "Error: gsed is not installed. Please install it using 'brew install gnu-sed'."
|
||||
exit 1
|
||||
fi
|
||||
SED_COMMAND=gsed
|
||||
fi
|
||||
|
||||
# This script removes superfluous copyright notices in source and header files
|
||||
@@ -43,56 +43,56 @@ ${SED_COMMAND} -i -E "s@\\\t@${PLACEHOLDER_TAB}@g" src/test/rpc/ValidatorInfo_te
|
||||
# Process the include/ and src/ directories.
|
||||
DIRECTORIES=("include" "src")
|
||||
for DIRECTORY in "${DIRECTORIES[@]}"; do
|
||||
echo "Processing directory: ${DIRECTORY}"
|
||||
echo "Processing directory: ${DIRECTORY}"
|
||||
|
||||
find "${DIRECTORY}" -type f \( -name "*.h" -o -name "*.hpp" -o -name "*.ipp" -o -name "*.cpp" -o -name "*.macro" \) | while read -r FILE; do
|
||||
echo "Processing file: ${FILE}"
|
||||
# Handle the cases where the copyright notice is enclosed in /* ... */
|
||||
# and usually surrounded by //---- and //======.
|
||||
${SED_COMMAND} -z -i -E 's@^//-------+\n+@@' "${FILE}"
|
||||
${SED_COMMAND} -z -i -E 's@^.*Copyright.+(Ripple|Bougalis|Falco|Hinnant|Null|Ritchford|XRPLF).+PERFORMANCE OF THIS SOFTWARE\.\n\*/\n+@@' "${FILE}" # cspell: ignore Bougalis Falco Hinnant Ritchford
|
||||
${SED_COMMAND} -z -i -E 's@^//=======+\n+@@' "${FILE}"
|
||||
find "${DIRECTORY}" -type f \( -name "*.h" -o -name "*.hpp" -o -name "*.ipp" -o -name "*.cpp" -o -name "*.macro" \) | while read -r FILE; do
|
||||
echo "Processing file: ${FILE}"
|
||||
# Handle the cases where the copyright notice is enclosed in /* ... */
|
||||
# and usually surrounded by //---- and //======.
|
||||
${SED_COMMAND} -z -i -E 's@^//-------+\n+@@' "${FILE}"
|
||||
${SED_COMMAND} -z -i -E 's@^.*Copyright.+(Ripple|Bougalis|Falco|Hinnant|Null|Ritchford|XRPLF).+PERFORMANCE OF THIS SOFTWARE\.\n\*/\n+@@' "${FILE}" # cspell: ignore Bougalis Falco Hinnant Ritchford
|
||||
${SED_COMMAND} -z -i -E 's@^//=======+\n+@@' "${FILE}"
|
||||
|
||||
# Handle the cases where the copyright notice is commented out with //.
|
||||
${SED_COMMAND} -z -i -E 's@^//\n// Copyright.+Falco \(vinnie dot falco at gmail dot com\)\n//\n+@@' "${FILE}" # cspell: ignore Vinnie Falco
|
||||
done
|
||||
# Handle the cases where the copyright notice is commented out with //.
|
||||
${SED_COMMAND} -z -i -E 's@^//\n// Copyright.+Falco \(vinnie dot falco at gmail dot com\)\n//\n+@@' "${FILE}" # cspell: ignore Vinnie Falco
|
||||
done
|
||||
done
|
||||
|
||||
# Restore copyright notices that were removed from specific files, without
|
||||
# restoring the verbiage that is already present in LICENSE.md. Ensure that if
|
||||
# the script is run multiple times, duplicate notices are not added.
|
||||
if ! grep -q 'Raw Material Software' include/xrpl/beast/core/CurrentThreadName.h; then
|
||||
echo -e "// Portions of this file are from JUCE (http://www.juce.com).\n// Copyright (c) 2013 - Raw Material Software Ltd.\n// Please visit http://www.juce.com\n\n$(cat include/xrpl/beast/core/CurrentThreadName.h)" > include/xrpl/beast/core/CurrentThreadName.h
|
||||
echo -e "// Portions of this file are from JUCE (http://www.juce.com).\n// Copyright (c) 2013 - Raw Material Software Ltd.\n// Please visit http://www.juce.com\n\n$(cat include/xrpl/beast/core/CurrentThreadName.h)" > include/xrpl/beast/core/CurrentThreadName.h
|
||||
fi
|
||||
if ! grep -q 'Dev Null' src/test/app/NetworkID_test.cpp; then
|
||||
echo -e "// Copyright (c) 2020 Dev Null Productions\n\n$(cat src/test/app/NetworkID_test.cpp)" > src/test/app/NetworkID_test.cpp
|
||||
echo -e "// Copyright (c) 2020 Dev Null Productions\n\n$(cat src/test/app/NetworkID_test.cpp)" > src/test/app/NetworkID_test.cpp
|
||||
fi
|
||||
if ! grep -q 'Dev Null' src/test/app/tx/apply_test.cpp; then
|
||||
echo -e "// Copyright (c) 2020 Dev Null Productions\n\n$(cat src/test/app/tx/apply_test.cpp)" > src/test/app/tx/apply_test.cpp
|
||||
echo -e "// Copyright (c) 2020 Dev Null Productions\n\n$(cat src/test/app/tx/apply_test.cpp)" > src/test/app/tx/apply_test.cpp
|
||||
fi
|
||||
if ! grep -q 'Dev Null' src/test/rpc/ManifestRPC_test.cpp; then
|
||||
echo -e "// Copyright (c) 2020 Dev Null Productions\n\n$(cat src/test/rpc/ManifestRPC_test.cpp)" > src/test/rpc/ManifestRPC_test.cpp
|
||||
echo -e "// Copyright (c) 2020 Dev Null Productions\n\n$(cat src/test/rpc/ManifestRPC_test.cpp)" > src/test/rpc/ManifestRPC_test.cpp
|
||||
fi
|
||||
if ! grep -q 'Dev Null' src/test/rpc/ValidatorInfo_test.cpp; then
|
||||
echo -e "// Copyright (c) 2020 Dev Null Productions\n\n$(cat src/test/rpc/ValidatorInfo_test.cpp)" > src/test/rpc/ValidatorInfo_test.cpp
|
||||
echo -e "// Copyright (c) 2020 Dev Null Productions\n\n$(cat src/test/rpc/ValidatorInfo_test.cpp)" > src/test/rpc/ValidatorInfo_test.cpp
|
||||
fi
|
||||
if ! grep -q 'Dev Null' src/xrpld/rpc/handlers/server_info/Manifest.cpp; then
|
||||
echo -e "// Copyright (c) 2019 Dev Null Productions\n\n$(cat src/xrpld/rpc/handlers/server_info/Manifest.cpp)" > src/xrpld/rpc/handlers/server_info/Manifest.cpp
|
||||
echo -e "// Copyright (c) 2019 Dev Null Productions\n\n$(cat src/xrpld/rpc/handlers/server_info/Manifest.cpp)" > src/xrpld/rpc/handlers/server_info/Manifest.cpp
|
||||
fi
|
||||
if ! grep -q 'Dev Null' src/xrpld/rpc/handlers/admin/status/ValidatorInfo.cpp; then
|
||||
echo -e "// Copyright (c) 2019 Dev Null Productions\n\n$(cat src/xrpld/rpc/handlers/admin/status/ValidatorInfo.cpp)" > src/xrpld/rpc/handlers/admin/status/ValidatorInfo.cpp
|
||||
echo -e "// Copyright (c) 2019 Dev Null Productions\n\n$(cat src/xrpld/rpc/handlers/admin/status/ValidatorInfo.cpp)" > src/xrpld/rpc/handlers/admin/status/ValidatorInfo.cpp
|
||||
fi
|
||||
if ! grep -q 'Bougalis' include/xrpl/basics/SlabAllocator.h; then
|
||||
echo -e "// Copyright (c) 2022, Nikolaos D. Bougalis <nikb@bougalis.net>\n\n$(cat include/xrpl/basics/SlabAllocator.h)" > include/xrpl/basics/SlabAllocator.h # cspell: ignore Nikolaos Bougalis nikb
|
||||
echo -e "// Copyright (c) 2022, Nikolaos D. Bougalis <nikb@bougalis.net>\n\n$(cat include/xrpl/basics/SlabAllocator.h)" > include/xrpl/basics/SlabAllocator.h # cspell: ignore Nikolaos Bougalis nikb
|
||||
fi
|
||||
if ! grep -q 'Bougalis' include/xrpl/basics/spinlock.h; then
|
||||
echo -e "// Copyright (c) 2022, Nikolaos D. Bougalis <nikb@bougalis.net>\n\n$(cat include/xrpl/basics/spinlock.h)" > include/xrpl/basics/spinlock.h # cspell: ignore Nikolaos Bougalis nikb
|
||||
echo -e "// Copyright (c) 2022, Nikolaos D. Bougalis <nikb@bougalis.net>\n\n$(cat include/xrpl/basics/spinlock.h)" > include/xrpl/basics/spinlock.h # cspell: ignore Nikolaos Bougalis nikb
|
||||
fi
|
||||
if ! grep -q 'Bougalis' include/xrpl/basics/tagged_integer.h; then
|
||||
echo -e "// Copyright (c) 2014, Nikolaos D. Bougalis <nikb@bougalis.net>\n\n$(cat include/xrpl/basics/tagged_integer.h)" > include/xrpl/basics/tagged_integer.h # cspell: ignore Nikolaos Bougalis nikb
|
||||
echo -e "// Copyright (c) 2014, Nikolaos D. Bougalis <nikb@bougalis.net>\n\n$(cat include/xrpl/basics/tagged_integer.h)" > include/xrpl/basics/tagged_integer.h # cspell: ignore Nikolaos Bougalis nikb
|
||||
fi
|
||||
if ! grep -q 'Ritchford' include/xrpl/beast/utility/Zero.h; then
|
||||
echo -e "// Copyright (c) 2014, Tom Ritchford <tom@swirly.com>\n\n$(cat include/xrpl/beast/utility/Zero.h)" > include/xrpl/beast/utility/Zero.h # cspell: ignore Ritchford
|
||||
echo -e "// Copyright (c) 2014, Tom Ritchford <tom@swirly.com>\n\n$(cat include/xrpl/beast/utility/Zero.h)" > include/xrpl/beast/utility/Zero.h # cspell: ignore Ritchford
|
||||
fi
|
||||
|
||||
# Restore newlines and tabs in string literals in the affected file.
|
||||
|
||||
10
.github/scripts/rename/definitions.sh
vendored
10
.github/scripts/rename/definitions.sh
vendored
@@ -6,11 +6,11 @@ set -e
|
||||
# On MacOS, ensure that GNU sed is installed and available as `gsed`.
|
||||
SED_COMMAND=sed
|
||||
if [[ "${OSTYPE}" == 'darwin'* ]]; then
|
||||
if ! command -v gsed &> /dev/null; then
|
||||
echo "Error: gsed is not installed. Please install it using 'brew install gnu-sed'."
|
||||
exit 1
|
||||
fi
|
||||
SED_COMMAND=gsed
|
||||
if ! command -v gsed &> /dev/null; then
|
||||
echo "Error: gsed is not installed. Please install it using 'brew install gnu-sed'."
|
||||
exit 1
|
||||
fi
|
||||
SED_COMMAND=gsed
|
||||
fi
|
||||
|
||||
# This script renames definitions, such as include guards, in this project.
|
||||
|
||||
10
.github/scripts/rename/docs.sh
vendored
10
.github/scripts/rename/docs.sh
vendored
@@ -6,11 +6,11 @@ set -e
|
||||
# On MacOS, ensure that GNU sed is installed and available as `gsed`.
|
||||
SED_COMMAND=sed
|
||||
if [[ "${OSTYPE}" == 'darwin'* ]]; then
|
||||
if ! command -v gsed &> /dev/null; then
|
||||
echo "Error: gsed is not installed. Please install it using 'brew install gnu-sed'."
|
||||
exit 1
|
||||
fi
|
||||
SED_COMMAND=gsed
|
||||
if ! command -v gsed &> /dev/null; then
|
||||
echo "Error: gsed is not installed. Please install it using 'brew install gnu-sed'."
|
||||
exit 1
|
||||
fi
|
||||
SED_COMMAND=gsed
|
||||
fi
|
||||
|
||||
# This script renames all remaining references to `ripple` and `rippled` to
|
||||
|
||||
4
.github/scripts/rename/include.sh
vendored
4
.github/scripts/rename/include.sh
vendored
@@ -23,8 +23,8 @@ fi
|
||||
find "${DIRECTORY}" -type f \( -name "*.h" -o -name "*.hpp" -o -name "*.ipp" \) | while read -r FILE; do
|
||||
echo "Processing file: ${FILE}"
|
||||
if grep -q "#ifndef XRPL_" "${FILE}"; then
|
||||
echo "Please replace all include guards by #pragma once."
|
||||
exit 1
|
||||
echo "Please replace all include guards by #pragma once."
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
echo "Checking complete."
|
||||
|
||||
26
.github/scripts/rename/namespace.sh
vendored
26
.github/scripts/rename/namespace.sh
vendored
@@ -6,11 +6,11 @@ set -e
|
||||
# On MacOS, ensure that GNU sed is installed and available as `gsed`.
|
||||
SED_COMMAND=sed
|
||||
if [[ "${OSTYPE}" == 'darwin'* ]]; then
|
||||
if ! command -v gsed &> /dev/null; then
|
||||
echo "Error: gsed is not installed. Please install it using 'brew install gnu-sed'."
|
||||
exit 1
|
||||
fi
|
||||
SED_COMMAND=gsed
|
||||
if ! command -v gsed &> /dev/null; then
|
||||
echo "Error: gsed is not installed. Please install it using 'brew install gnu-sed'."
|
||||
exit 1
|
||||
fi
|
||||
SED_COMMAND=gsed
|
||||
fi
|
||||
|
||||
# This script renames the `ripple` namespace to `xrpl` in this project.
|
||||
@@ -35,15 +35,15 @@ pushd "${DIRECTORY}"
|
||||
|
||||
DIRECTORIES=("include" "src" "tests")
|
||||
for DIRECTORY in "${DIRECTORIES[@]}"; do
|
||||
echo "Processing directory: ${DIRECTORY}"
|
||||
echo "Processing directory: ${DIRECTORY}"
|
||||
|
||||
find "${DIRECTORY}" -type f \( -name "*.h" -o -name "*.hpp" -o -name "*.ipp" -o -name "*.cpp" -o -name "*.macro" \) | while read -r FILE; do
|
||||
echo "Processing file: ${FILE}"
|
||||
${SED_COMMAND} -i 's/namespace ripple/namespace xrpl/g' "${FILE}"
|
||||
${SED_COMMAND} -i 's/ripple::/xrpl::/g' "${FILE}"
|
||||
${SED_COMMAND} -i 's/"ripple:/"xrpl::/g' "${FILE}"
|
||||
${SED_COMMAND} -i -E 's/(BEAST_DEFINE_TESTSUITE.+)ripple(.+)/\1xrpl\2/g' "${FILE}"
|
||||
done
|
||||
find "${DIRECTORY}" -type f \( -name "*.h" -o -name "*.hpp" -o -name "*.ipp" -o -name "*.cpp" -o -name "*.macro" \) | while read -r FILE; do
|
||||
echo "Processing file: ${FILE}"
|
||||
${SED_COMMAND} -i 's/namespace ripple/namespace xrpl/g' "${FILE}"
|
||||
${SED_COMMAND} -i 's/ripple::/xrpl::/g' "${FILE}"
|
||||
${SED_COMMAND} -i 's/"ripple:/"xrpl::/g' "${FILE}"
|
||||
${SED_COMMAND} -i -E 's/(BEAST_DEFINE_TESTSUITE.+)ripple(.+)/\1xrpl\2/g' "${FILE}"
|
||||
done
|
||||
done
|
||||
|
||||
# Special case for NuDBFactory that has ripple twice in the test suite name.
|
||||
|
||||
19
.github/workflows/reusable-clang-tidy-files.yml
vendored
19
.github/workflows/reusable-clang-tidy-files.yml
vendored
@@ -80,7 +80,7 @@ jobs:
|
||||
env:
|
||||
TARGETS: ${{ inputs.files != '' && inputs.files || 'src tests' }}
|
||||
run: |
|
||||
run-clang-tidy -j ${{ steps.nproc.outputs.nproc }} -p "${BUILD_DIR}" -quiet -fix -allow-no-checks ${TARGETS} 2>&1 | tee clang-tidy-output.txt
|
||||
run-clang-tidy -j ${{ steps.nproc.outputs.nproc }} -p "${BUILD_DIR}" -quiet -allow-no-checks ${TARGETS} 2>&1 | tee clang-tidy-output.txt
|
||||
|
||||
- name: Upload clang-tidy output
|
||||
if: ${{ github.event.repository.visibility == 'public' && steps.run_clang_tidy.outcome != 'success' }}
|
||||
@@ -90,21 +90,8 @@ jobs:
|
||||
path: clang-tidy-output.txt
|
||||
retention-days: 30
|
||||
|
||||
- name: Generate git diff
|
||||
if: ${{ steps.run_clang_tidy.outcome != 'success' }}
|
||||
run: |
|
||||
git diff | tee clang-tidy-git-diff.txt
|
||||
|
||||
- name: Upload clang-tidy diff output
|
||||
if: ${{ github.event.repository.visibility == 'public' && steps.run_clang_tidy.outcome != 'success' }}
|
||||
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
||||
with:
|
||||
name: clang-tidy-git-diff
|
||||
path: clang-tidy-git-diff.txt
|
||||
retention-days: 30
|
||||
|
||||
- name: Create an issue
|
||||
if: ${{ steps.run_clang_tidy.outcome != 'success' && inputs.create_issue_on_failure }}
|
||||
if: steps.run_clang_tidy.outcome != 'success' && inputs.create_issue_on_failure
|
||||
id: create_issue
|
||||
shell: bash
|
||||
env:
|
||||
@@ -169,7 +156,7 @@ jobs:
|
||||
rm -f create_issue.log issue.md clang-tidy-output.txt
|
||||
|
||||
- name: Fail the workflow if clang-tidy failed
|
||||
if: ${{ steps.run_clang_tidy.outcome != 'success' }}
|
||||
if: steps.run_clang_tidy.outcome != 'success'
|
||||
run: |
|
||||
echo "Clang-tidy check failed!"
|
||||
exit 1
|
||||
|
||||
@@ -44,12 +44,6 @@ repos:
|
||||
hooks:
|
||||
- id: black
|
||||
|
||||
- repo: https://github.com/openstack/bashate
|
||||
rev: 5798d24d571676fc407e81df574c1ef57b520f23 # frozen: 2.1.1
|
||||
hooks:
|
||||
- id: bashate
|
||||
args: ["--ignore=E006"]
|
||||
|
||||
- repo: https://github.com/streetsidesoftware/cspell-cli
|
||||
rev: a42085ade523f591dca134379a595e7859986445 # frozen: v9.7.0
|
||||
hooks:
|
||||
@@ -67,14 +61,6 @@ repos:
|
||||
|
||||
- repo: local
|
||||
hooks:
|
||||
- id: clang-tidy
|
||||
name: "clang-tidy (enable with: TIDY=1)"
|
||||
entry: ./bin/pre-commit/clang_tidy_check.py
|
||||
language: python
|
||||
types_or: [c++, c]
|
||||
exclude: ^include/xrpl/protocol_autogen
|
||||
pass_filenames: false # script determines the staged files itself
|
||||
|
||||
- id: nix-fmt
|
||||
name: Format Nix files
|
||||
entry: |
|
||||
|
||||
@@ -267,26 +267,6 @@ See the [environment setup guide](./docs/build/environment.md#clang-tidy) for pl
|
||||
|
||||
Before running clang-tidy, you must build the project to generate required files (particularly protobuf headers). Refer to [`BUILD.md`](./BUILD.md) for build instructions.
|
||||
|
||||
#### Via pre-commit (recommended)
|
||||
|
||||
If you have already installed the pre-commit hooks (see above), you can run clang-tidy on your staged files using:
|
||||
|
||||
```
|
||||
TIDY=1 pre-commit run clang-tidy
|
||||
```
|
||||
|
||||
This runs clang-tidy locally with the same configuration/flags as CI, scoped to your staged C++ files. The `TIDY=1` environment variable is required to opt in — without it the hook is skipped.
|
||||
|
||||
You can also have clang-tidy run automatically on every `git commit` by setting `TIDY=1` in your shell environment:
|
||||
|
||||
```
|
||||
export TIDY=1
|
||||
```
|
||||
|
||||
With this set, the hook will run as part of `git commit` alongside the other pre-commit checks.
|
||||
|
||||
#### Manually
|
||||
|
||||
Then run clang-tidy on your local changes:
|
||||
|
||||
```
|
||||
|
||||
113
SECURITY.md
113
SECURITY.md
@@ -22,10 +22,117 @@ Responsible investigation includes, but isn't limited to, the following:
|
||||
- Not targeting physical security measures, or attempting to use social engineering, spam, distributed denial of service (DDOS) attacks, etc.
|
||||
- Investigating bugs in a way that makes a reasonable, good faith effort not to be disruptive or harmful to the XRP Ledger and the broader ecosystem.
|
||||
|
||||
### Responsible Disclosure
|
||||
|
||||
If you discover a vulnerability or potential threat, or if you _think_
|
||||
you have, please reach out by dropping an email using the contact
|
||||
information below.
|
||||
|
||||
Your report should include the following:
|
||||
|
||||
- Your contact information (typically, an email address);
|
||||
- The description of the vulnerability;
|
||||
- The attack scenario (if any);
|
||||
- The steps to reproduce the vulnerability;
|
||||
- Any other relevant details or artifacts, including code, scripts or patches.
|
||||
|
||||
In your email, please describe the issue or potential threat. If possible, include a "repro" (code that can reproduce the issue) or describe the best way to reproduce and replicate the issue. Please make your report as detailed and comprehensive as possible.
|
||||
|
||||
For more information on responsible disclosure, please read this [Wikipedia article](https://en.wikipedia.org/wiki/Responsible_disclosure).
|
||||
|
||||
## Report Handling Process
|
||||
|
||||
Please report the bug directly to us and limit further disclosure. If you want to prove that you knew the bug as of a given time, consider using a cryptographic pre-commitment: hash the content of your report and publish the hash on a medium of your choice (e.g. on Twitter or as a memo in a transaction) as "proof" that you had written the text at a given point in time.
|
||||
|
||||
Once we receive a report, we:
|
||||
|
||||
1. Assign two people to independently evaluate the report;
|
||||
2. Consider their recommendations;
|
||||
3. If action is necessary, formulate a plan to address the issue;
|
||||
4. Communicate privately with the reporter to explain our plan.
|
||||
5. Prepare, test and release a version which fixes the issue; and
|
||||
6. Announce the vulnerability publicly.
|
||||
|
||||
We will triage and respond to your disclosure within 24 hours. Beyond that, we will work to analyze the issue in more detail, formulate, develop and test a fix.
|
||||
|
||||
While we commit to responding with 24 hours of your initial report with our triage assessment, we cannot guarantee a response time for the remaining steps. We will communicate with you throughout this process, letting you know where we are and keeping you updated on the timeframe.
|
||||
|
||||
## Bug Bounty Program
|
||||
|
||||
[Ripple](https://ripple.com) is generously sponsoring a bug bounty program for vulnerabilities in [`xrpld`](https://github.com/XRPLF/rippled) (and other related projects, like [`Clio`](https://github.com/XRPLF/clio), [`xrpl.js`](https://github.com/XRPLF/xrpl.js), [`xrpl-py`](https://github.com/XRPLF/xrpl-py), [`xrpl4j`](https://github.com/XRPLF/xrpl4j)).
|
||||
[Ripple](https://ripple.com) is generously sponsoring a bug bounty program for vulnerabilities in [`xrpld`](https://github.com/XRPLF/rippled) (and other related projects, like [`xrpl.js`](https://github.com/XRPLF/xrpl.js), [`xrpl-py`](https://github.com/XRPLF/xrpl-py), [`xrpl4j`](https://github.com/XRPLF/xrpl4j)).
|
||||
|
||||
This program allows us to recognize and reward individuals or groups that identify and report bugs.
|
||||
This program allows us to recognize and reward individuals or groups that identify and report bugs. In summary, in order to qualify for a bounty, the bug must be:
|
||||
|
||||
We have partnered with Bugcrowd to manage this program. It is a private program, and security researchers can participate based on invitation. However, if you plan to submit a bug, please email bugs@ripple.com with your Bugcrowd handle or Bugcrowd registered email. We will get you added to the program. The detailed bug bounty policy is available on the Bugcrowd website.
|
||||
1. **In scope**. Only bugs in software under the scope of the program qualify. Currently, that means `xrpld`, `xrpl.js`, `xrpl-py`, `xrpl4j`.
|
||||
2. **Relevant**. A security issue, posing a danger to user funds, privacy, or the operation of the XRP Ledger.
|
||||
3. **Original and previously unknown**. Bugs that are already known and discussed in public do not qualify. Previously reported bugs, even if publicly unknown, are not eligible.
|
||||
4. **Specific**. We welcome general security advice or recommendations, but we cannot pay bounties for that.
|
||||
5. **Fixable**. There has to be something we can do to permanently fix the problem. Note that bugs in other people’s software may still qualify in some cases. For example, if you find a bug in a library that we use which can compromise the security of software that is in scope and we can get it fixed, you may qualify for a bounty.
|
||||
6. **Unused**. If you use the exploit to attack the XRP Ledger, you do not qualify for a bounty. If you report a vulnerability used in an ongoing or past attack and there is specific, concrete evidence that suggests you are the attacker we reserve the right not to pay a bounty.
|
||||
|
||||
The amount paid varies dramatically. Vulnerabilities that are harmless on their own, but could form part of a critical exploit will usually receive a bounty. Full-blown exploits can receive much higher bounties. Please don’t hold back partial vulnerabilities while trying to construct a full-blown exploit. We will pay a bounty to anyone who reports a complete chain of vulnerabilities even if they have reported each component of the exploit separately and those vulnerabilities have been fixed in the meantime. However, to qualify for a the full bounty, you must to have been the first to report each of the partial exploits.
|
||||
|
||||
### Contacting Us
|
||||
|
||||
To report a qualifying bug, please send a detailed report to:
|
||||
|
||||
| Email Address | bugs@ripple.com |
|
||||
| :-----------: | :-------------------------------------------------- |
|
||||
| Short Key ID | `0xA9F514E0` |
|
||||
| Long Key ID | `0xD900855AA9F514E0` |
|
||||
| Fingerprint | `B72C 0654 2F2A E250 2763 A268 D900 855A A9F5 14E0` |
|
||||
|
||||
The full PGP key for this address, which is also available on several key servers (e.g. on [keyserver.ubuntu.com](https://keyserver.ubuntu.com)), is:
|
||||
|
||||
```
|
||||
-----BEGIN PGP PUBLIC KEY BLOCK-----
|
||||
mQINBGkSZAQBEACprU199OhgdsOsygNjiQV4msuN3vDOUooehL+NwfsGfW79Tbqq
|
||||
Q2u7uQ3NZjW+M2T4nsDwuhkr7pe7xSReR5W8ssaczvtUyxkvbMClilcgZ2OSCAuC
|
||||
N9tzJsqOqkwBvXoNXkn//T2jnPz0ZU2wSF+NrEibq5FeuyGdoX3yXXBxq9pW9HzK
|
||||
HkQll63QSl6BzVSGRQq+B6lGgaZGLwf3mzmIND9Z5VGLNK2jKynyz9z091whNG/M
|
||||
kV+E7/r/bujHk7WIVId07G5/COTXmSr7kFnNEkd2Umw42dkgfiNKvlmJ9M7c1wLK
|
||||
KbL9Eb4ADuW6rRc5k4s1e6GT8R4/VPliWbCl9SE32hXH8uTkqVIFZP2eyM5WRRHs
|
||||
aKzitkQG9UK9gcb0kdgUkxOvvgPHAe5IuZlcHFzU4y0dBbU1VEFWVpiLU0q+IuNw
|
||||
5BRemeHc59YNsngkmAZ+/9zouoShRusZmC8Wzotv75C2qVBcjijPvmjWAUz0Zunm
|
||||
Lsr+O71vqHE73pERjD07wuD/ISjiYRYYE/bVrXtXLZijC7qAH4RE3nID+2ojcZyO
|
||||
/2jMQvt7un56RsGH4UBHi3aBHi9bUoDGCXKiQY981cEuNaOxpou7Mh3x/ONzzSvk
|
||||
sTV6nl1LOZHykN1JyKwaNbTSAiuyoN+7lOBqbV04DNYAHL88PrT21P83aQARAQAB
|
||||
tB1SaXBwbGUgTGFicyA8YnVnc0ByaXBwbGUuY29tPokCTgQTAQgAOBYhBLcsBlQv
|
||||
KuJQJ2OiaNkAhVqp9RTgBQJpEmQEAhsDBQsJCAcCBhUKCQgLAgQWAgMBAh4BAheA
|
||||
AAoJENkAhVqp9RTgBzgP/i7y+aDWl1maig1XMdyb+o0UGusumFSW4Hmj278wlKVv
|
||||
usgLPihYgHE0PKrv6WRyKOMC1tQEcYYN93M+OeQ1vFhS2YyURq6RCMmh4zq/awXG
|
||||
uZbG36OURB5NH8lGBOHiN/7O+nY0CgenBT2JWm+GW3nEOAVOVm4+r5GlpPlv+Dp1
|
||||
NPBThcKXFMnH73++NpSQoDzTfRYHPxhDAX3jkLi/moXfSanOLlR6l94XNNN0jBHW
|
||||
Quao0rzf4WSXq9g6AS224xhAA5JyIcFl8TX7hzj5HaFn3VWo3COoDu4U7H+BM0fl
|
||||
85yqiMQypp7EhN2gxpMMWaHY5TFM85U/bFXFYfEgihZ4/gt4uoIzsNI9jlX7mYvG
|
||||
KFdDij+oTlRsuOxdIy60B3dKcwOH9nZZCz0SPsN/zlRWgKzK4gDKdGhFkU9OlvPu
|
||||
94ZqscanoiWKDoZkF96+sjgfjkuHsDK7Lwc1Xi+T4drHG/3aVpkYabXox+lrKB/S
|
||||
yxZjeqOIQzWPhnLgCaLyvsKo5hxKzL0w3eURu8F3IS7RgOOlljv4M+Me9sEVcdNV
|
||||
aN3/tQwbaomSX1X5D5YXqhBwC3rU3wXwamsscRTGEpkV+JCX6KUqGP7nWmxCpAly
|
||||
FL05XuOd5SVHJjXLeuje0JqLUpN514uL+bThWwDbDTdAdwW3oK/2WbXz7IfJRLBj
|
||||
uQINBGkSZAQBEADdI3SL2F72qkrgFqXWE6HSRBu9bsAvTE5QrRPWk7ux6at537r4
|
||||
S4sIw2dOwLvbyIrDgKNq3LQ5wCK88NO/NeCOFm4AiCJSl3pJHXYnTDoUxTrrxx+o
|
||||
vSRI4I3fHEql/MqzgiAb0YUezjgFdh3vYheMPp/309PFbOLhiFqEcx80Mx5h06UH
|
||||
gDzu1qNj3Ec+31NLic5zwkrAkvFvD54d6bqYR3SEgMau6aYEewpGHbWBi2pLqSi2
|
||||
lQcAeOFixqGpTwDmAnYR8YtjBYepy0MojEAdTHcQQlOYSDk4q4elG+io2N8vECfU
|
||||
rD6ORecN48GXdZINYWTAdslrUeanmBdgQrYkSpce8TSghgT9P01SNaXxmyaehVUO
|
||||
lqI4pcg5G2oojAE8ncNS3TwDtt7daTaTC3bAdr4PXDVAzNAiewjMNZPB7xidkDGQ
|
||||
Y4W1LxTMXyJVWxehYOH7tsbBRKninlfRnLgYzmtIbNRAAvNcsxU6ihv3AV0WFknN
|
||||
YbSzotEv1Xq/5wk309x8zCDe+sP0cQicvbXafXmUzPAZzeqFg+VLFn7F9MP1WGlW
|
||||
B1u7VIvBF1Mp9Nd3EAGBAoLRdRu+0dVWIjPTQuPIuD9cCatJA0wVaKUrjYbBMl88
|
||||
a12LixNVGeSFS9N7ADHx0/o7GNT6l88YbaLP6zggUHpUD/bR+cDN7vllIQARAQAB
|
||||
iQI2BBgBCAAgFiEEtywGVC8q4lAnY6Jo2QCFWqn1FOAFAmkSZAQCGwwACgkQ2QCF
|
||||
Wqn1FOAfAA/8CYq4p0p4bobY20CKEMsZrkBTFJyPDqzFwMeTjgpzqbD7Y3Qq5QCK
|
||||
OBbvY02GWdiIsNOzKdBxiuam2xYP9WHZj4y7/uWEvT0qlPVmDFu+HXjoJ43oxwFd
|
||||
CUp2gMuQ4cSL3X94VRJ3BkVL+tgBm8CNY0vnTLLOO3kum/R69VsGJS1JSGUWjNM+
|
||||
4qwS3mz+73xJu1HmERyN2RZF/DGIZI2PyONQQ6aH85G1Dd2ohu2/DBAkQAMBrPbj
|
||||
FrbDaBLyFhODxU3kTWqnfLlaElSm2EGdIU2yx7n4BggEa//NZRMm5kyeo4vzhtlQ
|
||||
YIVUMLAOLZvnEqDnsLKp+22FzNR/O+htBQC4lPywl53oYSALdhz1IQlcAC1ru5KR
|
||||
XPzhIXV6IIzkcx9xNkEclZxmsuy5ERXyKEmLbIHAlzFmnrldlt2ZgXDtzaorLmxj
|
||||
klKibxd5tF50qOpOivz+oPtFo7n+HmFa1nlVAMxlDCUdM0pEVeYDKI5zfVwalyhZ
|
||||
NnjpakdZSXMwgc7NP/hH9buF35hKDp7EckT2y3JNYwHsDdy1icXN2q40XZw5tSIn
|
||||
zkPWdu3OUY8PISohN6Pw4h0RH4ZmoX97E8sEfmdKaT58U4Hf2aAv5r9IWCSrAVqY
|
||||
u5jvac29CzQR9Kal0A+8phHAXHNFD83SwzIC0syaT9ficAguwGH8X6Q=
|
||||
=nGuD
|
||||
-----END PGP PUBLIC KEY BLOCK-----
|
||||
```
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [[ $# -ne 1 || "$1" == "--help" || "$1" == "-h" ]]; then
|
||||
name=$( basename $0 )
|
||||
cat <<- USAGE
|
||||
Usage: $name <username>
|
||||
if [[ $# -ne 1 || "$1" == "--help" || "$1" == "-h" ]]
|
||||
then
|
||||
name=$( basename $0 )
|
||||
cat <<- USAGE
|
||||
Usage: $name <username>
|
||||
|
||||
Where <username> is the Github username of the upstream repo. e.g. XRPLF
|
||||
Where <username> is the Github username of the upstream repo. e.g. XRPLF
|
||||
USAGE
|
||||
exit 0
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Create upstream remotes based on origin
|
||||
@@ -15,9 +16,10 @@ shift
|
||||
user="$1"
|
||||
# Get the origin URL. Expect it be an SSH-style URL
|
||||
origin=$( git remote get-url origin )
|
||||
if [[ "${origin}" == "" ]]; then
|
||||
echo Invalid origin remote >&2
|
||||
exit 1
|
||||
if [[ "${origin}" == "" ]]
|
||||
then
|
||||
echo Invalid origin remote >&2
|
||||
exit 1
|
||||
fi
|
||||
# echo "Origin: ${origin}"
|
||||
# Parse the origin
|
||||
@@ -28,9 +30,11 @@ IFS='@' read sshuser server <<< "${remote}"
|
||||
# echo "SSHUser: ${sshuser}, Server: ${server}"
|
||||
IFS='/' read originuser repo <<< "${originpath}"
|
||||
# echo "Originuser: ${originuser}, Repo: ${repo}"
|
||||
if [[ "${sshuser}" == "" || "${server}" == "" || "${originuser}" == "" || "${repo}" == "" ]]; then
|
||||
echo "Can't parse origin URL: ${origin}" >&2
|
||||
exit 1
|
||||
if [[ "${sshuser}" == "" || "${server}" == "" || "${originuser}" == ""
|
||||
|| "${repo}" == "" ]]
|
||||
then
|
||||
echo "Can't parse origin URL: ${origin}" >&2
|
||||
exit 1
|
||||
fi
|
||||
upstream="https://${server}/${user}/${repo}"
|
||||
upstreampush="${remote}:${user}/${repo}"
|
||||
@@ -38,34 +42,42 @@ upstreamgroup="upstream upstream-push"
|
||||
current=$( git remote get-url upstream 2>/dev/null )
|
||||
currentpush=$( git remote get-url upstream-push 2>/dev/null )
|
||||
currentgroup=$( git config remotes.upstreams )
|
||||
if [[ "${current}" == "${upstream}" ]]; then
|
||||
echo "Upstream already set up correctly. Skip"
|
||||
elif [[ -n "${current}" && "${current}" != "${upstream}" && "${current}" != "${upstreampush}" ]]; then
|
||||
echo "Upstream already set up as: ${current}. Skip"
|
||||
if [[ "${current}" == "${upstream}" ]]
|
||||
then
|
||||
echo "Upstream already set up correctly. Skip"
|
||||
elif [[ -n "${current}" && "${current}" != "${upstream}" &&
|
||||
"${current}" != "${upstreampush}" ]]
|
||||
then
|
||||
echo "Upstream already set up as: ${current}. Skip"
|
||||
else
|
||||
if [[ "${current}" == "${upstreampush}" ]]; then
|
||||
echo "Upstream set to dangerous push URL. Update."
|
||||
_run git remote rename upstream upstream-push || \
|
||||
_run git remote remove upstream
|
||||
currentpush=$( git remote get-url upstream-push 2>/dev/null )
|
||||
fi
|
||||
_run git remote add upstream "${upstream}"
|
||||
if [[ "${current}" == "${upstreampush}" ]]
|
||||
then
|
||||
echo "Upstream set to dangerous push URL. Update."
|
||||
_run git remote rename upstream upstream-push || \
|
||||
_run git remote remove upstream
|
||||
currentpush=$( git remote get-url upstream-push 2>/dev/null )
|
||||
fi
|
||||
_run git remote add upstream "${upstream}"
|
||||
fi
|
||||
|
||||
if [[ "${currentpush}" == "${upstreampush}" ]]; then
|
||||
echo "upstream-push already set up correctly. Skip"
|
||||
elif [[ -n "${currentpush}" && "${currentpush}" != "${upstreampush}" ]]; then
|
||||
echo "upstream-push already set up as: ${currentpush}. Skip"
|
||||
if [[ "${currentpush}" == "${upstreampush}" ]]
|
||||
then
|
||||
echo "upstream-push already set up correctly. Skip"
|
||||
elif [[ -n "${currentpush}" && "${currentpush}" != "${upstreampush}" ]]
|
||||
then
|
||||
echo "upstream-push already set up as: ${currentpush}. Skip"
|
||||
else
|
||||
_run git remote add upstream-push "${upstreampush}"
|
||||
_run git remote add upstream-push "${upstreampush}"
|
||||
fi
|
||||
|
||||
if [[ "${currentgroup}" == "${upstreamgroup}" ]]; then
|
||||
echo "Upstreams group already set up correctly. Skip"
|
||||
elif [[ -n "${currentgroup}" && "${currentgroup}" != "${upstreamgroup}" ]]; then
|
||||
echo "Upstreams group already set up as: ${currentgroup}. Skip"
|
||||
if [[ "${currentgroup}" == "${upstreamgroup}" ]]
|
||||
then
|
||||
echo "Upstreams group already set up correctly. Skip"
|
||||
elif [[ -n "${currentgroup}" && "${currentgroup}" != "${upstreamgroup}" ]]
|
||||
then
|
||||
echo "Upstreams group already set up as: ${currentgroup}. Skip"
|
||||
else
|
||||
_run git config --add remotes.upstreams "${upstreamgroup}"
|
||||
_run git config --add remotes.upstreams "${upstreamgroup}"
|
||||
fi
|
||||
|
||||
_run git fetch --jobs=$(nproc) upstreams
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [[ $# -lt 3 || "$1" == "--help" || "$1" = "-h" ]]; then
|
||||
name=$( basename $0 )
|
||||
cat <<- USAGE
|
||||
Usage: $name workbranch base/branch user/branch [user/branch [...]]
|
||||
if [[ $# -lt 3 || "$1" == "--help" || "$1" = "-h" ]]
|
||||
then
|
||||
name=$( basename $0 )
|
||||
cat <<- USAGE
|
||||
Usage: $name workbranch base/branch user/branch [user/branch [...]]
|
||||
|
||||
* workbranch will be created locally from base/branch
|
||||
* base/branch and user/branch may be specified as user:branch to allow
|
||||
easy copying from Github PRs
|
||||
* Remotes for each user must already be set up
|
||||
* workbranch will be created locally from base/branch
|
||||
* base/branch and user/branch may be specified as user:branch to allow
|
||||
easy copying from Github PRs
|
||||
* Remotes for each user must already be set up
|
||||
USAGE
|
||||
exit 0
|
||||
exit 0
|
||||
fi
|
||||
|
||||
work="$1"
|
||||
@@ -23,8 +24,9 @@ unset branches[0]
|
||||
set -e
|
||||
|
||||
users=()
|
||||
for b in "${branches[@]}"; do
|
||||
users+=( $( echo $b | cut -d/ -f1 ) )
|
||||
for b in "${branches[@]}"
|
||||
do
|
||||
users+=( $( echo $b | cut -d/ -f1 ) )
|
||||
done
|
||||
|
||||
users=( $( printf '%s\n' "${users[@]}" | sort -u ) )
|
||||
@@ -32,9 +34,10 @@ users=( $( printf '%s\n' "${users[@]}" | sort -u ) )
|
||||
git fetch --multiple upstreams "${users[@]}"
|
||||
git checkout -B "$work" --no-track "$base"
|
||||
|
||||
for b in "${branches[@]}"; do
|
||||
git merge --squash "${b}"
|
||||
git commit -S # Use the commit message provided on the PR
|
||||
for b in "${branches[@]}"
|
||||
do
|
||||
git merge --squash "${b}"
|
||||
git commit -S # Use the commit message provided on the PR
|
||||
done
|
||||
|
||||
# Make sure the commits look right
|
||||
@@ -44,11 +47,13 @@ parts=( $( echo $base | sed "s/\// /" ) )
|
||||
repo="${parts[0]}"
|
||||
b="${parts[1]}"
|
||||
push=$repo
|
||||
if [[ "$push" == "upstream" ]]; then
|
||||
push="upstream-push"
|
||||
if [[ "$push" == "upstream" ]]
|
||||
then
|
||||
push="upstream-push"
|
||||
fi
|
||||
if [[ "$repo" == "upstream" ]]; then
|
||||
repo="upstreams"
|
||||
if [[ "$repo" == "upstream" ]]
|
||||
then
|
||||
repo="upstreams"
|
||||
fi
|
||||
cat << PUSH
|
||||
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [[ $# -ne 3 || "$1" == "--help" || "$1" = "-h" ]]; then
|
||||
name=$( basename $0 )
|
||||
cat <<- USAGE
|
||||
Usage: $name workbranch base/branch version
|
||||
if [[ $# -ne 3 || "$1" == "--help" || "$1" = "-h" ]]
|
||||
then
|
||||
name=$( basename $0 )
|
||||
cat <<- USAGE
|
||||
Usage: $name workbranch base/branch version
|
||||
|
||||
* workbranch will be created locally from base/branch. If it exists,
|
||||
it will be reused, so make sure you don't overwrite any work.
|
||||
* base/branch may be specified as user:branch to allow easy copying
|
||||
from Github PRs.
|
||||
* workbranch will be created locally from base/branch. If it exists,
|
||||
it will be reused, so make sure you don't overwrite any work.
|
||||
* base/branch may be specified as user:branch to allow easy copying
|
||||
from Github PRs.
|
||||
USAGE
|
||||
exit 0
|
||||
exit 0
|
||||
fi
|
||||
|
||||
work="$1"
|
||||
@@ -29,9 +30,10 @@ git fetch upstreams
|
||||
git checkout -B "${work}" --no-track "${base}"
|
||||
|
||||
push=$( git rev-parse --abbrev-ref --symbolic-full-name '@{push}' \
|
||||
2>/dev/null ) || true
|
||||
if [[ "${push}" != "" ]]; then
|
||||
echo "Warning: ${push} may already exist."
|
||||
2>/dev/null ) || true
|
||||
if [[ "${push}" != "" ]]
|
||||
then
|
||||
echo "Warning: ${push} may already exist."
|
||||
fi
|
||||
|
||||
build=$( find -name BuildInfo.cpp )
|
||||
|
||||
@@ -1,206 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Pre-commit hook that runs clang-tidy on changed files using run-clang-tidy."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
from collections import defaultdict
|
||||
from pathlib import Path
|
||||
|
||||
HEADER_EXTENSIONS = {".h", ".hpp", ".ipp"}
|
||||
SOURCE_EXTENSIONS = {".cpp"}
|
||||
INCLUDE_RE = re.compile(r"^\s*#\s*include\s*[<\"]([^>\"]+)[>\"]")
|
||||
|
||||
|
||||
def find_run_clang_tidy() -> str | None:
|
||||
for candidate in ("run-clang-tidy-21", "run-clang-tidy"):
|
||||
if path := shutil.which(candidate):
|
||||
return path
|
||||
return None
|
||||
|
||||
|
||||
def find_build_dir(repo_root: Path) -> Path | None:
|
||||
for name in (".build", "build"):
|
||||
candidate = repo_root / name
|
||||
if (candidate / "compile_commands.json").exists():
|
||||
return candidate
|
||||
return None
|
||||
|
||||
|
||||
def build_include_graph(build_dir: Path, repo_root: Path) -> tuple[dict, set]:
|
||||
"""
|
||||
Scan all files reachable from compile_commands.json and build an inverted include graph.
|
||||
|
||||
Returns:
|
||||
inverted: header_path -> set of files that include it
|
||||
source_files: set of all TU paths from compile_commands.json
|
||||
"""
|
||||
with open(build_dir / "compile_commands.json") as f:
|
||||
db = json.load(f)
|
||||
|
||||
source_files = {Path(e["file"]).resolve() for e in db}
|
||||
include_roots = [repo_root / "include", repo_root / "src"]
|
||||
inverted: dict[Path, set[Path]] = defaultdict(set)
|
||||
|
||||
to_scan: set[Path] = set(source_files)
|
||||
scanned: set[Path] = set()
|
||||
|
||||
while to_scan:
|
||||
file = to_scan.pop()
|
||||
if file in scanned or not file.exists():
|
||||
continue
|
||||
scanned.add(file)
|
||||
|
||||
content = file.read_text()
|
||||
|
||||
for line in content.splitlines():
|
||||
m = INCLUDE_RE.match(line)
|
||||
if not m:
|
||||
continue
|
||||
for root in include_roots:
|
||||
candidate = (root / m.group(1)).resolve()
|
||||
if candidate.exists():
|
||||
inverted[candidate].add(file)
|
||||
if candidate not in scanned:
|
||||
to_scan.add(candidate)
|
||||
break
|
||||
|
||||
return inverted, source_files
|
||||
|
||||
|
||||
def find_tus_for_headers(
|
||||
headers: list[Path],
|
||||
inverted: dict[Path, set[Path]],
|
||||
source_files: set[Path],
|
||||
) -> set[Path]:
|
||||
"""
|
||||
For each header, pick one TU that transitively includes it.
|
||||
Prefers a TU whose stem matches the header's stem, otherwise picks the first found.
|
||||
"""
|
||||
result: set[Path] = set()
|
||||
|
||||
for header in headers:
|
||||
preferred: Path | None = None
|
||||
visited: set[Path] = {header}
|
||||
stack: list[Path] = [header]
|
||||
|
||||
while stack:
|
||||
h = stack.pop()
|
||||
for inc in inverted.get(h, ()):
|
||||
if inc in source_files:
|
||||
if inc.stem == header.stem:
|
||||
preferred = inc
|
||||
break
|
||||
if preferred is None:
|
||||
preferred = inc
|
||||
if inc not in visited:
|
||||
visited.add(inc)
|
||||
stack.append(inc)
|
||||
if preferred is not None and preferred.stem == header.stem:
|
||||
break
|
||||
|
||||
if preferred is not None:
|
||||
result.add(preferred)
|
||||
|
||||
return result
|
||||
|
||||
|
||||
def resolve_files(
|
||||
input_files: list[str], build_dir: Path, repo_root: Path
|
||||
) -> list[str]:
|
||||
"""
|
||||
Split input into source files and headers. Source files are passed through;
|
||||
headers are resolved to the TUs that transitively include them.
|
||||
"""
|
||||
sources: list[Path] = []
|
||||
headers: list[Path] = []
|
||||
|
||||
for f in input_files:
|
||||
p = Path(f).resolve()
|
||||
if p.suffix in SOURCE_EXTENSIONS:
|
||||
sources.append(p)
|
||||
elif p.suffix in HEADER_EXTENSIONS:
|
||||
headers.append(p)
|
||||
|
||||
if not headers:
|
||||
return [str(p) for p in sources]
|
||||
|
||||
print(
|
||||
f"Resolving {len(headers)} header(s) to compilation units...", file=sys.stderr
|
||||
)
|
||||
inverted, source_files = build_include_graph(build_dir, repo_root)
|
||||
tus = find_tus_for_headers(headers, inverted, source_files)
|
||||
|
||||
if not tus:
|
||||
print(
|
||||
"Warning: no compilation units found that include the modified headers; "
|
||||
"skipping clang-tidy for headers.",
|
||||
file=sys.stderr,
|
||||
)
|
||||
|
||||
return sorted({str(p) for p in (*sources, *tus)})
|
||||
|
||||
|
||||
def staged_files(repo_root: Path) -> list[str]:
|
||||
result = subprocess.run(
|
||||
["git", "diff", "--staged", "--name-only", "--diff-filter=d"],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
cwd=repo_root,
|
||||
)
|
||||
if result.returncode != 0:
|
||||
print(
|
||||
"clang-tidy check failed: 'git diff --staged' command failed.",
|
||||
file=sys.stderr,
|
||||
)
|
||||
if result.stderr:
|
||||
print(result.stderr, file=sys.stderr)
|
||||
sys.exit(result.returncode or 1)
|
||||
return [str(repo_root / p) for p in result.stdout.splitlines() if p]
|
||||
|
||||
|
||||
def main():
|
||||
if not os.environ.get("TIDY"):
|
||||
return 0
|
||||
|
||||
repo_root = Path(__file__).parent.parent
|
||||
files = staged_files(repo_root)
|
||||
if not files:
|
||||
return 0
|
||||
|
||||
run_clang_tidy = find_run_clang_tidy()
|
||||
if not run_clang_tidy:
|
||||
print(
|
||||
"clang-tidy check failed: TIDY is enabled but neither "
|
||||
"'run-clang-tidy-21' nor 'run-clang-tidy' was found in PATH.",
|
||||
file=sys.stderr,
|
||||
)
|
||||
return 1
|
||||
|
||||
build_dir = find_build_dir(repo_root)
|
||||
if not build_dir:
|
||||
print(
|
||||
"clang-tidy check failed: no build directory with compile_commands.json found "
|
||||
"(looked for .build/ and build/)",
|
||||
file=sys.stderr,
|
||||
)
|
||||
return 1
|
||||
|
||||
tidy_files = resolve_files(files, build_dir, repo_root)
|
||||
if not tidy_files:
|
||||
return 0
|
||||
|
||||
result = subprocess.run(
|
||||
[run_clang_tidy, "-quiet", "-p", str(build_dir), "-fix", "-allow-no-checks"]
|
||||
+ tidy_files
|
||||
)
|
||||
return result.returncode
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
@@ -1416,12 +1416,6 @@
|
||||
# in this section to a comma-separated list of the addresses
|
||||
# of your Clio servers, in order to bypass xrpld's rate limiting.
|
||||
#
|
||||
# TLS/SSL can be enabled for gRPC by specifying ssl_cert and ssl_key.
|
||||
# Both parameters must be provided together. The ssl_cert_chain parameter
|
||||
# is optional and provides intermediate CA certificates for the certificate
|
||||
# chain. The ssl_client_ca parameter is optional and enables mutual TLS
|
||||
# (client certificate verification).
|
||||
#
|
||||
# This port is commented out but can be enabled by removing
|
||||
# the '#' from each corresponding line including the entry under [server]
|
||||
#
|
||||
@@ -1471,74 +1465,11 @@ admin = 127.0.0.1
|
||||
protocol = ws
|
||||
send_queue_limit = 500
|
||||
|
||||
# gRPC TLS/SSL Configuration
|
||||
#
|
||||
# The gRPC port supports optional TLS/SSL encryption. When TLS is not
|
||||
# configured, the gRPC server will accept unencrypted connections.
|
||||
#
|
||||
# ssl_cert = <filename>
|
||||
# ssl_key = <filename>
|
||||
#
|
||||
# To enable TLS for gRPC, both ssl_cert and ssl_key must be specified.
|
||||
# If only one is provided, xrpld will fail to start.
|
||||
#
|
||||
# ssl_cert: Path to the server's SSL certificate file in PEM format.
|
||||
# ssl_key: Path to the server's SSL private key file in PEM format.
|
||||
#
|
||||
# When configured, the gRPC server will only accept TLS-encrypted
|
||||
# connections. Clients must use TLS (secure) channel credentials rather
|
||||
# than plaintext / insecure connections.
|
||||
#
|
||||
# ssl_cert_chain = <filename>
|
||||
#
|
||||
# Optional. Path to intermediate CA certificate(s) in PEM format that
|
||||
# complete the server's certificate chain.
|
||||
#
|
||||
# This file should contain the intermediate CA certificate(s) needed
|
||||
# to build a trust chain from the server certificate (ssl_cert) to a
|
||||
# root CA that clients trust. Multiple certificates should be
|
||||
# concatenated in PEM format.
|
||||
#
|
||||
# This is needed when your server certificate was signed by an
|
||||
# intermediate CA rather than directly by a root CA. Without this,
|
||||
# clients may fail to verify your server certificate.
|
||||
#
|
||||
# If not specified, only the server certificate from ssl_cert will be
|
||||
# presented to clients.
|
||||
#
|
||||
# ssl_client_ca = <filename>
|
||||
#
|
||||
# Optional. Path to a CA certificate file in PEM format for verifying
|
||||
# client certificates (mutual TLS / mTLS).
|
||||
#
|
||||
# When specified, the gRPC server will verify client certificates
|
||||
# against this CA. This enables mutual authentication where both the
|
||||
# server and client verify each other's identity.
|
||||
#
|
||||
# This is typically NOT needed for public-facing gRPC servers. Only
|
||||
# use this if you want to restrict access to clients with valid
|
||||
# certificates signed by the specified CA.
|
||||
#
|
||||
# If not specified, the server will use one-way TLS (server
|
||||
# authentication only) and will accept connections from any client.
|
||||
#
|
||||
[port_grpc]
|
||||
port = 50051
|
||||
ip = 127.0.0.1
|
||||
secure_gateway = 127.0.0.1
|
||||
|
||||
# Optional TLS/SSL configuration for gRPC
|
||||
# To enable TLS, uncomment and configure both ssl_cert and ssl_key:
|
||||
#ssl_cert = /etc/ssl/certs/grpc-server.crt
|
||||
#ssl_key = /etc/ssl/private/grpc-server.key
|
||||
|
||||
# Optional: Include intermediate CA certificates for complete certificate chain
|
||||
#ssl_cert_chain = /etc/ssl/certs/grpc-intermediate-ca.crt
|
||||
|
||||
# Optional: Enable mutual TLS (client certificate verification)
|
||||
# Uncomment to require and verify client certificates:
|
||||
#ssl_client_ca = /etc/ssl/certs/grpc-client-ca.crt
|
||||
|
||||
#[port_ws_public]
|
||||
#port = 6005
|
||||
#ip = 127.0.0.1
|
||||
|
||||
@@ -23,7 +23,6 @@ target_compile_definitions(
|
||||
BOOST_FILESYSTEM_NO_DEPRECATED
|
||||
>
|
||||
$<$<NOT:$<BOOL:${boost_show_deprecated}>>:
|
||||
BOOST_COROUTINES2_NO_DEPRECATION_WARNING
|
||||
BOOST_BEAST_ALLOW_DEPRECATED
|
||||
BOOST_FILESYSTEM_DEPRECATED
|
||||
>
|
||||
|
||||
@@ -23,14 +23,14 @@ rm -f conan.lock
|
||||
# first create command will create a new lockfile, while the subsequent create
|
||||
# commands will merge any additional dependencies into the created lockfile.
|
||||
conan lock create . \
|
||||
--options '&:jemalloc=True' \
|
||||
--options '&:rocksdb=True' \
|
||||
--profile:all=conan/lockfile/linux.profile
|
||||
--options '&:jemalloc=True' \
|
||||
--options '&:rocksdb=True' \
|
||||
--profile:all=conan/lockfile/linux.profile
|
||||
conan lock create . \
|
||||
--options '&:jemalloc=True' \
|
||||
--options '&:rocksdb=True' \
|
||||
--profile:all=conan/lockfile/macos.profile
|
||||
--options '&:jemalloc=True' \
|
||||
--options '&:rocksdb=True' \
|
||||
--profile:all=conan/lockfile/macos.profile
|
||||
conan lock create . \
|
||||
--options '&:jemalloc=True' \
|
||||
--options '&:rocksdb=True' \
|
||||
--profile:all=conan/lockfile/windows.profile
|
||||
--options '&:jemalloc=True' \
|
||||
--options '&:rocksdb=True' \
|
||||
--profile:all=conan/lockfile/windows.profile
|
||||
|
||||
@@ -82,5 +82,12 @@ tools.info.package_id:confs+=["tools.build:cxxflags", "tools.build:exelinkflags"
|
||||
boost/*:without_context=False
|
||||
# Boost stacktrace fails to build with some sanitizers
|
||||
boost/*:without_stacktrace=True
|
||||
{% elif "thread" in sanitizers %}
|
||||
# Build Boost.Context with ucontext backend for TSAN. fcontext (assembly)
|
||||
# has no TSAN annotations, so without this the BOOST_USE_TSAN/BOOST_USE_UCONTEXT
|
||||
# defines in [conf] would be ineffective.
|
||||
boost/*:extra_b2_flags=context-impl=ucontext thread-sanitizer=on define=BOOST_USE_TSAN=1
|
||||
boost/*:without_context=False
|
||||
boost/*:without_stacktrace=True
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
@@ -129,12 +129,6 @@ class Xrpl(ConanFile):
|
||||
if self.settings.compiler in ["clang", "gcc"]:
|
||||
self.options["boost"].without_cobalt = True
|
||||
|
||||
# Check if environment variable exists
|
||||
if "SANITIZERS" in os.environ:
|
||||
sanitizers = os.environ["SANITIZERS"]
|
||||
if "address" in sanitizers.lower():
|
||||
self.default_options["fPIC"] = False
|
||||
|
||||
def requirements(self):
|
||||
self.requires("boost/1.90.0", force=True, transitive_headers=True)
|
||||
self.requires("date/3.0.4", transitive_headers=True)
|
||||
|
||||
@@ -33,7 +33,7 @@ private:
|
||||
|
||||
public:
|
||||
/** Create an empty section. */
|
||||
explicit Section(std::string name = "");
|
||||
explicit Section(std::string const& name = "");
|
||||
|
||||
/** Returns the name of this section. */
|
||||
std::string const&
|
||||
@@ -275,7 +275,8 @@ public:
|
||||
bool
|
||||
had_trailing_comments() const
|
||||
{
|
||||
return std::ranges::any_of(map_, [](auto s) { return s.second.had_trailing_comments(); });
|
||||
return std::any_of(
|
||||
map_.cbegin(), map_.cend(), [](auto s) { return s.second.had_trailing_comments(); });
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
@@ -92,7 +92,7 @@ public:
|
||||
{
|
||||
// Ensure the slice isn't a subset of the buffer.
|
||||
XRPL_ASSERT(
|
||||
s.empty() || size_ == 0 || s.data() < p_.get() || s.data() >= p_.get() + size_,
|
||||
s.size() == 0 || size_ == 0 || s.data() < p_.get() || s.data() >= p_.get() + size_,
|
||||
"xrpl::Buffer::operator=(Slice) : input not a subset");
|
||||
|
||||
if (auto p = alloc(s.size()))
|
||||
|
||||
@@ -9,7 +9,9 @@
|
||||
#include <stdexcept>
|
||||
#include <vector>
|
||||
|
||||
namespace xrpl::compression_algorithms {
|
||||
namespace xrpl {
|
||||
|
||||
namespace compression_algorithms {
|
||||
|
||||
/** LZ4 block compression.
|
||||
* @tparam BufferFactory Callable object or lambda.
|
||||
@@ -139,4 +141,6 @@ lz4Decompress(
|
||||
return lz4Decompress(chunk, inSize, decompressed, decompressedSize);
|
||||
}
|
||||
|
||||
} // namespace xrpl::compression_algorithms
|
||||
} // namespace compression_algorithms
|
||||
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -61,7 +61,7 @@ template <class E>
|
||||
class Unexpected
|
||||
{
|
||||
public:
|
||||
static_assert(!std::is_same_v<E, void>, "E must not be void");
|
||||
static_assert(!std::is_same<E, void>::value, "E must not be void");
|
||||
|
||||
Unexpected() = delete;
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
#include <utility>
|
||||
|
||||
namespace xrpl {
|
||||
|
||||
@@ -29,7 +28,7 @@ struct LocalValues
|
||||
T t_;
|
||||
|
||||
Value() = default;
|
||||
explicit Value(T t) : t_(std::move(t))
|
||||
explicit Value(T const& t) : t_(t)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ private:
|
||||
std::string partition_;
|
||||
|
||||
public:
|
||||
Sink(std::string partition, beast::severities::Severity thresh, Logs& logs);
|
||||
Sink(std::string const& partition, beast::severities::Severity thresh, Logs& logs);
|
||||
|
||||
Sink(Sink const&) = delete;
|
||||
Sink&
|
||||
|
||||
@@ -66,10 +66,12 @@ class SlabAllocator
|
||||
}
|
||||
}
|
||||
|
||||
// Calling this destructor will release the allocated memory but
|
||||
// will not properly destroy any objects that are constructed in
|
||||
// the block itself.
|
||||
~SlabBlock() = default;
|
||||
~SlabBlock()
|
||||
{
|
||||
// Calling this destructor will release the allocated memory but
|
||||
// will not properly destroy any objects that are constructed in
|
||||
// the block itself.
|
||||
}
|
||||
|
||||
SlabBlock(SlabBlock const& other) = delete;
|
||||
SlabBlock&
|
||||
@@ -174,10 +176,12 @@ public:
|
||||
SlabAllocator&
|
||||
operator=(SlabAllocator&& other) = delete;
|
||||
|
||||
// FIXME: We can't destroy the memory blocks we've allocated, because
|
||||
// we can't be sure that they are not being used. Cleaning the
|
||||
// shutdown process up could make this possible.
|
||||
~SlabAllocator() = default;
|
||||
~SlabAllocator()
|
||||
{
|
||||
// FIXME: We can't destroy the memory blocks we've allocated, because
|
||||
// we can't be sure that they are not being used. Cleaning the
|
||||
// shutdown process up could make this possible.
|
||||
}
|
||||
|
||||
/** Returns the size of the memory block this allocator returns. */
|
||||
constexpr std::size_t
|
||||
@@ -343,7 +347,9 @@ public:
|
||||
SlabAllocatorSet&
|
||||
operator=(SlabAllocatorSet&& other) = delete;
|
||||
|
||||
~SlabAllocatorSet() = default;
|
||||
~SlabAllocatorSet()
|
||||
{
|
||||
}
|
||||
|
||||
/** Returns a suitably aligned pointer, if one is available.
|
||||
|
||||
|
||||
@@ -211,14 +211,14 @@ operator<<(Stream& s, Slice const& v)
|
||||
}
|
||||
|
||||
template <class T, std::size_t N>
|
||||
std::enable_if_t<std::is_same_v<T, char> || std::is_same_v<T, unsigned char>, Slice>
|
||||
std::enable_if_t<std::is_same<T, char>::value || std::is_same<T, unsigned char>::value, Slice>
|
||||
makeSlice(std::array<T, N> const& a)
|
||||
{
|
||||
return Slice(a.data(), a.size());
|
||||
}
|
||||
|
||||
template <class T, class Alloc>
|
||||
std::enable_if_t<std::is_same_v<T, char> || std::is_same_v<T, unsigned char>, Slice>
|
||||
std::enable_if_t<std::is_same<T, char>::value || std::is_same<T, unsigned char>::value, Slice>
|
||||
makeSlice(std::vector<T, Alloc> const& v)
|
||||
{
|
||||
return Slice(v.data(), v.size());
|
||||
|
||||
@@ -251,7 +251,7 @@ private:
|
||||
}
|
||||
};
|
||||
|
||||
using Entry = std::conditional_t<IsKeyCache, KeyOnlyEntry, ValueEntry>;
|
||||
typedef typename std::conditional<IsKeyCache, KeyOnlyEntry, ValueEntry>::type Entry;
|
||||
|
||||
using KeyOnlyCacheType = hardened_partitioned_hash_map<key_type, KeyOnlyEntry, Hash, KeyEqual>;
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace xrpl {
|
||||
*/
|
||||
|
||||
template <class T>
|
||||
std::enable_if_t<std::is_arithmetic_v<T>, std::string>
|
||||
typename std::enable_if<std::is_arithmetic<T>::value, std::string>::type
|
||||
to_string(T t)
|
||||
{
|
||||
return std::to_string(t);
|
||||
|
||||
@@ -269,7 +269,7 @@ public:
|
||||
class Container,
|
||||
class = std::enable_if_t<
|
||||
detail::is_contiguous_container<Container>::value &&
|
||||
std::is_trivially_copyable_v<typename Container::value_type>>>
|
||||
std::is_trivially_copyable<typename Container::value_type>::value>>
|
||||
explicit base_uint(Container const& c)
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
@@ -281,7 +281,7 @@ public:
|
||||
template <class Container>
|
||||
std::enable_if_t<
|
||||
detail::is_contiguous_container<Container>::value &&
|
||||
std::is_trivially_copyable_v<typename Container::value_type>,
|
||||
std::is_trivially_copyable<typename Container::value_type>::value,
|
||||
base_uint&>
|
||||
operator=(Container const& c)
|
||||
{
|
||||
|
||||
@@ -49,7 +49,8 @@ template <class E, class... Args>
|
||||
Throw(Args&&... args)
|
||||
{
|
||||
static_assert(
|
||||
std::is_convertible_v<E*, std::exception*>, "Exception must derive from std::exception.");
|
||||
std::is_convertible<E*, std::exception*>::value,
|
||||
"Exception must derive from std::exception.");
|
||||
|
||||
E e(std::forward<Args>(args)...);
|
||||
LogThrow(std::string("Throwing exception of type " + beast::type_name<E>() + ": ") + e.what());
|
||||
|
||||
@@ -15,8 +15,8 @@ namespace xrpl {
|
||||
#ifndef __INTELLISENSE__
|
||||
static_assert(
|
||||
// NOLINTNEXTLINE(misc-redundant-expression)
|
||||
std::is_integral_v<beast::xor_shift_engine::result_type> &&
|
||||
std::is_unsigned_v<beast::xor_shift_engine::result_type>,
|
||||
std::is_integral<beast::xor_shift_engine::result_type>::value &&
|
||||
std::is_unsigned<beast::xor_shift_engine::result_type>::value,
|
||||
"The XRPL default PRNG engine must return an unsigned integral type.");
|
||||
|
||||
static_assert(
|
||||
@@ -91,7 +91,7 @@ default_prng()
|
||||
*/
|
||||
/** @{ */
|
||||
template <class Engine, class Integral>
|
||||
std::enable_if_t<std::is_integral_v<Integral> && detail::is_engine<Engine>::value, Integral>
|
||||
std::enable_if_t<std::is_integral<Integral>::value && detail::is_engine<Engine>::value, Integral>
|
||||
rand_int(Engine& engine, Integral min, Integral max)
|
||||
{
|
||||
XRPL_ASSERT(max > min, "xrpl::rand_int : max over min inputs");
|
||||
@@ -103,35 +103,35 @@ rand_int(Engine& engine, Integral min, Integral max)
|
||||
}
|
||||
|
||||
template <class Integral>
|
||||
std::enable_if_t<std::is_integral_v<Integral>, Integral>
|
||||
std::enable_if_t<std::is_integral<Integral>::value, Integral>
|
||||
rand_int(Integral min, Integral max)
|
||||
{
|
||||
return rand_int(default_prng(), min, max);
|
||||
}
|
||||
|
||||
template <class Engine, class Integral>
|
||||
std::enable_if_t<std::is_integral_v<Integral> && detail::is_engine<Engine>::value, Integral>
|
||||
std::enable_if_t<std::is_integral<Integral>::value && detail::is_engine<Engine>::value, Integral>
|
||||
rand_int(Engine& engine, Integral max)
|
||||
{
|
||||
return rand_int(engine, Integral(0), max);
|
||||
}
|
||||
|
||||
template <class Integral>
|
||||
std::enable_if_t<std::is_integral_v<Integral>, Integral>
|
||||
std::enable_if_t<std::is_integral<Integral>::value, Integral>
|
||||
rand_int(Integral max)
|
||||
{
|
||||
return rand_int(default_prng(), max);
|
||||
}
|
||||
|
||||
template <class Integral, class Engine>
|
||||
std::enable_if_t<std::is_integral_v<Integral> && detail::is_engine<Engine>::value, Integral>
|
||||
std::enable_if_t<std::is_integral<Integral>::value && detail::is_engine<Engine>::value, Integral>
|
||||
rand_int(Engine& engine)
|
||||
{
|
||||
return rand_int(engine, std::numeric_limits<Integral>::max());
|
||||
}
|
||||
|
||||
template <class Integral = int>
|
||||
std::enable_if_t<std::is_integral_v<Integral>, Integral>
|
||||
std::enable_if_t<std::is_integral<Integral>::value, Integral>
|
||||
rand_int()
|
||||
{
|
||||
return rand_int(default_prng(), std::numeric_limits<Integral>::max());
|
||||
@@ -142,7 +142,7 @@ rand_int()
|
||||
/** @{ */
|
||||
template <class Byte, class Engine>
|
||||
std::enable_if_t<
|
||||
(std::is_same_v<Byte, unsigned char> || std::is_same_v<Byte, std::uint8_t>) &&
|
||||
(std::is_same<Byte, unsigned char>::value || std::is_same<Byte, std::uint8_t>::value) &&
|
||||
detail::is_engine<Engine>::value,
|
||||
Byte>
|
||||
rand_byte(Engine& engine)
|
||||
@@ -152,7 +152,9 @@ rand_byte(Engine& engine)
|
||||
}
|
||||
|
||||
template <class Byte = std::uint8_t>
|
||||
std::enable_if_t<(std::is_same_v<Byte, unsigned char> || std::is_same_v<Byte, std::uint8_t>), Byte>
|
||||
std::enable_if_t<
|
||||
(std::is_same<Byte, unsigned char>::value || std::is_same<Byte, std::uint8_t>::value),
|
||||
Byte>
|
||||
rand_byte()
|
||||
{
|
||||
return rand_byte<Byte>(default_prng());
|
||||
|
||||
@@ -12,9 +12,9 @@ namespace xrpl {
|
||||
|
||||
template <class Src, class Dest>
|
||||
concept SafeToCast = (std::is_integral_v<Src> && std::is_integral_v<Dest>) &&
|
||||
(std::is_signed_v<Src> || std::is_unsigned_v<Dest>) &&
|
||||
(std::is_signed_v<Src> != std::is_signed_v<Dest> ? sizeof(Dest) > sizeof(Src)
|
||||
: sizeof(Dest) >= sizeof(Src));
|
||||
(std::is_signed<Src>::value || std::is_unsigned<Dest>::value) &&
|
||||
(std::is_signed<Src>::value != std::is_signed<Dest>::value ? sizeof(Dest) > sizeof(Src)
|
||||
: sizeof(Dest) >= sizeof(Src));
|
||||
|
||||
template <class Dest, class Src>
|
||||
constexpr std::enable_if_t<std::is_integral_v<Dest> && std::is_integral_v<Src>, Dest>
|
||||
|
||||
@@ -10,9 +10,9 @@ std::string
|
||||
strHex(FwdIt begin, FwdIt end)
|
||||
{
|
||||
static_assert(
|
||||
std::is_convertible_v<
|
||||
std::is_convertible<
|
||||
typename std::iterator_traits<FwdIt>::iterator_category,
|
||||
std::forward_iterator_tag>,
|
||||
std::forward_iterator_tag>::value,
|
||||
"FwdIt must be a forward iterator");
|
||||
std::string result;
|
||||
result.reserve(2 * std::distance(begin, end));
|
||||
|
||||
@@ -44,7 +44,8 @@ public:
|
||||
|
||||
template <
|
||||
class OtherInt,
|
||||
class = std::enable_if_t<std::is_integral_v<OtherInt> && sizeof(OtherInt) <= sizeof(Int)>>
|
||||
class = typename std::enable_if<
|
||||
std::is_integral<OtherInt>::value && sizeof(OtherInt) <= sizeof(Int)>::type>
|
||||
explicit constexpr tagged_integer(OtherInt value) noexcept : m_value(value)
|
||||
{
|
||||
static_assert(sizeof(tagged_integer) == sizeof(Int), "tagged_integer is adding padding");
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace beast {
|
||||
|
||||
/** Expire aged container items past the specified age. */
|
||||
template <class AgedContainer, class Rep, class Period>
|
||||
std::enable_if_t<is_aged_container<AgedContainer>::value, std::size_t>
|
||||
typename std::enable_if<is_aged_container<AgedContainer>::value, std::size_t>::type
|
||||
expire(AgedContainer& c, std::chrono::duration<Rep, Period> const& age)
|
||||
{
|
||||
std::size_t n(0);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
namespace beast::detail {
|
||||
namespace beast {
|
||||
namespace detail {
|
||||
|
||||
// Extracts the key portion of value
|
||||
template <bool maybe_map>
|
||||
@@ -29,4 +30,5 @@ struct aged_associative_container_extract_t<false>
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace beast::detail
|
||||
} // namespace detail
|
||||
} // namespace beast
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
#include <iterator>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
namespace beast {
|
||||
|
||||
@@ -132,7 +131,7 @@ private:
|
||||
friend class aged_container_iterator;
|
||||
|
||||
template <class OtherIterator>
|
||||
aged_container_iterator(OtherIterator iter) : m_iter(std::move(iter))
|
||||
aged_container_iterator(OtherIterator const& iter) : m_iter(iter)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -57,7 +57,8 @@ template <
|
||||
class T,
|
||||
class Clock = std::chrono::steady_clock,
|
||||
class Compare = std::less<Key>,
|
||||
class Allocator = std::allocator<std::conditional_t<IsMap, std::pair<Key const, T>, Key>>>
|
||||
class Allocator =
|
||||
std::allocator<typename std::conditional<IsMap, std::pair<Key const, T>, Key>::type>>
|
||||
class aged_ordered_container
|
||||
{
|
||||
public:
|
||||
@@ -66,7 +67,7 @@ public:
|
||||
using duration = typename clock_type::duration;
|
||||
using key_type = Key;
|
||||
using mapped_type = T;
|
||||
using value_type = std::conditional_t<IsMap, std::pair<Key const, T>, Key>;
|
||||
using value_type = typename std::conditional<IsMap, std::pair<Key const, T>, Key>::type;
|
||||
using size_type = std::size_t;
|
||||
using difference_type = std::ptrdiff_t;
|
||||
|
||||
@@ -109,7 +110,8 @@ private:
|
||||
|
||||
template <
|
||||
class... Args,
|
||||
class = std::enable_if_t<std::is_constructible_v<value_type, Args...>>>
|
||||
class =
|
||||
typename std::enable_if<std::is_constructible<value_type, Args...>::value>::type>
|
||||
element(time_point const& when_, Args&&... args)
|
||||
: value(std::forward<Args>(args)...), when(when_)
|
||||
{
|
||||
@@ -133,7 +135,9 @@ private:
|
||||
return Compare::operator()(lhs.first, rhs.first);
|
||||
}
|
||||
|
||||
pair_value_compare() = default;
|
||||
pair_value_compare()
|
||||
{
|
||||
}
|
||||
|
||||
pair_value_compare(pair_value_compare const& other) : Compare(other)
|
||||
{
|
||||
@@ -196,7 +200,7 @@ private:
|
||||
using list_type = typename boost::intrusive::
|
||||
make_list<element, boost::intrusive::constant_time_size<false>>::type;
|
||||
|
||||
using cont_type = std::conditional_t<
|
||||
using cont_type = typename std::conditional<
|
||||
IsMulti,
|
||||
typename boost::intrusive::make_multiset<
|
||||
element,
|
||||
@@ -205,7 +209,7 @@ private:
|
||||
typename boost::intrusive::make_set<
|
||||
element,
|
||||
boost::intrusive::constant_time_size<true>,
|
||||
boost::intrusive::compare<KeyValueCompare>>::type>;
|
||||
boost::intrusive::compare<KeyValueCompare>>::type>::type;
|
||||
|
||||
using ElementAllocator =
|
||||
typename std::allocator_traits<Allocator>::template rebind_alloc<element>;
|
||||
@@ -370,7 +374,7 @@ private:
|
||||
|
||||
public:
|
||||
using key_compare = Compare;
|
||||
using value_compare = std::conditional_t<IsMap, pair_value_compare, Compare>;
|
||||
using value_compare = typename std::conditional<IsMap, pair_value_compare, Compare>::type;
|
||||
using allocator_type = Allocator;
|
||||
using reference = value_type&;
|
||||
using const_reference = value_type const&;
|
||||
@@ -398,8 +402,6 @@ public:
|
||||
|
||||
class chronological_t
|
||||
{
|
||||
chronological_t() = default;
|
||||
|
||||
public:
|
||||
// A set iterator (IsMap==false) is always const
|
||||
// because the elements of a set are immutable.
|
||||
@@ -487,7 +489,7 @@ public:
|
||||
iterator
|
||||
iterator_to(value_type& value)
|
||||
{
|
||||
static_assert(std::is_standard_layout_v<element>, "must be standard layout");
|
||||
static_assert(std::is_standard_layout<element>::value, "must be standard layout");
|
||||
return list.iterator_to(*reinterpret_cast<element*>(
|
||||
reinterpret_cast<uint8_t*>(&value) -
|
||||
((std::size_t)std::addressof(((element*)0)->member))));
|
||||
@@ -496,16 +498,20 @@ public:
|
||||
const_iterator
|
||||
iterator_to(value_type const& value) const
|
||||
{
|
||||
static_assert(std::is_standard_layout_v<element>, "must be standard layout");
|
||||
static_assert(std::is_standard_layout<element>::value, "must be standard layout");
|
||||
return list.iterator_to(*reinterpret_cast<element const*>(
|
||||
reinterpret_cast<uint8_t const*>(&value) -
|
||||
((std::size_t)std::addressof(((element*)0)->member))));
|
||||
}
|
||||
|
||||
private:
|
||||
chronological_t()
|
||||
{
|
||||
}
|
||||
|
||||
chronological_t(chronological_t const&) = delete;
|
||||
chronological_t(chronological_t&&) = delete;
|
||||
|
||||
private:
|
||||
friend class aged_ordered_container;
|
||||
list_type mutable list;
|
||||
} chronological;
|
||||
@@ -611,30 +617,30 @@ public:
|
||||
class K,
|
||||
bool maybe_multi = IsMulti,
|
||||
bool maybe_map = IsMap,
|
||||
class = std::enable_if_t<maybe_map && !maybe_multi>>
|
||||
std::conditional_t<IsMap, T, void*>&
|
||||
class = typename std::enable_if<maybe_map && !maybe_multi>::type>
|
||||
typename std::conditional<IsMap, T, void*>::type&
|
||||
at(K const& k);
|
||||
|
||||
template <
|
||||
class K,
|
||||
bool maybe_multi = IsMulti,
|
||||
bool maybe_map = IsMap,
|
||||
class = std::enable_if_t<maybe_map && !maybe_multi>>
|
||||
class = typename std::enable_if<maybe_map && !maybe_multi>::type>
|
||||
typename std::conditional<IsMap, T, void*>::type const&
|
||||
at(K const& k) const;
|
||||
|
||||
template <
|
||||
bool maybe_multi = IsMulti,
|
||||
bool maybe_map = IsMap,
|
||||
class = std::enable_if_t<maybe_map && !maybe_multi>>
|
||||
std::conditional_t<IsMap, T, void*>&
|
||||
class = typename std::enable_if<maybe_map && !maybe_multi>::type>
|
||||
typename std::conditional<IsMap, T, void*>::type&
|
||||
operator[](Key const& key);
|
||||
|
||||
template <
|
||||
bool maybe_multi = IsMulti,
|
||||
bool maybe_map = IsMap,
|
||||
class = std::enable_if_t<maybe_map && !maybe_multi>>
|
||||
std::conditional_t<IsMap, T, void*>&
|
||||
class = typename std::enable_if<maybe_map && !maybe_multi>::type>
|
||||
typename std::conditional<IsMap, T, void*>::type&
|
||||
operator[](Key&& key);
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
@@ -718,7 +724,7 @@ public:
|
||||
iterator
|
||||
iterator_to(value_type& value)
|
||||
{
|
||||
static_assert(std::is_standard_layout_v<element>, "must be standard layout");
|
||||
static_assert(std::is_standard_layout<element>::value, "must be standard layout");
|
||||
return m_cont.iterator_to(*reinterpret_cast<element*>(
|
||||
reinterpret_cast<uint8_t*>(&value) -
|
||||
((std::size_t)std::addressof(((element*)0)->member))));
|
||||
@@ -727,7 +733,7 @@ public:
|
||||
const_iterator
|
||||
iterator_to(value_type const& value) const
|
||||
{
|
||||
static_assert(std::is_standard_layout_v<element>, "must be standard layout");
|
||||
static_assert(std::is_standard_layout<element>::value, "must be standard layout");
|
||||
return m_cont.iterator_to(*reinterpret_cast<element const*>(
|
||||
reinterpret_cast<uint8_t const*>(&value) -
|
||||
((std::size_t)std::addressof(((element*)0)->member))));
|
||||
@@ -769,35 +775,37 @@ public:
|
||||
// map, set
|
||||
template <bool maybe_multi = IsMulti>
|
||||
auto
|
||||
insert(value_type const& value) -> std::enable_if_t<!maybe_multi, std::pair<iterator, bool>>;
|
||||
insert(value_type const& value) ->
|
||||
typename std::enable_if<!maybe_multi, std::pair<iterator, bool>>::type;
|
||||
|
||||
// multimap, multiset
|
||||
template <bool maybe_multi = IsMulti>
|
||||
auto
|
||||
insert(value_type const& value) -> std::enable_if_t<maybe_multi, iterator>;
|
||||
insert(value_type const& value) -> typename std::enable_if<maybe_multi, iterator>::type;
|
||||
|
||||
// set
|
||||
template <bool maybe_multi = IsMulti, bool maybe_map = IsMap>
|
||||
auto
|
||||
insert(value_type&& value)
|
||||
-> std::enable_if_t<!maybe_multi && !maybe_map, std::pair<iterator, bool>>;
|
||||
insert(value_type&& value) ->
|
||||
typename std::enable_if<!maybe_multi && !maybe_map, std::pair<iterator, bool>>::type;
|
||||
|
||||
// multiset
|
||||
template <bool maybe_multi = IsMulti, bool maybe_map = IsMap>
|
||||
auto
|
||||
insert(value_type&& value) -> std::enable_if_t<maybe_multi && !maybe_map, iterator>;
|
||||
insert(value_type&& value) ->
|
||||
typename std::enable_if<maybe_multi && !maybe_map, iterator>::type;
|
||||
|
||||
//---
|
||||
|
||||
// map, set
|
||||
template <bool maybe_multi = IsMulti>
|
||||
auto
|
||||
insert(const_iterator hint, value_type const& value)
|
||||
-> std::enable_if_t<!maybe_multi, iterator>;
|
||||
insert(const_iterator hint, value_type const& value) ->
|
||||
typename std::enable_if<!maybe_multi, iterator>::type;
|
||||
|
||||
// multimap, multiset
|
||||
template <bool maybe_multi = IsMulti>
|
||||
std::enable_if_t<maybe_multi, iterator>
|
||||
typename std::enable_if<maybe_multi, iterator>::type
|
||||
insert(const_iterator /*hint*/, value_type const& value)
|
||||
{
|
||||
// VFALCO TODO Figure out how to utilize 'hint'
|
||||
@@ -807,11 +815,12 @@ public:
|
||||
// map, set
|
||||
template <bool maybe_multi = IsMulti>
|
||||
auto
|
||||
insert(const_iterator hint, value_type&& value) -> std::enable_if_t<!maybe_multi, iterator>;
|
||||
insert(const_iterator hint, value_type&& value) ->
|
||||
typename std::enable_if<!maybe_multi, iterator>::type;
|
||||
|
||||
// multimap, multiset
|
||||
template <bool maybe_multi = IsMulti>
|
||||
std::enable_if_t<maybe_multi, iterator>
|
||||
typename std::enable_if<maybe_multi, iterator>::type
|
||||
insert(const_iterator /*hint*/, value_type&& value)
|
||||
{
|
||||
// VFALCO TODO Figure out how to utilize 'hint'
|
||||
@@ -820,9 +829,9 @@ public:
|
||||
|
||||
// map, multimap
|
||||
template <class P, bool maybe_map = IsMap>
|
||||
std::enable_if_t<
|
||||
maybe_map && std::is_constructible_v<value_type, P&&>,
|
||||
std::conditional_t<IsMulti, iterator, std::pair<iterator, bool>>>
|
||||
typename std::enable_if<
|
||||
maybe_map && std::is_constructible<value_type, P&&>::value,
|
||||
typename std::conditional<IsMulti, iterator, std::pair<iterator, bool>>::type>::type
|
||||
insert(P&& value)
|
||||
{
|
||||
return emplace(std::forward<P>(value));
|
||||
@@ -830,9 +839,9 @@ public:
|
||||
|
||||
// map, multimap
|
||||
template <class P, bool maybe_map = IsMap>
|
||||
std::enable_if_t<
|
||||
maybe_map && std::is_constructible_v<value_type, P&&>,
|
||||
std::conditional_t<IsMulti, iterator, std::pair<iterator, bool>>>
|
||||
typename std::enable_if<
|
||||
maybe_map && std::is_constructible<value_type, P&&>::value,
|
||||
typename std::conditional<IsMulti, iterator, std::pair<iterator, bool>>::type>::type
|
||||
insert(const_iterator hint, P&& value)
|
||||
{
|
||||
return emplace_hint(hint, std::forward<P>(value));
|
||||
@@ -855,22 +864,23 @@ public:
|
||||
// map, set
|
||||
template <bool maybe_multi = IsMulti, class... Args>
|
||||
auto
|
||||
emplace(Args&&... args) -> std::enable_if_t<!maybe_multi, std::pair<iterator, bool>>;
|
||||
emplace(Args&&... args) ->
|
||||
typename std::enable_if<!maybe_multi, std::pair<iterator, bool>>::type;
|
||||
|
||||
// multiset, multimap
|
||||
template <bool maybe_multi = IsMulti, class... Args>
|
||||
auto
|
||||
emplace(Args&&... args) -> std::enable_if_t<maybe_multi, iterator>;
|
||||
emplace(Args&&... args) -> typename std::enable_if<maybe_multi, iterator>::type;
|
||||
|
||||
// map, set
|
||||
template <bool maybe_multi = IsMulti, class... Args>
|
||||
auto
|
||||
emplace_hint(const_iterator hint, Args&&... args)
|
||||
-> std::enable_if_t<!maybe_multi, std::pair<iterator, bool>>;
|
||||
emplace_hint(const_iterator hint, Args&&... args) ->
|
||||
typename std::enable_if<!maybe_multi, std::pair<iterator, bool>>::type;
|
||||
|
||||
// multiset, multimap
|
||||
template <bool maybe_multi = IsMulti, class... Args>
|
||||
std::enable_if_t<maybe_multi, iterator>
|
||||
typename std::enable_if<maybe_multi, iterator>::type
|
||||
emplace_hint(const_iterator /*hint*/, Args&&... args)
|
||||
{
|
||||
// VFALCO TODO Figure out how to utilize 'hint'
|
||||
@@ -1154,12 +1164,12 @@ private:
|
||||
|
||||
template <
|
||||
bool maybe_propagate = std::allocator_traits<Allocator>::propagate_on_container_swap::value>
|
||||
std::enable_if_t<maybe_propagate>
|
||||
typename std::enable_if<maybe_propagate>::type
|
||||
swap_data(aged_ordered_container& other) noexcept;
|
||||
|
||||
template <
|
||||
bool maybe_propagate = std::allocator_traits<Allocator>::propagate_on_container_swap::value>
|
||||
std::enable_if_t<!maybe_propagate>
|
||||
typename std::enable_if<!maybe_propagate>::type
|
||||
swap_data(aged_ordered_container& other) noexcept;
|
||||
|
||||
private:
|
||||
@@ -1386,7 +1396,7 @@ aged_ordered_container<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::opera
|
||||
|
||||
template <bool IsMulti, bool IsMap, class Key, class T, class Clock, class Compare, class Allocator>
|
||||
template <class K, bool maybe_multi, bool maybe_map, class>
|
||||
std::conditional_t<IsMap, T, void*>&
|
||||
typename std::conditional<IsMap, T, void*>::type&
|
||||
aged_ordered_container<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::at(K const& k)
|
||||
{
|
||||
auto const iter(m_cont.find(k, std::cref(m_config.key_compare())));
|
||||
@@ -1408,7 +1418,7 @@ aged_ordered_container<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::at(K
|
||||
|
||||
template <bool IsMulti, bool IsMap, class Key, class T, class Clock, class Compare, class Allocator>
|
||||
template <bool maybe_multi, bool maybe_map, class>
|
||||
std::conditional_t<IsMap, T, void*>&
|
||||
typename std::conditional<IsMap, T, void*>::type&
|
||||
aged_ordered_container<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::operator[](
|
||||
Key const& key)
|
||||
{
|
||||
@@ -1427,7 +1437,7 @@ aged_ordered_container<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::opera
|
||||
|
||||
template <bool IsMulti, bool IsMap, class Key, class T, class Clock, class Compare, class Allocator>
|
||||
template <bool maybe_multi, bool maybe_map, class>
|
||||
std::conditional_t<IsMap, T, void*>&
|
||||
typename std::conditional<IsMap, T, void*>::type&
|
||||
aged_ordered_container<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::operator[](Key&& key)
|
||||
{
|
||||
typename cont_type::insert_commit_data d;
|
||||
@@ -1462,7 +1472,8 @@ template <bool IsMulti, bool IsMap, class Key, class T, class Clock, class Compa
|
||||
template <bool maybe_multi>
|
||||
auto
|
||||
aged_ordered_container<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::insert(
|
||||
value_type const& value) -> std::enable_if_t<!maybe_multi, std::pair<iterator, bool>>
|
||||
value_type const& value) ->
|
||||
typename std::enable_if<!maybe_multi, std::pair<iterator, bool>>::type
|
||||
{
|
||||
typename cont_type::insert_commit_data d;
|
||||
auto const result(m_cont.insert_check(extract(value), std::cref(m_config.key_compare()), d));
|
||||
@@ -1481,7 +1492,7 @@ template <bool IsMulti, bool IsMap, class Key, class T, class Clock, class Compa
|
||||
template <bool maybe_multi>
|
||||
auto
|
||||
aged_ordered_container<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::insert(
|
||||
value_type const& value) -> std::enable_if_t<maybe_multi, iterator>
|
||||
value_type const& value) -> typename std::enable_if<maybe_multi, iterator>::type
|
||||
{
|
||||
auto const before(m_cont.upper_bound(extract(value), std::cref(m_config.key_compare())));
|
||||
element* const p(new_element(value));
|
||||
@@ -1495,7 +1506,8 @@ template <bool IsMulti, bool IsMap, class Key, class T, class Clock, class Compa
|
||||
template <bool maybe_multi, bool maybe_map>
|
||||
auto
|
||||
aged_ordered_container<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::insert(
|
||||
value_type&& value) -> std::enable_if_t<!maybe_multi && !maybe_map, std::pair<iterator, bool>>
|
||||
value_type&& value) ->
|
||||
typename std::enable_if<!maybe_multi && !maybe_map, std::pair<iterator, bool>>::type
|
||||
{
|
||||
typename cont_type::insert_commit_data d;
|
||||
auto const result(m_cont.insert_check(extract(value), std::cref(m_config.key_compare()), d));
|
||||
@@ -1514,7 +1526,7 @@ template <bool IsMulti, bool IsMap, class Key, class T, class Clock, class Compa
|
||||
template <bool maybe_multi, bool maybe_map>
|
||||
auto
|
||||
aged_ordered_container<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::insert(
|
||||
value_type&& value) -> std::enable_if_t<maybe_multi && !maybe_map, iterator>
|
||||
value_type&& value) -> typename std::enable_if<maybe_multi && !maybe_map, iterator>::type
|
||||
{
|
||||
auto const before(m_cont.upper_bound(extract(value), std::cref(m_config.key_compare())));
|
||||
element* const p(new_element(std::move(value)));
|
||||
@@ -1531,7 +1543,7 @@ template <bool maybe_multi>
|
||||
auto
|
||||
aged_ordered_container<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::insert(
|
||||
const_iterator hint,
|
||||
value_type const& value) -> std::enable_if_t<!maybe_multi, iterator>
|
||||
value_type const& value) -> typename std::enable_if<!maybe_multi, iterator>::type
|
||||
{
|
||||
typename cont_type::insert_commit_data d;
|
||||
auto const result(
|
||||
@@ -1552,7 +1564,7 @@ template <bool maybe_multi>
|
||||
auto
|
||||
aged_ordered_container<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::insert(
|
||||
const_iterator hint,
|
||||
value_type&& value) -> std::enable_if_t<!maybe_multi, iterator>
|
||||
value_type&& value) -> typename std::enable_if<!maybe_multi, iterator>::type
|
||||
{
|
||||
typename cont_type::insert_commit_data d;
|
||||
auto const result(
|
||||
@@ -1572,7 +1584,7 @@ template <bool IsMulti, bool IsMap, class Key, class T, class Clock, class Compa
|
||||
template <bool maybe_multi, class... Args>
|
||||
auto
|
||||
aged_ordered_container<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::emplace(Args&&... args)
|
||||
-> std::enable_if_t<!maybe_multi, std::pair<iterator, bool>>
|
||||
-> typename std::enable_if<!maybe_multi, std::pair<iterator, bool>>::type
|
||||
{
|
||||
// VFALCO NOTE Its unfortunate that we need to
|
||||
// construct element here
|
||||
@@ -1594,7 +1606,7 @@ template <bool IsMulti, bool IsMap, class Key, class T, class Clock, class Compa
|
||||
template <bool maybe_multi, class... Args>
|
||||
auto
|
||||
aged_ordered_container<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::emplace(Args&&... args)
|
||||
-> std::enable_if_t<maybe_multi, iterator>
|
||||
-> typename std::enable_if<maybe_multi, iterator>::type
|
||||
{
|
||||
element* const p(new_element(std::forward<Args>(args)...));
|
||||
auto const before(m_cont.upper_bound(extract(p->value), std::cref(m_config.key_compare())));
|
||||
@@ -1609,7 +1621,7 @@ template <bool maybe_multi, class... Args>
|
||||
auto
|
||||
aged_ordered_container<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::emplace_hint(
|
||||
const_iterator hint,
|
||||
Args&&... args) -> std::enable_if_t<!maybe_multi, std::pair<iterator, bool>>
|
||||
Args&&... args) -> typename std::enable_if<!maybe_multi, std::pair<iterator, bool>>::type
|
||||
{
|
||||
// VFALCO NOTE Its unfortunate that we need to
|
||||
// construct element here
|
||||
@@ -1759,7 +1771,7 @@ aged_ordered_container<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::touch
|
||||
|
||||
template <bool IsMulti, bool IsMap, class Key, class T, class Clock, class Compare, class Allocator>
|
||||
template <bool maybe_propagate>
|
||||
std::enable_if_t<maybe_propagate>
|
||||
typename std::enable_if<maybe_propagate>::type
|
||||
aged_ordered_container<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::swap_data(
|
||||
aged_ordered_container& other) noexcept
|
||||
{
|
||||
@@ -1770,7 +1782,7 @@ aged_ordered_container<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::swap_
|
||||
|
||||
template <bool IsMulti, bool IsMap, class Key, class T, class Clock, class Compare, class Allocator>
|
||||
template <bool maybe_propagate>
|
||||
std::enable_if_t<!maybe_propagate>
|
||||
typename std::enable_if<!maybe_propagate>::type
|
||||
aged_ordered_container<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::swap_data(
|
||||
aged_ordered_container& other) noexcept
|
||||
{
|
||||
|
||||
@@ -62,7 +62,8 @@ template <
|
||||
class Clock = std::chrono::steady_clock,
|
||||
class Hash = std::hash<Key>,
|
||||
class KeyEqual = std::equal_to<Key>,
|
||||
class Allocator = std::allocator<std::conditional_t<IsMap, std::pair<Key const, T>, Key>>>
|
||||
class Allocator =
|
||||
std::allocator<typename std::conditional<IsMap, std::pair<Key const, T>, Key>::type>>
|
||||
class aged_unordered_container
|
||||
{
|
||||
public:
|
||||
@@ -71,7 +72,7 @@ public:
|
||||
using duration = typename clock_type::duration;
|
||||
using key_type = Key;
|
||||
using mapped_type = T;
|
||||
using value_type = std::conditional_t<IsMap, std::pair<Key const, T>, Key>;
|
||||
using value_type = typename std::conditional<IsMap, std::pair<Key const, T>, Key>::type;
|
||||
using size_type = std::size_t;
|
||||
using difference_type = std::ptrdiff_t;
|
||||
|
||||
@@ -114,7 +115,8 @@ private:
|
||||
|
||||
template <
|
||||
class... Args,
|
||||
class = std::enable_if_t<std::is_constructible_v<value_type, Args...>>>
|
||||
class =
|
||||
typename std::enable_if<std::is_constructible<value_type, Args...>::value>::type>
|
||||
element(time_point const& when_, Args&&... args)
|
||||
: value(std::forward<Args>(args)...), when(when_)
|
||||
{
|
||||
@@ -131,7 +133,9 @@ private:
|
||||
using argument_type = element;
|
||||
using result_type = size_t;
|
||||
|
||||
ValueHash() = default;
|
||||
ValueHash()
|
||||
{
|
||||
}
|
||||
|
||||
ValueHash(Hash const& h) : Hash(h)
|
||||
{
|
||||
@@ -165,7 +169,9 @@ private:
|
||||
using second_argument_type = element;
|
||||
using result_type = bool;
|
||||
|
||||
KeyValueEqual() = default;
|
||||
KeyValueEqual()
|
||||
{
|
||||
}
|
||||
|
||||
KeyValueEqual(KeyEqual const& keyEqual) : KeyEqual(keyEqual)
|
||||
{
|
||||
@@ -205,7 +211,7 @@ private:
|
||||
using list_type = typename boost::intrusive::
|
||||
make_list<element, boost::intrusive::constant_time_size<false>>::type;
|
||||
|
||||
using cont_type = std::conditional_t<
|
||||
using cont_type = typename std::conditional<
|
||||
IsMulti,
|
||||
typename boost::intrusive::make_unordered_multiset<
|
||||
element,
|
||||
@@ -218,7 +224,7 @@ private:
|
||||
boost::intrusive::constant_time_size<true>,
|
||||
boost::intrusive::hash<ValueHash>,
|
||||
boost::intrusive::equal<KeyValueEqual>,
|
||||
boost::intrusive::cache_begin<true>>::type>;
|
||||
boost::intrusive::cache_begin<true>>::type>::type;
|
||||
|
||||
using bucket_type = typename cont_type::bucket_type;
|
||||
using bucket_traits = typename cont_type::bucket_traits;
|
||||
@@ -656,7 +662,7 @@ public:
|
||||
iterator
|
||||
iterator_to(value_type& value)
|
||||
{
|
||||
static_assert(std::is_standard_layout_v<element>, "must be standard layout");
|
||||
static_assert(std::is_standard_layout<element>::value, "must be standard layout");
|
||||
return list.iterator_to(*reinterpret_cast<element*>(
|
||||
reinterpret_cast<uint8_t*>(&value) -
|
||||
((std::size_t)std::addressof(((element*)0)->member))));
|
||||
@@ -665,17 +671,20 @@ public:
|
||||
const_iterator
|
||||
iterator_to(value_type const& value) const
|
||||
{
|
||||
static_assert(std::is_standard_layout_v<element>, "must be standard layout");
|
||||
static_assert(std::is_standard_layout<element>::value, "must be standard layout");
|
||||
return list.iterator_to(*reinterpret_cast<element const*>(
|
||||
reinterpret_cast<uint8_t const*>(&value) -
|
||||
((std::size_t)std::addressof(((element*)0)->member))));
|
||||
}
|
||||
|
||||
private:
|
||||
chronological_t()
|
||||
{
|
||||
}
|
||||
|
||||
chronological_t(chronological_t const&) = delete;
|
||||
chronological_t(chronological_t&&) = delete;
|
||||
chronological_t() = default;
|
||||
|
||||
private:
|
||||
friend class aged_unordered_container;
|
||||
list_type mutable list;
|
||||
} chronological;
|
||||
@@ -853,30 +862,30 @@ public:
|
||||
class K,
|
||||
bool maybe_multi = IsMulti,
|
||||
bool maybe_map = IsMap,
|
||||
class = std::enable_if_t<maybe_map && !maybe_multi>>
|
||||
std::conditional_t<IsMap, T, void*>&
|
||||
class = typename std::enable_if<maybe_map && !maybe_multi>::type>
|
||||
typename std::conditional<IsMap, T, void*>::type&
|
||||
at(K const& k);
|
||||
|
||||
template <
|
||||
class K,
|
||||
bool maybe_multi = IsMulti,
|
||||
bool maybe_map = IsMap,
|
||||
class = std::enable_if_t<maybe_map && !maybe_multi>>
|
||||
class = typename std::enable_if<maybe_map && !maybe_multi>::type>
|
||||
typename std::conditional<IsMap, T, void*>::type const&
|
||||
at(K const& k) const;
|
||||
|
||||
template <
|
||||
bool maybe_multi = IsMulti,
|
||||
bool maybe_map = IsMap,
|
||||
class = std::enable_if_t<maybe_map && !maybe_multi>>
|
||||
std::conditional_t<IsMap, T, void*>&
|
||||
class = typename std::enable_if<maybe_map && !maybe_multi>::type>
|
||||
typename std::conditional<IsMap, T, void*>::type&
|
||||
operator[](Key const& key);
|
||||
|
||||
template <
|
||||
bool maybe_multi = IsMulti,
|
||||
bool maybe_map = IsMap,
|
||||
class = std::enable_if_t<maybe_map && !maybe_multi>>
|
||||
std::conditional_t<IsMap, T, void*>&
|
||||
class = typename std::enable_if<maybe_map && !maybe_multi>::type>
|
||||
typename std::conditional<IsMap, T, void*>::type&
|
||||
operator[](Key&& key);
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
@@ -924,7 +933,7 @@ public:
|
||||
iterator
|
||||
iterator_to(value_type& value)
|
||||
{
|
||||
static_assert(std::is_standard_layout_v<element>, "must be standard layout");
|
||||
static_assert(std::is_standard_layout<element>::value, "must be standard layout");
|
||||
return m_cont.iterator_to(*reinterpret_cast<element*>(
|
||||
reinterpret_cast<uint8_t*>(&value) -
|
||||
((std::size_t)std::addressof(((element*)0)->member))));
|
||||
@@ -933,7 +942,7 @@ public:
|
||||
const_iterator
|
||||
iterator_to(value_type const& value) const
|
||||
{
|
||||
static_assert(std::is_standard_layout_v<element>, "must be standard layout");
|
||||
static_assert(std::is_standard_layout<element>::value, "must be standard layout");
|
||||
return m_cont.iterator_to(*reinterpret_cast<element const*>(
|
||||
reinterpret_cast<uint8_t const*>(&value) -
|
||||
((std::size_t)std::addressof(((element*)0)->member))));
|
||||
@@ -975,27 +984,29 @@ public:
|
||||
// map, set
|
||||
template <bool maybe_multi = IsMulti>
|
||||
auto
|
||||
insert(value_type const& value) -> std::enable_if_t<!maybe_multi, std::pair<iterator, bool>>;
|
||||
insert(value_type const& value) ->
|
||||
typename std::enable_if<!maybe_multi, std::pair<iterator, bool>>::type;
|
||||
|
||||
// multimap, multiset
|
||||
template <bool maybe_multi = IsMulti>
|
||||
auto
|
||||
insert(value_type const& value) -> std::enable_if_t<maybe_multi, iterator>;
|
||||
insert(value_type const& value) -> typename std::enable_if<maybe_multi, iterator>::type;
|
||||
|
||||
// map, set
|
||||
template <bool maybe_multi = IsMulti, bool maybe_map = IsMap>
|
||||
auto
|
||||
insert(value_type&& value)
|
||||
-> std::enable_if_t<!maybe_multi && !maybe_map, std::pair<iterator, bool>>;
|
||||
insert(value_type&& value) ->
|
||||
typename std::enable_if<!maybe_multi && !maybe_map, std::pair<iterator, bool>>::type;
|
||||
|
||||
// multimap, multiset
|
||||
template <bool maybe_multi = IsMulti, bool maybe_map = IsMap>
|
||||
auto
|
||||
insert(value_type&& value) -> std::enable_if_t<maybe_multi && !maybe_map, iterator>;
|
||||
insert(value_type&& value) ->
|
||||
typename std::enable_if<maybe_multi && !maybe_map, iterator>::type;
|
||||
|
||||
// map, set
|
||||
template <bool maybe_multi = IsMulti>
|
||||
std::enable_if_t<!maybe_multi, iterator>
|
||||
typename std::enable_if<!maybe_multi, iterator>::type
|
||||
insert(const_iterator /*hint*/, value_type const& value)
|
||||
{
|
||||
// Hint is ignored but we provide the interface so
|
||||
@@ -1005,7 +1016,7 @@ public:
|
||||
|
||||
// multimap, multiset
|
||||
template <bool maybe_multi = IsMulti>
|
||||
std::enable_if_t<maybe_multi, iterator>
|
||||
typename std::enable_if<maybe_multi, iterator>::type
|
||||
insert(const_iterator /*hint*/, value_type const& value)
|
||||
{
|
||||
// VFALCO TODO The hint could be used to let
|
||||
@@ -1015,7 +1026,7 @@ public:
|
||||
|
||||
// map, set
|
||||
template <bool maybe_multi = IsMulti>
|
||||
std::enable_if_t<!maybe_multi, iterator>
|
||||
typename std::enable_if<!maybe_multi, iterator>::type
|
||||
insert(const_iterator /*hint*/, value_type&& value)
|
||||
{
|
||||
// Hint is ignored but we provide the interface so
|
||||
@@ -1025,7 +1036,7 @@ public:
|
||||
|
||||
// multimap, multiset
|
||||
template <bool maybe_multi = IsMulti>
|
||||
std::enable_if_t<maybe_multi, iterator>
|
||||
typename std::enable_if<maybe_multi, iterator>::type
|
||||
insert(const_iterator /*hint*/, value_type&& value)
|
||||
{
|
||||
// VFALCO TODO The hint could be used to let
|
||||
@@ -1035,9 +1046,9 @@ public:
|
||||
|
||||
// map, multimap
|
||||
template <class P, bool maybe_map = IsMap>
|
||||
std::enable_if_t<
|
||||
maybe_map && std::is_constructible_v<value_type, P&&>,
|
||||
std::conditional_t<IsMulti, iterator, std::pair<iterator, bool>>>
|
||||
typename std::enable_if<
|
||||
maybe_map && std::is_constructible<value_type, P&&>::value,
|
||||
typename std::conditional<IsMulti, iterator, std::pair<iterator, bool>>::type>::type
|
||||
insert(P&& value)
|
||||
{
|
||||
return emplace(std::forward<P>(value));
|
||||
@@ -1045,9 +1056,9 @@ public:
|
||||
|
||||
// map, multimap
|
||||
template <class P, bool maybe_map = IsMap>
|
||||
std::enable_if_t<
|
||||
maybe_map && std::is_constructible_v<value_type, P&&>,
|
||||
std::conditional_t<IsMulti, iterator, std::pair<iterator, bool>>>
|
||||
typename std::enable_if<
|
||||
maybe_map && std::is_constructible<value_type, P&&>::value,
|
||||
typename std::conditional<IsMulti, iterator, std::pair<iterator, bool>>::type>::type
|
||||
insert(const_iterator hint, P&& value)
|
||||
{
|
||||
return emplace_hint(hint, std::forward<P>(value));
|
||||
@@ -1069,22 +1080,23 @@ public:
|
||||
// set, map
|
||||
template <bool maybe_multi = IsMulti, class... Args>
|
||||
auto
|
||||
emplace(Args&&... args) -> std::enable_if_t<!maybe_multi, std::pair<iterator, bool>>;
|
||||
emplace(Args&&... args) ->
|
||||
typename std::enable_if<!maybe_multi, std::pair<iterator, bool>>::type;
|
||||
|
||||
// multiset, multimap
|
||||
template <bool maybe_multi = IsMulti, class... Args>
|
||||
auto
|
||||
emplace(Args&&... args) -> std::enable_if_t<maybe_multi, iterator>;
|
||||
emplace(Args&&... args) -> typename std::enable_if<maybe_multi, iterator>::type;
|
||||
|
||||
// set, map
|
||||
template <bool maybe_multi = IsMulti, class... Args>
|
||||
auto
|
||||
emplace_hint(const_iterator /*hint*/, Args&&... args)
|
||||
-> std::enable_if_t<!maybe_multi, std::pair<iterator, bool>>;
|
||||
emplace_hint(const_iterator /*hint*/, Args&&... args) ->
|
||||
typename std::enable_if<!maybe_multi, std::pair<iterator, bool>>::type;
|
||||
|
||||
// multiset, multimap
|
||||
template <bool maybe_multi = IsMulti, class... Args>
|
||||
std::enable_if_t<maybe_multi, iterator>
|
||||
typename std::enable_if<maybe_multi, iterator>::type
|
||||
emplace_hint(const_iterator /*hint*/, Args&&... args)
|
||||
{
|
||||
// VFALCO TODO The hint could be used for multi, to let
|
||||
@@ -1316,7 +1328,7 @@ public:
|
||||
class OtherHash,
|
||||
class OtherAllocator,
|
||||
bool maybe_multi = IsMulti>
|
||||
std::enable_if_t<!maybe_multi, bool>
|
||||
typename std::enable_if<!maybe_multi, bool>::type
|
||||
operator==(aged_unordered_container<
|
||||
false,
|
||||
OtherIsMap,
|
||||
@@ -1335,7 +1347,7 @@ public:
|
||||
class OtherHash,
|
||||
class OtherAllocator,
|
||||
bool maybe_multi = IsMulti>
|
||||
std::enable_if_t<maybe_multi, bool>
|
||||
typename std::enable_if<maybe_multi, bool>::type
|
||||
operator==(aged_unordered_container<
|
||||
true,
|
||||
OtherIsMap,
|
||||
@@ -1389,13 +1401,14 @@ private:
|
||||
// map, set
|
||||
template <bool maybe_multi = IsMulti>
|
||||
auto
|
||||
insert_unchecked(value_type const& value)
|
||||
-> std::enable_if_t<!maybe_multi, std::pair<iterator, bool>>;
|
||||
insert_unchecked(value_type const& value) ->
|
||||
typename std::enable_if<!maybe_multi, std::pair<iterator, bool>>::type;
|
||||
|
||||
// multimap, multiset
|
||||
template <bool maybe_multi = IsMulti>
|
||||
auto
|
||||
insert_unchecked(value_type const& value) -> std::enable_if_t<maybe_multi, iterator>;
|
||||
insert_unchecked(value_type const& value) ->
|
||||
typename std::enable_if<maybe_multi, iterator>::type;
|
||||
|
||||
template <class InputIt>
|
||||
void
|
||||
@@ -1436,7 +1449,7 @@ private:
|
||||
|
||||
template <
|
||||
bool maybe_propagate = std::allocator_traits<Allocator>::propagate_on_container_swap::value>
|
||||
std::enable_if_t<maybe_propagate>
|
||||
typename std::enable_if<maybe_propagate>::type
|
||||
swap_data(aged_unordered_container& other) noexcept
|
||||
{
|
||||
std::swap(m_config.key_compare(), other.m_config.key_compare());
|
||||
@@ -1446,7 +1459,7 @@ private:
|
||||
|
||||
template <
|
||||
bool maybe_propagate = std::allocator_traits<Allocator>::propagate_on_container_swap::value>
|
||||
std::enable_if_t<!maybe_propagate>
|
||||
typename std::enable_if<!maybe_propagate>::type
|
||||
swap_data(aged_unordered_container& other) noexcept
|
||||
{
|
||||
std::swap(m_config.key_compare(), other.m_config.key_compare());
|
||||
@@ -2101,7 +2114,7 @@ template <
|
||||
class KeyEqual,
|
||||
class Allocator>
|
||||
template <class K, bool maybe_multi, bool maybe_map, class>
|
||||
std::conditional_t<IsMap, T, void*>&
|
||||
typename std::conditional<IsMap, T, void*>::type&
|
||||
aged_unordered_container<IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>::at(K const& k)
|
||||
{
|
||||
auto const iter(
|
||||
@@ -2142,7 +2155,7 @@ template <
|
||||
class KeyEqual,
|
||||
class Allocator>
|
||||
template <bool maybe_multi, bool maybe_map, class>
|
||||
std::conditional_t<IsMap, T, void*>&
|
||||
typename std::conditional<IsMap, T, void*>::type&
|
||||
aged_unordered_container<IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>::operator[](
|
||||
Key const& key)
|
||||
{
|
||||
@@ -2171,7 +2184,7 @@ template <
|
||||
class KeyEqual,
|
||||
class Allocator>
|
||||
template <bool maybe_multi, bool maybe_map, class>
|
||||
std::conditional_t<IsMap, T, void*>&
|
||||
typename std::conditional<IsMap, T, void*>::type&
|
||||
aged_unordered_container<IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>::operator[](
|
||||
Key&& key)
|
||||
{
|
||||
@@ -2226,7 +2239,8 @@ template <
|
||||
template <bool maybe_multi>
|
||||
auto
|
||||
aged_unordered_container<IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>::insert(
|
||||
value_type const& value) -> std::enable_if_t<!maybe_multi, std::pair<iterator, bool>>
|
||||
value_type const& value) ->
|
||||
typename std::enable_if<!maybe_multi, std::pair<iterator, bool>>::type
|
||||
{
|
||||
maybe_rehash(1);
|
||||
typename cont_type::insert_commit_data d;
|
||||
@@ -2258,7 +2272,7 @@ template <
|
||||
template <bool maybe_multi>
|
||||
auto
|
||||
aged_unordered_container<IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>::insert(
|
||||
value_type const& value) -> std::enable_if_t<maybe_multi, iterator>
|
||||
value_type const& value) -> typename std::enable_if<maybe_multi, iterator>::type
|
||||
{
|
||||
maybe_rehash(1);
|
||||
element* const p(new_element(value));
|
||||
@@ -2280,7 +2294,8 @@ template <
|
||||
template <bool maybe_multi, bool maybe_map>
|
||||
auto
|
||||
aged_unordered_container<IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>::insert(
|
||||
value_type&& value) -> std::enable_if_t<!maybe_multi && !maybe_map, std::pair<iterator, bool>>
|
||||
value_type&& value) ->
|
||||
typename std::enable_if<!maybe_multi && !maybe_map, std::pair<iterator, bool>>::type
|
||||
{
|
||||
maybe_rehash(1);
|
||||
typename cont_type::insert_commit_data d;
|
||||
@@ -2312,7 +2327,7 @@ template <
|
||||
template <bool maybe_multi, bool maybe_map>
|
||||
auto
|
||||
aged_unordered_container<IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>::insert(
|
||||
value_type&& value) -> std::enable_if_t<maybe_multi && !maybe_map, iterator>
|
||||
value_type&& value) -> typename std::enable_if<maybe_multi && !maybe_map, iterator>::type
|
||||
{
|
||||
maybe_rehash(1);
|
||||
element* const p(new_element(std::move(value)));
|
||||
@@ -2335,7 +2350,7 @@ template <
|
||||
template <bool maybe_multi, class... Args>
|
||||
auto
|
||||
aged_unordered_container<IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>::emplace(
|
||||
Args&&... args) -> std::enable_if_t<!maybe_multi, std::pair<iterator, bool>>
|
||||
Args&&... args) -> typename std::enable_if<!maybe_multi, std::pair<iterator, bool>>::type
|
||||
{
|
||||
maybe_rehash(1);
|
||||
// VFALCO NOTE Its unfortunate that we need to
|
||||
@@ -2400,7 +2415,7 @@ template <
|
||||
template <bool maybe_multi, class... Args>
|
||||
auto
|
||||
aged_unordered_container<IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>::emplace(
|
||||
Args&&... args) -> std::enable_if_t<maybe_multi, iterator>
|
||||
Args&&... args) -> typename std::enable_if<maybe_multi, iterator>::type
|
||||
{
|
||||
maybe_rehash(1);
|
||||
element* const p(new_element(std::forward<Args>(args)...));
|
||||
@@ -2423,7 +2438,7 @@ template <bool maybe_multi, class... Args>
|
||||
auto
|
||||
aged_unordered_container<IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>::emplace_hint(
|
||||
const_iterator /*hint*/,
|
||||
Args&&... args) -> std::enable_if_t<!maybe_multi, std::pair<iterator, bool>>
|
||||
Args&&... args) -> typename std::enable_if<!maybe_multi, std::pair<iterator, bool>>::type
|
||||
{
|
||||
maybe_rehash(1);
|
||||
// VFALCO NOTE Its unfortunate that we need to
|
||||
@@ -2575,7 +2590,7 @@ template <
|
||||
class OtherHash,
|
||||
class OtherAllocator,
|
||||
bool maybe_multi>
|
||||
std::enable_if_t<!maybe_multi, bool>
|
||||
typename std::enable_if<!maybe_multi, bool>::type
|
||||
aged_unordered_container<IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>::operator==(
|
||||
aged_unordered_container<
|
||||
false,
|
||||
@@ -2615,7 +2630,7 @@ template <
|
||||
class OtherHash,
|
||||
class OtherAllocator,
|
||||
bool maybe_multi>
|
||||
std::enable_if_t<maybe_multi, bool>
|
||||
typename std::enable_if<maybe_multi, bool>::type
|
||||
aged_unordered_container<IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>::operator==(
|
||||
aged_unordered_container<
|
||||
true,
|
||||
@@ -2662,8 +2677,8 @@ template <
|
||||
template <bool maybe_multi>
|
||||
auto
|
||||
aged_unordered_container<IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>::
|
||||
insert_unchecked(value_type const& value)
|
||||
-> std::enable_if_t<!maybe_multi, std::pair<iterator, bool>>
|
||||
insert_unchecked(value_type const& value) ->
|
||||
typename std::enable_if<!maybe_multi, std::pair<iterator, bool>>::type
|
||||
{
|
||||
typename cont_type::insert_commit_data d;
|
||||
auto const result(m_cont.insert_check(
|
||||
@@ -2694,7 +2709,8 @@ template <
|
||||
template <bool maybe_multi>
|
||||
auto
|
||||
aged_unordered_container<IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>::
|
||||
insert_unchecked(value_type const& value) -> std::enable_if_t<maybe_multi, iterator>
|
||||
insert_unchecked(value_type const& value) ->
|
||||
typename std::enable_if<maybe_multi, iterator>::type
|
||||
{
|
||||
element* const p(new_element(value));
|
||||
chronological.list.push_back(*p);
|
||||
|
||||
@@ -11,11 +11,12 @@
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
namespace beast::detail {
|
||||
namespace beast {
|
||||
namespace detail {
|
||||
|
||||
template <class T>
|
||||
struct is_empty_base_optimization_derived
|
||||
: std::integral_constant<bool, std::is_empty_v<T> && !boost::is_final<T>::value>
|
||||
: std::integral_constant<bool, std::is_empty<T>::value && !boost::is_final<T>::value>
|
||||
{
|
||||
};
|
||||
|
||||
@@ -85,4 +86,5 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace beast::detail
|
||||
} // namespace detail
|
||||
} // namespace beast
|
||||
|
||||
@@ -16,7 +16,7 @@ struct CopyConst
|
||||
{
|
||||
explicit CopyConst() = default;
|
||||
|
||||
using type = std::remove_const_t<U>;
|
||||
using type = typename std::remove_const<U>::type;
|
||||
};
|
||||
|
||||
template <typename T, typename U>
|
||||
|
||||
@@ -13,16 +13,18 @@ class LockFreeStackIterator
|
||||
{
|
||||
protected:
|
||||
using Node = typename Container::Node;
|
||||
using NodePtr = std::conditional_t<IsConst, Node const*, Node*>;
|
||||
using NodePtr = typename std::conditional<IsConst, Node const*, Node*>::type;
|
||||
|
||||
public:
|
||||
using iterator_category = std::forward_iterator_tag;
|
||||
using value_type = typename Container::value_type;
|
||||
using difference_type = typename Container::difference_type;
|
||||
using pointer =
|
||||
std::conditional_t<IsConst, typename Container::const_pointer, typename Container::pointer>;
|
||||
using reference = std::
|
||||
conditional_t<IsConst, typename Container::const_reference, typename Container::reference>;
|
||||
using pointer = typename std::
|
||||
conditional<IsConst, typename Container::const_pointer, typename Container::pointer>::type;
|
||||
using reference = typename std::conditional<
|
||||
IsConst,
|
||||
typename Container::const_reference,
|
||||
typename Container::reference>::type;
|
||||
|
||||
LockFreeStackIterator() : m_node()
|
||||
{
|
||||
|
||||
@@ -69,7 +69,7 @@ template <class T>
|
||||
struct is_uniquely_represented
|
||||
: public std::integral_constant<
|
||||
bool,
|
||||
std::is_integral_v<T> || std::is_enum_v<T> || std::is_pointer_v<T>>
|
||||
std::is_integral<T>::value || std::is_enum<T>::value || std::is_pointer<T>::value>
|
||||
{
|
||||
explicit is_uniquely_represented() = default;
|
||||
};
|
||||
@@ -210,7 +210,7 @@ hash_append(Hasher& h, T const& t) noexcept
|
||||
template <class Hasher, class T>
|
||||
inline std::enable_if_t<
|
||||
!is_contiguously_hashable<T, Hasher>::value &&
|
||||
(std::is_integral_v<T> || std::is_pointer_v<T> || std::is_enum_v<T>)>
|
||||
(std::is_integral<T>::value || std::is_pointer<T>::value || std::is_enum<T>::value)>
|
||||
hash_append(Hasher& h, T t) noexcept
|
||||
{
|
||||
detail::reverse_bytes(t);
|
||||
@@ -218,7 +218,7 @@ hash_append(Hasher& h, T t) noexcept
|
||||
}
|
||||
|
||||
template <class Hasher, class T>
|
||||
inline std::enable_if_t<std::is_floating_point_v<T>>
|
||||
inline std::enable_if_t<std::is_floating_point<T>::value>
|
||||
hash_append(Hasher& h, T t) noexcept
|
||||
{
|
||||
if (t == 0)
|
||||
|
||||
@@ -121,13 +121,13 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
template <class Seed, std::enable_if_t<std::is_unsigned_v<Seed>>* = nullptr>
|
||||
template <class Seed, std::enable_if_t<std::is_unsigned<Seed>::value>* = nullptr>
|
||||
explicit xxhasher(Seed seed) : seed_(seed)
|
||||
{
|
||||
resetBuffers();
|
||||
}
|
||||
|
||||
template <class Seed, std::enable_if_t<std::is_unsigned_v<Seed>>* = nullptr>
|
||||
template <class Seed, std::enable_if_t<std::is_unsigned<Seed>::value>* = nullptr>
|
||||
xxhasher(Seed seed, Seed) : seed_(seed)
|
||||
{
|
||||
resetBuffers();
|
||||
|
||||
@@ -8,7 +8,8 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace beast::insight {
|
||||
namespace beast {
|
||||
namespace insight {
|
||||
|
||||
/** Interface for a manager that allows collection of metrics.
|
||||
|
||||
@@ -116,4 +117,5 @@ public:
|
||||
/** @} */
|
||||
};
|
||||
|
||||
} // namespace beast::insight
|
||||
} // namespace insight
|
||||
} // namespace beast
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace beast::insight {
|
||||
namespace beast {
|
||||
namespace insight {
|
||||
|
||||
/** A metric for measuring an integral value.
|
||||
|
||||
@@ -22,7 +23,9 @@ public:
|
||||
/** Create a null metric.
|
||||
A null metric reports no information.
|
||||
*/
|
||||
Counter() = default;
|
||||
Counter()
|
||||
{
|
||||
}
|
||||
|
||||
/** Create the metric reference the specified implementation.
|
||||
Normally this won't be called directly. Instead, call the appropriate
|
||||
@@ -88,4 +91,5 @@ private:
|
||||
std::shared_ptr<CounterImpl> m_impl;
|
||||
};
|
||||
|
||||
} // namespace beast::insight
|
||||
} // namespace insight
|
||||
} // namespace beast
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
|
||||
namespace beast::insight {
|
||||
namespace beast {
|
||||
namespace insight {
|
||||
|
||||
class Counter;
|
||||
|
||||
@@ -17,4 +18,5 @@ public:
|
||||
increment(value_type amount) = 0;
|
||||
};
|
||||
|
||||
} // namespace beast::insight
|
||||
} // namespace insight
|
||||
} // namespace beast
|
||||
|
||||
@@ -5,7 +5,8 @@
|
||||
#include <chrono>
|
||||
#include <memory>
|
||||
|
||||
namespace beast::insight {
|
||||
namespace beast {
|
||||
namespace insight {
|
||||
|
||||
/** A metric for reporting event timing.
|
||||
|
||||
@@ -24,7 +25,9 @@ public:
|
||||
/** Create a null metric.
|
||||
A null metric reports no information.
|
||||
*/
|
||||
Event() = default;
|
||||
Event()
|
||||
{
|
||||
}
|
||||
|
||||
/** Create the metric reference the specified implementation.
|
||||
Normally this won't be called directly. Instead, call the appropriate
|
||||
@@ -55,4 +58,5 @@ private:
|
||||
std::shared_ptr<EventImpl> m_impl;
|
||||
};
|
||||
|
||||
} // namespace beast::insight
|
||||
} // namespace insight
|
||||
} // namespace beast
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
#include <chrono>
|
||||
#include <memory>
|
||||
|
||||
namespace beast::insight {
|
||||
namespace beast {
|
||||
namespace insight {
|
||||
|
||||
class Event;
|
||||
|
||||
@@ -17,4 +18,5 @@ public:
|
||||
notify(value_type const& value) = 0;
|
||||
};
|
||||
|
||||
} // namespace beast::insight
|
||||
} // namespace insight
|
||||
} // namespace beast
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace beast::insight {
|
||||
namespace beast {
|
||||
namespace insight {
|
||||
|
||||
/** A metric for measuring an integral value.
|
||||
|
||||
@@ -24,7 +25,9 @@ public:
|
||||
/** Create a null metric.
|
||||
A null metric reports no information.
|
||||
*/
|
||||
Gauge() = default;
|
||||
Gauge()
|
||||
{
|
||||
}
|
||||
|
||||
/** Create the metric reference the specified implementation.
|
||||
Normally this won't be called directly. Instead, call the appropriate
|
||||
@@ -118,4 +121,5 @@ private:
|
||||
std::shared_ptr<GaugeImpl> m_impl;
|
||||
};
|
||||
|
||||
} // namespace beast::insight
|
||||
} // namespace insight
|
||||
} // namespace beast
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
|
||||
namespace beast::insight {
|
||||
namespace beast {
|
||||
namespace insight {
|
||||
|
||||
class Gauge;
|
||||
|
||||
@@ -20,4 +21,5 @@ public:
|
||||
increment(difference_type amount) = 0;
|
||||
};
|
||||
|
||||
} // namespace beast::insight
|
||||
} // namespace insight
|
||||
} // namespace beast
|
||||
|
||||
@@ -5,7 +5,8 @@
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
namespace beast::insight {
|
||||
namespace beast {
|
||||
namespace insight {
|
||||
|
||||
/** A collector front-end that manages a group of metrics. */
|
||||
class Group : public Collector
|
||||
@@ -18,4 +19,5 @@ public:
|
||||
name() const = 0;
|
||||
};
|
||||
|
||||
} // namespace beast::insight
|
||||
} // namespace insight
|
||||
} // namespace beast
|
||||
|
||||
@@ -6,7 +6,8 @@
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
namespace beast::insight {
|
||||
namespace beast {
|
||||
namespace insight {
|
||||
|
||||
/** A container for managing a set of metric groups. */
|
||||
class Groups
|
||||
@@ -31,4 +32,5 @@ public:
|
||||
std::unique_ptr<Groups>
|
||||
make_Groups(Collector::ptr const& collector);
|
||||
|
||||
} // namespace beast::insight
|
||||
} // namespace insight
|
||||
} // namespace beast
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace beast::insight {
|
||||
namespace beast {
|
||||
namespace insight {
|
||||
|
||||
/** A reference to a handler for performing polled collection. */
|
||||
class Hook final
|
||||
@@ -13,7 +14,9 @@ public:
|
||||
/** Create a null hook.
|
||||
A null hook has no associated handler.
|
||||
*/
|
||||
Hook() = default;
|
||||
Hook()
|
||||
{
|
||||
}
|
||||
|
||||
/** Create a hook referencing the specified implementation.
|
||||
Normally this won't be called directly. Instead, call the appropriate
|
||||
@@ -34,4 +37,5 @@ private:
|
||||
std::shared_ptr<HookImpl> m_impl;
|
||||
};
|
||||
|
||||
} // namespace beast::insight
|
||||
} // namespace insight
|
||||
} // namespace beast
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
|
||||
namespace beast::insight {
|
||||
namespace beast {
|
||||
namespace insight {
|
||||
|
||||
class HookImpl : public std::enable_shared_from_this<HookImpl>
|
||||
{
|
||||
@@ -13,4 +14,5 @@ public:
|
||||
virtual ~HookImpl() = 0;
|
||||
};
|
||||
|
||||
} // namespace beast::insight
|
||||
} // namespace insight
|
||||
} // namespace beast
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace beast::insight {
|
||||
namespace beast {
|
||||
namespace insight {
|
||||
|
||||
/** A metric for measuring an integral value.
|
||||
|
||||
@@ -21,7 +22,9 @@ public:
|
||||
/** Create a null metric.
|
||||
A null metric reports no information.
|
||||
*/
|
||||
Meter() = default;
|
||||
Meter()
|
||||
{
|
||||
}
|
||||
|
||||
/** Create the metric reference the specified implementation.
|
||||
Normally this won't be called directly. Instead, call the appropriate
|
||||
@@ -73,4 +76,5 @@ private:
|
||||
std::shared_ptr<MeterImpl> m_impl;
|
||||
};
|
||||
|
||||
} // namespace beast::insight
|
||||
} // namespace insight
|
||||
} // namespace beast
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
|
||||
namespace beast::insight {
|
||||
namespace beast {
|
||||
namespace insight {
|
||||
|
||||
class Meter;
|
||||
|
||||
@@ -17,4 +18,5 @@ public:
|
||||
increment(value_type amount) = 0;
|
||||
};
|
||||
|
||||
} // namespace beast::insight
|
||||
} // namespace insight
|
||||
} // namespace beast
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
|
||||
#include <xrpl/beast/insight/Collector.h>
|
||||
|
||||
namespace beast::insight {
|
||||
namespace beast {
|
||||
namespace insight {
|
||||
|
||||
/** A Collector which does not collect metrics. */
|
||||
class NullCollector : public Collector
|
||||
@@ -14,4 +15,5 @@ public:
|
||||
New();
|
||||
};
|
||||
|
||||
} // namespace beast::insight
|
||||
} // namespace insight
|
||||
} // namespace beast
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
#include <xrpl/beast/net/IPEndpoint.h>
|
||||
#include <xrpl/beast/utility/Journal.h>
|
||||
|
||||
namespace beast::insight {
|
||||
namespace beast {
|
||||
namespace insight {
|
||||
|
||||
/** A Collector that reports metrics to a StatsD server.
|
||||
Reference:
|
||||
@@ -24,4 +25,5 @@ public:
|
||||
New(IP::Endpoint const& address, std::string const& prefix, Journal journal);
|
||||
};
|
||||
|
||||
} // namespace beast::insight
|
||||
} // namespace insight
|
||||
} // namespace beast
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
|
||||
#include <boost/asio.hpp>
|
||||
|
||||
namespace beast::IP {
|
||||
namespace beast {
|
||||
namespace IP {
|
||||
|
||||
/** Convert to Endpoint.
|
||||
The port is set to zero.
|
||||
@@ -26,7 +27,8 @@ to_asio_address(Endpoint const& endpoint);
|
||||
boost::asio::ip::tcp::endpoint
|
||||
to_asio_endpoint(Endpoint const& endpoint);
|
||||
|
||||
} // namespace beast::IP
|
||||
} // namespace IP
|
||||
} // namespace beast
|
||||
|
||||
namespace beast {
|
||||
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
|
||||
#include <boost/asio/ip/address_v4.hpp>
|
||||
|
||||
namespace beast::IP {
|
||||
namespace beast {
|
||||
namespace IP {
|
||||
|
||||
using AddressV4 = boost::asio::ip::address_v4;
|
||||
|
||||
@@ -22,4 +23,5 @@ is_public(AddressV4 const& addr);
|
||||
char
|
||||
get_class(AddressV4 const& address);
|
||||
|
||||
} // namespace beast::IP
|
||||
} // namespace IP
|
||||
} // namespace beast
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
|
||||
#include <boost/asio/ip/address_v6.hpp>
|
||||
|
||||
namespace beast::IP {
|
||||
namespace beast {
|
||||
namespace IP {
|
||||
|
||||
using AddressV6 = boost::asio::ip::address_v6;
|
||||
|
||||
@@ -16,4 +17,5 @@ is_private(AddressV6 const& addr);
|
||||
bool
|
||||
is_public(AddressV6 const& addr);
|
||||
|
||||
} // namespace beast::IP
|
||||
} // namespace IP
|
||||
} // namespace beast
|
||||
|
||||
@@ -8,7 +8,8 @@
|
||||
#include <optional>
|
||||
#include <string>
|
||||
|
||||
namespace beast::IP {
|
||||
namespace beast {
|
||||
namespace IP {
|
||||
|
||||
using Port = std::uint16_t;
|
||||
|
||||
@@ -20,7 +21,7 @@ public:
|
||||
Endpoint();
|
||||
|
||||
/** Create an endpoint from the address and optional port. */
|
||||
explicit Endpoint(Address addr, Port port = 0);
|
||||
explicit Endpoint(Address const& addr, Port port = 0);
|
||||
|
||||
/** Create an Endpoint from a string.
|
||||
If the port is omitted, the endpoint will have a zero port.
|
||||
@@ -183,7 +184,8 @@ operator<<(OutputStream& os, Endpoint const& endpoint)
|
||||
std::istream&
|
||||
operator>>(std::istream& is, Endpoint& endpoint);
|
||||
|
||||
} // namespace beast::IP
|
||||
} // namespace IP
|
||||
} // namespace beast
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -12,7 +12,8 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace beast::rfc2616 {
|
||||
namespace beast {
|
||||
namespace rfc2616 {
|
||||
|
||||
namespace detail {
|
||||
|
||||
@@ -369,4 +370,5 @@ is_keep_alive(boost::beast::http::message<isRequest, Body, Fields> const& m)
|
||||
"close");
|
||||
}
|
||||
|
||||
} // namespace beast::rfc2616
|
||||
} // namespace rfc2616
|
||||
} // namespace beast
|
||||
|
||||
@@ -15,7 +15,8 @@
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
|
||||
namespace beast::test {
|
||||
namespace beast {
|
||||
namespace test {
|
||||
|
||||
/** Mix-in to support tests using asio coroutines.
|
||||
|
||||
@@ -124,4 +125,5 @@ enable_yield_to::spawn(F0&& f, FN&&... fn)
|
||||
spawn(fn...);
|
||||
}
|
||||
|
||||
} // namespace beast::test
|
||||
} // namespace test
|
||||
} // namespace beast
|
||||
|
||||
@@ -15,7 +15,7 @@ template <typename T>
|
||||
std::string
|
||||
type_name()
|
||||
{
|
||||
using TR = std::remove_reference_t<T>;
|
||||
using TR = typename std::remove_reference<T>::type;
|
||||
|
||||
std::string name = typeid(TR).name();
|
||||
|
||||
@@ -27,15 +27,15 @@ type_name()
|
||||
}
|
||||
#endif
|
||||
|
||||
if (std::is_const_v<TR>)
|
||||
if (std::is_const<TR>::value)
|
||||
name += " const";
|
||||
if (std::is_volatile_v<TR>)
|
||||
if (std::is_volatile<TR>::value)
|
||||
name += " volatile";
|
||||
if (std::is_lvalue_reference_v<T>)
|
||||
if (std::is_lvalue_reference<T>::value)
|
||||
{
|
||||
name += "&";
|
||||
}
|
||||
else if (std::is_rvalue_reference_v<T>)
|
||||
else if (std::is_rvalue_reference<T>::value)
|
||||
{
|
||||
name += "&&";
|
||||
}
|
||||
|
||||
@@ -8,7 +8,8 @@
|
||||
#include <ostream>
|
||||
#include <string>
|
||||
|
||||
namespace beast::unit_test {
|
||||
namespace beast {
|
||||
namespace unit_test {
|
||||
|
||||
/** Utility for producing nicely composed output of amounts with units. */
|
||||
class amount
|
||||
@@ -41,4 +42,5 @@ operator<<(std::ostream& s, amount const& t)
|
||||
return s;
|
||||
}
|
||||
|
||||
} // namespace beast::unit_test
|
||||
} // namespace unit_test
|
||||
} // namespace beast
|
||||
|
||||
@@ -4,7 +4,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace beast::unit_test::detail {
|
||||
namespace beast {
|
||||
namespace unit_test {
|
||||
namespace detail {
|
||||
|
||||
/** Adapter to constrain a container interface.
|
||||
The interface allows for limited read only operations. Derived classes
|
||||
@@ -80,4 +82,6 @@ public:
|
||||
/** @} */
|
||||
};
|
||||
|
||||
} // namespace beast::unit_test::detail
|
||||
} // namespace detail
|
||||
} // namespace unit_test
|
||||
} // namespace beast
|
||||
|
||||
@@ -6,7 +6,8 @@
|
||||
|
||||
#include <xrpl/beast/unit_test/suite_list.h>
|
||||
|
||||
namespace beast::unit_test {
|
||||
namespace beast {
|
||||
namespace unit_test {
|
||||
|
||||
namespace detail {
|
||||
|
||||
@@ -41,4 +42,5 @@ global_suites()
|
||||
return detail::global_suites();
|
||||
}
|
||||
|
||||
} // namespace beast::unit_test
|
||||
} // namespace unit_test
|
||||
} // namespace beast
|
||||
|
||||
@@ -8,7 +8,8 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace beast::unit_test {
|
||||
namespace beast {
|
||||
namespace unit_test {
|
||||
|
||||
// Predicate for implementing matches
|
||||
class selector
|
||||
@@ -162,4 +163,5 @@ match_library(std::string const& name)
|
||||
return selector(selector::library, name);
|
||||
}
|
||||
|
||||
} // namespace beast::unit_test
|
||||
} // namespace unit_test
|
||||
} // namespace beast
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
#include <xrpl/beast/unit_test/results.h>
|
||||
#include <xrpl/beast/unit_test/runner.h>
|
||||
|
||||
namespace beast::unit_test {
|
||||
namespace beast {
|
||||
namespace unit_test {
|
||||
|
||||
/** A test runner that stores the results. */
|
||||
class recorder : public runner
|
||||
@@ -28,48 +29,49 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
void
|
||||
virtual void
|
||||
on_suite_begin(suite_info const& info) override
|
||||
{
|
||||
m_suite = suite_results(info.full_name());
|
||||
}
|
||||
|
||||
void
|
||||
virtual void
|
||||
on_suite_end() override
|
||||
{
|
||||
m_results.insert(std::move(m_suite));
|
||||
}
|
||||
|
||||
void
|
||||
virtual void
|
||||
on_case_begin(std::string const& name) override
|
||||
{
|
||||
m_case = case_results(name);
|
||||
}
|
||||
|
||||
void
|
||||
virtual void
|
||||
on_case_end() override
|
||||
{
|
||||
if (!m_case.tests.empty())
|
||||
m_suite.insert(std::move(m_case));
|
||||
}
|
||||
|
||||
void
|
||||
virtual void
|
||||
on_pass() override
|
||||
{
|
||||
m_case.tests.pass();
|
||||
}
|
||||
|
||||
void
|
||||
virtual void
|
||||
on_fail(std::string const& reason) override
|
||||
{
|
||||
m_case.tests.fail(reason);
|
||||
}
|
||||
|
||||
void
|
||||
virtual void
|
||||
on_log(std::string const& s) override
|
||||
{
|
||||
m_case.log.insert(s);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace beast::unit_test
|
||||
} // namespace unit_test
|
||||
} // namespace beast
|
||||
|
||||
@@ -18,7 +18,8 @@
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
namespace beast::unit_test {
|
||||
namespace beast {
|
||||
namespace unit_test {
|
||||
|
||||
namespace detail {
|
||||
|
||||
@@ -85,7 +86,7 @@ public:
|
||||
reporter&
|
||||
operator=(reporter const&) = delete;
|
||||
|
||||
~reporter() override;
|
||||
~reporter();
|
||||
|
||||
explicit reporter(std::ostream& os = std::cout);
|
||||
|
||||
@@ -93,25 +94,25 @@ private:
|
||||
static std::string
|
||||
fmtdur(typename clock_type::duration const& d);
|
||||
|
||||
void
|
||||
virtual void
|
||||
on_suite_begin(suite_info const& info) override;
|
||||
|
||||
void
|
||||
virtual void
|
||||
on_suite_end() override;
|
||||
|
||||
void
|
||||
virtual void
|
||||
on_case_begin(std::string const& name) override;
|
||||
|
||||
void
|
||||
virtual void
|
||||
on_case_end() override;
|
||||
|
||||
void
|
||||
virtual void
|
||||
on_pass() override;
|
||||
|
||||
void
|
||||
virtual void
|
||||
on_fail(std::string const& reason) override;
|
||||
|
||||
void
|
||||
virtual void
|
||||
on_log(std::string const& s) override;
|
||||
};
|
||||
|
||||
@@ -250,4 +251,5 @@ reporter<Unused>::on_log(std::string const& s)
|
||||
|
||||
using reporter = detail::reporter<>;
|
||||
|
||||
} // namespace beast::unit_test
|
||||
} // namespace unit_test
|
||||
} // namespace beast
|
||||
|
||||
@@ -7,10 +7,10 @@
|
||||
#include <xrpl/beast/unit_test/detail/const_container.h>
|
||||
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace beast::unit_test {
|
||||
namespace beast {
|
||||
namespace unit_test {
|
||||
|
||||
/** Holds a set of test condition outcomes in a testcase. */
|
||||
class case_results
|
||||
@@ -23,7 +23,7 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
test(bool pass_, std::string reason_) : pass(pass_), reason(std::move(reason_))
|
||||
test(bool pass_, std::string const& reason_) : pass(pass_), reason(reason_)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -38,7 +38,9 @@ private:
|
||||
std::size_t failed_{0};
|
||||
|
||||
public:
|
||||
tests_t() = default;
|
||||
tests_t()
|
||||
{
|
||||
}
|
||||
|
||||
/** Returns the total number of test conditions. */
|
||||
std::size_t
|
||||
@@ -84,7 +86,7 @@ private:
|
||||
std::string name_;
|
||||
|
||||
public:
|
||||
explicit case_results(std::string name = "") : name_(std::move(name))
|
||||
explicit case_results(std::string const& name = "") : name_(name)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -113,7 +115,7 @@ private:
|
||||
std::size_t failed_ = 0;
|
||||
|
||||
public:
|
||||
explicit suite_results(std::string name = "") : name_(std::move(name))
|
||||
explicit suite_results(std::string const& name = "") : name_(name)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -170,7 +172,9 @@ private:
|
||||
std::size_t failed_{0};
|
||||
|
||||
public:
|
||||
results() = default;
|
||||
results()
|
||||
{
|
||||
}
|
||||
|
||||
/** Returns the total number of test cases. */
|
||||
std::size_t
|
||||
@@ -215,4 +219,5 @@ public:
|
||||
/** @} */
|
||||
};
|
||||
|
||||
} // namespace beast::unit_test
|
||||
} // namespace unit_test
|
||||
} // namespace beast
|
||||
|
||||
@@ -11,7 +11,8 @@
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
|
||||
namespace beast::unit_test {
|
||||
namespace beast {
|
||||
namespace unit_test {
|
||||
|
||||
/** Unit test runner interface.
|
||||
|
||||
@@ -276,4 +277,5 @@ runner::log(std::string const& s)
|
||||
on_log(s);
|
||||
}
|
||||
|
||||
} // namespace beast::unit_test
|
||||
} // namespace unit_test
|
||||
} // namespace beast
|
||||
|
||||
@@ -14,7 +14,8 @@
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
namespace beast::unit_test {
|
||||
namespace beast {
|
||||
namespace unit_test {
|
||||
|
||||
namespace detail {
|
||||
|
||||
@@ -74,7 +75,7 @@ private:
|
||||
{
|
||||
}
|
||||
|
||||
~log_buf() override
|
||||
~log_buf()
|
||||
{
|
||||
sync();
|
||||
}
|
||||
@@ -572,7 +573,8 @@ suite::run(runner& r)
|
||||
((cond) ? (pass(), true) : (fail((reason), __FILE__, __LINE__), false))
|
||||
#endif
|
||||
|
||||
} // namespace beast::unit_test
|
||||
} // namespace unit_test
|
||||
} // namespace beast
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -9,7 +9,8 @@
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
namespace beast::unit_test {
|
||||
namespace beast {
|
||||
namespace unit_test {
|
||||
|
||||
class runner;
|
||||
|
||||
@@ -109,4 +110,5 @@ make_suite_info(
|
||||
});
|
||||
}
|
||||
|
||||
} // namespace beast::unit_test
|
||||
} // namespace unit_test
|
||||
} // namespace beast
|
||||
|
||||
@@ -13,7 +13,8 @@
|
||||
#include <typeindex>
|
||||
#include <unordered_set>
|
||||
|
||||
namespace beast::unit_test {
|
||||
namespace beast {
|
||||
namespace unit_test {
|
||||
|
||||
/// A container of test suites.
|
||||
class suite_list : public detail::const_container<std::set<suite_info>>
|
||||
@@ -61,4 +62,5 @@ suite_list::insert(
|
||||
cont().emplace(make_suite_info<Suite>(name, module, library, manual, priority));
|
||||
}
|
||||
|
||||
} // namespace beast::unit_test
|
||||
} // namespace unit_test
|
||||
} // namespace beast
|
||||
|
||||
@@ -10,7 +10,8 @@
|
||||
#include <thread>
|
||||
#include <utility>
|
||||
|
||||
namespace beast::unit_test {
|
||||
namespace beast {
|
||||
namespace unit_test {
|
||||
|
||||
/** Replacement for std::thread that handles exceptions in unit tests. */
|
||||
class Thread
|
||||
@@ -107,4 +108,5 @@ private:
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace beast::unit_test
|
||||
} // namespace unit_test
|
||||
} // namespace beast
|
||||
|
||||
@@ -55,16 +55,15 @@ public:
|
||||
class Sink
|
||||
{
|
||||
protected:
|
||||
Sink() = delete;
|
||||
explicit Sink(Sink const& sink) = default;
|
||||
Sink(Severity thresh, bool console);
|
||||
Sink&
|
||||
operator=(Sink const& lhs) = delete;
|
||||
|
||||
public:
|
||||
virtual ~Sink() = 0;
|
||||
|
||||
Sink() = delete;
|
||||
Sink&
|
||||
operator=(Sink const& lhs) = delete;
|
||||
|
||||
/** Returns `true` if text at the passed severity produces output. */
|
||||
virtual bool
|
||||
active(Severity level) const;
|
||||
@@ -372,6 +371,10 @@ class logstream_buf : public std::basic_stringbuf<CharT, Traits>
|
||||
{
|
||||
beast::Journal::Stream strm_;
|
||||
|
||||
template <class T>
|
||||
void
|
||||
write(T const*) = delete;
|
||||
|
||||
void
|
||||
write(char const* s)
|
||||
{
|
||||
@@ -391,7 +394,7 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
~logstream_buf() override
|
||||
~logstream_buf()
|
||||
{
|
||||
sync();
|
||||
}
|
||||
@@ -403,10 +406,6 @@ public:
|
||||
this->str("");
|
||||
return 0;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void
|
||||
write(T const*) = delete;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
@@ -414,11 +413,11 @@ public:
|
||||
template <class CharT, class Traits = std::char_traits<CharT>>
|
||||
class basic_logstream : public std::basic_ostream<CharT, Traits>
|
||||
{
|
||||
using char_type = CharT;
|
||||
using traits_type = Traits;
|
||||
using int_type = typename traits_type::int_type;
|
||||
using pos_type = typename traits_type::pos_type;
|
||||
using off_type = typename traits_type::off_type;
|
||||
typedef CharT char_type;
|
||||
typedef Traits traits_type;
|
||||
typedef typename traits_type::int_type int_type;
|
||||
typedef typename traits_type::pos_type pos_type;
|
||||
typedef typename traits_type::off_type off_type;
|
||||
|
||||
detail::logstream_buf<CharT, Traits> buf_;
|
||||
|
||||
|
||||
@@ -174,7 +174,7 @@ private:
|
||||
std::ostringstream mutable m_ostream;
|
||||
|
||||
public:
|
||||
Proxy(Map const& map, std::string key);
|
||||
Proxy(Map const& map, std::string const& key);
|
||||
Proxy(Proxy const& other);
|
||||
~Proxy();
|
||||
|
||||
@@ -315,7 +315,7 @@ private:
|
||||
List<Item> children_;
|
||||
|
||||
public:
|
||||
explicit Source(std::string name);
|
||||
explicit Source(std::string const& name);
|
||||
virtual ~Source();
|
||||
|
||||
Source(Source const&) = delete;
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
|
||||
#include <xrpl/beast/utility/Journal.h>
|
||||
|
||||
#include <utility>
|
||||
|
||||
namespace beast {
|
||||
|
||||
/** Wraps a Journal::Sink to prefix its output with a string. */
|
||||
@@ -19,8 +17,8 @@ private:
|
||||
std::string prefix_;
|
||||
|
||||
public:
|
||||
explicit WrappedSink(beast::Journal::Sink& sink, std::string prefix = "")
|
||||
: Sink(sink), sink_(sink), prefix_(std::move(prefix))
|
||||
explicit WrappedSink(beast::Journal::Sink& sink, std::string const& prefix = "")
|
||||
: Sink(sink), sink_(sink), prefix_(prefix)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,8 @@ signum(T const& t)
|
||||
return t.signum();
|
||||
}
|
||||
|
||||
namespace detail::zero_helper {
|
||||
namespace detail {
|
||||
namespace zero_helper {
|
||||
|
||||
// For argument dependent lookup to function properly, calls to signum must
|
||||
// be made from a namespace that does not include overloads of the function..
|
||||
@@ -49,7 +50,8 @@ call_signum(T const& t)
|
||||
return signum(t);
|
||||
}
|
||||
|
||||
} // namespace detail::zero_helper
|
||||
} // namespace zero_helper
|
||||
} // namespace detail
|
||||
|
||||
// Handle operators where T is on the left side using signum.
|
||||
|
||||
|
||||
@@ -9,8 +9,10 @@ template <bool IsConst, class T>
|
||||
struct maybe_const
|
||||
{
|
||||
explicit maybe_const() = default;
|
||||
using type = std::
|
||||
conditional_t<IsConst, typename std::remove_const<T>::type const, std::remove_const_t<T>>;
|
||||
using type = typename std::conditional<
|
||||
IsConst,
|
||||
typename std::remove_const<T>::type const,
|
||||
typename std::remove_const<T>::type>::type;
|
||||
};
|
||||
|
||||
/** Alias for omitting `typename`. */
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
#include <cstdint>
|
||||
#include <set>
|
||||
|
||||
namespace xrpl::cryptoconditions {
|
||||
namespace xrpl {
|
||||
namespace cryptoconditions {
|
||||
|
||||
enum class Type : std::uint8_t {
|
||||
preimageSha256 = 0,
|
||||
@@ -87,4 +88,6 @@ operator!=(Condition const& lhs, Condition const& rhs)
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
} // namespace xrpl::cryptoconditions
|
||||
} // namespace cryptoconditions
|
||||
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
#include <xrpl/basics/Slice.h>
|
||||
#include <xrpl/conditions/Condition.h>
|
||||
|
||||
namespace xrpl::cryptoconditions {
|
||||
namespace xrpl {
|
||||
namespace cryptoconditions {
|
||||
|
||||
struct Fulfillment
|
||||
{
|
||||
@@ -118,4 +119,5 @@ validate(Fulfillment const& f, Condition const& c, Slice m);
|
||||
bool
|
||||
validate(Fulfillment const& f, Condition const& c);
|
||||
|
||||
} // namespace xrpl::cryptoconditions
|
||||
} // namespace cryptoconditions
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -9,7 +9,8 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace xrpl::cryptoconditions {
|
||||
namespace xrpl {
|
||||
namespace cryptoconditions {
|
||||
|
||||
class PreimageSha256 final : public Fulfillment
|
||||
{
|
||||
@@ -126,4 +127,5 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace xrpl::cryptoconditions
|
||||
} // namespace cryptoconditions
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
|
||||
#include <system_error>
|
||||
|
||||
namespace xrpl::cryptoconditions {
|
||||
namespace xrpl {
|
||||
namespace cryptoconditions {
|
||||
|
||||
enum class error {
|
||||
generic = 1,
|
||||
@@ -27,7 +28,8 @@ enum class error {
|
||||
std::error_code
|
||||
make_error_code(error ev);
|
||||
|
||||
} // namespace xrpl::cryptoconditions
|
||||
} // namespace cryptoconditions
|
||||
} // namespace xrpl
|
||||
|
||||
namespace std {
|
||||
|
||||
|
||||
@@ -8,12 +8,15 @@
|
||||
|
||||
#include <limits>
|
||||
|
||||
namespace xrpl {
|
||||
namespace cryptoconditions {
|
||||
|
||||
// A collection of functions to decode binary blobs
|
||||
// encoded with X.690 Distinguished Encoding Rules.
|
||||
//
|
||||
// This is a very trivial decoder and only implements
|
||||
// the bare minimum needed to support PreimageSha256.
|
||||
namespace xrpl::cryptoconditions::der {
|
||||
namespace der {
|
||||
|
||||
// The preamble encapsulates the DER identifier and
|
||||
// length octets:
|
||||
@@ -201,4 +204,6 @@ parseInteger(Slice& s, std::size_t count, std::error_code& ec)
|
||||
return v;
|
||||
}
|
||||
|
||||
} // namespace xrpl::cryptoconditions::der
|
||||
} // namespace der
|
||||
} // namespace cryptoconditions
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -75,7 +75,7 @@ private:
|
||||
std::remove_reference_t<Closure> closure_;
|
||||
|
||||
static_assert(
|
||||
std::is_same_v<decltype(closure_(std::declval<Args_t>()...)), Ret_t>,
|
||||
std::is_same<decltype(closure_(std::declval<Args_t>()...)), Ret_t>::value,
|
||||
"Closure arguments don't match ClosureCounter Ret_t or Args_t");
|
||||
|
||||
public:
|
||||
@@ -86,7 +86,7 @@ private:
|
||||
++counter_;
|
||||
}
|
||||
|
||||
Substitute(Substitute&& rhs) noexcept(std::is_nothrow_move_constructible_v<Closure>)
|
||||
Substitute(Substitute&& rhs) noexcept(std::is_nothrow_move_constructible<Closure>::value)
|
||||
: counter_(rhs.counter_), closure_(std::move(rhs.closure_))
|
||||
{
|
||||
++counter_;
|
||||
|
||||
@@ -2,17 +2,19 @@
|
||||
|
||||
namespace xrpl {
|
||||
|
||||
/// Coroutine stack size (1.5 MB). Increased from 1 MB because
|
||||
/// ASAN-instrumented deep call stacks exceeded the original limit.
|
||||
constexpr std::size_t coroStackSize = 1536 * 1024;
|
||||
|
||||
template <class F>
|
||||
JobQueue::Coro::Coro(Coro_create_t, JobQueue& jq, JobType type, std::string const& name, F&& f)
|
||||
: jq_(jq)
|
||||
, type_(type)
|
||||
, name_(name)
|
||||
, coro_(
|
||||
// Stack size of 1MB wasn't sufficient for deep calls. ASAN tests flagged the issue. Hence
|
||||
// increasing the size to 1.5MB.
|
||||
boost::context::protected_fixedsize_stack(1536 * 1024),
|
||||
[this, fn = std::forward<F>(f)](
|
||||
boost::coroutines2::asymmetric_coroutine<void>::push_type& do_yield) {
|
||||
boost::context::protected_fixedsize_stack(coroStackSize),
|
||||
[this,
|
||||
fn = std::forward<F>(f)](boost::coroutines2::coroutine<void>::push_type& do_yield) {
|
||||
yield_ = &do_yield;
|
||||
yield();
|
||||
fn(shared_from_this());
|
||||
|
||||
@@ -109,7 +109,9 @@ private:
|
||||
class Entry : public CountedObject<Entry>
|
||||
{
|
||||
public:
|
||||
Entry() = default;
|
||||
Entry()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
addPeer(PeerShortID peer)
|
||||
|
||||
@@ -128,7 +128,7 @@ public:
|
||||
beast::Journal journal,
|
||||
Logs& logs,
|
||||
perf::PerfLog& perfLog);
|
||||
~JobQueue() override;
|
||||
~JobQueue();
|
||||
|
||||
/** Adds a job to the JobQueue.
|
||||
|
||||
@@ -141,7 +141,8 @@ public:
|
||||
*/
|
||||
template <
|
||||
typename JobHandler,
|
||||
typename = std::enable_if_t<std::is_same_v<decltype(std::declval<JobHandler&&>()()), void>>>
|
||||
typename =
|
||||
std::enable_if_t<std::is_same<decltype(std::declval<JobHandler&&>()()), void>::value>>
|
||||
bool
|
||||
addJob(JobType type, std::string const& name, JobHandler&& jobHandler)
|
||||
{
|
||||
|
||||
@@ -4,8 +4,6 @@
|
||||
#include <xrpl/beast/insight/Collector.h>
|
||||
#include <xrpl/core/JobTypeInfo.h>
|
||||
|
||||
#include <utility>
|
||||
|
||||
namespace xrpl {
|
||||
|
||||
struct JobTypeData
|
||||
@@ -35,9 +33,9 @@ public:
|
||||
|
||||
JobTypeData(
|
||||
JobTypeInfo const& info_,
|
||||
beast::insight::Collector::ptr collector,
|
||||
beast::insight::Collector::ptr const& collector,
|
||||
Logs& logs) noexcept
|
||||
: m_load(logs.journal("LoadMonitor")), m_collector(std::move(collector)), info(info_)
|
||||
: m_load(logs.journal("LoadMonitor")), m_collector(collector), info(info_)
|
||||
|
||||
{
|
||||
m_load.setTargetLatency(info.getAverageLatency(), info.getPeakLatency());
|
||||
|
||||
@@ -33,7 +33,8 @@ private:
|
||||
std::chrono::milliseconds avgLatency,
|
||||
std::chrono::milliseconds peakLatency) {
|
||||
XRPL_ASSERT(
|
||||
!m_map.contains(jt), "xrpl::JobTypes::JobTypes::add : unique job type input");
|
||||
m_map.find(jt) == m_map.end(),
|
||||
"xrpl::JobTypes::JobTypes::add : unique job type input");
|
||||
|
||||
[[maybe_unused]] auto const inserted =
|
||||
m_map
|
||||
|
||||
@@ -16,7 +16,7 @@ class LoadEvent
|
||||
{
|
||||
public:
|
||||
// VFALCO TODO remove the dependency on LoadMonitor. Is that possible?
|
||||
LoadEvent(LoadMonitor& monitor, std::string name, bool shouldStart);
|
||||
LoadEvent(LoadMonitor& monitor, std::string const& name, bool shouldStart);
|
||||
LoadEvent(LoadEvent const&) = delete;
|
||||
|
||||
~LoadEvent();
|
||||
|
||||
@@ -93,7 +93,7 @@ public:
|
||||
explicit Workers(
|
||||
Callback& callback,
|
||||
perf::PerfLog* perfLog,
|
||||
std::string threadNames = "Worker",
|
||||
std::string const& threadNames = "Worker",
|
||||
int numberOfThreads = static_cast<int>(std::thread::hardware_concurrency()));
|
||||
|
||||
~Workers();
|
||||
@@ -164,7 +164,7 @@ private:
|
||||
public beast::LockFreeStack<Worker, PausedTag>::Node
|
||||
{
|
||||
public:
|
||||
Worker(Workers& workers, std::string threadName, int const instance);
|
||||
Worker(Workers& workers, std::string const& threadName, int const instance);
|
||||
|
||||
~Worker();
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user