mirror of
https://github.com/XRPLF/rippled.git
synced 2026-04-29 15:37:57 +00:00
Compare commits
28 Commits
pratik/fix
...
develop
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
46b997b774 | ||
|
|
147da57348 | ||
|
|
3547112540 | ||
|
|
4dc923dcc5 | ||
|
|
158df5394c | ||
|
|
a6bd9251d2 | ||
|
|
9ae29612ea | ||
|
|
82abf2a849 | ||
|
|
7cfa5d4610 | ||
|
|
248cb29681 | ||
|
|
7a449edebb | ||
|
|
19da25812b | ||
|
|
7cd503859e | ||
|
|
b41cbb08c6 | ||
|
|
bd1b126230 | ||
|
|
1c6cdc653c | ||
|
|
4ab20770f7 | ||
|
|
2e307329f0 | ||
|
|
3429845c40 | ||
|
|
7c7c1894b9 | ||
|
|
45d4aacb53 | ||
|
|
ce3951bbb3 | ||
|
|
ab887f5049 | ||
|
|
ea023121f5 | ||
|
|
4b198cd5bb | ||
|
|
726f20c8f6 | ||
|
|
96643bb0fa | ||
|
|
e83818241a |
32
.clang-tidy
32
.clang-tidy
@@ -66,14 +66,14 @@ Checks: "-*,
|
|||||||
bugprone-terminating-continue,
|
bugprone-terminating-continue,
|
||||||
bugprone-throw-keyword-missing,
|
bugprone-throw-keyword-missing,
|
||||||
bugprone-too-small-loop-variable,
|
bugprone-too-small-loop-variable,
|
||||||
# bugprone-unchecked-optional-access, # see https://github.com/XRPLF/rippled/pull/6502
|
bugprone-unchecked-optional-access,
|
||||||
bugprone-undefined-memory-manipulation,
|
bugprone-undefined-memory-manipulation,
|
||||||
bugprone-undelegated-constructor,
|
bugprone-undelegated-constructor,
|
||||||
bugprone-unhandled-exception-at-new,
|
bugprone-unhandled-exception-at-new,
|
||||||
bugprone-unhandled-self-assignment,
|
bugprone-unhandled-self-assignment,
|
||||||
bugprone-unique-ptr-array-mismatch,
|
bugprone-unique-ptr-array-mismatch,
|
||||||
bugprone-unsafe-functions,
|
bugprone-unsafe-functions,
|
||||||
bugprone-use-after-move, # has issues
|
bugprone-use-after-move,
|
||||||
bugprone-unused-raii,
|
bugprone-unused-raii,
|
||||||
bugprone-unused-return-value,
|
bugprone-unused-return-value,
|
||||||
bugprone-unused-local-non-trivial-variable,
|
bugprone-unused-local-non-trivial-variable,
|
||||||
@@ -97,9 +97,22 @@ Checks: "-*,
|
|||||||
misc-throw-by-value-catch-by-reference,
|
misc-throw-by-value-catch-by-reference,
|
||||||
misc-unused-alias-decls,
|
misc-unused-alias-decls,
|
||||||
misc-unused-using-decls,
|
misc-unused-using-decls,
|
||||||
modernize-deprecated-headers,
|
modernize-concat-nested-namespaces,
|
||||||
modernize-make-shared,
|
modernize-make-shared,
|
||||||
modernize-make-unique,
|
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-nodiscard,
|
||||||
|
modernize-use-override,
|
||||||
|
modernize-use-ranges,
|
||||||
|
modernize-use-starts-ends-with,
|
||||||
|
modernize-use-std-numbers,
|
||||||
|
modernize-use-using,
|
||||||
|
modernize-deprecated-headers,
|
||||||
llvm-namespace-comment,
|
llvm-namespace-comment,
|
||||||
performance-faster-string-find,
|
performance-faster-string-find,
|
||||||
performance-for-range-copy,
|
performance-for-range-copy,
|
||||||
@@ -141,19 +154,6 @@ Checks: "-*,
|
|||||||
# readability-inconsistent-declaration-parameter-name, # in this codebase this check will break a lot of arg names
|
# 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-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
|
# 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:
|
CheckOptions:
|
||||||
|
|||||||
@@ -93,6 +93,7 @@ test.core > xrpl.basics
|
|||||||
test.core > xrpl.core
|
test.core > xrpl.core
|
||||||
test.core > xrpld.core
|
test.core > xrpld.core
|
||||||
test.core > xrpl.json
|
test.core > xrpl.json
|
||||||
|
test.core > xrpl.protocol
|
||||||
test.core > xrpl.rdb
|
test.core > xrpl.rdb
|
||||||
test.core > xrpl.server
|
test.core > xrpl.server
|
||||||
test.csf > xrpl.basics
|
test.csf > xrpl.basics
|
||||||
@@ -187,10 +188,16 @@ test.toplevel > xrpl.json
|
|||||||
test.unit_test > xrpl.basics
|
test.unit_test > xrpl.basics
|
||||||
test.unit_test > xrpl.protocol
|
test.unit_test > xrpl.protocol
|
||||||
tests.libxrpl > xrpl.basics
|
tests.libxrpl > xrpl.basics
|
||||||
|
tests.libxrpl > xrpl.core
|
||||||
tests.libxrpl > xrpl.json
|
tests.libxrpl > xrpl.json
|
||||||
|
tests.libxrpl > xrpl.ledger
|
||||||
tests.libxrpl > xrpl.net
|
tests.libxrpl > xrpl.net
|
||||||
|
tests.libxrpl > xrpl.nodestore
|
||||||
tests.libxrpl > xrpl.protocol
|
tests.libxrpl > xrpl.protocol
|
||||||
tests.libxrpl > xrpl.protocol_autogen
|
tests.libxrpl > xrpl.protocol_autogen
|
||||||
|
tests.libxrpl > xrpl.server
|
||||||
|
tests.libxrpl > xrpl.shamap
|
||||||
|
tests.libxrpl > xrpl.tx
|
||||||
xrpl.conditions > xrpl.basics
|
xrpl.conditions > xrpl.basics
|
||||||
xrpl.conditions > xrpl.protocol
|
xrpl.conditions > xrpl.protocol
|
||||||
xrpl.core > xrpl.basics
|
xrpl.core > xrpl.basics
|
||||||
|
|||||||
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`.
|
# On MacOS, ensure that GNU sed is installed and available as `gsed`.
|
||||||
SED_COMMAND=sed
|
SED_COMMAND=sed
|
||||||
if [[ "${OSTYPE}" == 'darwin'* ]]; then
|
if [[ "${OSTYPE}" == 'darwin'* ]]; then
|
||||||
if ! command -v gsed &> /dev/null; then
|
if ! command -v gsed &> /dev/null; then
|
||||||
echo "Error: gsed is not installed. Please install it using 'brew install gnu-sed'."
|
echo "Error: gsed is not installed. Please install it using 'brew install gnu-sed'."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
SED_COMMAND=gsed
|
SED_COMMAND=gsed
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# This script changes the binary name from `rippled` to `xrpld`, and reverses
|
# 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
|
SED_COMMAND=sed
|
||||||
HEAD_COMMAND=head
|
HEAD_COMMAND=head
|
||||||
if [[ "${OSTYPE}" == 'darwin'* ]]; then
|
if [[ "${OSTYPE}" == 'darwin'* ]]; then
|
||||||
if ! command -v gsed &> /dev/null; then
|
if ! command -v gsed &> /dev/null; then
|
||||||
echo "Error: gsed is not installed. Please install it using 'brew install gnu-sed'."
|
echo "Error: gsed is not installed. Please install it using 'brew install gnu-sed'."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
SED_COMMAND=gsed
|
SED_COMMAND=gsed
|
||||||
if ! command -v ghead &> /dev/null; then
|
if ! command -v ghead &> /dev/null; then
|
||||||
echo "Error: ghead is not installed. Please install it using 'brew install coreutils'."
|
echo "Error: ghead is not installed. Please install it using 'brew install coreutils'."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
HEAD_COMMAND=ghead
|
HEAD_COMMAND=ghead
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# This script renames CMake files from `RippleXXX.cmake` or `RippledXXX.cmake`
|
# 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 '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}"' - {} \;
|
find cmake -type f -name 'Ripple*.cmake' -exec bash -c 'mv "${1}" "${1/Ripple/Xrpl}"' - {} \;
|
||||||
if [ -e cmake/xrpl_add_test.cmake ]; then
|
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
|
fi
|
||||||
if [ -e include/xrpl/proto/ripple.proto ]; then
|
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
|
fi
|
||||||
|
|
||||||
# Rename inside the files.
|
# 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.
|
# 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
|
${SED_COMMAND} -i -E 's/xrpld(-example)?\.cfg/rippled\1.cfg/g' cmake/XrplInstall.cmake
|
||||||
if grep -q '"xrpld"' cmake/XrplCore.cmake; then
|
if grep -q '"xrpld"' cmake/XrplCore.cmake; then
|
||||||
# The script has been rerun, so just restore the name of the binary.
|
# The script has been rerun, so just restore the name of the binary.
|
||||||
${SED_COMMAND} -i 's/"xrpld"/"rippled"/' cmake/XrplCore.cmake
|
${SED_COMMAND} -i 's/"xrpld"/"rippled"/' cmake/XrplCore.cmake
|
||||||
elif ! grep -q '"rippled"' cmake/XrplCore.cmake; then
|
elif ! grep -q '"rippled"' cmake/XrplCore.cmake; then
|
||||||
${HEAD_COMMAND} -n -1 cmake/XrplCore.cmake > cmake.tmp
|
${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 ' # 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
|
echo ' set_target_properties(xrpld PROPERTIES OUTPUT_NAME "rippled")' >> cmake.tmp
|
||||||
tail -1 cmake/XrplCore.cmake >> cmake.tmp
|
tail -1 cmake/XrplCore.cmake >> cmake.tmp
|
||||||
mv cmake.tmp cmake/XrplCore.cmake
|
mv cmake.tmp cmake/XrplCore.cmake
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Restore the symlink from 'xrpld' to 'rippled'.
|
# 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`.
|
# On MacOS, ensure that GNU sed is installed and available as `gsed`.
|
||||||
SED_COMMAND=sed
|
SED_COMMAND=sed
|
||||||
if [[ "${OSTYPE}" == 'darwin'* ]]; then
|
if [[ "${OSTYPE}" == 'darwin'* ]]; then
|
||||||
if ! command -v gsed &> /dev/null; then
|
if ! command -v gsed &> /dev/null; then
|
||||||
echo "Error: gsed is not installed. Please install it using 'brew install gnu-sed'."
|
echo "Error: gsed is not installed. Please install it using 'brew install gnu-sed'."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
SED_COMMAND=gsed
|
SED_COMMAND=gsed
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# This script renames the config from `rippled.cfg` to `xrpld.cfg`, and updates
|
# 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.
|
# Add the xrpld.cfg to the .gitignore.
|
||||||
if ! grep -q 'xrpld.cfg' .gitignore; then
|
if ! grep -q 'xrpld.cfg' .gitignore; then
|
||||||
${SED_COMMAND} -i '/rippled.cfg/a\
|
${SED_COMMAND} -i '/rippled.cfg/a\
|
||||||
/xrpld.cfg' .gitignore
|
/xrpld.cfg' .gitignore
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Rename the files.
|
# Rename the files.
|
||||||
if [ -e rippled.cfg ]; then
|
if [ -e rippled.cfg ]; then
|
||||||
mv rippled.cfg xrpld.cfg
|
mv rippled.cfg xrpld.cfg
|
||||||
fi
|
fi
|
||||||
if [ -e cfg/rippled-example.cfg ]; then
|
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
|
fi
|
||||||
|
|
||||||
# Rename inside the files.
|
# Rename inside the files.
|
||||||
DIRECTORIES=("cfg" "cmake" "include" "src")
|
DIRECTORIES=("cfg" "cmake" "include" "src")
|
||||||
for DIRECTORY in "${DIRECTORIES[@]}"; do
|
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
|
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}"
|
echo "Processing file: ${FILE}"
|
||||||
${SED_COMMAND} -i -E 's/rippled(-example)?[ .]cfg/xrpld\1.cfg/g' "${FILE}"
|
${SED_COMMAND} -i -E 's/rippled(-example)?[ .]cfg/xrpld\1.cfg/g' "${FILE}"
|
||||||
${SED_COMMAND} -i 's/rippleConfig/xrpldConfig/g' "${FILE}"
|
${SED_COMMAND} -i 's/rippleConfig/xrpldConfig/g' "${FILE}"
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
${SED_COMMAND} -i 's/rippled/xrpld/g' cfg/xrpld-example.cfg
|
${SED_COMMAND} -i 's/rippled/xrpld/g' cfg/xrpld-example.cfg
|
||||||
${SED_COMMAND} -i 's/rippled/xrpld/g' src/test/core/Config_test.cpp
|
${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`.
|
# On MacOS, ensure that GNU sed is installed and available as `gsed`.
|
||||||
SED_COMMAND=sed
|
SED_COMMAND=sed
|
||||||
if [[ "${OSTYPE}" == 'darwin'* ]]; then
|
if [[ "${OSTYPE}" == 'darwin'* ]]; then
|
||||||
if ! command -v gsed &> /dev/null; then
|
if ! command -v gsed &> /dev/null; then
|
||||||
echo "Error: gsed is not installed. Please install it using 'brew install gnu-sed'."
|
echo "Error: gsed is not installed. Please install it using 'brew install gnu-sed'."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
SED_COMMAND=gsed
|
SED_COMMAND=gsed
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# This script removes superfluous copyright notices in source and header files
|
# 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.
|
# Process the include/ and src/ directories.
|
||||||
DIRECTORIES=("include" "src")
|
DIRECTORIES=("include" "src")
|
||||||
for DIRECTORY in "${DIRECTORIES[@]}"; do
|
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
|
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}"
|
echo "Processing file: ${FILE}"
|
||||||
# Handle the cases where the copyright notice is enclosed in /* ... */
|
# Handle the cases where the copyright notice is enclosed in /* ... */
|
||||||
# and usually surrounded by //---- and //======.
|
# and usually surrounded by //---- and //======.
|
||||||
${SED_COMMAND} -z -i -E 's@^//-------+\n+@@' "${FILE}"
|
${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@^.*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}"
|
${SED_COMMAND} -z -i -E 's@^//=======+\n+@@' "${FILE}"
|
||||||
|
|
||||||
# Handle the cases where the copyright notice is commented out with //.
|
# 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
|
${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
|
||||||
done
|
done
|
||||||
|
|
||||||
# Restore copyright notices that were removed from specific files, without
|
# Restore copyright notices that were removed from specific files, without
|
||||||
# restoring the verbiage that is already present in LICENSE.md. Ensure that if
|
# restoring the verbiage that is already present in LICENSE.md. Ensure that if
|
||||||
# the script is run multiple times, duplicate notices are not added.
|
# the script is run multiple times, duplicate notices are not added.
|
||||||
if ! grep -q 'Raw Material Software' include/xrpl/beast/core/CurrentThreadName.h; then
|
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
|
fi
|
||||||
if ! grep -q 'Dev Null' src/test/app/NetworkID_test.cpp; then
|
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
|
fi
|
||||||
if ! grep -q 'Dev Null' src/test/app/tx/apply_test.cpp; then
|
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
|
fi
|
||||||
if ! grep -q 'Dev Null' src/test/rpc/ManifestRPC_test.cpp; then
|
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
|
fi
|
||||||
if ! grep -q 'Dev Null' src/test/rpc/ValidatorInfo_test.cpp; then
|
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
|
fi
|
||||||
if ! grep -q 'Dev Null' src/xrpld/rpc/handlers/server_info/Manifest.cpp; then
|
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
|
fi
|
||||||
if ! grep -q 'Dev Null' src/xrpld/rpc/handlers/admin/status/ValidatorInfo.cpp; then
|
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
|
fi
|
||||||
if ! grep -q 'Bougalis' include/xrpl/basics/SlabAllocator.h; then
|
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
|
fi
|
||||||
if ! grep -q 'Bougalis' include/xrpl/basics/spinlock.h; then
|
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
|
fi
|
||||||
if ! grep -q 'Bougalis' include/xrpl/basics/tagged_integer.h; then
|
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
|
fi
|
||||||
if ! grep -q 'Ritchford' include/xrpl/beast/utility/Zero.h; then
|
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
|
fi
|
||||||
|
|
||||||
# Restore newlines and tabs in string literals in the affected file.
|
# 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`.
|
# On MacOS, ensure that GNU sed is installed and available as `gsed`.
|
||||||
SED_COMMAND=sed
|
SED_COMMAND=sed
|
||||||
if [[ "${OSTYPE}" == 'darwin'* ]]; then
|
if [[ "${OSTYPE}" == 'darwin'* ]]; then
|
||||||
if ! command -v gsed &> /dev/null; then
|
if ! command -v gsed &> /dev/null; then
|
||||||
echo "Error: gsed is not installed. Please install it using 'brew install gnu-sed'."
|
echo "Error: gsed is not installed. Please install it using 'brew install gnu-sed'."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
SED_COMMAND=gsed
|
SED_COMMAND=gsed
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# This script renames definitions, such as include guards, in this project.
|
# 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`.
|
# On MacOS, ensure that GNU sed is installed and available as `gsed`.
|
||||||
SED_COMMAND=sed
|
SED_COMMAND=sed
|
||||||
if [[ "${OSTYPE}" == 'darwin'* ]]; then
|
if [[ "${OSTYPE}" == 'darwin'* ]]; then
|
||||||
if ! command -v gsed &> /dev/null; then
|
if ! command -v gsed &> /dev/null; then
|
||||||
echo "Error: gsed is not installed. Please install it using 'brew install gnu-sed'."
|
echo "Error: gsed is not installed. Please install it using 'brew install gnu-sed'."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
SED_COMMAND=gsed
|
SED_COMMAND=gsed
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# This script renames all remaining references to `ripple` and `rippled` to
|
# 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
|
find "${DIRECTORY}" -type f \( -name "*.h" -o -name "*.hpp" -o -name "*.ipp" \) | while read -r FILE; do
|
||||||
echo "Processing file: ${FILE}"
|
echo "Processing file: ${FILE}"
|
||||||
if grep -q "#ifndef XRPL_" "${FILE}"; then
|
if grep -q "#ifndef XRPL_" "${FILE}"; then
|
||||||
echo "Please replace all include guards by #pragma once."
|
echo "Please replace all include guards by #pragma once."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
echo "Checking complete."
|
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`.
|
# On MacOS, ensure that GNU sed is installed and available as `gsed`.
|
||||||
SED_COMMAND=sed
|
SED_COMMAND=sed
|
||||||
if [[ "${OSTYPE}" == 'darwin'* ]]; then
|
if [[ "${OSTYPE}" == 'darwin'* ]]; then
|
||||||
if ! command -v gsed &> /dev/null; then
|
if ! command -v gsed &> /dev/null; then
|
||||||
echo "Error: gsed is not installed. Please install it using 'brew install gnu-sed'."
|
echo "Error: gsed is not installed. Please install it using 'brew install gnu-sed'."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
SED_COMMAND=gsed
|
SED_COMMAND=gsed
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# This script renames the `ripple` namespace to `xrpl` in this project.
|
# This script renames the `ripple` namespace to `xrpl` in this project.
|
||||||
@@ -35,15 +35,15 @@ pushd "${DIRECTORY}"
|
|||||||
|
|
||||||
DIRECTORIES=("include" "src" "tests")
|
DIRECTORIES=("include" "src" "tests")
|
||||||
for DIRECTORY in "${DIRECTORIES[@]}"; do
|
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
|
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}"
|
echo "Processing file: ${FILE}"
|
||||||
${SED_COMMAND} -i 's/namespace ripple/namespace xrpl/g' "${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 '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}"
|
${SED_COMMAND} -i -E 's/(BEAST_DEFINE_TESTSUITE.+)ripple(.+)/\1xrpl\2/g' "${FILE}"
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
|
|
||||||
# Special case for NuDBFactory that has ripple twice in the test suite name.
|
# Special case for NuDBFactory that has ripple twice in the test suite name.
|
||||||
|
|||||||
51
.github/scripts/strategy-matrix/generate.py
vendored
51
.github/scripts/strategy-matrix/generate.py
vendored
@@ -51,20 +51,21 @@ def generate_strategy_matrix(all: bool, config: Config) -> list:
|
|||||||
# Only generate a subset of configurations in PRs.
|
# Only generate a subset of configurations in PRs.
|
||||||
if not all:
|
if not all:
|
||||||
# Debian:
|
# Debian:
|
||||||
# - Bookworm using GCC 13: Release on linux/amd64, set the reference
|
# - Bookworm using GCC 13: Debug on linux/amd64, set the reference
|
||||||
# fee to 500.
|
# fee to 500 and enable code coverage (which will be done below).
|
||||||
# - Bookworm using GCC 15: Debug on linux/amd64, enable code
|
# - Bookworm using GCC 15: Debug on linux/amd64, enable Address and
|
||||||
# coverage (which will be done below).
|
# UB sanitizers (which will be done below).
|
||||||
# - Bookworm using Clang 16: Debug on linux/amd64, enable voidstar.
|
# - Bookworm using Clang 16: Debug on linux/amd64, enable voidstar.
|
||||||
# - Bookworm using Clang 17: Release on linux/amd64, set the
|
# - Bookworm using Clang 17: Release on linux/amd64, set the
|
||||||
# reference fee to 1000.
|
# reference fee to 1000.
|
||||||
# - Bookworm using Clang 20: Debug on linux/amd64.
|
# - Bookworm using Clang 20: Debug on linux/amd64, enable Address
|
||||||
|
# and UB sanitizers (which will be done below).
|
||||||
if os["distro_name"] == "debian":
|
if os["distro_name"] == "debian":
|
||||||
skip = True
|
skip = True
|
||||||
if os["distro_version"] == "bookworm":
|
if os["distro_version"] == "bookworm":
|
||||||
if (
|
if (
|
||||||
f"{os['compiler_name']}-{os['compiler_version']}" == "gcc-13"
|
f"{os['compiler_name']}-{os['compiler_version']}" == "gcc-13"
|
||||||
and build_type == "Release"
|
and build_type == "Debug"
|
||||||
and architecture["platform"] == "linux/amd64"
|
and architecture["platform"] == "linux/amd64"
|
||||||
):
|
):
|
||||||
cmake_args = f"-DUNIT_TEST_REFERENCE_FEE=500 {cmake_args}"
|
cmake_args = f"-DUNIT_TEST_REFERENCE_FEE=500 {cmake_args}"
|
||||||
@@ -193,11 +194,11 @@ def generate_strategy_matrix(all: bool, config: Config) -> list:
|
|||||||
):
|
):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Enable code coverage for Debian Bookworm using GCC 15 in Debug on
|
# Enable code coverage for Debian Bookworm using GCC 13 in Debug on
|
||||||
# linux/amd64
|
# linux/amd64.
|
||||||
if (
|
if (
|
||||||
f"{os['distro_name']}-{os['distro_version']}" == "debian-bookworm"
|
f"{os['distro_name']}-{os['distro_version']}" == "debian-bookworm"
|
||||||
and f"{os['compiler_name']}-{os['compiler_version']}" == "gcc-15"
|
and f"{os['compiler_name']}-{os['compiler_version']}" == "gcc-13"
|
||||||
and build_type == "Debug"
|
and build_type == "Debug"
|
||||||
and architecture["platform"] == "linux/amd64"
|
and architecture["platform"] == "linux/amd64"
|
||||||
):
|
):
|
||||||
@@ -234,23 +235,39 @@ def generate_strategy_matrix(all: bool, config: Config) -> list:
|
|||||||
# Add the configuration to the list, with the most unique fields first,
|
# Add the configuration to the list, with the most unique fields first,
|
||||||
# so that they are easier to identify in the GitHub Actions UI, as long
|
# so that they are easier to identify in the GitHub Actions UI, as long
|
||||||
# names get truncated.
|
# names get truncated.
|
||||||
# Add Address and Thread (both coupled with UB) sanitizers for specific bookworm distros.
|
# Add Address and UB sanitizers as separate configurations for specific
|
||||||
|
# bookworm distros. Thread sanitizer is currently disabled (see below).
|
||||||
# GCC-Asan xrpld-embedded tests are failing because of https://github.com/google/sanitizers/issues/856
|
# GCC-Asan xrpld-embedded tests are failing because of https://github.com/google/sanitizers/issues/856
|
||||||
if (
|
if os[
|
||||||
os["distro_version"] == "bookworm"
|
"distro_version"
|
||||||
and f"{os['compiler_name']}-{os['compiler_version']}" == "clang-20"
|
] == "bookworm" and f"{os['compiler_name']}-{os['compiler_version']}" in [
|
||||||
):
|
"gcc-15",
|
||||||
# Add ASAN + UBSAN configuration.
|
"clang-20",
|
||||||
|
]:
|
||||||
|
# Add ASAN configuration.
|
||||||
configurations.append(
|
configurations.append(
|
||||||
{
|
{
|
||||||
"config_name": config_name + "-asan-ubsan",
|
"config_name": config_name + "-asan",
|
||||||
"cmake_args": cmake_args,
|
"cmake_args": cmake_args,
|
||||||
"cmake_target": cmake_target,
|
"cmake_target": cmake_target,
|
||||||
"build_only": build_only,
|
"build_only": build_only,
|
||||||
"build_type": build_type,
|
"build_type": build_type,
|
||||||
"os": os,
|
"os": os,
|
||||||
"architecture": architecture,
|
"architecture": architecture,
|
||||||
"sanitizers": "address,undefinedbehavior",
|
"sanitizers": "address",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
# Add UBSAN configuration.
|
||||||
|
configurations.append(
|
||||||
|
{
|
||||||
|
"config_name": config_name + "-ubsan",
|
||||||
|
"cmake_args": cmake_args,
|
||||||
|
"cmake_target": cmake_target,
|
||||||
|
"build_only": build_only,
|
||||||
|
"build_type": build_type,
|
||||||
|
"os": os,
|
||||||
|
"architecture": architecture,
|
||||||
|
"sanitizers": "undefinedbehavior",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
# TSAN is deactivated due to seg faults with latest compilers.
|
# TSAN is deactivated due to seg faults with latest compilers.
|
||||||
|
|||||||
16
.github/workflows/reusable-build-test-config.yml
vendored
16
.github/workflows/reusable-build-test-config.yml
vendored
@@ -210,6 +210,22 @@ jobs:
|
|||||||
retention-days: 3
|
retention-days: 3
|
||||||
if-no-files-found: error
|
if-no-files-found: error
|
||||||
|
|
||||||
|
- name: Export server definitions
|
||||||
|
if: ${{ runner.os != 'Windows' && !inputs.build_only && env.VOIDSTAR_ENABLED != 'true' }}
|
||||||
|
working-directory: ${{ env.BUILD_DIR }}
|
||||||
|
run: |
|
||||||
|
set -o pipefail
|
||||||
|
./xrpld --definitions | python3 -m json.tool > server_definitions.json
|
||||||
|
|
||||||
|
- name: Upload server definitions
|
||||||
|
if: ${{ github.event.repository.visibility == 'public' && inputs.config_name == 'debian-bookworm-gcc-13-amd64-release' }}
|
||||||
|
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
||||||
|
with:
|
||||||
|
name: server-definitions
|
||||||
|
path: ${{ env.BUILD_DIR }}/server_definitions.json
|
||||||
|
retention-days: 3
|
||||||
|
if-no-files-found: error
|
||||||
|
|
||||||
- name: Check linking (Linux)
|
- name: Check linking (Linux)
|
||||||
if: ${{ runner.os == 'Linux' && env.SANITIZERS_ENABLED == 'false' }}
|
if: ${{ runner.os == 'Linux' && env.SANITIZERS_ENABLED == 'false' }}
|
||||||
working-directory: ${{ env.BUILD_DIR }}
|
working-directory: ${{ env.BUILD_DIR }}
|
||||||
|
|||||||
19
.github/workflows/reusable-clang-tidy-files.yml
vendored
19
.github/workflows/reusable-clang-tidy-files.yml
vendored
@@ -80,7 +80,7 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
TARGETS: ${{ inputs.files != '' && inputs.files || 'src tests' }}
|
TARGETS: ${{ inputs.files != '' && inputs.files || 'src tests' }}
|
||||||
run: |
|
run: |
|
||||||
run-clang-tidy -j ${{ steps.nproc.outputs.nproc }} -p "${BUILD_DIR}" -quiet -allow-no-checks ${TARGETS} 2>&1 | tee clang-tidy-output.txt
|
run-clang-tidy -j ${{ steps.nproc.outputs.nproc }} -p "${BUILD_DIR}" -quiet -fix -allow-no-checks ${TARGETS} 2>&1 | tee clang-tidy-output.txt
|
||||||
|
|
||||||
- name: Upload clang-tidy output
|
- name: Upload clang-tidy output
|
||||||
if: ${{ github.event.repository.visibility == 'public' && steps.run_clang_tidy.outcome != 'success' }}
|
if: ${{ github.event.repository.visibility == 'public' && steps.run_clang_tidy.outcome != 'success' }}
|
||||||
@@ -90,8 +90,21 @@ jobs:
|
|||||||
path: clang-tidy-output.txt
|
path: clang-tidy-output.txt
|
||||||
retention-days: 30
|
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
|
- 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
|
id: create_issue
|
||||||
shell: bash
|
shell: bash
|
||||||
env:
|
env:
|
||||||
@@ -156,7 +169,7 @@ jobs:
|
|||||||
rm -f create_issue.log issue.md clang-tidy-output.txt
|
rm -f create_issue.log issue.md clang-tidy-output.txt
|
||||||
|
|
||||||
- name: Fail the workflow if clang-tidy failed
|
- name: Fail the workflow if clang-tidy failed
|
||||||
if: steps.run_clang_tidy.outcome != 'success'
|
if: ${{ steps.run_clang_tidy.outcome != 'success' }}
|
||||||
run: |
|
run: |
|
||||||
echo "Clang-tidy check failed!"
|
echo "Clang-tidy check failed!"
|
||||||
exit 1
|
exit 1
|
||||||
|
|||||||
@@ -20,6 +20,22 @@ repos:
|
|||||||
- id: check-merge-conflict
|
- id: check-merge-conflict
|
||||||
args: [--assume-in-merge]
|
args: [--assume-in-merge]
|
||||||
|
|
||||||
|
- 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: fix-include-style
|
||||||
|
name: fix include style
|
||||||
|
entry: ./bin/pre-commit/fix_include_style.py
|
||||||
|
language: python
|
||||||
|
types_or: [c++, c]
|
||||||
|
exclude: ^include/xrpl/protocol_autogen/(transactions|ledger_entries)/
|
||||||
|
|
||||||
- repo: https://github.com/pre-commit/mirrors-clang-format
|
- repo: https://github.com/pre-commit/mirrors-clang-format
|
||||||
rev: cd481d7b0bfb5c7b3090c21846317f9a8262e891 # frozen: v22.1.0
|
rev: cd481d7b0bfb5c7b3090c21846317f9a8262e891 # frozen: v22.1.0
|
||||||
hooks:
|
hooks:
|
||||||
@@ -44,6 +60,12 @@ repos:
|
|||||||
hooks:
|
hooks:
|
||||||
- id: black
|
- 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
|
- repo: https://github.com/streetsidesoftware/cspell-cli
|
||||||
rev: a42085ade523f591dca134379a595e7859986445 # frozen: v9.7.0
|
rev: a42085ade523f591dca134379a595e7859986445 # frozen: v9.7.0
|
||||||
hooks:
|
hooks:
|
||||||
|
|||||||
@@ -267,6 +267,26 @@ 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.
|
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:
|
Then run clang-tidy on your local changes:
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|||||||
113
SECURITY.md
113
SECURITY.md
@@ -22,117 +22,10 @@ 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.
|
- 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.
|
- 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
|
## 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 [`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 [`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)).
|
||||||
|
|
||||||
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:
|
This program allows us to recognize and reward individuals or groups that identify and report bugs.
|
||||||
|
|
||||||
1. **In scope**. Only bugs in software under the scope of the program qualify. Currently, that means `xrpld`, `xrpl.js`, `xrpl-py`, `xrpl4j`.
|
We have partnered with Bugcrowd to manage this program. It is a private program, and security researchers can participate based on invitation. If you need access to the program, please email bugs@ripple.com with your Bugcrowd handle or Bugcrowd registered email, and we will get you added to the program. Once you have been added, please submit vulnerability reports through Bugcrowd, not by email. The detailed bug bounty policy is available on the Bugcrowd website.
|
||||||
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,14 +1,13 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
if [[ $# -ne 1 || "$1" == "--help" || "$1" == "-h" ]]
|
if [[ $# -ne 1 || "$1" == "--help" || "$1" == "-h" ]]; then
|
||||||
then
|
name=$( basename $0 )
|
||||||
name=$( basename $0 )
|
cat <<- USAGE
|
||||||
cat <<- USAGE
|
Usage: $name <username>
|
||||||
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
|
USAGE
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Create upstream remotes based on origin
|
# Create upstream remotes based on origin
|
||||||
@@ -16,10 +15,9 @@ shift
|
|||||||
user="$1"
|
user="$1"
|
||||||
# Get the origin URL. Expect it be an SSH-style URL
|
# Get the origin URL. Expect it be an SSH-style URL
|
||||||
origin=$( git remote get-url origin )
|
origin=$( git remote get-url origin )
|
||||||
if [[ "${origin}" == "" ]]
|
if [[ "${origin}" == "" ]]; then
|
||||||
then
|
echo Invalid origin remote >&2
|
||||||
echo Invalid origin remote >&2
|
exit 1
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
# echo "Origin: ${origin}"
|
# echo "Origin: ${origin}"
|
||||||
# Parse the origin
|
# Parse the origin
|
||||||
@@ -30,11 +28,9 @@ IFS='@' read sshuser server <<< "${remote}"
|
|||||||
# echo "SSHUser: ${sshuser}, Server: ${server}"
|
# echo "SSHUser: ${sshuser}, Server: ${server}"
|
||||||
IFS='/' read originuser repo <<< "${originpath}"
|
IFS='/' read originuser repo <<< "${originpath}"
|
||||||
# echo "Originuser: ${originuser}, Repo: ${repo}"
|
# echo "Originuser: ${originuser}, Repo: ${repo}"
|
||||||
if [[ "${sshuser}" == "" || "${server}" == "" || "${originuser}" == ""
|
if [[ "${sshuser}" == "" || "${server}" == "" || "${originuser}" == "" || "${repo}" == "" ]]; then
|
||||||
|| "${repo}" == "" ]]
|
echo "Can't parse origin URL: ${origin}" >&2
|
||||||
then
|
exit 1
|
||||||
echo "Can't parse origin URL: ${origin}" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
upstream="https://${server}/${user}/${repo}"
|
upstream="https://${server}/${user}/${repo}"
|
||||||
upstreampush="${remote}:${user}/${repo}"
|
upstreampush="${remote}:${user}/${repo}"
|
||||||
@@ -42,42 +38,34 @@ upstreamgroup="upstream upstream-push"
|
|||||||
current=$( git remote get-url upstream 2>/dev/null )
|
current=$( git remote get-url upstream 2>/dev/null )
|
||||||
currentpush=$( git remote get-url upstream-push 2>/dev/null )
|
currentpush=$( git remote get-url upstream-push 2>/dev/null )
|
||||||
currentgroup=$( git config remotes.upstreams )
|
currentgroup=$( git config remotes.upstreams )
|
||||||
if [[ "${current}" == "${upstream}" ]]
|
if [[ "${current}" == "${upstream}" ]]; then
|
||||||
then
|
echo "Upstream already set up correctly. Skip"
|
||||||
echo "Upstream already set up correctly. Skip"
|
elif [[ -n "${current}" && "${current}" != "${upstream}" && "${current}" != "${upstreampush}" ]]; then
|
||||||
elif [[ -n "${current}" && "${current}" != "${upstream}" &&
|
echo "Upstream already set up as: ${current}. Skip"
|
||||||
"${current}" != "${upstreampush}" ]]
|
|
||||||
then
|
|
||||||
echo "Upstream already set up as: ${current}. Skip"
|
|
||||||
else
|
else
|
||||||
if [[ "${current}" == "${upstreampush}" ]]
|
if [[ "${current}" == "${upstreampush}" ]]; then
|
||||||
then
|
echo "Upstream set to dangerous push URL. Update."
|
||||||
echo "Upstream set to dangerous push URL. Update."
|
_run git remote rename upstream upstream-push || \
|
||||||
_run git remote rename upstream upstream-push || \
|
_run git remote remove upstream
|
||||||
_run git remote remove upstream
|
currentpush=$( git remote get-url upstream-push 2>/dev/null )
|
||||||
currentpush=$( git remote get-url upstream-push 2>/dev/null )
|
fi
|
||||||
fi
|
_run git remote add upstream "${upstream}"
|
||||||
_run git remote add upstream "${upstream}"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "${currentpush}" == "${upstreampush}" ]]
|
if [[ "${currentpush}" == "${upstreampush}" ]]; then
|
||||||
then
|
echo "upstream-push already set up correctly. Skip"
|
||||||
echo "upstream-push already set up correctly. Skip"
|
elif [[ -n "${currentpush}" && "${currentpush}" != "${upstreampush}" ]]; then
|
||||||
elif [[ -n "${currentpush}" && "${currentpush}" != "${upstreampush}" ]]
|
echo "upstream-push already set up as: ${currentpush}. Skip"
|
||||||
then
|
|
||||||
echo "upstream-push already set up as: ${currentpush}. Skip"
|
|
||||||
else
|
else
|
||||||
_run git remote add upstream-push "${upstreampush}"
|
_run git remote add upstream-push "${upstreampush}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "${currentgroup}" == "${upstreamgroup}" ]]
|
if [[ "${currentgroup}" == "${upstreamgroup}" ]]; then
|
||||||
then
|
echo "Upstreams group already set up correctly. Skip"
|
||||||
echo "Upstreams group already set up correctly. Skip"
|
elif [[ -n "${currentgroup}" && "${currentgroup}" != "${upstreamgroup}" ]]; then
|
||||||
elif [[ -n "${currentgroup}" && "${currentgroup}" != "${upstreamgroup}" ]]
|
echo "Upstreams group already set up as: ${currentgroup}. Skip"
|
||||||
then
|
|
||||||
echo "Upstreams group already set up as: ${currentgroup}. Skip"
|
|
||||||
else
|
else
|
||||||
_run git config --add remotes.upstreams "${upstreamgroup}"
|
_run git config --add remotes.upstreams "${upstreamgroup}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
_run git fetch --jobs=$(nproc) upstreams
|
_run git fetch --jobs=$(nproc) upstreams
|
||||||
|
|||||||
@@ -1,17 +1,16 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
if [[ $# -lt 3 || "$1" == "--help" || "$1" = "-h" ]]
|
if [[ $# -lt 3 || "$1" == "--help" || "$1" = "-h" ]]; then
|
||||||
then
|
name=$( basename $0 )
|
||||||
name=$( basename $0 )
|
cat <<- USAGE
|
||||||
cat <<- USAGE
|
Usage: $name workbranch base/branch user/branch [user/branch [...]]
|
||||||
Usage: $name workbranch base/branch user/branch [user/branch [...]]
|
|
||||||
|
|
||||||
* workbranch will be created locally from base/branch
|
* workbranch will be created locally from base/branch
|
||||||
* base/branch and user/branch may be specified as user:branch to allow
|
* base/branch and user/branch may be specified as user:branch to allow
|
||||||
easy copying from Github PRs
|
easy copying from Github PRs
|
||||||
* Remotes for each user must already be set up
|
* Remotes for each user must already be set up
|
||||||
USAGE
|
USAGE
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
work="$1"
|
work="$1"
|
||||||
@@ -24,9 +23,8 @@ unset branches[0]
|
|||||||
set -e
|
set -e
|
||||||
|
|
||||||
users=()
|
users=()
|
||||||
for b in "${branches[@]}"
|
for b in "${branches[@]}"; do
|
||||||
do
|
users+=( $( echo $b | cut -d/ -f1 ) )
|
||||||
users+=( $( echo $b | cut -d/ -f1 ) )
|
|
||||||
done
|
done
|
||||||
|
|
||||||
users=( $( printf '%s\n' "${users[@]}" | sort -u ) )
|
users=( $( printf '%s\n' "${users[@]}" | sort -u ) )
|
||||||
@@ -34,10 +32,9 @@ users=( $( printf '%s\n' "${users[@]}" | sort -u ) )
|
|||||||
git fetch --multiple upstreams "${users[@]}"
|
git fetch --multiple upstreams "${users[@]}"
|
||||||
git checkout -B "$work" --no-track "$base"
|
git checkout -B "$work" --no-track "$base"
|
||||||
|
|
||||||
for b in "${branches[@]}"
|
for b in "${branches[@]}"; do
|
||||||
do
|
git merge --squash "${b}"
|
||||||
git merge --squash "${b}"
|
git commit -S # Use the commit message provided on the PR
|
||||||
git commit -S # Use the commit message provided on the PR
|
|
||||||
done
|
done
|
||||||
|
|
||||||
# Make sure the commits look right
|
# Make sure the commits look right
|
||||||
@@ -47,13 +44,11 @@ parts=( $( echo $base | sed "s/\// /" ) )
|
|||||||
repo="${parts[0]}"
|
repo="${parts[0]}"
|
||||||
b="${parts[1]}"
|
b="${parts[1]}"
|
||||||
push=$repo
|
push=$repo
|
||||||
if [[ "$push" == "upstream" ]]
|
if [[ "$push" == "upstream" ]]; then
|
||||||
then
|
push="upstream-push"
|
||||||
push="upstream-push"
|
|
||||||
fi
|
fi
|
||||||
if [[ "$repo" == "upstream" ]]
|
if [[ "$repo" == "upstream" ]]; then
|
||||||
then
|
repo="upstreams"
|
||||||
repo="upstreams"
|
|
||||||
fi
|
fi
|
||||||
cat << PUSH
|
cat << PUSH
|
||||||
|
|
||||||
|
|||||||
@@ -1,17 +1,16 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
if [[ $# -ne 3 || "$1" == "--help" || "$1" = "-h" ]]
|
if [[ $# -ne 3 || "$1" == "--help" || "$1" = "-h" ]]; then
|
||||||
then
|
name=$( basename $0 )
|
||||||
name=$( basename $0 )
|
cat <<- USAGE
|
||||||
cat <<- USAGE
|
Usage: $name workbranch base/branch version
|
||||||
Usage: $name workbranch base/branch version
|
|
||||||
|
|
||||||
* workbranch will be created locally from base/branch. If it exists,
|
* workbranch will be created locally from base/branch. If it exists,
|
||||||
it will be reused, so make sure you don't overwrite any work.
|
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
|
* base/branch may be specified as user:branch to allow easy copying
|
||||||
from Github PRs.
|
from Github PRs.
|
||||||
USAGE
|
USAGE
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
work="$1"
|
work="$1"
|
||||||
@@ -30,10 +29,9 @@ git fetch upstreams
|
|||||||
git checkout -B "${work}" --no-track "${base}"
|
git checkout -B "${work}" --no-track "${base}"
|
||||||
|
|
||||||
push=$( git rev-parse --abbrev-ref --symbolic-full-name '@{push}' \
|
push=$( git rev-parse --abbrev-ref --symbolic-full-name '@{push}' \
|
||||||
2>/dev/null ) || true
|
2>/dev/null ) || true
|
||||||
if [[ "${push}" != "" ]]
|
if [[ "${push}" != "" ]]; then
|
||||||
then
|
echo "Warning: ${push} may already exist."
|
||||||
echo "Warning: ${push} may already exist."
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
build=$( find -name BuildInfo.cpp )
|
build=$( find -name BuildInfo.cpp )
|
||||||
|
|||||||
206
bin/pre-commit/clang_tidy_check.py
Executable file
206
bin/pre-commit/clang_tidy_check.py
Executable file
@@ -0,0 +1,206 @@
|
|||||||
|
#!/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())
|
||||||
37
bin/pre-commit/fix_include_style.py
Executable file
37
bin/pre-commit/fix_include_style.py
Executable file
@@ -0,0 +1,37 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
"""
|
||||||
|
Converts quoted includes (#include "...") to angle-bracket includes
|
||||||
|
(#include <...>), which is the required style in this project.
|
||||||
|
|
||||||
|
Usage: ./bin/pre-commit/fix_include_style.py <file1> <file2> ...
|
||||||
|
"""
|
||||||
|
|
||||||
|
import re
|
||||||
|
import sys
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
PATTERN = re.compile(r'^(\s*#include\s*)"([^"]+)"', re.MULTILINE)
|
||||||
|
|
||||||
|
|
||||||
|
def fix_includes(path: Path) -> bool:
|
||||||
|
original = path.read_text(encoding="utf-8")
|
||||||
|
fixed = PATTERN.sub(r"\1<\2>", original)
|
||||||
|
if fixed != original:
|
||||||
|
path.write_text(fixed, encoding="utf-8")
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
def main() -> int:
|
||||||
|
files = [Path(f) for f in sys.argv[1:]]
|
||||||
|
success = True
|
||||||
|
|
||||||
|
for path in files:
|
||||||
|
success &= fix_includes(path)
|
||||||
|
|
||||||
|
return 0 if success else 1
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
sys.exit(main())
|
||||||
@@ -1416,6 +1416,12 @@
|
|||||||
# in this section to a comma-separated list of the addresses
|
# in this section to a comma-separated list of the addresses
|
||||||
# of your Clio servers, in order to bypass xrpld's rate limiting.
|
# 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
|
# This port is commented out but can be enabled by removing
|
||||||
# the '#' from each corresponding line including the entry under [server]
|
# the '#' from each corresponding line including the entry under [server]
|
||||||
#
|
#
|
||||||
@@ -1465,11 +1471,74 @@ admin = 127.0.0.1
|
|||||||
protocol = ws
|
protocol = ws
|
||||||
send_queue_limit = 500
|
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_grpc]
|
||||||
port = 50051
|
port = 50051
|
||||||
ip = 127.0.0.1
|
ip = 127.0.0.1
|
||||||
secure_gateway = 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_ws_public]
|
||||||
#port = 6005
|
#port = 6005
|
||||||
#ip = 127.0.0.1
|
#ip = 127.0.0.1
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ if(MSVC)
|
|||||||
NOMINMAX
|
NOMINMAX
|
||||||
# TODO: Resolve these warnings, don't just silence them
|
# TODO: Resolve these warnings, don't just silence them
|
||||||
_SILENCE_ALL_CXX17_DEPRECATION_WARNINGS
|
_SILENCE_ALL_CXX17_DEPRECATION_WARNINGS
|
||||||
$<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:Debug>,$<NOT:$<BOOL:${is_ci}>>>:_CRTDBG_MAP_ALLOC>
|
$<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:Debug>>:_CRTDBG_MAP_ALLOC>
|
||||||
)
|
)
|
||||||
target_link_libraries(common INTERFACE -errorreport:none -machine:X64)
|
target_link_libraries(common INTERFACE -errorreport:none -machine:X64)
|
||||||
else()
|
else()
|
||||||
|
|||||||
@@ -23,14 +23,14 @@ rm -f conan.lock
|
|||||||
# first create command will create a new lockfile, while the subsequent create
|
# first create command will create a new lockfile, while the subsequent create
|
||||||
# commands will merge any additional dependencies into the created lockfile.
|
# commands will merge any additional dependencies into the created lockfile.
|
||||||
conan lock create . \
|
conan lock create . \
|
||||||
--options '&:jemalloc=True' \
|
--options '&:jemalloc=True' \
|
||||||
--options '&:rocksdb=True' \
|
--options '&:rocksdb=True' \
|
||||||
--profile:all=conan/lockfile/linux.profile
|
--profile:all=conan/lockfile/linux.profile
|
||||||
conan lock create . \
|
conan lock create . \
|
||||||
--options '&:jemalloc=True' \
|
--options '&:jemalloc=True' \
|
||||||
--options '&:rocksdb=True' \
|
--options '&:rocksdb=True' \
|
||||||
--profile:all=conan/lockfile/macos.profile
|
--profile:all=conan/lockfile/macos.profile
|
||||||
conan lock create . \
|
conan lock create . \
|
||||||
--options '&:jemalloc=True' \
|
--options '&:jemalloc=True' \
|
||||||
--options '&:rocksdb=True' \
|
--options '&:rocksdb=True' \
|
||||||
--profile:all=conan/lockfile/windows.profile
|
--profile:all=conan/lockfile/windows.profile
|
||||||
|
|||||||
@@ -33,10 +33,10 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
/** Create an empty section. */
|
/** Create an empty section. */
|
||||||
explicit Section(std::string const& name = "");
|
explicit Section(std::string name = "");
|
||||||
|
|
||||||
/** Returns the name of this section. */
|
/** Returns the name of this section. */
|
||||||
std::string const&
|
[[nodiscard]] std::string const&
|
||||||
name() const
|
name() const
|
||||||
{
|
{
|
||||||
return name_;
|
return name_;
|
||||||
@@ -45,7 +45,7 @@ public:
|
|||||||
/** Returns all the lines in the section.
|
/** Returns all the lines in the section.
|
||||||
This includes everything.
|
This includes everything.
|
||||||
*/
|
*/
|
||||||
std::vector<std::string> const&
|
[[nodiscard]] std::vector<std::string> const&
|
||||||
lines() const
|
lines() const
|
||||||
{
|
{
|
||||||
return lines_;
|
return lines_;
|
||||||
@@ -54,7 +54,7 @@ public:
|
|||||||
/** Returns all the values in the section.
|
/** Returns all the values in the section.
|
||||||
Values are non-empty lines which are not key/value pairs.
|
Values are non-empty lines which are not key/value pairs.
|
||||||
*/
|
*/
|
||||||
std::vector<std::string> const&
|
[[nodiscard]] std::vector<std::string> const&
|
||||||
values() const
|
values() const
|
||||||
{
|
{
|
||||||
return values_;
|
return values_;
|
||||||
@@ -82,7 +82,7 @@ public:
|
|||||||
* @return The retrieved value. A section with an empty legacy value returns
|
* @return The retrieved value. A section with an empty legacy value returns
|
||||||
an empty string.
|
an empty string.
|
||||||
*/
|
*/
|
||||||
std::string
|
[[nodiscard]] std::string
|
||||||
legacy() const
|
legacy() const
|
||||||
{
|
{
|
||||||
if (lines_.empty())
|
if (lines_.empty())
|
||||||
@@ -117,11 +117,11 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Returns `true` if a key with the given name exists. */
|
/** Returns `true` if a key with the given name exists. */
|
||||||
bool
|
[[nodiscard]] bool
|
||||||
exists(std::string const& name) const;
|
exists(std::string const& name) const;
|
||||||
|
|
||||||
template <class T = std::string>
|
template <class T = std::string>
|
||||||
std::optional<T>
|
[[nodiscard]] std::optional<T>
|
||||||
get(std::string const& name) const
|
get(std::string const& name) const
|
||||||
{
|
{
|
||||||
auto const iter = lookup_.find(name);
|
auto const iter = lookup_.find(name);
|
||||||
@@ -132,7 +132,7 @@ public:
|
|||||||
|
|
||||||
/// Returns a value if present, else another value.
|
/// Returns a value if present, else another value.
|
||||||
template <class T>
|
template <class T>
|
||||||
T
|
[[nodiscard]] T
|
||||||
value_or(std::string const& name, T const& other) const
|
value_or(std::string const& name, T const& other) const
|
||||||
{
|
{
|
||||||
auto const v = get<T>(name);
|
auto const v = get<T>(name);
|
||||||
@@ -141,7 +141,7 @@ public:
|
|||||||
|
|
||||||
// indicates if trailing comments were seen
|
// indicates if trailing comments were seen
|
||||||
// during the appending of any lines/values
|
// during the appending of any lines/values
|
||||||
bool
|
[[nodiscard]] bool
|
||||||
had_trailing_comments() const
|
had_trailing_comments() const
|
||||||
{
|
{
|
||||||
return had_trailing_comments_;
|
return had_trailing_comments_;
|
||||||
@@ -151,42 +151,42 @@ public:
|
|||||||
operator<<(std::ostream&, Section const& section);
|
operator<<(std::ostream&, Section const& section);
|
||||||
|
|
||||||
// Returns `true` if there are no key/value pairs.
|
// Returns `true` if there are no key/value pairs.
|
||||||
bool
|
[[nodiscard]] bool
|
||||||
empty() const
|
empty() const
|
||||||
{
|
{
|
||||||
return lookup_.empty();
|
return lookup_.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns the number of key/value pairs.
|
// Returns the number of key/value pairs.
|
||||||
std::size_t
|
[[nodiscard]] std::size_t
|
||||||
size() const
|
size() const
|
||||||
{
|
{
|
||||||
return lookup_.size();
|
return lookup_.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
// For iteration of key/value pairs.
|
// For iteration of key/value pairs.
|
||||||
const_iterator
|
[[nodiscard]] const_iterator
|
||||||
begin() const
|
begin() const
|
||||||
{
|
{
|
||||||
return lookup_.cbegin();
|
return lookup_.cbegin();
|
||||||
}
|
}
|
||||||
|
|
||||||
// For iteration of key/value pairs.
|
// For iteration of key/value pairs.
|
||||||
const_iterator
|
[[nodiscard]] const_iterator
|
||||||
cbegin() const
|
cbegin() const
|
||||||
{
|
{
|
||||||
return lookup_.cbegin();
|
return lookup_.cbegin();
|
||||||
}
|
}
|
||||||
|
|
||||||
// For iteration of key/value pairs.
|
// For iteration of key/value pairs.
|
||||||
const_iterator
|
[[nodiscard]] const_iterator
|
||||||
end() const
|
end() const
|
||||||
{
|
{
|
||||||
return lookup_.cend();
|
return lookup_.cend();
|
||||||
}
|
}
|
||||||
|
|
||||||
// For iteration of key/value pairs.
|
// For iteration of key/value pairs.
|
||||||
const_iterator
|
[[nodiscard]] const_iterator
|
||||||
cend() const
|
cend() const
|
||||||
{
|
{
|
||||||
return lookup_.cend();
|
return lookup_.cend();
|
||||||
@@ -206,7 +206,7 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
/** Returns `true` if a section with the given name exists. */
|
/** Returns `true` if a section with the given name exists. */
|
||||||
bool
|
[[nodiscard]] bool
|
||||||
exists(std::string const& name) const;
|
exists(std::string const& name) const;
|
||||||
|
|
||||||
/** Returns the section with the given name.
|
/** Returns the section with the given name.
|
||||||
@@ -216,7 +216,7 @@ public:
|
|||||||
Section&
|
Section&
|
||||||
section(std::string const& name);
|
section(std::string const& name);
|
||||||
|
|
||||||
Section const&
|
[[nodiscard]] Section const&
|
||||||
section(std::string const& name) const;
|
section(std::string const& name) const;
|
||||||
|
|
||||||
Section const&
|
Section const&
|
||||||
@@ -264,7 +264,7 @@ public:
|
|||||||
* legacy value.
|
* legacy value.
|
||||||
* @return Contents of the legacy value.
|
* @return Contents of the legacy value.
|
||||||
*/
|
*/
|
||||||
std::string
|
[[nodiscard]] std::string
|
||||||
legacy(std::string const& sectionName) const;
|
legacy(std::string const& sectionName) const;
|
||||||
|
|
||||||
friend std::ostream&
|
friend std::ostream&
|
||||||
@@ -272,11 +272,10 @@ public:
|
|||||||
|
|
||||||
// indicates if trailing comments were seen
|
// indicates if trailing comments were seen
|
||||||
// in any loaded Sections
|
// in any loaded Sections
|
||||||
bool
|
[[nodiscard]] bool
|
||||||
had_trailing_comments() const
|
had_trailing_comments() const
|
||||||
{
|
{
|
||||||
return std::any_of(
|
return std::ranges::any_of(map_, [](auto s) { return s.second.had_trailing_comments(); });
|
||||||
map_.cbegin(), map_.cend(), [](auto s) { return s.second.had_trailing_comments(); });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ public:
|
|||||||
{
|
{
|
||||||
// Ensure the slice isn't a subset of the buffer.
|
// Ensure the slice isn't a subset of the buffer.
|
||||||
XRPL_ASSERT(
|
XRPL_ASSERT(
|
||||||
s.size() == 0 || size_ == 0 || s.data() < p_.get() || s.data() >= p_.get() + size_,
|
s.empty() || size_ == 0 || s.data() < p_.get() || s.data() >= p_.get() + size_,
|
||||||
"xrpl::Buffer::operator=(Slice) : input not a subset");
|
"xrpl::Buffer::operator=(Slice) : input not a subset");
|
||||||
|
|
||||||
if (auto p = alloc(s.size()))
|
if (auto p = alloc(s.size()))
|
||||||
@@ -101,13 +101,13 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the number of bytes in the buffer. */
|
/** Returns the number of bytes in the buffer. */
|
||||||
std::size_t
|
[[nodiscard]] std::size_t
|
||||||
size() const noexcept
|
size() const noexcept
|
||||||
{
|
{
|
||||||
return size_;
|
return size_;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
[[nodiscard]] bool
|
||||||
empty() const noexcept
|
empty() const noexcept
|
||||||
{
|
{
|
||||||
return 0 == size_;
|
return 0 == size_;
|
||||||
@@ -125,7 +125,7 @@ public:
|
|||||||
to a single byte, to facilitate pointer arithmetic.
|
to a single byte, to facilitate pointer arithmetic.
|
||||||
*/
|
*/
|
||||||
/** @{ */
|
/** @{ */
|
||||||
std::uint8_t const*
|
[[nodiscard]] std::uint8_t const*
|
||||||
data() const noexcept
|
data() const noexcept
|
||||||
{
|
{
|
||||||
return p_.get();
|
return p_.get();
|
||||||
@@ -169,25 +169,25 @@ public:
|
|||||||
return alloc(n);
|
return alloc(n);
|
||||||
}
|
}
|
||||||
|
|
||||||
const_iterator
|
[[nodiscard]] const_iterator
|
||||||
begin() const noexcept
|
begin() const noexcept
|
||||||
{
|
{
|
||||||
return p_.get();
|
return p_.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
const_iterator
|
[[nodiscard]] const_iterator
|
||||||
cbegin() const noexcept
|
cbegin() const noexcept
|
||||||
{
|
{
|
||||||
return p_.get();
|
return p_.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
const_iterator
|
[[nodiscard]] const_iterator
|
||||||
end() const noexcept
|
end() const noexcept
|
||||||
{
|
{
|
||||||
return p_.get() + size_;
|
return p_.get() + size_;
|
||||||
}
|
}
|
||||||
|
|
||||||
const_iterator
|
[[nodiscard]] const_iterator
|
||||||
cend() const noexcept
|
cend() const noexcept
|
||||||
{
|
{
|
||||||
return p_.get() + size_;
|
return p_.get() + size_;
|
||||||
|
|||||||
@@ -9,9 +9,7 @@
|
|||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace xrpl {
|
namespace xrpl::compression_algorithms {
|
||||||
|
|
||||||
namespace compression_algorithms {
|
|
||||||
|
|
||||||
/** LZ4 block compression.
|
/** LZ4 block compression.
|
||||||
* @tparam BufferFactory Callable object or lambda.
|
* @tparam BufferFactory Callable object or lambda.
|
||||||
@@ -141,6 +139,4 @@ lz4Decompress(
|
|||||||
return lz4Decompress(chunk, inSize, decompressed, decompressedSize);
|
return lz4Decompress(chunk, inSize, decompressed, decompressedSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace compression_algorithms
|
} // namespace xrpl::compression_algorithms
|
||||||
|
|
||||||
} // namespace xrpl
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ public:
|
|||||||
using Entry = std::pair<std::string, int>;
|
using Entry = std::pair<std::string, int>;
|
||||||
using List = std::vector<Entry>;
|
using List = std::vector<Entry>;
|
||||||
|
|
||||||
List
|
[[nodiscard]] List
|
||||||
getCounts(int minimumThreshold) const;
|
getCounts(int minimumThreshold) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -59,19 +59,19 @@ public:
|
|||||||
return --count_;
|
return --count_;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
[[nodiscard]] int
|
||||||
getCount() const noexcept
|
getCount() const noexcept
|
||||||
{
|
{
|
||||||
return count_.load();
|
return count_.load();
|
||||||
}
|
}
|
||||||
|
|
||||||
Counter*
|
[[nodiscard]] Counter*
|
||||||
getNext() const noexcept
|
getNext() const noexcept
|
||||||
{
|
{
|
||||||
return next_;
|
return next_;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string const&
|
[[nodiscard]] std::string const&
|
||||||
getName() const noexcept
|
getName() const noexcept
|
||||||
{
|
{
|
||||||
return name_;
|
return name_;
|
||||||
|
|||||||
@@ -67,8 +67,10 @@ private:
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
while ((elapsed--) != 0u)
|
for (; elapsed > 0; --elapsed)
|
||||||
|
{
|
||||||
m_value -= (m_value + Window - 1) / Window;
|
m_value -= (m_value + Window - 1) / Window;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ template <class E>
|
|||||||
class Unexpected
|
class Unexpected
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static_assert(!std::is_same<E, void>::value, "E must not be void");
|
static_assert(!std::is_same_v<E, void>, "E must not be void");
|
||||||
|
|
||||||
Unexpected() = delete;
|
Unexpected() = delete;
|
||||||
|
|
||||||
@@ -73,7 +73,7 @@ public:
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr E const&
|
[[nodiscard]] constexpr E const&
|
||||||
value() const&
|
value() const&
|
||||||
{
|
{
|
||||||
return val_;
|
return val_;
|
||||||
@@ -91,7 +91,7 @@ public:
|
|||||||
return std::move(val_);
|
return std::move(val_);
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr E const&&
|
[[nodiscard]] constexpr E const&&
|
||||||
value() const&&
|
value() const&&
|
||||||
{
|
{
|
||||||
return std::move(val_);
|
return std::move(val_);
|
||||||
@@ -125,13 +125,13 @@ public:
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr bool
|
[[nodiscard]] constexpr bool
|
||||||
has_value() const
|
has_value() const
|
||||||
{
|
{
|
||||||
return Base::has_value();
|
return Base::has_value();
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr T const&
|
[[nodiscard]] constexpr T const&
|
||||||
value() const
|
value() const
|
||||||
{
|
{
|
||||||
return Base::value();
|
return Base::value();
|
||||||
@@ -143,7 +143,7 @@ public:
|
|||||||
return Base::value();
|
return Base::value();
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr E const&
|
[[nodiscard]] constexpr E const&
|
||||||
error() const
|
error() const
|
||||||
{
|
{
|
||||||
return Base::error();
|
return Base::error();
|
||||||
@@ -210,7 +210,7 @@ public:
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr E const&
|
[[nodiscard]] constexpr E const&
|
||||||
error() const
|
error() const
|
||||||
{
|
{
|
||||||
return Base::error();
|
return Base::error();
|
||||||
|
|||||||
@@ -159,11 +159,11 @@ public:
|
|||||||
reset();
|
reset();
|
||||||
|
|
||||||
/** Get the raw pointer */
|
/** Get the raw pointer */
|
||||||
T*
|
[[nodiscard]] T*
|
||||||
get() const;
|
get() const;
|
||||||
|
|
||||||
/** Return the strong count */
|
/** Return the strong count */
|
||||||
std::size_t
|
[[nodiscard]] std::size_t
|
||||||
use_count() const;
|
use_count() const;
|
||||||
|
|
||||||
template <class TT, class... Args>
|
template <class TT, class... Args>
|
||||||
@@ -181,7 +181,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
/** Return the raw pointer held by this object. */
|
/** Return the raw pointer held by this object. */
|
||||||
T*
|
[[nodiscard]] T*
|
||||||
unsafeGetRawPtr() const;
|
unsafeGetRawPtr() const;
|
||||||
|
|
||||||
/** Exchange the current raw pointer held by this object with the given
|
/** Exchange the current raw pointer held by this object with the given
|
||||||
@@ -260,7 +260,7 @@ public:
|
|||||||
lock() const;
|
lock() const;
|
||||||
|
|
||||||
/** Return true if the strong count is zero. */
|
/** Return true if the strong count is zero. */
|
||||||
bool
|
[[nodiscard]] bool
|
||||||
expired() const;
|
expired() const;
|
||||||
|
|
||||||
/** Set the pointer to null and decrement the weak count.
|
/** Set the pointer to null and decrement the weak count.
|
||||||
@@ -339,7 +339,7 @@ public:
|
|||||||
don't lock the weak pointer. Use the `lock` method if that's what's
|
don't lock the weak pointer. Use the `lock` method if that's what's
|
||||||
needed)
|
needed)
|
||||||
*/
|
*/
|
||||||
SharedIntrusive<T>
|
[[nodiscard]] SharedIntrusive<T>
|
||||||
getStrong() const;
|
getStrong() const;
|
||||||
|
|
||||||
/** Return true if this is a strong pointer and the strong pointer is
|
/** Return true if this is a strong pointer and the strong pointer is
|
||||||
@@ -357,31 +357,31 @@ public:
|
|||||||
/** If this is a strong pointer, return the raw pointer. Otherwise
|
/** If this is a strong pointer, return the raw pointer. Otherwise
|
||||||
return null.
|
return null.
|
||||||
*/
|
*/
|
||||||
T*
|
[[nodiscard]] T*
|
||||||
get() const;
|
get() const;
|
||||||
|
|
||||||
/** If this is a strong pointer, return the strong count. Otherwise
|
/** If this is a strong pointer, return the strong count. Otherwise
|
||||||
* return 0
|
* return 0
|
||||||
*/
|
*/
|
||||||
std::size_t
|
[[nodiscard]] std::size_t
|
||||||
use_count() const;
|
use_count() const;
|
||||||
|
|
||||||
/** Return true if there is a non-zero strong count. */
|
/** Return true if there is a non-zero strong count. */
|
||||||
bool
|
[[nodiscard]] bool
|
||||||
expired() const;
|
expired() const;
|
||||||
|
|
||||||
/** If this is a strong pointer, return the strong pointer. Otherwise
|
/** If this is a strong pointer, return the strong pointer. Otherwise
|
||||||
attempt to lock the weak pointer.
|
attempt to lock the weak pointer.
|
||||||
*/
|
*/
|
||||||
SharedIntrusive<T>
|
[[nodiscard]] SharedIntrusive<T>
|
||||||
lock() const;
|
lock() const;
|
||||||
|
|
||||||
/** Return true is this represents a strong pointer. */
|
/** Return true is this represents a strong pointer. */
|
||||||
bool
|
[[nodiscard]] bool
|
||||||
isStrong() const;
|
isStrong() const;
|
||||||
|
|
||||||
/** Return true is this represents a weak pointer. */
|
/** Return true is this represents a weak pointer. */
|
||||||
bool
|
[[nodiscard]] bool
|
||||||
isWeak() const;
|
isWeak() const;
|
||||||
|
|
||||||
/** If this is a weak pointer, attempt to convert it to a strong
|
/** If this is a weak pointer, attempt to convert it to a strong
|
||||||
@@ -412,7 +412,7 @@ private:
|
|||||||
private:
|
private:
|
||||||
/** Return the raw pointer held by this object.
|
/** Return the raw pointer held by this object.
|
||||||
*/
|
*/
|
||||||
T*
|
[[nodiscard]] T*
|
||||||
unsafeGetRawPtr() const;
|
unsafeGetRawPtr() const;
|
||||||
|
|
||||||
enum class RefStrength { strong, weak };
|
enum class RefStrength { strong, weak };
|
||||||
|
|||||||
@@ -207,7 +207,7 @@ private:
|
|||||||
RefCountPair(CountType s, CountType w) noexcept;
|
RefCountPair(CountType s, CountType w) noexcept;
|
||||||
|
|
||||||
/** Convert back to the packed integer form. */
|
/** Convert back to the packed integer form. */
|
||||||
FieldType
|
[[nodiscard]] FieldType
|
||||||
combinedValue() const noexcept;
|
combinedValue() const noexcept;
|
||||||
|
|
||||||
static constexpr CountType maxStrongValue =
|
static constexpr CountType maxStrongValue =
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
namespace xrpl {
|
namespace xrpl {
|
||||||
|
|
||||||
@@ -28,7 +29,7 @@ struct LocalValues
|
|||||||
T t_;
|
T t_;
|
||||||
|
|
||||||
Value() = default;
|
Value() = default;
|
||||||
explicit Value(T const& t) : t_(t)
|
explicit Value(T t) : t_(std::move(t))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ private:
|
|||||||
std::string partition_;
|
std::string partition_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Sink(std::string const& partition, beast::severities::Severity thresh, Logs& logs);
|
Sink(std::string partition, beast::severities::Severity thresh, Logs& logs);
|
||||||
|
|
||||||
Sink(Sink const&) = delete;
|
Sink(Sink const&) = delete;
|
||||||
Sink&
|
Sink&
|
||||||
@@ -76,7 +76,7 @@ private:
|
|||||||
@return `true` if a system file is associated and opened for
|
@return `true` if a system file is associated and opened for
|
||||||
writing.
|
writing.
|
||||||
*/
|
*/
|
||||||
bool
|
[[nodiscard]] bool
|
||||||
isOpen() const noexcept;
|
isOpen() const noexcept;
|
||||||
|
|
||||||
/** Associate a system file with the log.
|
/** Associate a system file with the log.
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ public:
|
|||||||
return data_;
|
return data_;
|
||||||
}
|
}
|
||||||
|
|
||||||
ProtectedDataType const&
|
[[nodiscard]] ProtectedDataType const&
|
||||||
get() const
|
get() const
|
||||||
{
|
{
|
||||||
return data_;
|
return data_;
|
||||||
|
|||||||
@@ -252,9 +252,9 @@ public:
|
|||||||
// Assume unsigned values are... unsigned. i.e. positive
|
// Assume unsigned values are... unsigned. i.e. positive
|
||||||
explicit Number(internalrep mantissa, int exponent, normalized);
|
explicit Number(internalrep mantissa, int exponent, normalized);
|
||||||
|
|
||||||
constexpr rep
|
[[nodiscard]] constexpr rep
|
||||||
mantissa() const noexcept;
|
mantissa() const noexcept;
|
||||||
constexpr int
|
[[nodiscard]] constexpr int
|
||||||
exponent() const noexcept;
|
exponent() const noexcept;
|
||||||
|
|
||||||
constexpr Number
|
constexpr Number
|
||||||
@@ -339,7 +339,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Return the sign of the amount */
|
/** Return the sign of the amount */
|
||||||
constexpr int
|
[[nodiscard]] constexpr int
|
||||||
signum() const noexcept
|
signum() const noexcept
|
||||||
{
|
{
|
||||||
if (negative_)
|
if (negative_)
|
||||||
@@ -347,7 +347,7 @@ public:
|
|||||||
return (mantissa_ != 0u) ? 1 : 0;
|
return (mantissa_ != 0u) ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Number
|
[[nodiscard]] Number
|
||||||
truncate() const noexcept;
|
truncate() const noexcept;
|
||||||
|
|
||||||
friend constexpr bool
|
friend constexpr bool
|
||||||
@@ -490,13 +490,13 @@ private:
|
|||||||
MantissaRange::rep const& minMantissa,
|
MantissaRange::rep const& minMantissa,
|
||||||
MantissaRange::rep const& maxMantissa);
|
MantissaRange::rep const& maxMantissa);
|
||||||
|
|
||||||
bool
|
[[nodiscard]] bool
|
||||||
isnormal() const noexcept;
|
isnormal() const noexcept;
|
||||||
|
|
||||||
// Copy the number, but modify the exponent by "exponentDelta". Because the
|
// Copy the number, but modify the exponent by "exponentDelta". Because the
|
||||||
// mantissa doesn't change, the result will be "mostly" normalized, but the
|
// mantissa doesn't change, the result will be "mostly" normalized, but the
|
||||||
// exponent could go out of range, so it will be checked.
|
// exponent could go out of range, so it will be checked.
|
||||||
Number
|
[[nodiscard]] Number
|
||||||
shiftExponent(int exponentDelta) const;
|
shiftExponent(int exponentDelta) const;
|
||||||
|
|
||||||
// Safely convert rep (int64) mantissa to internalrep (uint64). If the rep
|
// Safely convert rep (int64) mantissa to internalrep (uint64). If the rep
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ public:
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
uint256 const&
|
[[nodiscard]] uint256 const&
|
||||||
as_uint256() const
|
as_uint256() const
|
||||||
{
|
{
|
||||||
return hash_;
|
return hash_;
|
||||||
@@ -30,17 +30,17 @@ public:
|
|||||||
{
|
{
|
||||||
return hash_;
|
return hash_;
|
||||||
}
|
}
|
||||||
bool
|
[[nodiscard]] bool
|
||||||
isZero() const
|
isZero() const
|
||||||
{
|
{
|
||||||
return hash_.isZero();
|
return hash_.isZero();
|
||||||
}
|
}
|
||||||
bool
|
[[nodiscard]] bool
|
||||||
isNonZero() const
|
isNonZero() const
|
||||||
{
|
{
|
||||||
return hash_.isNonZero();
|
return hash_.isNonZero();
|
||||||
}
|
}
|
||||||
int
|
[[nodiscard]] int
|
||||||
signum() const
|
signum() const
|
||||||
{
|
{
|
||||||
return hash_.signum();
|
return hash_.signum();
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ public:
|
|||||||
/** Return a strong pointer if this is already a strong pointer (i.e. don't
|
/** Return a strong pointer if this is already a strong pointer (i.e. don't
|
||||||
lock the weak pointer. Use the `lock` method if that's what's needed)
|
lock the weak pointer. Use the `lock` method if that's what's needed)
|
||||||
*/
|
*/
|
||||||
std::shared_ptr<T> const&
|
[[nodiscard]] std::shared_ptr<T> const&
|
||||||
getStrong() const;
|
getStrong() const;
|
||||||
|
|
||||||
/** Return true if this is a strong pointer and the strong pointer is
|
/** Return true if this is a strong pointer and the strong pointer is
|
||||||
@@ -67,30 +67,30 @@ public:
|
|||||||
/** If this is a strong pointer, return the raw pointer. Otherwise return
|
/** If this is a strong pointer, return the raw pointer. Otherwise return
|
||||||
null.
|
null.
|
||||||
*/
|
*/
|
||||||
T*
|
[[nodiscard]] T*
|
||||||
get() const;
|
get() const;
|
||||||
|
|
||||||
/** If this is a strong pointer, return the strong count. Otherwise return 0
|
/** If this is a strong pointer, return the strong count. Otherwise return 0
|
||||||
*/
|
*/
|
||||||
std::size_t
|
[[nodiscard]] std::size_t
|
||||||
use_count() const;
|
use_count() const;
|
||||||
|
|
||||||
/** Return true if there is a non-zero strong count. */
|
/** Return true if there is a non-zero strong count. */
|
||||||
bool
|
[[nodiscard]] bool
|
||||||
expired() const;
|
expired() const;
|
||||||
|
|
||||||
/** If this is a strong pointer, return the strong pointer. Otherwise
|
/** If this is a strong pointer, return the strong pointer. Otherwise
|
||||||
attempt to lock the weak pointer.
|
attempt to lock the weak pointer.
|
||||||
*/
|
*/
|
||||||
std::shared_ptr<T>
|
[[nodiscard]] std::shared_ptr<T>
|
||||||
lock() const;
|
lock() const;
|
||||||
|
|
||||||
/** Return true is this represents a strong pointer. */
|
/** Return true is this represents a strong pointer. */
|
||||||
bool
|
[[nodiscard]] bool
|
||||||
isStrong() const;
|
isStrong() const;
|
||||||
|
|
||||||
/** Return true is this represents a weak pointer. */
|
/** Return true is this represents a weak pointer. */
|
||||||
bool
|
[[nodiscard]] bool
|
||||||
isWeak() const;
|
isWeak() const;
|
||||||
|
|
||||||
/** If this is a weak pointer, attempt to convert it to a strong pointer.
|
/** If this is a weak pointer, attempt to convert it to a strong pointer.
|
||||||
|
|||||||
@@ -66,12 +66,10 @@ class SlabAllocator
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
~SlabBlock()
|
// Calling this destructor will release the allocated memory but
|
||||||
{
|
// will not properly destroy any objects that are constructed in
|
||||||
// Calling this destructor will release the allocated memory but
|
// the block itself.
|
||||||
// will not properly destroy any objects that are constructed in
|
~SlabBlock() = default;
|
||||||
// the block itself.
|
|
||||||
}
|
|
||||||
|
|
||||||
SlabBlock(SlabBlock const& other) = delete;
|
SlabBlock(SlabBlock const& other) = delete;
|
||||||
SlabBlock&
|
SlabBlock&
|
||||||
@@ -176,15 +174,13 @@ public:
|
|||||||
SlabAllocator&
|
SlabAllocator&
|
||||||
operator=(SlabAllocator&& other) = delete;
|
operator=(SlabAllocator&& other) = delete;
|
||||||
|
|
||||||
~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
|
||||||
// FIXME: We can't destroy the memory blocks we've allocated, because
|
// shutdown process up could make this possible.
|
||||||
// we can't be sure that they are not being used. Cleaning the
|
~SlabAllocator() = default;
|
||||||
// shutdown process up could make this possible.
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Returns the size of the memory block this allocator returns. */
|
/** Returns the size of the memory block this allocator returns. */
|
||||||
constexpr std::size_t
|
[[nodiscard]] constexpr std::size_t
|
||||||
size() const noexcept
|
size() const noexcept
|
||||||
{
|
{
|
||||||
return itemSize_;
|
return itemSize_;
|
||||||
@@ -288,7 +284,7 @@ class SlabAllocatorSet
|
|||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
// The list of allocators that belong to this set
|
// The list of allocators that belong to this set
|
||||||
boost::container::static_vector<SlabAllocator<Type>, 64> allocators_;
|
boost::container::static_vector<SlabAllocator<Type>, 64> allocators_{};
|
||||||
|
|
||||||
std::size_t maxSize_ = 0;
|
std::size_t maxSize_ = 0;
|
||||||
|
|
||||||
@@ -347,9 +343,7 @@ public:
|
|||||||
SlabAllocatorSet&
|
SlabAllocatorSet&
|
||||||
operator=(SlabAllocatorSet&& other) = delete;
|
operator=(SlabAllocatorSet&& other) = delete;
|
||||||
|
|
||||||
~SlabAllocatorSet()
|
~SlabAllocatorSet() = default;
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Returns a suitably aligned pointer, if one is available.
|
/** Returns a suitably aligned pointer, if one is available.
|
||||||
|
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ public:
|
|||||||
@note The return type is guaranteed to be a pointer
|
@note The return type is guaranteed to be a pointer
|
||||||
to a single byte, to facilitate pointer arithmetic.
|
to a single byte, to facilitate pointer arithmetic.
|
||||||
*/
|
*/
|
||||||
std::uint8_t const*
|
[[nodiscard]] std::uint8_t const*
|
||||||
data() const noexcept
|
data() const noexcept
|
||||||
{
|
{
|
||||||
return data_;
|
return data_;
|
||||||
@@ -123,25 +123,25 @@ public:
|
|||||||
size_ -= n;
|
size_ -= n;
|
||||||
}
|
}
|
||||||
|
|
||||||
const_iterator
|
[[nodiscard]] const_iterator
|
||||||
begin() const noexcept
|
begin() const noexcept
|
||||||
{
|
{
|
||||||
return data_;
|
return data_;
|
||||||
}
|
}
|
||||||
|
|
||||||
const_iterator
|
[[nodiscard]] const_iterator
|
||||||
cbegin() const noexcept
|
cbegin() const noexcept
|
||||||
{
|
{
|
||||||
return data_;
|
return data_;
|
||||||
}
|
}
|
||||||
|
|
||||||
const_iterator
|
[[nodiscard]] const_iterator
|
||||||
end() const noexcept
|
end() const noexcept
|
||||||
{
|
{
|
||||||
return data_ + size_;
|
return data_ + size_;
|
||||||
}
|
}
|
||||||
|
|
||||||
const_iterator
|
[[nodiscard]] const_iterator
|
||||||
cend() const noexcept
|
cend() const noexcept
|
||||||
{
|
{
|
||||||
return data_ + size_;
|
return data_ + size_;
|
||||||
@@ -158,7 +158,7 @@ public:
|
|||||||
@returns The requested subslice, if the request is valid.
|
@returns The requested subslice, if the request is valid.
|
||||||
@throws std::out_of_range if pos > size()
|
@throws std::out_of_range if pos > size()
|
||||||
*/
|
*/
|
||||||
Slice
|
[[nodiscard]] Slice
|
||||||
substr(std::size_t pos, std::size_t count = std::numeric_limits<std::size_t>::max()) const
|
substr(std::size_t pos, std::size_t count = std::numeric_limits<std::size_t>::max()) const
|
||||||
{
|
{
|
||||||
if (pos > size())
|
if (pos > size())
|
||||||
@@ -211,14 +211,14 @@ operator<<(Stream& s, Slice const& v)
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <class T, std::size_t N>
|
template <class T, std::size_t N>
|
||||||
std::enable_if_t<std::is_same<T, char>::value || std::is_same<T, unsigned char>::value, Slice>
|
std::enable_if_t<std::is_same_v<T, char> || std::is_same_v<T, unsigned char>, Slice>
|
||||||
makeSlice(std::array<T, N> const& a)
|
makeSlice(std::array<T, N> const& a)
|
||||||
{
|
{
|
||||||
return Slice(a.data(), a.size());
|
return Slice(a.data(), a.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T, class Alloc>
|
template <class T, class Alloc>
|
||||||
std::enable_if_t<std::is_same<T, char>::value || std::is_same<T, unsigned char>::value, Slice>
|
std::enable_if_t<std::is_same_v<T, char> || std::is_same_v<T, unsigned char>, Slice>
|
||||||
makeSlice(std::vector<T, Alloc> const& v)
|
makeSlice(std::vector<T, Alloc> const& v)
|
||||||
{
|
{
|
||||||
return Slice(v.data(), v.size());
|
return Slice(v.data(), v.size());
|
||||||
|
|||||||
@@ -222,19 +222,19 @@ private:
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
[[nodiscard]] bool
|
||||||
isWeak() const
|
isWeak() const
|
||||||
{
|
{
|
||||||
if (!ptr)
|
if (!ptr)
|
||||||
return true;
|
return true;
|
||||||
return ptr.isWeak();
|
return ptr.isWeak();
|
||||||
}
|
}
|
||||||
bool
|
[[nodiscard]] bool
|
||||||
isCached() const
|
isCached() const
|
||||||
{
|
{
|
||||||
return ptr && ptr.isStrong();
|
return ptr && ptr.isStrong();
|
||||||
}
|
}
|
||||||
bool
|
[[nodiscard]] bool
|
||||||
isExpired() const
|
isExpired() const
|
||||||
{
|
{
|
||||||
return ptr.expired();
|
return ptr.expired();
|
||||||
@@ -251,7 +251,7 @@ private:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef typename std::conditional<IsKeyCache, KeyOnlyEntry, ValueEntry>::type Entry;
|
using Entry = std::conditional_t<IsKeyCache, KeyOnlyEntry, ValueEntry>;
|
||||||
|
|
||||||
using KeyOnlyCacheType = hardened_partitioned_hash_map<key_type, KeyOnlyEntry, Hash, KeyEqual>;
|
using KeyOnlyCacheType = hardened_partitioned_hash_map<key_type, KeyOnlyEntry, Hash, KeyEqual>;
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ namespace xrpl {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
typename std::enable_if<std::is_arithmetic<T>::value, std::string>::type
|
std::enable_if_t<std::is_arithmetic_v<T>, std::string>
|
||||||
to_string(T t)
|
to_string(T t)
|
||||||
{
|
{
|
||||||
return std::to_string(t);
|
return std::to_string(t);
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ public:
|
|||||||
{
|
{
|
||||||
return reinterpret_cast<pointer>(data_.data());
|
return reinterpret_cast<pointer>(data_.data());
|
||||||
}
|
}
|
||||||
const_pointer
|
[[nodiscard]] const_pointer
|
||||||
data() const
|
data() const
|
||||||
{
|
{
|
||||||
return reinterpret_cast<const_pointer>(data_.data());
|
return reinterpret_cast<const_pointer>(data_.data());
|
||||||
@@ -118,22 +118,22 @@ public:
|
|||||||
{
|
{
|
||||||
return data() + bytes;
|
return data() + bytes;
|
||||||
}
|
}
|
||||||
const_iterator
|
[[nodiscard]] const_iterator
|
||||||
begin() const
|
begin() const
|
||||||
{
|
{
|
||||||
return data();
|
return data();
|
||||||
}
|
}
|
||||||
const_iterator
|
[[nodiscard]] const_iterator
|
||||||
end() const
|
end() const
|
||||||
{
|
{
|
||||||
return data() + bytes;
|
return data() + bytes;
|
||||||
}
|
}
|
||||||
const_iterator
|
[[nodiscard]] const_iterator
|
||||||
cbegin() const
|
cbegin() const
|
||||||
{
|
{
|
||||||
return data();
|
return data();
|
||||||
}
|
}
|
||||||
const_iterator
|
[[nodiscard]] const_iterator
|
||||||
cend() const
|
cend() const
|
||||||
{
|
{
|
||||||
return data() + bytes;
|
return data() + bytes;
|
||||||
@@ -269,7 +269,7 @@ public:
|
|||||||
class Container,
|
class Container,
|
||||||
class = std::enable_if_t<
|
class = std::enable_if_t<
|
||||||
detail::is_contiguous_container<Container>::value &&
|
detail::is_contiguous_container<Container>::value &&
|
||||||
std::is_trivially_copyable<typename Container::value_type>::value>>
|
std::is_trivially_copyable_v<typename Container::value_type>>>
|
||||||
explicit base_uint(Container const& c)
|
explicit base_uint(Container const& c)
|
||||||
{
|
{
|
||||||
XRPL_ASSERT(
|
XRPL_ASSERT(
|
||||||
@@ -281,7 +281,7 @@ public:
|
|||||||
template <class Container>
|
template <class Container>
|
||||||
std::enable_if_t<
|
std::enable_if_t<
|
||||||
detail::is_contiguous_container<Container>::value &&
|
detail::is_contiguous_container<Container>::value &&
|
||||||
std::is_trivially_copyable<typename Container::value_type>::value,
|
std::is_trivially_copyable_v<typename Container::value_type>,
|
||||||
base_uint&>
|
base_uint&>
|
||||||
operator=(Container const& c)
|
operator=(Container const& c)
|
||||||
{
|
{
|
||||||
@@ -310,7 +310,7 @@ public:
|
|||||||
return fromVoid(from.data());
|
return fromVoid(from.data());
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr int
|
[[nodiscard]] constexpr int
|
||||||
signum() const
|
signum() const
|
||||||
{
|
{
|
||||||
for (int i = 0; i < WIDTH; i++)
|
for (int i = 0; i < WIDTH; i++)
|
||||||
@@ -433,14 +433,14 @@ public:
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
base_uint
|
[[nodiscard]] base_uint
|
||||||
next() const
|
next() const
|
||||||
{
|
{
|
||||||
auto ret = *this;
|
auto ret = *this;
|
||||||
return ++ret;
|
return ++ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
base_uint
|
[[nodiscard]] base_uint
|
||||||
prev() const
|
prev() const
|
||||||
{
|
{
|
||||||
auto ret = *this;
|
auto ret = *this;
|
||||||
@@ -517,12 +517,12 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Deprecated.
|
// Deprecated.
|
||||||
bool
|
[[nodiscard]] bool
|
||||||
isZero() const
|
isZero() const
|
||||||
{
|
{
|
||||||
return *this == beast::zero;
|
return *this == beast::zero;
|
||||||
}
|
}
|
||||||
bool
|
[[nodiscard]] bool
|
||||||
isNonZero() const
|
isNonZero() const
|
||||||
{
|
{
|
||||||
return *this != beast::zero;
|
return *this != beast::zero;
|
||||||
|
|||||||
@@ -49,8 +49,7 @@ template <class E, class... Args>
|
|||||||
Throw(Args&&... args)
|
Throw(Args&&... args)
|
||||||
{
|
{
|
||||||
static_assert(
|
static_assert(
|
||||||
std::is_convertible<E*, std::exception*>::value,
|
std::is_convertible_v<E*, std::exception*>, "Exception must derive from std::exception.");
|
||||||
"Exception must derive from std::exception.");
|
|
||||||
|
|
||||||
E e(std::forward<Args>(args)...);
|
E e(std::forward<Args>(args)...);
|
||||||
LogThrow(std::string("Throwing exception of type " + beast::type_name<E>() + ": ") + e.what());
|
LogThrow(std::string("Throwing exception of type " + beast::type_name<E>() + ": ") + e.what());
|
||||||
|
|||||||
@@ -72,14 +72,12 @@ template <class HashAlgorithm = beast::xxhasher>
|
|||||||
class hardened_hash
|
class hardened_hash
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
detail::seed_pair m_seeds;
|
detail::seed_pair m_seeds{detail::make_seed_pair<>()};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
using result_type = typename HashAlgorithm::result_type;
|
using result_type = typename HashAlgorithm::result_type;
|
||||||
|
|
||||||
hardened_hash() : m_seeds(detail::make_seed_pair<>())
|
hardened_hash() = default;
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
result_type
|
result_type
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ public:
|
|||||||
{
|
{
|
||||||
using iterator_category = std::forward_iterator_tag;
|
using iterator_category = std::forward_iterator_tag;
|
||||||
partition_map_type* map_{nullptr};
|
partition_map_type* map_{nullptr};
|
||||||
typename partition_map_type::iterator ait_;
|
typename partition_map_type::iterator ait_{};
|
||||||
typename map_type::iterator mit_;
|
typename map_type::iterator mit_;
|
||||||
|
|
||||||
iterator() = default;
|
iterator() = default;
|
||||||
@@ -126,7 +126,7 @@ public:
|
|||||||
using iterator_category = std::forward_iterator_tag;
|
using iterator_category = std::forward_iterator_tag;
|
||||||
|
|
||||||
partition_map_type* map_{nullptr};
|
partition_map_type* map_{nullptr};
|
||||||
typename partition_map_type::iterator ait_;
|
typename partition_map_type::iterator ait_{};
|
||||||
typename map_type::iterator mit_;
|
typename map_type::iterator mit_;
|
||||||
|
|
||||||
const_iterator() = default;
|
const_iterator() = default;
|
||||||
|
|||||||
@@ -15,8 +15,8 @@ namespace xrpl {
|
|||||||
#ifndef __INTELLISENSE__
|
#ifndef __INTELLISENSE__
|
||||||
static_assert(
|
static_assert(
|
||||||
// NOLINTNEXTLINE(misc-redundant-expression)
|
// NOLINTNEXTLINE(misc-redundant-expression)
|
||||||
std::is_integral<beast::xor_shift_engine::result_type>::value &&
|
std::is_integral_v<beast::xor_shift_engine::result_type> &&
|
||||||
std::is_unsigned<beast::xor_shift_engine::result_type>::value,
|
std::is_unsigned_v<beast::xor_shift_engine::result_type>,
|
||||||
"The XRPL default PRNG engine must return an unsigned integral type.");
|
"The XRPL default PRNG engine must return an unsigned integral type.");
|
||||||
|
|
||||||
static_assert(
|
static_assert(
|
||||||
@@ -91,7 +91,7 @@ default_prng()
|
|||||||
*/
|
*/
|
||||||
/** @{ */
|
/** @{ */
|
||||||
template <class Engine, class Integral>
|
template <class Engine, class Integral>
|
||||||
std::enable_if_t<std::is_integral<Integral>::value && detail::is_engine<Engine>::value, Integral>
|
std::enable_if_t<std::is_integral_v<Integral> && detail::is_engine<Engine>::value, Integral>
|
||||||
rand_int(Engine& engine, Integral min, Integral max)
|
rand_int(Engine& engine, Integral min, Integral max)
|
||||||
{
|
{
|
||||||
XRPL_ASSERT(max > min, "xrpl::rand_int : max over min inputs");
|
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>
|
template <class Integral>
|
||||||
std::enable_if_t<std::is_integral<Integral>::value, Integral>
|
std::enable_if_t<std::is_integral_v<Integral>, Integral>
|
||||||
rand_int(Integral min, Integral max)
|
rand_int(Integral min, Integral max)
|
||||||
{
|
{
|
||||||
return rand_int(default_prng(), min, max);
|
return rand_int(default_prng(), min, max);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Engine, class Integral>
|
template <class Engine, class Integral>
|
||||||
std::enable_if_t<std::is_integral<Integral>::value && detail::is_engine<Engine>::value, Integral>
|
std::enable_if_t<std::is_integral_v<Integral> && detail::is_engine<Engine>::value, Integral>
|
||||||
rand_int(Engine& engine, Integral max)
|
rand_int(Engine& engine, Integral max)
|
||||||
{
|
{
|
||||||
return rand_int(engine, Integral(0), max);
|
return rand_int(engine, Integral(0), max);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Integral>
|
template <class Integral>
|
||||||
std::enable_if_t<std::is_integral<Integral>::value, Integral>
|
std::enable_if_t<std::is_integral_v<Integral>, Integral>
|
||||||
rand_int(Integral max)
|
rand_int(Integral max)
|
||||||
{
|
{
|
||||||
return rand_int(default_prng(), max);
|
return rand_int(default_prng(), max);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Integral, class Engine>
|
template <class Integral, class Engine>
|
||||||
std::enable_if_t<std::is_integral<Integral>::value && detail::is_engine<Engine>::value, Integral>
|
std::enable_if_t<std::is_integral_v<Integral> && detail::is_engine<Engine>::value, Integral>
|
||||||
rand_int(Engine& engine)
|
rand_int(Engine& engine)
|
||||||
{
|
{
|
||||||
return rand_int(engine, std::numeric_limits<Integral>::max());
|
return rand_int(engine, std::numeric_limits<Integral>::max());
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Integral = int>
|
template <class Integral = int>
|
||||||
std::enable_if_t<std::is_integral<Integral>::value, Integral>
|
std::enable_if_t<std::is_integral_v<Integral>, Integral>
|
||||||
rand_int()
|
rand_int()
|
||||||
{
|
{
|
||||||
return rand_int(default_prng(), std::numeric_limits<Integral>::max());
|
return rand_int(default_prng(), std::numeric_limits<Integral>::max());
|
||||||
@@ -142,7 +142,7 @@ rand_int()
|
|||||||
/** @{ */
|
/** @{ */
|
||||||
template <class Byte, class Engine>
|
template <class Byte, class Engine>
|
||||||
std::enable_if_t<
|
std::enable_if_t<
|
||||||
(std::is_same<Byte, unsigned char>::value || std::is_same<Byte, std::uint8_t>::value) &&
|
(std::is_same_v<Byte, unsigned char> || std::is_same_v<Byte, std::uint8_t>) &&
|
||||||
detail::is_engine<Engine>::value,
|
detail::is_engine<Engine>::value,
|
||||||
Byte>
|
Byte>
|
||||||
rand_byte(Engine& engine)
|
rand_byte(Engine& engine)
|
||||||
@@ -152,9 +152,7 @@ rand_byte(Engine& engine)
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <class Byte = std::uint8_t>
|
template <class Byte = std::uint8_t>
|
||||||
std::enable_if_t<
|
std::enable_if_t<(std::is_same_v<Byte, unsigned char> || std::is_same_v<Byte, std::uint8_t>), Byte>
|
||||||
(std::is_same<Byte, unsigned char>::value || std::is_same<Byte, std::uint8_t>::value),
|
|
||||||
Byte>
|
|
||||||
rand_byte()
|
rand_byte()
|
||||||
{
|
{
|
||||||
return rand_byte<Byte>(default_prng());
|
return rand_byte<Byte>(default_prng());
|
||||||
|
|||||||
@@ -12,9 +12,9 @@ namespace xrpl {
|
|||||||
|
|
||||||
template <class Src, class Dest>
|
template <class Src, class Dest>
|
||||||
concept SafeToCast = (std::is_integral_v<Src> && std::is_integral_v<Dest>) &&
|
concept SafeToCast = (std::is_integral_v<Src> && std::is_integral_v<Dest>) &&
|
||||||
(std::is_signed<Src>::value || std::is_unsigned<Dest>::value) &&
|
(std::is_signed_v<Src> || std::is_unsigned_v<Dest>) &&
|
||||||
(std::is_signed<Src>::value != std::is_signed<Dest>::value ? sizeof(Dest) > sizeof(Src)
|
(std::is_signed_v<Src> != std::is_signed_v<Dest> ? sizeof(Dest) > sizeof(Src)
|
||||||
: sizeof(Dest) >= sizeof(Src));
|
: sizeof(Dest) >= sizeof(Src));
|
||||||
|
|
||||||
template <class Dest, class Src>
|
template <class Dest, class Src>
|
||||||
constexpr std::enable_if_t<std::is_integral_v<Dest> && std::is_integral_v<Src>, Dest>
|
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)
|
strHex(FwdIt begin, FwdIt end)
|
||||||
{
|
{
|
||||||
static_assert(
|
static_assert(
|
||||||
std::is_convertible<
|
std::is_convertible_v<
|
||||||
typename std::iterator_traits<FwdIt>::iterator_category,
|
typename std::iterator_traits<FwdIt>::iterator_category,
|
||||||
std::forward_iterator_tag>::value,
|
std::forward_iterator_tag>,
|
||||||
"FwdIt must be a forward iterator");
|
"FwdIt must be a forward iterator");
|
||||||
std::string result;
|
std::string result;
|
||||||
result.reserve(2 * std::distance(begin, end));
|
result.reserve(2 * std::distance(begin, end));
|
||||||
|
|||||||
@@ -44,8 +44,7 @@ public:
|
|||||||
|
|
||||||
template <
|
template <
|
||||||
class OtherInt,
|
class OtherInt,
|
||||||
class = typename std::enable_if<
|
class = std::enable_if_t<std::is_integral_v<OtherInt> && sizeof(OtherInt) <= sizeof(Int)>>
|
||||||
std::is_integral<OtherInt>::value && sizeof(OtherInt) <= sizeof(Int)>::type>
|
|
||||||
explicit constexpr tagged_integer(OtherInt value) noexcept : m_value(value)
|
explicit constexpr tagged_integer(OtherInt value) noexcept : m_value(value)
|
||||||
{
|
{
|
||||||
static_assert(sizeof(tagged_integer) == sizeof(Int), "tagged_integer is adding padding");
|
static_assert(sizeof(tagged_integer) == sizeof(Int), "tagged_integer is adding padding");
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ public:
|
|||||||
return m_ios;
|
return m_ios;
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::asio::io_context const&
|
[[nodiscard]] boost::asio::io_context const&
|
||||||
get_io_context() const
|
get_io_context() const
|
||||||
{
|
{
|
||||||
return m_ios;
|
return m_ios;
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ struct abstract_clock_wrapper : public abstract_clock<Facade>
|
|||||||
using typename abstract_clock<Facade>::duration;
|
using typename abstract_clock<Facade>::duration;
|
||||||
using typename abstract_clock<Facade>::time_point;
|
using typename abstract_clock<Facade>::time_point;
|
||||||
|
|
||||||
time_point
|
[[nodiscard]] time_point
|
||||||
now() const override
|
now() const override
|
||||||
{
|
{
|
||||||
return Clock::now();
|
return Clock::now();
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ public:
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
time_point
|
[[nodiscard]] time_point
|
||||||
now() const override
|
now() const override
|
||||||
{
|
{
|
||||||
return now_;
|
return now_;
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ namespace beast {
|
|||||||
|
|
||||||
/** Expire aged container items past the specified age. */
|
/** Expire aged container items past the specified age. */
|
||||||
template <class AgedContainer, class Rep, class Period>
|
template <class AgedContainer, class Rep, class Period>
|
||||||
typename std::enable_if<is_aged_container<AgedContainer>::value, std::size_t>::type
|
std::enable_if_t<is_aged_container<AgedContainer>::value, std::size_t>
|
||||||
expire(AgedContainer& c, std::chrono::duration<Rep, Period> const& age)
|
expire(AgedContainer& c, std::chrono::duration<Rep, Period> const& age)
|
||||||
{
|
{
|
||||||
std::size_t n(0);
|
std::size_t n(0);
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
namespace beast {
|
namespace beast::detail {
|
||||||
namespace detail {
|
|
||||||
|
|
||||||
// Extracts the key portion of value
|
// Extracts the key portion of value
|
||||||
template <bool maybe_map>
|
template <bool maybe_map>
|
||||||
@@ -30,5 +29,4 @@ struct aged_associative_container_extract_t<false>
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace detail
|
} // namespace beast::detail
|
||||||
} // namespace beast
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
namespace beast {
|
namespace beast {
|
||||||
|
|
||||||
@@ -114,7 +115,7 @@ public:
|
|||||||
return &m_iter->value;
|
return &m_iter->value;
|
||||||
}
|
}
|
||||||
|
|
||||||
time_point const&
|
[[nodiscard]] time_point const&
|
||||||
when() const
|
when() const
|
||||||
{
|
{
|
||||||
return m_iter->when;
|
return m_iter->when;
|
||||||
@@ -131,11 +132,11 @@ private:
|
|||||||
friend class aged_container_iterator;
|
friend class aged_container_iterator;
|
||||||
|
|
||||||
template <class OtherIterator>
|
template <class OtherIterator>
|
||||||
aged_container_iterator(OtherIterator const& iter) : m_iter(iter)
|
aged_container_iterator(OtherIterator iter) : m_iter(std::move(iter))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Iterator const&
|
[[nodiscard]] Iterator const&
|
||||||
iterator() const
|
iterator() const
|
||||||
{
|
{
|
||||||
return m_iter;
|
return m_iter;
|
||||||
|
|||||||
@@ -57,8 +57,7 @@ template <
|
|||||||
class T,
|
class T,
|
||||||
class Clock = std::chrono::steady_clock,
|
class Clock = std::chrono::steady_clock,
|
||||||
class Compare = std::less<Key>,
|
class Compare = std::less<Key>,
|
||||||
class Allocator =
|
class Allocator = std::allocator<std::conditional_t<IsMap, std::pair<Key const, T>, Key>>>
|
||||||
std::allocator<typename std::conditional<IsMap, std::pair<Key const, T>, Key>::type>>
|
|
||||||
class aged_ordered_container
|
class aged_ordered_container
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -67,7 +66,7 @@ public:
|
|||||||
using duration = typename clock_type::duration;
|
using duration = typename clock_type::duration;
|
||||||
using key_type = Key;
|
using key_type = Key;
|
||||||
using mapped_type = T;
|
using mapped_type = T;
|
||||||
using value_type = typename std::conditional<IsMap, std::pair<Key const, T>, Key>::type;
|
using value_type = std::conditional_t<IsMap, std::pair<Key const, T>, Key>;
|
||||||
using size_type = std::size_t;
|
using size_type = std::size_t;
|
||||||
using difference_type = std::ptrdiff_t;
|
using difference_type = std::ptrdiff_t;
|
||||||
|
|
||||||
@@ -110,8 +109,7 @@ private:
|
|||||||
|
|
||||||
template <
|
template <
|
||||||
class... Args,
|
class... Args,
|
||||||
class =
|
class = std::enable_if_t<std::is_constructible_v<value_type, Args...>>>
|
||||||
typename std::enable_if<std::is_constructible<value_type, Args...>::value>::type>
|
|
||||||
element(time_point const& when_, Args&&... args)
|
element(time_point const& when_, Args&&... args)
|
||||||
: value(std::forward<Args>(args)...), when(when_)
|
: value(std::forward<Args>(args)...), when(when_)
|
||||||
{
|
{
|
||||||
@@ -135,9 +133,7 @@ private:
|
|||||||
return Compare::operator()(lhs.first, rhs.first);
|
return Compare::operator()(lhs.first, rhs.first);
|
||||||
}
|
}
|
||||||
|
|
||||||
pair_value_compare()
|
pair_value_compare() = default;
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
pair_value_compare(pair_value_compare const& other) : Compare(other)
|
pair_value_compare(pair_value_compare const& other) : Compare(other)
|
||||||
{
|
{
|
||||||
@@ -190,7 +186,7 @@ private:
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
Compare const&
|
[[nodiscard]] Compare const&
|
||||||
compare() const
|
compare() const
|
||||||
{
|
{
|
||||||
return *this;
|
return *this;
|
||||||
@@ -200,7 +196,7 @@ private:
|
|||||||
using list_type = typename boost::intrusive::
|
using list_type = typename boost::intrusive::
|
||||||
make_list<element, boost::intrusive::constant_time_size<false>>::type;
|
make_list<element, boost::intrusive::constant_time_size<false>>::type;
|
||||||
|
|
||||||
using cont_type = typename std::conditional<
|
using cont_type = std::conditional_t<
|
||||||
IsMulti,
|
IsMulti,
|
||||||
typename boost::intrusive::make_multiset<
|
typename boost::intrusive::make_multiset<
|
||||||
element,
|
element,
|
||||||
@@ -209,7 +205,7 @@ private:
|
|||||||
typename boost::intrusive::make_set<
|
typename boost::intrusive::make_set<
|
||||||
element,
|
element,
|
||||||
boost::intrusive::constant_time_size<true>,
|
boost::intrusive::constant_time_size<true>,
|
||||||
boost::intrusive::compare<KeyValueCompare>>::type>::type;
|
boost::intrusive::compare<KeyValueCompare>>::type>;
|
||||||
|
|
||||||
using ElementAllocator =
|
using ElementAllocator =
|
||||||
typename std::allocator_traits<Allocator>::template rebind_alloc<element>;
|
typename std::allocator_traits<Allocator>::template rebind_alloc<element>;
|
||||||
@@ -299,7 +295,7 @@ private:
|
|||||||
return KeyValueCompare::compare();
|
return KeyValueCompare::compare();
|
||||||
}
|
}
|
||||||
|
|
||||||
Compare const&
|
[[nodiscard]] Compare const&
|
||||||
compare() const
|
compare() const
|
||||||
{
|
{
|
||||||
return KeyValueCompare::compare();
|
return KeyValueCompare::compare();
|
||||||
@@ -311,7 +307,7 @@ private:
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
KeyValueCompare const&
|
[[nodiscard]] KeyValueCompare const&
|
||||||
key_compare() const
|
key_compare() const
|
||||||
{
|
{
|
||||||
return *this;
|
return *this;
|
||||||
@@ -323,7 +319,7 @@ private:
|
|||||||
return beast::detail::empty_base_optimization<ElementAllocator>::member();
|
return beast::detail::empty_base_optimization<ElementAllocator>::member();
|
||||||
}
|
}
|
||||||
|
|
||||||
ElementAllocator const&
|
[[nodiscard]] ElementAllocator const&
|
||||||
alloc() const
|
alloc() const
|
||||||
{
|
{
|
||||||
return beast::detail::empty_base_optimization<ElementAllocator>::member();
|
return beast::detail::empty_base_optimization<ElementAllocator>::member();
|
||||||
@@ -374,7 +370,7 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
using key_compare = Compare;
|
using key_compare = Compare;
|
||||||
using value_compare = typename std::conditional<IsMap, pair_value_compare, Compare>::type;
|
using value_compare = std::conditional_t<IsMap, pair_value_compare, Compare>;
|
||||||
using allocator_type = Allocator;
|
using allocator_type = Allocator;
|
||||||
using reference = value_type&;
|
using reference = value_type&;
|
||||||
using const_reference = value_type const&;
|
using const_reference = value_type const&;
|
||||||
@@ -402,6 +398,8 @@ public:
|
|||||||
|
|
||||||
class chronological_t
|
class chronological_t
|
||||||
{
|
{
|
||||||
|
chronological_t() = default;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// A set iterator (IsMap==false) is always const
|
// A set iterator (IsMap==false) is always const
|
||||||
// because the elements of a set are immutable.
|
// because the elements of a set are immutable.
|
||||||
@@ -489,7 +487,7 @@ public:
|
|||||||
iterator
|
iterator
|
||||||
iterator_to(value_type& value)
|
iterator_to(value_type& value)
|
||||||
{
|
{
|
||||||
static_assert(std::is_standard_layout<element>::value, "must be standard layout");
|
static_assert(std::is_standard_layout_v<element>, "must be standard layout");
|
||||||
return list.iterator_to(*reinterpret_cast<element*>(
|
return list.iterator_to(*reinterpret_cast<element*>(
|
||||||
reinterpret_cast<uint8_t*>(&value) -
|
reinterpret_cast<uint8_t*>(&value) -
|
||||||
((std::size_t)std::addressof(((element*)0)->member))));
|
((std::size_t)std::addressof(((element*)0)->member))));
|
||||||
@@ -498,20 +496,16 @@ public:
|
|||||||
const_iterator
|
const_iterator
|
||||||
iterator_to(value_type const& value) const
|
iterator_to(value_type const& value) const
|
||||||
{
|
{
|
||||||
static_assert(std::is_standard_layout<element>::value, "must be standard layout");
|
static_assert(std::is_standard_layout_v<element>, "must be standard layout");
|
||||||
return list.iterator_to(*reinterpret_cast<element const*>(
|
return list.iterator_to(*reinterpret_cast<element const*>(
|
||||||
reinterpret_cast<uint8_t const*>(&value) -
|
reinterpret_cast<uint8_t const*>(&value) -
|
||||||
((std::size_t)std::addressof(((element*)0)->member))));
|
((std::size_t)std::addressof(((element*)0)->member))));
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
|
||||||
chronological_t()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
chronological_t(chronological_t const&) = delete;
|
chronological_t(chronological_t const&) = delete;
|
||||||
chronological_t(chronological_t&&) = delete;
|
chronological_t(chronological_t&&) = delete;
|
||||||
|
|
||||||
|
private:
|
||||||
friend class aged_ordered_container;
|
friend class aged_ordered_container;
|
||||||
list_type mutable list;
|
list_type mutable list;
|
||||||
} chronological;
|
} chronological;
|
||||||
@@ -617,30 +611,30 @@ public:
|
|||||||
class K,
|
class K,
|
||||||
bool maybe_multi = IsMulti,
|
bool maybe_multi = IsMulti,
|
||||||
bool maybe_map = IsMap,
|
bool maybe_map = IsMap,
|
||||||
class = typename std::enable_if<maybe_map && !maybe_multi>::type>
|
class = std::enable_if_t<maybe_map && !maybe_multi>>
|
||||||
typename std::conditional<IsMap, T, void*>::type&
|
std::conditional_t<IsMap, T, void*>&
|
||||||
at(K const& k);
|
at(K const& k);
|
||||||
|
|
||||||
template <
|
template <
|
||||||
class K,
|
class K,
|
||||||
bool maybe_multi = IsMulti,
|
bool maybe_multi = IsMulti,
|
||||||
bool maybe_map = IsMap,
|
bool maybe_map = IsMap,
|
||||||
class = typename std::enable_if<maybe_map && !maybe_multi>::type>
|
class = std::enable_if_t<maybe_map && !maybe_multi>>
|
||||||
typename std::conditional<IsMap, T, void*>::type const&
|
typename std::conditional<IsMap, T, void*>::type const&
|
||||||
at(K const& k) const;
|
at(K const& k) const;
|
||||||
|
|
||||||
template <
|
template <
|
||||||
bool maybe_multi = IsMulti,
|
bool maybe_multi = IsMulti,
|
||||||
bool maybe_map = IsMap,
|
bool maybe_map = IsMap,
|
||||||
class = typename std::enable_if<maybe_map && !maybe_multi>::type>
|
class = std::enable_if_t<maybe_map && !maybe_multi>>
|
||||||
typename std::conditional<IsMap, T, void*>::type&
|
std::conditional_t<IsMap, T, void*>&
|
||||||
operator[](Key const& key);
|
operator[](Key const& key);
|
||||||
|
|
||||||
template <
|
template <
|
||||||
bool maybe_multi = IsMulti,
|
bool maybe_multi = IsMulti,
|
||||||
bool maybe_map = IsMap,
|
bool maybe_map = IsMap,
|
||||||
class = typename std::enable_if<maybe_map && !maybe_multi>::type>
|
class = std::enable_if_t<maybe_map && !maybe_multi>>
|
||||||
typename std::conditional<IsMap, T, void*>::type&
|
std::conditional_t<IsMap, T, void*>&
|
||||||
operator[](Key&& key);
|
operator[](Key&& key);
|
||||||
|
|
||||||
//--------------------------------------------------------------------------
|
//--------------------------------------------------------------------------
|
||||||
@@ -724,7 +718,7 @@ public:
|
|||||||
iterator
|
iterator
|
||||||
iterator_to(value_type& value)
|
iterator_to(value_type& value)
|
||||||
{
|
{
|
||||||
static_assert(std::is_standard_layout<element>::value, "must be standard layout");
|
static_assert(std::is_standard_layout_v<element>, "must be standard layout");
|
||||||
return m_cont.iterator_to(*reinterpret_cast<element*>(
|
return m_cont.iterator_to(*reinterpret_cast<element*>(
|
||||||
reinterpret_cast<uint8_t*>(&value) -
|
reinterpret_cast<uint8_t*>(&value) -
|
||||||
((std::size_t)std::addressof(((element*)0)->member))));
|
((std::size_t)std::addressof(((element*)0)->member))));
|
||||||
@@ -733,7 +727,7 @@ public:
|
|||||||
const_iterator
|
const_iterator
|
||||||
iterator_to(value_type const& value) const
|
iterator_to(value_type const& value) const
|
||||||
{
|
{
|
||||||
static_assert(std::is_standard_layout<element>::value, "must be standard layout");
|
static_assert(std::is_standard_layout_v<element>, "must be standard layout");
|
||||||
return m_cont.iterator_to(*reinterpret_cast<element const*>(
|
return m_cont.iterator_to(*reinterpret_cast<element const*>(
|
||||||
reinterpret_cast<uint8_t const*>(&value) -
|
reinterpret_cast<uint8_t const*>(&value) -
|
||||||
((std::size_t)std::addressof(((element*)0)->member))));
|
((std::size_t)std::addressof(((element*)0)->member))));
|
||||||
@@ -775,37 +769,35 @@ public:
|
|||||||
// map, set
|
// map, set
|
||||||
template <bool maybe_multi = IsMulti>
|
template <bool maybe_multi = IsMulti>
|
||||||
auto
|
auto
|
||||||
insert(value_type const& value) ->
|
insert(value_type const& value) -> std::enable_if_t<!maybe_multi, std::pair<iterator, bool>>;
|
||||||
typename std::enable_if<!maybe_multi, std::pair<iterator, bool>>::type;
|
|
||||||
|
|
||||||
// multimap, multiset
|
// multimap, multiset
|
||||||
template <bool maybe_multi = IsMulti>
|
template <bool maybe_multi = IsMulti>
|
||||||
auto
|
auto
|
||||||
insert(value_type const& value) -> typename std::enable_if<maybe_multi, iterator>::type;
|
insert(value_type const& value) -> std::enable_if_t<maybe_multi, iterator>;
|
||||||
|
|
||||||
// set
|
// set
|
||||||
template <bool maybe_multi = IsMulti, bool maybe_map = IsMap>
|
template <bool maybe_multi = IsMulti, bool maybe_map = IsMap>
|
||||||
auto
|
auto
|
||||||
insert(value_type&& value) ->
|
insert(value_type&& value)
|
||||||
typename std::enable_if<!maybe_multi && !maybe_map, std::pair<iterator, bool>>::type;
|
-> std::enable_if_t<!maybe_multi && !maybe_map, std::pair<iterator, bool>>;
|
||||||
|
|
||||||
// multiset
|
// multiset
|
||||||
template <bool maybe_multi = IsMulti, bool maybe_map = IsMap>
|
template <bool maybe_multi = IsMulti, bool maybe_map = IsMap>
|
||||||
auto
|
auto
|
||||||
insert(value_type&& value) ->
|
insert(value_type&& value) -> std::enable_if_t<maybe_multi && !maybe_map, iterator>;
|
||||||
typename std::enable_if<maybe_multi && !maybe_map, iterator>::type;
|
|
||||||
|
|
||||||
//---
|
//---
|
||||||
|
|
||||||
// map, set
|
// map, set
|
||||||
template <bool maybe_multi = IsMulti>
|
template <bool maybe_multi = IsMulti>
|
||||||
auto
|
auto
|
||||||
insert(const_iterator hint, value_type const& value) ->
|
insert(const_iterator hint, value_type const& value)
|
||||||
typename std::enable_if<!maybe_multi, iterator>::type;
|
-> std::enable_if_t<!maybe_multi, iterator>;
|
||||||
|
|
||||||
// multimap, multiset
|
// multimap, multiset
|
||||||
template <bool maybe_multi = IsMulti>
|
template <bool maybe_multi = IsMulti>
|
||||||
typename std::enable_if<maybe_multi, iterator>::type
|
std::enable_if_t<maybe_multi, iterator>
|
||||||
insert(const_iterator /*hint*/, value_type const& value)
|
insert(const_iterator /*hint*/, value_type const& value)
|
||||||
{
|
{
|
||||||
// VFALCO TODO Figure out how to utilize 'hint'
|
// VFALCO TODO Figure out how to utilize 'hint'
|
||||||
@@ -815,12 +807,11 @@ public:
|
|||||||
// map, set
|
// map, set
|
||||||
template <bool maybe_multi = IsMulti>
|
template <bool maybe_multi = IsMulti>
|
||||||
auto
|
auto
|
||||||
insert(const_iterator hint, value_type&& value) ->
|
insert(const_iterator hint, value_type&& value) -> std::enable_if_t<!maybe_multi, iterator>;
|
||||||
typename std::enable_if<!maybe_multi, iterator>::type;
|
|
||||||
|
|
||||||
// multimap, multiset
|
// multimap, multiset
|
||||||
template <bool maybe_multi = IsMulti>
|
template <bool maybe_multi = IsMulti>
|
||||||
typename std::enable_if<maybe_multi, iterator>::type
|
std::enable_if_t<maybe_multi, iterator>
|
||||||
insert(const_iterator /*hint*/, value_type&& value)
|
insert(const_iterator /*hint*/, value_type&& value)
|
||||||
{
|
{
|
||||||
// VFALCO TODO Figure out how to utilize 'hint'
|
// VFALCO TODO Figure out how to utilize 'hint'
|
||||||
@@ -829,9 +820,9 @@ public:
|
|||||||
|
|
||||||
// map, multimap
|
// map, multimap
|
||||||
template <class P, bool maybe_map = IsMap>
|
template <class P, bool maybe_map = IsMap>
|
||||||
typename std::enable_if<
|
std::enable_if_t<
|
||||||
maybe_map && std::is_constructible<value_type, P&&>::value,
|
maybe_map && std::is_constructible_v<value_type, P&&>,
|
||||||
typename std::conditional<IsMulti, iterator, std::pair<iterator, bool>>::type>::type
|
std::conditional_t<IsMulti, iterator, std::pair<iterator, bool>>>
|
||||||
insert(P&& value)
|
insert(P&& value)
|
||||||
{
|
{
|
||||||
return emplace(std::forward<P>(value));
|
return emplace(std::forward<P>(value));
|
||||||
@@ -839,9 +830,9 @@ public:
|
|||||||
|
|
||||||
// map, multimap
|
// map, multimap
|
||||||
template <class P, bool maybe_map = IsMap>
|
template <class P, bool maybe_map = IsMap>
|
||||||
typename std::enable_if<
|
std::enable_if_t<
|
||||||
maybe_map && std::is_constructible<value_type, P&&>::value,
|
maybe_map && std::is_constructible_v<value_type, P&&>,
|
||||||
typename std::conditional<IsMulti, iterator, std::pair<iterator, bool>>::type>::type
|
std::conditional_t<IsMulti, iterator, std::pair<iterator, bool>>>
|
||||||
insert(const_iterator hint, P&& value)
|
insert(const_iterator hint, P&& value)
|
||||||
{
|
{
|
||||||
return emplace_hint(hint, std::forward<P>(value));
|
return emplace_hint(hint, std::forward<P>(value));
|
||||||
@@ -864,23 +855,22 @@ public:
|
|||||||
// map, set
|
// map, set
|
||||||
template <bool maybe_multi = IsMulti, class... Args>
|
template <bool maybe_multi = IsMulti, class... Args>
|
||||||
auto
|
auto
|
||||||
emplace(Args&&... args) ->
|
emplace(Args&&... args) -> std::enable_if_t<!maybe_multi, std::pair<iterator, bool>>;
|
||||||
typename std::enable_if<!maybe_multi, std::pair<iterator, bool>>::type;
|
|
||||||
|
|
||||||
// multiset, multimap
|
// multiset, multimap
|
||||||
template <bool maybe_multi = IsMulti, class... Args>
|
template <bool maybe_multi = IsMulti, class... Args>
|
||||||
auto
|
auto
|
||||||
emplace(Args&&... args) -> typename std::enable_if<maybe_multi, iterator>::type;
|
emplace(Args&&... args) -> std::enable_if_t<maybe_multi, iterator>;
|
||||||
|
|
||||||
// map, set
|
// map, set
|
||||||
template <bool maybe_multi = IsMulti, class... Args>
|
template <bool maybe_multi = IsMulti, class... Args>
|
||||||
auto
|
auto
|
||||||
emplace_hint(const_iterator hint, Args&&... args) ->
|
emplace_hint(const_iterator hint, Args&&... args)
|
||||||
typename std::enable_if<!maybe_multi, std::pair<iterator, bool>>::type;
|
-> std::enable_if_t<!maybe_multi, std::pair<iterator, bool>>;
|
||||||
|
|
||||||
// multiset, multimap
|
// multiset, multimap
|
||||||
template <bool maybe_multi = IsMulti, class... Args>
|
template <bool maybe_multi = IsMulti, class... Args>
|
||||||
typename std::enable_if<maybe_multi, iterator>::type
|
std::enable_if_t<maybe_multi, iterator>
|
||||||
emplace_hint(const_iterator /*hint*/, Args&&... args)
|
emplace_hint(const_iterator /*hint*/, Args&&... args)
|
||||||
{
|
{
|
||||||
// VFALCO TODO Figure out how to utilize 'hint'
|
// VFALCO TODO Figure out how to utilize 'hint'
|
||||||
@@ -1164,12 +1154,12 @@ private:
|
|||||||
|
|
||||||
template <
|
template <
|
||||||
bool maybe_propagate = std::allocator_traits<Allocator>::propagate_on_container_swap::value>
|
bool maybe_propagate = std::allocator_traits<Allocator>::propagate_on_container_swap::value>
|
||||||
typename std::enable_if<maybe_propagate>::type
|
std::enable_if_t<maybe_propagate>
|
||||||
swap_data(aged_ordered_container& other) noexcept;
|
swap_data(aged_ordered_container& other) noexcept;
|
||||||
|
|
||||||
template <
|
template <
|
||||||
bool maybe_propagate = std::allocator_traits<Allocator>::propagate_on_container_swap::value>
|
bool maybe_propagate = std::allocator_traits<Allocator>::propagate_on_container_swap::value>
|
||||||
typename std::enable_if<!maybe_propagate>::type
|
std::enable_if_t<!maybe_propagate>
|
||||||
swap_data(aged_ordered_container& other) noexcept;
|
swap_data(aged_ordered_container& other) noexcept;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -1396,7 +1386,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 IsMulti, bool IsMap, class Key, class T, class Clock, class Compare, class Allocator>
|
||||||
template <class K, bool maybe_multi, bool maybe_map, class>
|
template <class K, bool maybe_multi, bool maybe_map, class>
|
||||||
typename std::conditional<IsMap, T, void*>::type&
|
std::conditional_t<IsMap, T, void*>&
|
||||||
aged_ordered_container<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::at(K const& k)
|
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())));
|
auto const iter(m_cont.find(k, std::cref(m_config.key_compare())));
|
||||||
@@ -1418,7 +1408,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 IsMulti, bool IsMap, class Key, class T, class Clock, class Compare, class Allocator>
|
||||||
template <bool maybe_multi, bool maybe_map, class>
|
template <bool maybe_multi, bool maybe_map, class>
|
||||||
typename std::conditional<IsMap, T, void*>::type&
|
std::conditional_t<IsMap, T, void*>&
|
||||||
aged_ordered_container<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::operator[](
|
aged_ordered_container<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::operator[](
|
||||||
Key const& key)
|
Key const& key)
|
||||||
{
|
{
|
||||||
@@ -1437,7 +1427,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 IsMulti, bool IsMap, class Key, class T, class Clock, class Compare, class Allocator>
|
||||||
template <bool maybe_multi, bool maybe_map, class>
|
template <bool maybe_multi, bool maybe_map, class>
|
||||||
typename std::conditional<IsMap, T, void*>::type&
|
std::conditional_t<IsMap, T, void*>&
|
||||||
aged_ordered_container<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::operator[](Key&& key)
|
aged_ordered_container<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::operator[](Key&& key)
|
||||||
{
|
{
|
||||||
typename cont_type::insert_commit_data d;
|
typename cont_type::insert_commit_data d;
|
||||||
@@ -1472,8 +1462,7 @@ template <bool IsMulti, bool IsMap, class Key, class T, class Clock, class Compa
|
|||||||
template <bool maybe_multi>
|
template <bool maybe_multi>
|
||||||
auto
|
auto
|
||||||
aged_ordered_container<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::insert(
|
aged_ordered_container<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::insert(
|
||||||
value_type const& value) ->
|
value_type const& value) -> std::enable_if_t<!maybe_multi, std::pair<iterator, bool>>
|
||||||
typename std::enable_if<!maybe_multi, std::pair<iterator, bool>>::type
|
|
||||||
{
|
{
|
||||||
typename cont_type::insert_commit_data d;
|
typename cont_type::insert_commit_data d;
|
||||||
auto const result(m_cont.insert_check(extract(value), std::cref(m_config.key_compare()), d));
|
auto const result(m_cont.insert_check(extract(value), std::cref(m_config.key_compare()), d));
|
||||||
@@ -1492,7 +1481,7 @@ template <bool IsMulti, bool IsMap, class Key, class T, class Clock, class Compa
|
|||||||
template <bool maybe_multi>
|
template <bool maybe_multi>
|
||||||
auto
|
auto
|
||||||
aged_ordered_container<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::insert(
|
aged_ordered_container<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::insert(
|
||||||
value_type const& value) -> typename std::enable_if<maybe_multi, iterator>::type
|
value_type const& value) -> std::enable_if_t<maybe_multi, iterator>
|
||||||
{
|
{
|
||||||
auto const before(m_cont.upper_bound(extract(value), std::cref(m_config.key_compare())));
|
auto const before(m_cont.upper_bound(extract(value), std::cref(m_config.key_compare())));
|
||||||
element* const p(new_element(value));
|
element* const p(new_element(value));
|
||||||
@@ -1506,8 +1495,7 @@ template <bool IsMulti, bool IsMap, class Key, class T, class Clock, class Compa
|
|||||||
template <bool maybe_multi, bool maybe_map>
|
template <bool maybe_multi, bool maybe_map>
|
||||||
auto
|
auto
|
||||||
aged_ordered_container<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::insert(
|
aged_ordered_container<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::insert(
|
||||||
value_type&& value) ->
|
value_type&& value) -> std::enable_if_t<!maybe_multi && !maybe_map, std::pair<iterator, bool>>
|
||||||
typename std::enable_if<!maybe_multi && !maybe_map, std::pair<iterator, bool>>::type
|
|
||||||
{
|
{
|
||||||
typename cont_type::insert_commit_data d;
|
typename cont_type::insert_commit_data d;
|
||||||
auto const result(m_cont.insert_check(extract(value), std::cref(m_config.key_compare()), d));
|
auto const result(m_cont.insert_check(extract(value), std::cref(m_config.key_compare()), d));
|
||||||
@@ -1526,7 +1514,7 @@ template <bool IsMulti, bool IsMap, class Key, class T, class Clock, class Compa
|
|||||||
template <bool maybe_multi, bool maybe_map>
|
template <bool maybe_multi, bool maybe_map>
|
||||||
auto
|
auto
|
||||||
aged_ordered_container<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::insert(
|
aged_ordered_container<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::insert(
|
||||||
value_type&& value) -> typename std::enable_if<maybe_multi && !maybe_map, iterator>::type
|
value_type&& value) -> std::enable_if_t<maybe_multi && !maybe_map, iterator>
|
||||||
{
|
{
|
||||||
auto const before(m_cont.upper_bound(extract(value), std::cref(m_config.key_compare())));
|
auto const before(m_cont.upper_bound(extract(value), std::cref(m_config.key_compare())));
|
||||||
element* const p(new_element(std::move(value)));
|
element* const p(new_element(std::move(value)));
|
||||||
@@ -1543,7 +1531,7 @@ template <bool maybe_multi>
|
|||||||
auto
|
auto
|
||||||
aged_ordered_container<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::insert(
|
aged_ordered_container<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::insert(
|
||||||
const_iterator hint,
|
const_iterator hint,
|
||||||
value_type const& value) -> typename std::enable_if<!maybe_multi, iterator>::type
|
value_type const& value) -> std::enable_if_t<!maybe_multi, iterator>
|
||||||
{
|
{
|
||||||
typename cont_type::insert_commit_data d;
|
typename cont_type::insert_commit_data d;
|
||||||
auto const result(
|
auto const result(
|
||||||
@@ -1564,7 +1552,7 @@ template <bool maybe_multi>
|
|||||||
auto
|
auto
|
||||||
aged_ordered_container<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::insert(
|
aged_ordered_container<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::insert(
|
||||||
const_iterator hint,
|
const_iterator hint,
|
||||||
value_type&& value) -> typename std::enable_if<!maybe_multi, iterator>::type
|
value_type&& value) -> std::enable_if_t<!maybe_multi, iterator>
|
||||||
{
|
{
|
||||||
typename cont_type::insert_commit_data d;
|
typename cont_type::insert_commit_data d;
|
||||||
auto const result(
|
auto const result(
|
||||||
@@ -1584,7 +1572,7 @@ template <bool IsMulti, bool IsMap, class Key, class T, class Clock, class Compa
|
|||||||
template <bool maybe_multi, class... Args>
|
template <bool maybe_multi, class... Args>
|
||||||
auto
|
auto
|
||||||
aged_ordered_container<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::emplace(Args&&... args)
|
aged_ordered_container<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::emplace(Args&&... args)
|
||||||
-> typename std::enable_if<!maybe_multi, std::pair<iterator, bool>>::type
|
-> std::enable_if_t<!maybe_multi, std::pair<iterator, bool>>
|
||||||
{
|
{
|
||||||
// VFALCO NOTE Its unfortunate that we need to
|
// VFALCO NOTE Its unfortunate that we need to
|
||||||
// construct element here
|
// construct element here
|
||||||
@@ -1606,7 +1594,7 @@ template <bool IsMulti, bool IsMap, class Key, class T, class Clock, class Compa
|
|||||||
template <bool maybe_multi, class... Args>
|
template <bool maybe_multi, class... Args>
|
||||||
auto
|
auto
|
||||||
aged_ordered_container<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::emplace(Args&&... args)
|
aged_ordered_container<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::emplace(Args&&... args)
|
||||||
-> typename std::enable_if<maybe_multi, iterator>::type
|
-> std::enable_if_t<maybe_multi, iterator>
|
||||||
{
|
{
|
||||||
element* const p(new_element(std::forward<Args>(args)...));
|
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())));
|
auto const before(m_cont.upper_bound(extract(p->value), std::cref(m_config.key_compare())));
|
||||||
@@ -1621,7 +1609,7 @@ template <bool maybe_multi, class... Args>
|
|||||||
auto
|
auto
|
||||||
aged_ordered_container<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::emplace_hint(
|
aged_ordered_container<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::emplace_hint(
|
||||||
const_iterator hint,
|
const_iterator hint,
|
||||||
Args&&... args) -> typename std::enable_if<!maybe_multi, std::pair<iterator, bool>>::type
|
Args&&... args) -> std::enable_if_t<!maybe_multi, std::pair<iterator, bool>>
|
||||||
{
|
{
|
||||||
// VFALCO NOTE Its unfortunate that we need to
|
// VFALCO NOTE Its unfortunate that we need to
|
||||||
// construct element here
|
// construct element here
|
||||||
@@ -1771,7 +1759,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 IsMulti, bool IsMap, class Key, class T, class Clock, class Compare, class Allocator>
|
||||||
template <bool maybe_propagate>
|
template <bool maybe_propagate>
|
||||||
typename std::enable_if<maybe_propagate>::type
|
std::enable_if_t<maybe_propagate>
|
||||||
aged_ordered_container<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::swap_data(
|
aged_ordered_container<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::swap_data(
|
||||||
aged_ordered_container& other) noexcept
|
aged_ordered_container& other) noexcept
|
||||||
{
|
{
|
||||||
@@ -1782,7 +1770,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 IsMulti, bool IsMap, class Key, class T, class Clock, class Compare, class Allocator>
|
||||||
template <bool maybe_propagate>
|
template <bool maybe_propagate>
|
||||||
typename std::enable_if<!maybe_propagate>::type
|
std::enable_if_t<!maybe_propagate>
|
||||||
aged_ordered_container<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::swap_data(
|
aged_ordered_container<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::swap_data(
|
||||||
aged_ordered_container& other) noexcept
|
aged_ordered_container& other) noexcept
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -62,8 +62,7 @@ template <
|
|||||||
class Clock = std::chrono::steady_clock,
|
class Clock = std::chrono::steady_clock,
|
||||||
class Hash = std::hash<Key>,
|
class Hash = std::hash<Key>,
|
||||||
class KeyEqual = std::equal_to<Key>,
|
class KeyEqual = std::equal_to<Key>,
|
||||||
class Allocator =
|
class Allocator = std::allocator<std::conditional_t<IsMap, std::pair<Key const, T>, Key>>>
|
||||||
std::allocator<typename std::conditional<IsMap, std::pair<Key const, T>, Key>::type>>
|
|
||||||
class aged_unordered_container
|
class aged_unordered_container
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -72,7 +71,7 @@ public:
|
|||||||
using duration = typename clock_type::duration;
|
using duration = typename clock_type::duration;
|
||||||
using key_type = Key;
|
using key_type = Key;
|
||||||
using mapped_type = T;
|
using mapped_type = T;
|
||||||
using value_type = typename std::conditional<IsMap, std::pair<Key const, T>, Key>::type;
|
using value_type = std::conditional_t<IsMap, std::pair<Key const, T>, Key>;
|
||||||
using size_type = std::size_t;
|
using size_type = std::size_t;
|
||||||
using difference_type = std::ptrdiff_t;
|
using difference_type = std::ptrdiff_t;
|
||||||
|
|
||||||
@@ -115,8 +114,7 @@ private:
|
|||||||
|
|
||||||
template <
|
template <
|
||||||
class... Args,
|
class... Args,
|
||||||
class =
|
class = std::enable_if_t<std::is_constructible_v<value_type, Args...>>>
|
||||||
typename std::enable_if<std::is_constructible<value_type, Args...>::value>::type>
|
|
||||||
element(time_point const& when_, Args&&... args)
|
element(time_point const& when_, Args&&... args)
|
||||||
: value(std::forward<Args>(args)...), when(when_)
|
: value(std::forward<Args>(args)...), when(when_)
|
||||||
{
|
{
|
||||||
@@ -133,9 +131,7 @@ private:
|
|||||||
using argument_type = element;
|
using argument_type = element;
|
||||||
using result_type = size_t;
|
using result_type = size_t;
|
||||||
|
|
||||||
ValueHash()
|
ValueHash() = default;
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
ValueHash(Hash const& h) : Hash(h)
|
ValueHash(Hash const& h) : Hash(h)
|
||||||
{
|
{
|
||||||
@@ -153,7 +149,7 @@ private:
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
Hash const&
|
[[nodiscard]] Hash const&
|
||||||
hash_function() const
|
hash_function() const
|
||||||
{
|
{
|
||||||
return *this;
|
return *this;
|
||||||
@@ -169,9 +165,7 @@ private:
|
|||||||
using second_argument_type = element;
|
using second_argument_type = element;
|
||||||
using result_type = bool;
|
using result_type = bool;
|
||||||
|
|
||||||
KeyValueEqual()
|
KeyValueEqual() = default;
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
KeyValueEqual(KeyEqual const& keyEqual) : KeyEqual(keyEqual)
|
KeyValueEqual(KeyEqual const& keyEqual) : KeyEqual(keyEqual)
|
||||||
{
|
{
|
||||||
@@ -201,7 +195,7 @@ private:
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
KeyEqual const&
|
[[nodiscard]] KeyEqual const&
|
||||||
key_eq() const
|
key_eq() const
|
||||||
{
|
{
|
||||||
return *this;
|
return *this;
|
||||||
@@ -211,7 +205,7 @@ private:
|
|||||||
using list_type = typename boost::intrusive::
|
using list_type = typename boost::intrusive::
|
||||||
make_list<element, boost::intrusive::constant_time_size<false>>::type;
|
make_list<element, boost::intrusive::constant_time_size<false>>::type;
|
||||||
|
|
||||||
using cont_type = typename std::conditional<
|
using cont_type = std::conditional_t<
|
||||||
IsMulti,
|
IsMulti,
|
||||||
typename boost::intrusive::make_unordered_multiset<
|
typename boost::intrusive::make_unordered_multiset<
|
||||||
element,
|
element,
|
||||||
@@ -224,7 +218,7 @@ private:
|
|||||||
boost::intrusive::constant_time_size<true>,
|
boost::intrusive::constant_time_size<true>,
|
||||||
boost::intrusive::hash<ValueHash>,
|
boost::intrusive::hash<ValueHash>,
|
||||||
boost::intrusive::equal<KeyValueEqual>,
|
boost::intrusive::equal<KeyValueEqual>,
|
||||||
boost::intrusive::cache_begin<true>>::type>::type;
|
boost::intrusive::cache_begin<true>>::type>;
|
||||||
|
|
||||||
using bucket_type = typename cont_type::bucket_type;
|
using bucket_type = typename cont_type::bucket_type;
|
||||||
using bucket_traits = typename cont_type::bucket_traits;
|
using bucket_traits = typename cont_type::bucket_traits;
|
||||||
@@ -354,7 +348,7 @@ private:
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
ValueHash const&
|
[[nodiscard]] ValueHash const&
|
||||||
value_hash() const
|
value_hash() const
|
||||||
{
|
{
|
||||||
return *this;
|
return *this;
|
||||||
@@ -366,7 +360,7 @@ private:
|
|||||||
return ValueHash::hash_function();
|
return ValueHash::hash_function();
|
||||||
}
|
}
|
||||||
|
|
||||||
Hash const&
|
[[nodiscard]] Hash const&
|
||||||
hash_function() const
|
hash_function() const
|
||||||
{
|
{
|
||||||
return ValueHash::hash_function();
|
return ValueHash::hash_function();
|
||||||
@@ -378,7 +372,7 @@ private:
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
KeyValueEqual const&
|
[[nodiscard]] KeyValueEqual const&
|
||||||
key_value_equal() const
|
key_value_equal() const
|
||||||
{
|
{
|
||||||
return *this;
|
return *this;
|
||||||
@@ -390,7 +384,7 @@ private:
|
|||||||
return key_value_equal().key_eq();
|
return key_value_equal().key_eq();
|
||||||
}
|
}
|
||||||
|
|
||||||
KeyEqual const&
|
[[nodiscard]] KeyEqual const&
|
||||||
key_eq() const
|
key_eq() const
|
||||||
{
|
{
|
||||||
return key_value_equal().key_eq();
|
return key_value_equal().key_eq();
|
||||||
@@ -402,7 +396,7 @@ private:
|
|||||||
return beast::detail::empty_base_optimization<ElementAllocator>::member();
|
return beast::detail::empty_base_optimization<ElementAllocator>::member();
|
||||||
}
|
}
|
||||||
|
|
||||||
ElementAllocator const&
|
[[nodiscard]] ElementAllocator const&
|
||||||
alloc() const
|
alloc() const
|
||||||
{
|
{
|
||||||
return beast::detail::empty_base_optimization<ElementAllocator>::member();
|
return beast::detail::empty_base_optimization<ElementAllocator>::member();
|
||||||
@@ -439,7 +433,7 @@ private:
|
|||||||
m_vec.clear();
|
m_vec.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
size_type
|
[[nodiscard]] size_type
|
||||||
max_bucket_count() const
|
max_bucket_count() const
|
||||||
{
|
{
|
||||||
return m_vec.max_size();
|
return m_vec.max_size();
|
||||||
@@ -451,7 +445,7 @@ private:
|
|||||||
return m_max_load_factor;
|
return m_max_load_factor;
|
||||||
}
|
}
|
||||||
|
|
||||||
float const&
|
[[nodiscard]] float const&
|
||||||
max_load_factor() const
|
max_load_factor() const
|
||||||
{
|
{
|
||||||
return m_max_load_factor;
|
return m_max_load_factor;
|
||||||
@@ -662,7 +656,7 @@ public:
|
|||||||
iterator
|
iterator
|
||||||
iterator_to(value_type& value)
|
iterator_to(value_type& value)
|
||||||
{
|
{
|
||||||
static_assert(std::is_standard_layout<element>::value, "must be standard layout");
|
static_assert(std::is_standard_layout_v<element>, "must be standard layout");
|
||||||
return list.iterator_to(*reinterpret_cast<element*>(
|
return list.iterator_to(*reinterpret_cast<element*>(
|
||||||
reinterpret_cast<uint8_t*>(&value) -
|
reinterpret_cast<uint8_t*>(&value) -
|
||||||
((std::size_t)std::addressof(((element*)0)->member))));
|
((std::size_t)std::addressof(((element*)0)->member))));
|
||||||
@@ -671,20 +665,17 @@ public:
|
|||||||
const_iterator
|
const_iterator
|
||||||
iterator_to(value_type const& value) const
|
iterator_to(value_type const& value) const
|
||||||
{
|
{
|
||||||
static_assert(std::is_standard_layout<element>::value, "must be standard layout");
|
static_assert(std::is_standard_layout_v<element>, "must be standard layout");
|
||||||
return list.iterator_to(*reinterpret_cast<element const*>(
|
return list.iterator_to(*reinterpret_cast<element const*>(
|
||||||
reinterpret_cast<uint8_t const*>(&value) -
|
reinterpret_cast<uint8_t const*>(&value) -
|
||||||
((std::size_t)std::addressof(((element*)0)->member))));
|
((std::size_t)std::addressof(((element*)0)->member))));
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
|
||||||
chronological_t()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
chronological_t(chronological_t const&) = delete;
|
chronological_t(chronological_t const&) = delete;
|
||||||
chronological_t(chronological_t&&) = delete;
|
chronological_t(chronological_t&&) = delete;
|
||||||
|
chronological_t() = default;
|
||||||
|
|
||||||
|
private:
|
||||||
friend class aged_unordered_container;
|
friend class aged_unordered_container;
|
||||||
list_type mutable list;
|
list_type mutable list;
|
||||||
} chronological;
|
} chronological;
|
||||||
@@ -862,30 +853,30 @@ public:
|
|||||||
class K,
|
class K,
|
||||||
bool maybe_multi = IsMulti,
|
bool maybe_multi = IsMulti,
|
||||||
bool maybe_map = IsMap,
|
bool maybe_map = IsMap,
|
||||||
class = typename std::enable_if<maybe_map && !maybe_multi>::type>
|
class = std::enable_if_t<maybe_map && !maybe_multi>>
|
||||||
typename std::conditional<IsMap, T, void*>::type&
|
std::conditional_t<IsMap, T, void*>&
|
||||||
at(K const& k);
|
at(K const& k);
|
||||||
|
|
||||||
template <
|
template <
|
||||||
class K,
|
class K,
|
||||||
bool maybe_multi = IsMulti,
|
bool maybe_multi = IsMulti,
|
||||||
bool maybe_map = IsMap,
|
bool maybe_map = IsMap,
|
||||||
class = typename std::enable_if<maybe_map && !maybe_multi>::type>
|
class = std::enable_if_t<maybe_map && !maybe_multi>>
|
||||||
typename std::conditional<IsMap, T, void*>::type const&
|
typename std::conditional<IsMap, T, void*>::type const&
|
||||||
at(K const& k) const;
|
at(K const& k) const;
|
||||||
|
|
||||||
template <
|
template <
|
||||||
bool maybe_multi = IsMulti,
|
bool maybe_multi = IsMulti,
|
||||||
bool maybe_map = IsMap,
|
bool maybe_map = IsMap,
|
||||||
class = typename std::enable_if<maybe_map && !maybe_multi>::type>
|
class = std::enable_if_t<maybe_map && !maybe_multi>>
|
||||||
typename std::conditional<IsMap, T, void*>::type&
|
std::conditional_t<IsMap, T, void*>&
|
||||||
operator[](Key const& key);
|
operator[](Key const& key);
|
||||||
|
|
||||||
template <
|
template <
|
||||||
bool maybe_multi = IsMulti,
|
bool maybe_multi = IsMulti,
|
||||||
bool maybe_map = IsMap,
|
bool maybe_map = IsMap,
|
||||||
class = typename std::enable_if<maybe_map && !maybe_multi>::type>
|
class = std::enable_if_t<maybe_map && !maybe_multi>>
|
||||||
typename std::conditional<IsMap, T, void*>::type&
|
std::conditional_t<IsMap, T, void*>&
|
||||||
operator[](Key&& key);
|
operator[](Key&& key);
|
||||||
|
|
||||||
//--------------------------------------------------------------------------
|
//--------------------------------------------------------------------------
|
||||||
@@ -933,7 +924,7 @@ public:
|
|||||||
iterator
|
iterator
|
||||||
iterator_to(value_type& value)
|
iterator_to(value_type& value)
|
||||||
{
|
{
|
||||||
static_assert(std::is_standard_layout<element>::value, "must be standard layout");
|
static_assert(std::is_standard_layout_v<element>, "must be standard layout");
|
||||||
return m_cont.iterator_to(*reinterpret_cast<element*>(
|
return m_cont.iterator_to(*reinterpret_cast<element*>(
|
||||||
reinterpret_cast<uint8_t*>(&value) -
|
reinterpret_cast<uint8_t*>(&value) -
|
||||||
((std::size_t)std::addressof(((element*)0)->member))));
|
((std::size_t)std::addressof(((element*)0)->member))));
|
||||||
@@ -942,7 +933,7 @@ public:
|
|||||||
const_iterator
|
const_iterator
|
||||||
iterator_to(value_type const& value) const
|
iterator_to(value_type const& value) const
|
||||||
{
|
{
|
||||||
static_assert(std::is_standard_layout<element>::value, "must be standard layout");
|
static_assert(std::is_standard_layout_v<element>, "must be standard layout");
|
||||||
return m_cont.iterator_to(*reinterpret_cast<element const*>(
|
return m_cont.iterator_to(*reinterpret_cast<element const*>(
|
||||||
reinterpret_cast<uint8_t const*>(&value) -
|
reinterpret_cast<uint8_t const*>(&value) -
|
||||||
((std::size_t)std::addressof(((element*)0)->member))));
|
((std::size_t)std::addressof(((element*)0)->member))));
|
||||||
@@ -984,29 +975,27 @@ public:
|
|||||||
// map, set
|
// map, set
|
||||||
template <bool maybe_multi = IsMulti>
|
template <bool maybe_multi = IsMulti>
|
||||||
auto
|
auto
|
||||||
insert(value_type const& value) ->
|
insert(value_type const& value) -> std::enable_if_t<!maybe_multi, std::pair<iterator, bool>>;
|
||||||
typename std::enable_if<!maybe_multi, std::pair<iterator, bool>>::type;
|
|
||||||
|
|
||||||
// multimap, multiset
|
// multimap, multiset
|
||||||
template <bool maybe_multi = IsMulti>
|
template <bool maybe_multi = IsMulti>
|
||||||
auto
|
auto
|
||||||
insert(value_type const& value) -> typename std::enable_if<maybe_multi, iterator>::type;
|
insert(value_type const& value) -> std::enable_if_t<maybe_multi, iterator>;
|
||||||
|
|
||||||
// map, set
|
// map, set
|
||||||
template <bool maybe_multi = IsMulti, bool maybe_map = IsMap>
|
template <bool maybe_multi = IsMulti, bool maybe_map = IsMap>
|
||||||
auto
|
auto
|
||||||
insert(value_type&& value) ->
|
insert(value_type&& value)
|
||||||
typename std::enable_if<!maybe_multi && !maybe_map, std::pair<iterator, bool>>::type;
|
-> std::enable_if_t<!maybe_multi && !maybe_map, std::pair<iterator, bool>>;
|
||||||
|
|
||||||
// multimap, multiset
|
// multimap, multiset
|
||||||
template <bool maybe_multi = IsMulti, bool maybe_map = IsMap>
|
template <bool maybe_multi = IsMulti, bool maybe_map = IsMap>
|
||||||
auto
|
auto
|
||||||
insert(value_type&& value) ->
|
insert(value_type&& value) -> std::enable_if_t<maybe_multi && !maybe_map, iterator>;
|
||||||
typename std::enable_if<maybe_multi && !maybe_map, iterator>::type;
|
|
||||||
|
|
||||||
// map, set
|
// map, set
|
||||||
template <bool maybe_multi = IsMulti>
|
template <bool maybe_multi = IsMulti>
|
||||||
typename std::enable_if<!maybe_multi, iterator>::type
|
std::enable_if_t<!maybe_multi, iterator>
|
||||||
insert(const_iterator /*hint*/, value_type const& value)
|
insert(const_iterator /*hint*/, value_type const& value)
|
||||||
{
|
{
|
||||||
// Hint is ignored but we provide the interface so
|
// Hint is ignored but we provide the interface so
|
||||||
@@ -1016,7 +1005,7 @@ public:
|
|||||||
|
|
||||||
// multimap, multiset
|
// multimap, multiset
|
||||||
template <bool maybe_multi = IsMulti>
|
template <bool maybe_multi = IsMulti>
|
||||||
typename std::enable_if<maybe_multi, iterator>::type
|
std::enable_if_t<maybe_multi, iterator>
|
||||||
insert(const_iterator /*hint*/, value_type const& value)
|
insert(const_iterator /*hint*/, value_type const& value)
|
||||||
{
|
{
|
||||||
// VFALCO TODO The hint could be used to let
|
// VFALCO TODO The hint could be used to let
|
||||||
@@ -1026,7 +1015,7 @@ public:
|
|||||||
|
|
||||||
// map, set
|
// map, set
|
||||||
template <bool maybe_multi = IsMulti>
|
template <bool maybe_multi = IsMulti>
|
||||||
typename std::enable_if<!maybe_multi, iterator>::type
|
std::enable_if_t<!maybe_multi, iterator>
|
||||||
insert(const_iterator /*hint*/, value_type&& value)
|
insert(const_iterator /*hint*/, value_type&& value)
|
||||||
{
|
{
|
||||||
// Hint is ignored but we provide the interface so
|
// Hint is ignored but we provide the interface so
|
||||||
@@ -1036,7 +1025,7 @@ public:
|
|||||||
|
|
||||||
// multimap, multiset
|
// multimap, multiset
|
||||||
template <bool maybe_multi = IsMulti>
|
template <bool maybe_multi = IsMulti>
|
||||||
typename std::enable_if<maybe_multi, iterator>::type
|
std::enable_if_t<maybe_multi, iterator>
|
||||||
insert(const_iterator /*hint*/, value_type&& value)
|
insert(const_iterator /*hint*/, value_type&& value)
|
||||||
{
|
{
|
||||||
// VFALCO TODO The hint could be used to let
|
// VFALCO TODO The hint could be used to let
|
||||||
@@ -1046,9 +1035,9 @@ public:
|
|||||||
|
|
||||||
// map, multimap
|
// map, multimap
|
||||||
template <class P, bool maybe_map = IsMap>
|
template <class P, bool maybe_map = IsMap>
|
||||||
typename std::enable_if<
|
std::enable_if_t<
|
||||||
maybe_map && std::is_constructible<value_type, P&&>::value,
|
maybe_map && std::is_constructible_v<value_type, P&&>,
|
||||||
typename std::conditional<IsMulti, iterator, std::pair<iterator, bool>>::type>::type
|
std::conditional_t<IsMulti, iterator, std::pair<iterator, bool>>>
|
||||||
insert(P&& value)
|
insert(P&& value)
|
||||||
{
|
{
|
||||||
return emplace(std::forward<P>(value));
|
return emplace(std::forward<P>(value));
|
||||||
@@ -1056,9 +1045,9 @@ public:
|
|||||||
|
|
||||||
// map, multimap
|
// map, multimap
|
||||||
template <class P, bool maybe_map = IsMap>
|
template <class P, bool maybe_map = IsMap>
|
||||||
typename std::enable_if<
|
std::enable_if_t<
|
||||||
maybe_map && std::is_constructible<value_type, P&&>::value,
|
maybe_map && std::is_constructible_v<value_type, P&&>,
|
||||||
typename std::conditional<IsMulti, iterator, std::pair<iterator, bool>>::type>::type
|
std::conditional_t<IsMulti, iterator, std::pair<iterator, bool>>>
|
||||||
insert(const_iterator hint, P&& value)
|
insert(const_iterator hint, P&& value)
|
||||||
{
|
{
|
||||||
return emplace_hint(hint, std::forward<P>(value));
|
return emplace_hint(hint, std::forward<P>(value));
|
||||||
@@ -1080,23 +1069,22 @@ public:
|
|||||||
// set, map
|
// set, map
|
||||||
template <bool maybe_multi = IsMulti, class... Args>
|
template <bool maybe_multi = IsMulti, class... Args>
|
||||||
auto
|
auto
|
||||||
emplace(Args&&... args) ->
|
emplace(Args&&... args) -> std::enable_if_t<!maybe_multi, std::pair<iterator, bool>>;
|
||||||
typename std::enable_if<!maybe_multi, std::pair<iterator, bool>>::type;
|
|
||||||
|
|
||||||
// multiset, multimap
|
// multiset, multimap
|
||||||
template <bool maybe_multi = IsMulti, class... Args>
|
template <bool maybe_multi = IsMulti, class... Args>
|
||||||
auto
|
auto
|
||||||
emplace(Args&&... args) -> typename std::enable_if<maybe_multi, iterator>::type;
|
emplace(Args&&... args) -> std::enable_if_t<maybe_multi, iterator>;
|
||||||
|
|
||||||
// set, map
|
// set, map
|
||||||
template <bool maybe_multi = IsMulti, class... Args>
|
template <bool maybe_multi = IsMulti, class... Args>
|
||||||
auto
|
auto
|
||||||
emplace_hint(const_iterator /*hint*/, Args&&... args) ->
|
emplace_hint(const_iterator /*hint*/, Args&&... args)
|
||||||
typename std::enable_if<!maybe_multi, std::pair<iterator, bool>>::type;
|
-> std::enable_if_t<!maybe_multi, std::pair<iterator, bool>>;
|
||||||
|
|
||||||
// multiset, multimap
|
// multiset, multimap
|
||||||
template <bool maybe_multi = IsMulti, class... Args>
|
template <bool maybe_multi = IsMulti, class... Args>
|
||||||
typename std::enable_if<maybe_multi, iterator>::type
|
std::enable_if_t<maybe_multi, iterator>
|
||||||
emplace_hint(const_iterator /*hint*/, Args&&... args)
|
emplace_hint(const_iterator /*hint*/, Args&&... args)
|
||||||
{
|
{
|
||||||
// VFALCO TODO The hint could be used for multi, to let
|
// VFALCO TODO The hint could be used for multi, to let
|
||||||
@@ -1328,7 +1316,7 @@ public:
|
|||||||
class OtherHash,
|
class OtherHash,
|
||||||
class OtherAllocator,
|
class OtherAllocator,
|
||||||
bool maybe_multi = IsMulti>
|
bool maybe_multi = IsMulti>
|
||||||
typename std::enable_if<!maybe_multi, bool>::type
|
std::enable_if_t<!maybe_multi, bool>
|
||||||
operator==(aged_unordered_container<
|
operator==(aged_unordered_container<
|
||||||
false,
|
false,
|
||||||
OtherIsMap,
|
OtherIsMap,
|
||||||
@@ -1347,7 +1335,7 @@ public:
|
|||||||
class OtherHash,
|
class OtherHash,
|
||||||
class OtherAllocator,
|
class OtherAllocator,
|
||||||
bool maybe_multi = IsMulti>
|
bool maybe_multi = IsMulti>
|
||||||
typename std::enable_if<maybe_multi, bool>::type
|
std::enable_if_t<maybe_multi, bool>
|
||||||
operator==(aged_unordered_container<
|
operator==(aged_unordered_container<
|
||||||
true,
|
true,
|
||||||
OtherIsMap,
|
OtherIsMap,
|
||||||
@@ -1401,14 +1389,13 @@ private:
|
|||||||
// map, set
|
// map, set
|
||||||
template <bool maybe_multi = IsMulti>
|
template <bool maybe_multi = IsMulti>
|
||||||
auto
|
auto
|
||||||
insert_unchecked(value_type const& value) ->
|
insert_unchecked(value_type const& value)
|
||||||
typename std::enable_if<!maybe_multi, std::pair<iterator, bool>>::type;
|
-> std::enable_if_t<!maybe_multi, std::pair<iterator, bool>>;
|
||||||
|
|
||||||
// multimap, multiset
|
// multimap, multiset
|
||||||
template <bool maybe_multi = IsMulti>
|
template <bool maybe_multi = IsMulti>
|
||||||
auto
|
auto
|
||||||
insert_unchecked(value_type const& value) ->
|
insert_unchecked(value_type const& value) -> std::enable_if_t<maybe_multi, iterator>;
|
||||||
typename std::enable_if<maybe_multi, iterator>::type;
|
|
||||||
|
|
||||||
template <class InputIt>
|
template <class InputIt>
|
||||||
void
|
void
|
||||||
@@ -1449,7 +1436,7 @@ private:
|
|||||||
|
|
||||||
template <
|
template <
|
||||||
bool maybe_propagate = std::allocator_traits<Allocator>::propagate_on_container_swap::value>
|
bool maybe_propagate = std::allocator_traits<Allocator>::propagate_on_container_swap::value>
|
||||||
typename std::enable_if<maybe_propagate>::type
|
std::enable_if_t<maybe_propagate>
|
||||||
swap_data(aged_unordered_container& other) noexcept
|
swap_data(aged_unordered_container& other) noexcept
|
||||||
{
|
{
|
||||||
std::swap(m_config.key_compare(), other.m_config.key_compare());
|
std::swap(m_config.key_compare(), other.m_config.key_compare());
|
||||||
@@ -1459,7 +1446,7 @@ private:
|
|||||||
|
|
||||||
template <
|
template <
|
||||||
bool maybe_propagate = std::allocator_traits<Allocator>::propagate_on_container_swap::value>
|
bool maybe_propagate = std::allocator_traits<Allocator>::propagate_on_container_swap::value>
|
||||||
typename std::enable_if<!maybe_propagate>::type
|
std::enable_if_t<!maybe_propagate>
|
||||||
swap_data(aged_unordered_container& other) noexcept
|
swap_data(aged_unordered_container& other) noexcept
|
||||||
{
|
{
|
||||||
std::swap(m_config.key_compare(), other.m_config.key_compare());
|
std::swap(m_config.key_compare(), other.m_config.key_compare());
|
||||||
@@ -2114,7 +2101,7 @@ template <
|
|||||||
class KeyEqual,
|
class KeyEqual,
|
||||||
class Allocator>
|
class Allocator>
|
||||||
template <class K, bool maybe_multi, bool maybe_map, class>
|
template <class K, bool maybe_multi, bool maybe_map, class>
|
||||||
typename std::conditional<IsMap, T, void*>::type&
|
std::conditional_t<IsMap, T, void*>&
|
||||||
aged_unordered_container<IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>::at(K const& k)
|
aged_unordered_container<IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>::at(K const& k)
|
||||||
{
|
{
|
||||||
auto const iter(
|
auto const iter(
|
||||||
@@ -2155,7 +2142,7 @@ template <
|
|||||||
class KeyEqual,
|
class KeyEqual,
|
||||||
class Allocator>
|
class Allocator>
|
||||||
template <bool maybe_multi, bool maybe_map, class>
|
template <bool maybe_multi, bool maybe_map, class>
|
||||||
typename std::conditional<IsMap, T, void*>::type&
|
std::conditional_t<IsMap, T, void*>&
|
||||||
aged_unordered_container<IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>::operator[](
|
aged_unordered_container<IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>::operator[](
|
||||||
Key const& key)
|
Key const& key)
|
||||||
{
|
{
|
||||||
@@ -2184,7 +2171,7 @@ template <
|
|||||||
class KeyEqual,
|
class KeyEqual,
|
||||||
class Allocator>
|
class Allocator>
|
||||||
template <bool maybe_multi, bool maybe_map, class>
|
template <bool maybe_multi, bool maybe_map, class>
|
||||||
typename std::conditional<IsMap, T, void*>::type&
|
std::conditional_t<IsMap, T, void*>&
|
||||||
aged_unordered_container<IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>::operator[](
|
aged_unordered_container<IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>::operator[](
|
||||||
Key&& key)
|
Key&& key)
|
||||||
{
|
{
|
||||||
@@ -2239,8 +2226,7 @@ template <
|
|||||||
template <bool maybe_multi>
|
template <bool maybe_multi>
|
||||||
auto
|
auto
|
||||||
aged_unordered_container<IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>::insert(
|
aged_unordered_container<IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>::insert(
|
||||||
value_type const& value) ->
|
value_type const& value) -> std::enable_if_t<!maybe_multi, std::pair<iterator, bool>>
|
||||||
typename std::enable_if<!maybe_multi, std::pair<iterator, bool>>::type
|
|
||||||
{
|
{
|
||||||
maybe_rehash(1);
|
maybe_rehash(1);
|
||||||
typename cont_type::insert_commit_data d;
|
typename cont_type::insert_commit_data d;
|
||||||
@@ -2272,7 +2258,7 @@ template <
|
|||||||
template <bool maybe_multi>
|
template <bool maybe_multi>
|
||||||
auto
|
auto
|
||||||
aged_unordered_container<IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>::insert(
|
aged_unordered_container<IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>::insert(
|
||||||
value_type const& value) -> typename std::enable_if<maybe_multi, iterator>::type
|
value_type const& value) -> std::enable_if_t<maybe_multi, iterator>
|
||||||
{
|
{
|
||||||
maybe_rehash(1);
|
maybe_rehash(1);
|
||||||
element* const p(new_element(value));
|
element* const p(new_element(value));
|
||||||
@@ -2294,8 +2280,7 @@ template <
|
|||||||
template <bool maybe_multi, bool maybe_map>
|
template <bool maybe_multi, bool maybe_map>
|
||||||
auto
|
auto
|
||||||
aged_unordered_container<IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>::insert(
|
aged_unordered_container<IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>::insert(
|
||||||
value_type&& value) ->
|
value_type&& value) -> std::enable_if_t<!maybe_multi && !maybe_map, std::pair<iterator, bool>>
|
||||||
typename std::enable_if<!maybe_multi && !maybe_map, std::pair<iterator, bool>>::type
|
|
||||||
{
|
{
|
||||||
maybe_rehash(1);
|
maybe_rehash(1);
|
||||||
typename cont_type::insert_commit_data d;
|
typename cont_type::insert_commit_data d;
|
||||||
@@ -2327,7 +2312,7 @@ template <
|
|||||||
template <bool maybe_multi, bool maybe_map>
|
template <bool maybe_multi, bool maybe_map>
|
||||||
auto
|
auto
|
||||||
aged_unordered_container<IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>::insert(
|
aged_unordered_container<IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>::insert(
|
||||||
value_type&& value) -> typename std::enable_if<maybe_multi && !maybe_map, iterator>::type
|
value_type&& value) -> std::enable_if_t<maybe_multi && !maybe_map, iterator>
|
||||||
{
|
{
|
||||||
maybe_rehash(1);
|
maybe_rehash(1);
|
||||||
element* const p(new_element(std::move(value)));
|
element* const p(new_element(std::move(value)));
|
||||||
@@ -2350,7 +2335,7 @@ template <
|
|||||||
template <bool maybe_multi, class... Args>
|
template <bool maybe_multi, class... Args>
|
||||||
auto
|
auto
|
||||||
aged_unordered_container<IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>::emplace(
|
aged_unordered_container<IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>::emplace(
|
||||||
Args&&... args) -> typename std::enable_if<!maybe_multi, std::pair<iterator, bool>>::type
|
Args&&... args) -> std::enable_if_t<!maybe_multi, std::pair<iterator, bool>>
|
||||||
{
|
{
|
||||||
maybe_rehash(1);
|
maybe_rehash(1);
|
||||||
// VFALCO NOTE Its unfortunate that we need to
|
// VFALCO NOTE Its unfortunate that we need to
|
||||||
@@ -2415,7 +2400,7 @@ template <
|
|||||||
template <bool maybe_multi, class... Args>
|
template <bool maybe_multi, class... Args>
|
||||||
auto
|
auto
|
||||||
aged_unordered_container<IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>::emplace(
|
aged_unordered_container<IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>::emplace(
|
||||||
Args&&... args) -> typename std::enable_if<maybe_multi, iterator>::type
|
Args&&... args) -> std::enable_if_t<maybe_multi, iterator>
|
||||||
{
|
{
|
||||||
maybe_rehash(1);
|
maybe_rehash(1);
|
||||||
element* const p(new_element(std::forward<Args>(args)...));
|
element* const p(new_element(std::forward<Args>(args)...));
|
||||||
@@ -2438,7 +2423,7 @@ template <bool maybe_multi, class... Args>
|
|||||||
auto
|
auto
|
||||||
aged_unordered_container<IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>::emplace_hint(
|
aged_unordered_container<IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>::emplace_hint(
|
||||||
const_iterator /*hint*/,
|
const_iterator /*hint*/,
|
||||||
Args&&... args) -> typename std::enable_if<!maybe_multi, std::pair<iterator, bool>>::type
|
Args&&... args) -> std::enable_if_t<!maybe_multi, std::pair<iterator, bool>>
|
||||||
{
|
{
|
||||||
maybe_rehash(1);
|
maybe_rehash(1);
|
||||||
// VFALCO NOTE Its unfortunate that we need to
|
// VFALCO NOTE Its unfortunate that we need to
|
||||||
@@ -2590,7 +2575,7 @@ template <
|
|||||||
class OtherHash,
|
class OtherHash,
|
||||||
class OtherAllocator,
|
class OtherAllocator,
|
||||||
bool maybe_multi>
|
bool maybe_multi>
|
||||||
typename std::enable_if<!maybe_multi, bool>::type
|
std::enable_if_t<!maybe_multi, bool>
|
||||||
aged_unordered_container<IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>::operator==(
|
aged_unordered_container<IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>::operator==(
|
||||||
aged_unordered_container<
|
aged_unordered_container<
|
||||||
false,
|
false,
|
||||||
@@ -2630,7 +2615,7 @@ template <
|
|||||||
class OtherHash,
|
class OtherHash,
|
||||||
class OtherAllocator,
|
class OtherAllocator,
|
||||||
bool maybe_multi>
|
bool maybe_multi>
|
||||||
typename std::enable_if<maybe_multi, bool>::type
|
std::enable_if_t<maybe_multi, bool>
|
||||||
aged_unordered_container<IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>::operator==(
|
aged_unordered_container<IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>::operator==(
|
||||||
aged_unordered_container<
|
aged_unordered_container<
|
||||||
true,
|
true,
|
||||||
@@ -2677,8 +2662,8 @@ template <
|
|||||||
template <bool maybe_multi>
|
template <bool maybe_multi>
|
||||||
auto
|
auto
|
||||||
aged_unordered_container<IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>::
|
aged_unordered_container<IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>::
|
||||||
insert_unchecked(value_type const& value) ->
|
insert_unchecked(value_type const& value)
|
||||||
typename std::enable_if<!maybe_multi, std::pair<iterator, bool>>::type
|
-> std::enable_if_t<!maybe_multi, std::pair<iterator, bool>>
|
||||||
{
|
{
|
||||||
typename cont_type::insert_commit_data d;
|
typename cont_type::insert_commit_data d;
|
||||||
auto const result(m_cont.insert_check(
|
auto const result(m_cont.insert_check(
|
||||||
@@ -2709,8 +2694,7 @@ template <
|
|||||||
template <bool maybe_multi>
|
template <bool maybe_multi>
|
||||||
auto
|
auto
|
||||||
aged_unordered_container<IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>::
|
aged_unordered_container<IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>::
|
||||||
insert_unchecked(value_type const& value) ->
|
insert_unchecked(value_type const& value) -> std::enable_if_t<maybe_multi, iterator>
|
||||||
typename std::enable_if<maybe_multi, iterator>::type
|
|
||||||
{
|
{
|
||||||
element* const p(new_element(value));
|
element* const p(new_element(value));
|
||||||
chronological.list.push_back(*p);
|
chronological.list.push_back(*p);
|
||||||
|
|||||||
@@ -11,12 +11,11 @@
|
|||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
namespace beast {
|
namespace beast::detail {
|
||||||
namespace detail {
|
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
struct is_empty_base_optimization_derived
|
struct is_empty_base_optimization_derived
|
||||||
: std::integral_constant<bool, std::is_empty<T>::value && !boost::is_final<T>::value>
|
: std::integral_constant<bool, std::is_empty_v<T> && !boost::is_final<T>::value>
|
||||||
{
|
{
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -44,7 +43,7 @@ public:
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
T const&
|
[[nodiscard]] T const&
|
||||||
member() const noexcept
|
member() const noexcept
|
||||||
{
|
{
|
||||||
return *this;
|
return *this;
|
||||||
@@ -86,5 +85,4 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace detail
|
} // namespace beast::detail
|
||||||
} // namespace beast
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ struct CopyConst
|
|||||||
{
|
{
|
||||||
explicit CopyConst() = default;
|
explicit CopyConst() = default;
|
||||||
|
|
||||||
using type = typename std::remove_const<U>::type;
|
using type = std::remove_const_t<U>;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename T, typename U>
|
template <typename T, typename U>
|
||||||
@@ -128,7 +128,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
reference
|
[[nodiscard]] reference
|
||||||
dereference() const noexcept
|
dereference() const noexcept
|
||||||
{
|
{
|
||||||
return static_cast<reference>(*m_node);
|
return static_cast<reference>(*m_node);
|
||||||
@@ -287,14 +287,14 @@ public:
|
|||||||
/** Determine if the list is empty.
|
/** Determine if the list is empty.
|
||||||
@return `true` if the list is empty.
|
@return `true` if the list is empty.
|
||||||
*/
|
*/
|
||||||
bool
|
[[nodiscard]] bool
|
||||||
empty() const noexcept
|
empty() const noexcept
|
||||||
{
|
{
|
||||||
return size() == 0;
|
return size() == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the number of elements in the list. */
|
/** Returns the number of elements in the list. */
|
||||||
size_type
|
[[nodiscard]] size_type
|
||||||
size() const noexcept
|
size() const noexcept
|
||||||
{
|
{
|
||||||
return m_size;
|
return m_size;
|
||||||
@@ -314,7 +314,7 @@ public:
|
|||||||
@invariant The list may not be empty.
|
@invariant The list may not be empty.
|
||||||
@return A const reference to the first element.
|
@return A const reference to the first element.
|
||||||
*/
|
*/
|
||||||
const_reference
|
[[nodiscard]] const_reference
|
||||||
front() const noexcept
|
front() const noexcept
|
||||||
{
|
{
|
||||||
return element_from(m_head.m_next);
|
return element_from(m_head.m_next);
|
||||||
@@ -334,7 +334,7 @@ public:
|
|||||||
@invariant The list may not be empty.
|
@invariant The list may not be empty.
|
||||||
@return A const reference to the last element.
|
@return A const reference to the last element.
|
||||||
*/
|
*/
|
||||||
const_reference
|
[[nodiscard]] const_reference
|
||||||
back() const noexcept
|
back() const noexcept
|
||||||
{
|
{
|
||||||
return element_from(m_tail.m_prev);
|
return element_from(m_tail.m_prev);
|
||||||
@@ -352,7 +352,7 @@ public:
|
|||||||
/** Obtain a const iterator to the beginning of the list.
|
/** Obtain a const iterator to the beginning of the list.
|
||||||
@return A const iterator pointing to the beginning of the list.
|
@return A const iterator pointing to the beginning of the list.
|
||||||
*/
|
*/
|
||||||
const_iterator
|
[[nodiscard]] const_iterator
|
||||||
begin() const noexcept
|
begin() const noexcept
|
||||||
{
|
{
|
||||||
return const_iterator(m_head.m_next);
|
return const_iterator(m_head.m_next);
|
||||||
@@ -361,7 +361,7 @@ public:
|
|||||||
/** Obtain a const iterator to the beginning of the list.
|
/** Obtain a const iterator to the beginning of the list.
|
||||||
@return A const iterator pointing to the beginning of the list.
|
@return A const iterator pointing to the beginning of the list.
|
||||||
*/
|
*/
|
||||||
const_iterator
|
[[nodiscard]] const_iterator
|
||||||
cbegin() const noexcept
|
cbegin() const noexcept
|
||||||
{
|
{
|
||||||
return const_iterator(m_head.m_next);
|
return const_iterator(m_head.m_next);
|
||||||
@@ -379,7 +379,7 @@ public:
|
|||||||
/** Obtain a const iterator to the end of the list.
|
/** Obtain a const iterator to the end of the list.
|
||||||
@return A constiterator pointing to the end of the list.
|
@return A constiterator pointing to the end of the list.
|
||||||
*/
|
*/
|
||||||
const_iterator
|
[[nodiscard]] const_iterator
|
||||||
end() const noexcept
|
end() const noexcept
|
||||||
{
|
{
|
||||||
return const_iterator(&m_tail);
|
return const_iterator(&m_tail);
|
||||||
@@ -388,7 +388,7 @@ public:
|
|||||||
/** Obtain a const iterator to the end of the list
|
/** Obtain a const iterator to the end of the list
|
||||||
@return A constiterator pointing to the end of the list.
|
@return A constiterator pointing to the end of the list.
|
||||||
*/
|
*/
|
||||||
const_iterator
|
[[nodiscard]] const_iterator
|
||||||
cend() const noexcept
|
cend() const noexcept
|
||||||
{
|
{
|
||||||
return const_iterator(&m_tail);
|
return const_iterator(&m_tail);
|
||||||
@@ -549,7 +549,7 @@ public:
|
|||||||
@param element The element to obtain an iterator for.
|
@param element The element to obtain an iterator for.
|
||||||
@return A const iterator to the element.
|
@return A const iterator to the element.
|
||||||
*/
|
*/
|
||||||
const_iterator
|
[[nodiscard]] const_iterator
|
||||||
const_iterator_to(T const& element) const noexcept
|
const_iterator_to(T const& element) const noexcept
|
||||||
{
|
{
|
||||||
return const_iterator(static_cast<Node const*>(&element));
|
return const_iterator(static_cast<Node const*>(&element));
|
||||||
|
|||||||
@@ -13,22 +13,18 @@ class LockFreeStackIterator
|
|||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
using Node = typename Container::Node;
|
using Node = typename Container::Node;
|
||||||
using NodePtr = typename std::conditional<IsConst, Node const*, Node*>::type;
|
using NodePtr = std::conditional_t<IsConst, Node const*, Node*>;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
using iterator_category = std::forward_iterator_tag;
|
using iterator_category = std::forward_iterator_tag;
|
||||||
using value_type = typename Container::value_type;
|
using value_type = typename Container::value_type;
|
||||||
using difference_type = typename Container::difference_type;
|
using difference_type = typename Container::difference_type;
|
||||||
using pointer = typename std::
|
using pointer =
|
||||||
conditional<IsConst, typename Container::const_pointer, typename Container::pointer>::type;
|
std::conditional_t<IsConst, typename Container::const_pointer, typename Container::pointer>;
|
||||||
using reference = typename std::conditional<
|
using reference = std::
|
||||||
IsConst,
|
conditional_t<IsConst, typename Container::const_reference, typename Container::reference>;
|
||||||
typename Container::const_reference,
|
|
||||||
typename Container::reference>::type;
|
|
||||||
|
|
||||||
LockFreeStackIterator() : m_node()
|
LockFreeStackIterator() = default;
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
LockFreeStackIterator(NodePtr node) : m_node(node)
|
LockFreeStackIterator(NodePtr node) : m_node(node)
|
||||||
{
|
{
|
||||||
@@ -81,7 +77,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
NodePtr m_node;
|
NodePtr m_node{};
|
||||||
};
|
};
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
@@ -166,7 +162,7 @@ public:
|
|||||||
operator=(LockFreeStack const&) = delete;
|
operator=(LockFreeStack const&) = delete;
|
||||||
|
|
||||||
/** Returns true if the stack is empty. */
|
/** Returns true if the stack is empty. */
|
||||||
bool
|
[[nodiscard]] bool
|
||||||
empty() const
|
empty() const
|
||||||
{
|
{
|
||||||
return m_head.load() == &m_end;
|
return m_head.load() == &m_end;
|
||||||
@@ -241,25 +237,25 @@ public:
|
|||||||
return iterator(&m_end);
|
return iterator(&m_end);
|
||||||
}
|
}
|
||||||
|
|
||||||
const_iterator
|
[[nodiscard]] const_iterator
|
||||||
begin() const
|
begin() const
|
||||||
{
|
{
|
||||||
return const_iterator(m_head.load());
|
return const_iterator(m_head.load());
|
||||||
}
|
}
|
||||||
|
|
||||||
const_iterator
|
[[nodiscard]] const_iterator
|
||||||
end() const
|
end() const
|
||||||
{
|
{
|
||||||
return const_iterator(&m_end);
|
return const_iterator(&m_end);
|
||||||
}
|
}
|
||||||
|
|
||||||
const_iterator
|
[[nodiscard]] const_iterator
|
||||||
cbegin() const
|
cbegin() const
|
||||||
{
|
{
|
||||||
return const_iterator(m_head.load());
|
return const_iterator(m_head.load());
|
||||||
}
|
}
|
||||||
|
|
||||||
const_iterator
|
[[nodiscard]] const_iterator
|
||||||
cend() const
|
cend() const
|
||||||
{
|
{
|
||||||
return const_iterator(&m_end);
|
return const_iterator(&m_end);
|
||||||
|
|||||||
@@ -37,15 +37,15 @@ public:
|
|||||||
parse(std::string_view input);
|
parse(std::string_view input);
|
||||||
|
|
||||||
/** Produce a string from semantic version components. */
|
/** Produce a string from semantic version components. */
|
||||||
std::string
|
[[nodiscard]] std::string
|
||||||
print() const;
|
print() const;
|
||||||
|
|
||||||
bool
|
[[nodiscard]] bool
|
||||||
isRelease() const noexcept
|
isRelease() const noexcept
|
||||||
{
|
{
|
||||||
return preReleaseIdentifiers.empty();
|
return preReleaseIdentifiers.empty();
|
||||||
}
|
}
|
||||||
bool
|
[[nodiscard]] bool
|
||||||
isPreRelease() const noexcept
|
isPreRelease() const noexcept
|
||||||
{
|
{
|
||||||
return !isRelease();
|
return !isRelease();
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ template <class T>
|
|||||||
struct is_uniquely_represented
|
struct is_uniquely_represented
|
||||||
: public std::integral_constant<
|
: public std::integral_constant<
|
||||||
bool,
|
bool,
|
||||||
std::is_integral<T>::value || std::is_enum<T>::value || std::is_pointer<T>::value>
|
std::is_integral_v<T> || std::is_enum_v<T> || std::is_pointer_v<T>>
|
||||||
{
|
{
|
||||||
explicit is_uniquely_represented() = default;
|
explicit is_uniquely_represented() = default;
|
||||||
};
|
};
|
||||||
@@ -210,7 +210,7 @@ hash_append(Hasher& h, T const& t) noexcept
|
|||||||
template <class Hasher, class T>
|
template <class Hasher, class T>
|
||||||
inline std::enable_if_t<
|
inline std::enable_if_t<
|
||||||
!is_contiguously_hashable<T, Hasher>::value &&
|
!is_contiguously_hashable<T, Hasher>::value &&
|
||||||
(std::is_integral<T>::value || std::is_pointer<T>::value || std::is_enum<T>::value)>
|
(std::is_integral_v<T> || std::is_pointer_v<T> || std::is_enum_v<T>)>
|
||||||
hash_append(Hasher& h, T t) noexcept
|
hash_append(Hasher& h, T t) noexcept
|
||||||
{
|
{
|
||||||
detail::reverse_bytes(t);
|
detail::reverse_bytes(t);
|
||||||
@@ -218,7 +218,7 @@ hash_append(Hasher& h, T t) noexcept
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <class Hasher, class T>
|
template <class Hasher, class T>
|
||||||
inline std::enable_if_t<std::is_floating_point<T>::value>
|
inline std::enable_if_t<std::is_floating_point_v<T>>
|
||||||
hash_append(Hasher& h, T t) noexcept
|
hash_append(Hasher& h, T t) noexcept
|
||||||
{
|
{
|
||||||
if (t == 0)
|
if (t == 0)
|
||||||
|
|||||||
@@ -121,13 +121,13 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Seed, std::enable_if_t<std::is_unsigned<Seed>::value>* = nullptr>
|
template <class Seed, std::enable_if_t<std::is_unsigned_v<Seed>>* = nullptr>
|
||||||
explicit xxhasher(Seed seed) : seed_(seed)
|
explicit xxhasher(Seed seed) : seed_(seed)
|
||||||
{
|
{
|
||||||
resetBuffers();
|
resetBuffers();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Seed, std::enable_if_t<std::is_unsigned<Seed>::value>* = nullptr>
|
template <class Seed, std::enable_if_t<std::is_unsigned_v<Seed>>* = nullptr>
|
||||||
xxhasher(Seed seed, Seed) : seed_(seed)
|
xxhasher(Seed seed, Seed) : seed_(seed)
|
||||||
{
|
{
|
||||||
resetBuffers();
|
resetBuffers();
|
||||||
|
|||||||
@@ -8,8 +8,7 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace beast {
|
namespace beast::insight {
|
||||||
namespace insight {
|
|
||||||
|
|
||||||
/** Interface for a manager that allows collection of metrics.
|
/** Interface for a manager that allows collection of metrics.
|
||||||
|
|
||||||
@@ -117,5 +116,4 @@ public:
|
|||||||
/** @} */
|
/** @} */
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace insight
|
} // namespace beast::insight
|
||||||
} // namespace beast
|
|
||||||
|
|||||||
@@ -4,8 +4,7 @@
|
|||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
namespace beast {
|
namespace beast::insight {
|
||||||
namespace insight {
|
|
||||||
|
|
||||||
/** A metric for measuring an integral value.
|
/** A metric for measuring an integral value.
|
||||||
|
|
||||||
@@ -23,9 +22,7 @@ public:
|
|||||||
/** Create a null metric.
|
/** Create a null metric.
|
||||||
A null metric reports no information.
|
A null metric reports no information.
|
||||||
*/
|
*/
|
||||||
Counter()
|
Counter() = default;
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Create the metric reference the specified implementation.
|
/** Create the metric reference the specified implementation.
|
||||||
Normally this won't be called directly. Instead, call the appropriate
|
Normally this won't be called directly. Instead, call the appropriate
|
||||||
@@ -91,5 +88,4 @@ private:
|
|||||||
std::shared_ptr<CounterImpl> m_impl;
|
std::shared_ptr<CounterImpl> m_impl;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace insight
|
} // namespace beast::insight
|
||||||
} // namespace beast
|
|
||||||
|
|||||||
@@ -3,8 +3,7 @@
|
|||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
namespace beast {
|
namespace beast::insight {
|
||||||
namespace insight {
|
|
||||||
|
|
||||||
class Counter;
|
class Counter;
|
||||||
|
|
||||||
@@ -18,5 +17,4 @@ public:
|
|||||||
increment(value_type amount) = 0;
|
increment(value_type amount) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace insight
|
} // namespace beast::insight
|
||||||
} // namespace beast
|
|
||||||
|
|||||||
@@ -5,8 +5,7 @@
|
|||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
namespace beast {
|
namespace beast::insight {
|
||||||
namespace insight {
|
|
||||||
|
|
||||||
/** A metric for reporting event timing.
|
/** A metric for reporting event timing.
|
||||||
|
|
||||||
@@ -25,9 +24,7 @@ public:
|
|||||||
/** Create a null metric.
|
/** Create a null metric.
|
||||||
A null metric reports no information.
|
A null metric reports no information.
|
||||||
*/
|
*/
|
||||||
Event()
|
Event() = default;
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Create the metric reference the specified implementation.
|
/** Create the metric reference the specified implementation.
|
||||||
Normally this won't be called directly. Instead, call the appropriate
|
Normally this won't be called directly. Instead, call the appropriate
|
||||||
@@ -48,7 +45,7 @@ public:
|
|||||||
m_impl->notify(ceil<value_type>(value));
|
m_impl->notify(ceil<value_type>(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<EventImpl> const&
|
[[nodiscard]] std::shared_ptr<EventImpl> const&
|
||||||
impl() const
|
impl() const
|
||||||
{
|
{
|
||||||
return m_impl;
|
return m_impl;
|
||||||
@@ -58,5 +55,4 @@ private:
|
|||||||
std::shared_ptr<EventImpl> m_impl;
|
std::shared_ptr<EventImpl> m_impl;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace insight
|
} // namespace beast::insight
|
||||||
} // namespace beast
|
|
||||||
|
|||||||
@@ -3,8 +3,7 @@
|
|||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
namespace beast {
|
namespace beast::insight {
|
||||||
namespace insight {
|
|
||||||
|
|
||||||
class Event;
|
class Event;
|
||||||
|
|
||||||
@@ -18,5 +17,4 @@ public:
|
|||||||
notify(value_type const& value) = 0;
|
notify(value_type const& value) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace insight
|
} // namespace beast::insight
|
||||||
} // namespace beast
|
|
||||||
|
|||||||
@@ -4,8 +4,7 @@
|
|||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
namespace beast {
|
namespace beast::insight {
|
||||||
namespace insight {
|
|
||||||
|
|
||||||
/** A metric for measuring an integral value.
|
/** A metric for measuring an integral value.
|
||||||
|
|
||||||
@@ -25,9 +24,7 @@ public:
|
|||||||
/** Create a null metric.
|
/** Create a null metric.
|
||||||
A null metric reports no information.
|
A null metric reports no information.
|
||||||
*/
|
*/
|
||||||
Gauge()
|
Gauge() = default;
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Create the metric reference the specified implementation.
|
/** Create the metric reference the specified implementation.
|
||||||
Normally this won't be called directly. Instead, call the appropriate
|
Normally this won't be called directly. Instead, call the appropriate
|
||||||
@@ -111,7 +108,7 @@ public:
|
|||||||
}
|
}
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
std::shared_ptr<GaugeImpl> const&
|
[[nodiscard]] std::shared_ptr<GaugeImpl> const&
|
||||||
impl() const
|
impl() const
|
||||||
{
|
{
|
||||||
return m_impl;
|
return m_impl;
|
||||||
@@ -121,5 +118,4 @@ private:
|
|||||||
std::shared_ptr<GaugeImpl> m_impl;
|
std::shared_ptr<GaugeImpl> m_impl;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace insight
|
} // namespace beast::insight
|
||||||
} // namespace beast
|
|
||||||
|
|||||||
@@ -3,8 +3,7 @@
|
|||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
namespace beast {
|
namespace beast::insight {
|
||||||
namespace insight {
|
|
||||||
|
|
||||||
class Gauge;
|
class Gauge;
|
||||||
|
|
||||||
@@ -21,5 +20,4 @@ public:
|
|||||||
increment(difference_type amount) = 0;
|
increment(difference_type amount) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace insight
|
} // namespace beast::insight
|
||||||
} // namespace beast
|
|
||||||
|
|||||||
@@ -5,8 +5,7 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace beast {
|
namespace beast::insight {
|
||||||
namespace insight {
|
|
||||||
|
|
||||||
/** A collector front-end that manages a group of metrics. */
|
/** A collector front-end that manages a group of metrics. */
|
||||||
class Group : public Collector
|
class Group : public Collector
|
||||||
@@ -15,9 +14,8 @@ public:
|
|||||||
using ptr = std::shared_ptr<Group>;
|
using ptr = std::shared_ptr<Group>;
|
||||||
|
|
||||||
/** Returns the name of this group, for diagnostics. */
|
/** Returns the name of this group, for diagnostics. */
|
||||||
virtual std::string const&
|
[[nodiscard]] virtual std::string const&
|
||||||
name() const = 0;
|
name() const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace insight
|
} // namespace beast::insight
|
||||||
} // namespace beast
|
|
||||||
|
|||||||
@@ -6,8 +6,7 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace beast {
|
namespace beast::insight {
|
||||||
namespace insight {
|
|
||||||
|
|
||||||
/** A container for managing a set of metric groups. */
|
/** A container for managing a set of metric groups. */
|
||||||
class Groups
|
class Groups
|
||||||
@@ -32,5 +31,4 @@ public:
|
|||||||
std::unique_ptr<Groups>
|
std::unique_ptr<Groups>
|
||||||
make_Groups(Collector::ptr const& collector);
|
make_Groups(Collector::ptr const& collector);
|
||||||
|
|
||||||
} // namespace insight
|
} // namespace beast::insight
|
||||||
} // namespace beast
|
|
||||||
|
|||||||
@@ -4,8 +4,7 @@
|
|||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
namespace beast {
|
namespace beast::insight {
|
||||||
namespace insight {
|
|
||||||
|
|
||||||
/** A reference to a handler for performing polled collection. */
|
/** A reference to a handler for performing polled collection. */
|
||||||
class Hook final
|
class Hook final
|
||||||
@@ -14,9 +13,7 @@ public:
|
|||||||
/** Create a null hook.
|
/** Create a null hook.
|
||||||
A null hook has no associated handler.
|
A null hook has no associated handler.
|
||||||
*/
|
*/
|
||||||
Hook()
|
Hook() = default;
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Create a hook referencing the specified implementation.
|
/** Create a hook referencing the specified implementation.
|
||||||
Normally this won't be called directly. Instead, call the appropriate
|
Normally this won't be called directly. Instead, call the appropriate
|
||||||
@@ -27,7 +24,7 @@ public:
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<HookImpl> const&
|
[[nodiscard]] std::shared_ptr<HookImpl> const&
|
||||||
impl() const
|
impl() const
|
||||||
{
|
{
|
||||||
return m_impl;
|
return m_impl;
|
||||||
@@ -37,5 +34,4 @@ private:
|
|||||||
std::shared_ptr<HookImpl> m_impl;
|
std::shared_ptr<HookImpl> m_impl;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace insight
|
} // namespace beast::insight
|
||||||
} // namespace beast
|
|
||||||
|
|||||||
@@ -3,8 +3,7 @@
|
|||||||
#include <functional>
|
#include <functional>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
namespace beast {
|
namespace beast::insight {
|
||||||
namespace insight {
|
|
||||||
|
|
||||||
class HookImpl : public std::enable_shared_from_this<HookImpl>
|
class HookImpl : public std::enable_shared_from_this<HookImpl>
|
||||||
{
|
{
|
||||||
@@ -14,5 +13,4 @@ public:
|
|||||||
virtual ~HookImpl() = 0;
|
virtual ~HookImpl() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace insight
|
} // namespace beast::insight
|
||||||
} // namespace beast
|
|
||||||
|
|||||||
@@ -4,8 +4,7 @@
|
|||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
namespace beast {
|
namespace beast::insight {
|
||||||
namespace insight {
|
|
||||||
|
|
||||||
/** A metric for measuring an integral value.
|
/** A metric for measuring an integral value.
|
||||||
|
|
||||||
@@ -22,9 +21,7 @@ public:
|
|||||||
/** Create a null metric.
|
/** Create a null metric.
|
||||||
A null metric reports no information.
|
A null metric reports no information.
|
||||||
*/
|
*/
|
||||||
Meter()
|
Meter() = default;
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Create the metric reference the specified implementation.
|
/** Create the metric reference the specified implementation.
|
||||||
Normally this won't be called directly. Instead, call the appropriate
|
Normally this won't be called directly. Instead, call the appropriate
|
||||||
@@ -66,7 +63,7 @@ public:
|
|||||||
}
|
}
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
std::shared_ptr<MeterImpl> const&
|
[[nodiscard]] std::shared_ptr<MeterImpl> const&
|
||||||
impl() const
|
impl() const
|
||||||
{
|
{
|
||||||
return m_impl;
|
return m_impl;
|
||||||
@@ -76,5 +73,4 @@ private:
|
|||||||
std::shared_ptr<MeterImpl> m_impl;
|
std::shared_ptr<MeterImpl> m_impl;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace insight
|
} // namespace beast::insight
|
||||||
} // namespace beast
|
|
||||||
|
|||||||
@@ -3,8 +3,7 @@
|
|||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
namespace beast {
|
namespace beast::insight {
|
||||||
namespace insight {
|
|
||||||
|
|
||||||
class Meter;
|
class Meter;
|
||||||
|
|
||||||
@@ -18,5 +17,4 @@ public:
|
|||||||
increment(value_type amount) = 0;
|
increment(value_type amount) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace insight
|
} // namespace beast::insight
|
||||||
} // namespace beast
|
|
||||||
|
|||||||
@@ -2,8 +2,7 @@
|
|||||||
|
|
||||||
#include <xrpl/beast/insight/Collector.h>
|
#include <xrpl/beast/insight/Collector.h>
|
||||||
|
|
||||||
namespace beast {
|
namespace beast::insight {
|
||||||
namespace insight {
|
|
||||||
|
|
||||||
/** A Collector which does not collect metrics. */
|
/** A Collector which does not collect metrics. */
|
||||||
class NullCollector : public Collector
|
class NullCollector : public Collector
|
||||||
@@ -15,5 +14,4 @@ public:
|
|||||||
New();
|
New();
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace insight
|
} // namespace beast::insight
|
||||||
} // namespace beast
|
|
||||||
|
|||||||
@@ -4,8 +4,7 @@
|
|||||||
#include <xrpl/beast/net/IPEndpoint.h>
|
#include <xrpl/beast/net/IPEndpoint.h>
|
||||||
#include <xrpl/beast/utility/Journal.h>
|
#include <xrpl/beast/utility/Journal.h>
|
||||||
|
|
||||||
namespace beast {
|
namespace beast::insight {
|
||||||
namespace insight {
|
|
||||||
|
|
||||||
/** A Collector that reports metrics to a StatsD server.
|
/** A Collector that reports metrics to a StatsD server.
|
||||||
Reference:
|
Reference:
|
||||||
@@ -25,5 +24,4 @@ public:
|
|||||||
New(IP::Endpoint const& address, std::string const& prefix, Journal journal);
|
New(IP::Endpoint const& address, std::string const& prefix, Journal journal);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace insight
|
} // namespace beast::insight
|
||||||
} // namespace beast
|
|
||||||
|
|||||||
@@ -4,8 +4,7 @@
|
|||||||
|
|
||||||
#include <boost/asio.hpp>
|
#include <boost/asio.hpp>
|
||||||
|
|
||||||
namespace beast {
|
namespace beast::IP {
|
||||||
namespace IP {
|
|
||||||
|
|
||||||
/** Convert to Endpoint.
|
/** Convert to Endpoint.
|
||||||
The port is set to zero.
|
The port is set to zero.
|
||||||
@@ -27,8 +26,7 @@ to_asio_address(Endpoint const& endpoint);
|
|||||||
boost::asio::ip::tcp::endpoint
|
boost::asio::ip::tcp::endpoint
|
||||||
to_asio_endpoint(Endpoint const& endpoint);
|
to_asio_endpoint(Endpoint const& endpoint);
|
||||||
|
|
||||||
} // namespace IP
|
} // namespace beast::IP
|
||||||
} // namespace beast
|
|
||||||
|
|
||||||
namespace beast {
|
namespace beast {
|
||||||
|
|
||||||
|
|||||||
@@ -4,8 +4,7 @@
|
|||||||
|
|
||||||
#include <boost/asio/ip/address_v4.hpp>
|
#include <boost/asio/ip/address_v4.hpp>
|
||||||
|
|
||||||
namespace beast {
|
namespace beast::IP {
|
||||||
namespace IP {
|
|
||||||
|
|
||||||
using AddressV4 = boost::asio::ip::address_v4;
|
using AddressV4 = boost::asio::ip::address_v4;
|
||||||
|
|
||||||
@@ -23,5 +22,4 @@ is_public(AddressV4 const& addr);
|
|||||||
char
|
char
|
||||||
get_class(AddressV4 const& address);
|
get_class(AddressV4 const& address);
|
||||||
|
|
||||||
} // namespace IP
|
} // namespace beast::IP
|
||||||
} // namespace beast
|
|
||||||
|
|||||||
@@ -4,8 +4,7 @@
|
|||||||
|
|
||||||
#include <boost/asio/ip/address_v6.hpp>
|
#include <boost/asio/ip/address_v6.hpp>
|
||||||
|
|
||||||
namespace beast {
|
namespace beast::IP {
|
||||||
namespace IP {
|
|
||||||
|
|
||||||
using AddressV6 = boost::asio::ip::address_v6;
|
using AddressV6 = boost::asio::ip::address_v6;
|
||||||
|
|
||||||
@@ -17,5 +16,4 @@ is_private(AddressV6 const& addr);
|
|||||||
bool
|
bool
|
||||||
is_public(AddressV6 const& addr);
|
is_public(AddressV6 const& addr);
|
||||||
|
|
||||||
} // namespace IP
|
} // namespace beast::IP
|
||||||
} // namespace beast
|
|
||||||
|
|||||||
@@ -8,8 +8,7 @@
|
|||||||
#include <optional>
|
#include <optional>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace beast {
|
namespace beast::IP {
|
||||||
namespace IP {
|
|
||||||
|
|
||||||
using Port = std::uint16_t;
|
using Port = std::uint16_t;
|
||||||
|
|
||||||
@@ -21,7 +20,7 @@ public:
|
|||||||
Endpoint();
|
Endpoint();
|
||||||
|
|
||||||
/** Create an endpoint from the address and optional port. */
|
/** Create an endpoint from the address and optional port. */
|
||||||
explicit Endpoint(Address const& addr, Port port = 0);
|
explicit Endpoint(Address addr, Port port = 0);
|
||||||
|
|
||||||
/** Create an Endpoint from a string.
|
/** Create an Endpoint from a string.
|
||||||
If the port is omitted, the endpoint will have a zero port.
|
If the port is omitted, the endpoint will have a zero port.
|
||||||
@@ -33,25 +32,25 @@ public:
|
|||||||
from_string(std::string const& s);
|
from_string(std::string const& s);
|
||||||
|
|
||||||
/** Returns a string representing the endpoint. */
|
/** Returns a string representing the endpoint. */
|
||||||
std::string
|
[[nodiscard]] std::string
|
||||||
to_string() const;
|
to_string() const;
|
||||||
|
|
||||||
/** Returns the port number on the endpoint. */
|
/** Returns the port number on the endpoint. */
|
||||||
Port
|
[[nodiscard]] Port
|
||||||
port() const
|
port() const
|
||||||
{
|
{
|
||||||
return m_port;
|
return m_port;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns a new Endpoint with a different port. */
|
/** Returns a new Endpoint with a different port. */
|
||||||
Endpoint
|
[[nodiscard]] Endpoint
|
||||||
at_port(Port port) const
|
at_port(Port port) const
|
||||||
{
|
{
|
||||||
return Endpoint(m_addr, port);
|
return Endpoint(m_addr, port);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the address portion of this endpoint. */
|
/** Returns the address portion of this endpoint. */
|
||||||
Address const&
|
[[nodiscard]] Address const&
|
||||||
address() const
|
address() const
|
||||||
{
|
{
|
||||||
return m_addr;
|
return m_addr;
|
||||||
@@ -59,22 +58,22 @@ public:
|
|||||||
|
|
||||||
/** Convenience accessors for the address part. */
|
/** Convenience accessors for the address part. */
|
||||||
/** @{ */
|
/** @{ */
|
||||||
bool
|
[[nodiscard]] bool
|
||||||
is_v4() const
|
is_v4() const
|
||||||
{
|
{
|
||||||
return m_addr.is_v4();
|
return m_addr.is_v4();
|
||||||
}
|
}
|
||||||
bool
|
[[nodiscard]] bool
|
||||||
is_v6() const
|
is_v6() const
|
||||||
{
|
{
|
||||||
return m_addr.is_v6();
|
return m_addr.is_v6();
|
||||||
}
|
}
|
||||||
AddressV4
|
[[nodiscard]] AddressV4
|
||||||
to_v4() const
|
to_v4() const
|
||||||
{
|
{
|
||||||
return m_addr.to_v4();
|
return m_addr.to_v4();
|
||||||
}
|
}
|
||||||
AddressV6
|
[[nodiscard]] AddressV6
|
||||||
to_v6() const
|
to_v6() const
|
||||||
{
|
{
|
||||||
return m_addr.to_v6();
|
return m_addr.to_v6();
|
||||||
@@ -184,8 +183,7 @@ operator<<(OutputStream& os, Endpoint const& endpoint)
|
|||||||
std::istream&
|
std::istream&
|
||||||
operator>>(std::istream& is, Endpoint& endpoint);
|
operator>>(std::istream& is, Endpoint& endpoint);
|
||||||
|
|
||||||
} // namespace IP
|
} // namespace beast::IP
|
||||||
} // namespace beast
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|||||||
@@ -12,8 +12,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace beast {
|
namespace beast::rfc2616 {
|
||||||
namespace rfc2616 {
|
|
||||||
|
|
||||||
namespace detail {
|
namespace detail {
|
||||||
|
|
||||||
@@ -370,5 +369,4 @@ is_keep_alive(boost::beast::http::message<isRequest, Body, Fields> const& m)
|
|||||||
"close");
|
"close");
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace rfc2616
|
} // namespace beast::rfc2616
|
||||||
} // namespace beast
|
|
||||||
|
|||||||
@@ -15,8 +15,7 @@
|
|||||||
#include <thread>
|
#include <thread>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace beast {
|
namespace beast::test {
|
||||||
namespace test {
|
|
||||||
|
|
||||||
/** Mix-in to support tests using asio coroutines.
|
/** Mix-in to support tests using asio coroutines.
|
||||||
|
|
||||||
@@ -44,8 +43,10 @@ public:
|
|||||||
: work_(boost::asio::make_work_guard(ios_))
|
: work_(boost::asio::make_work_guard(ios_))
|
||||||
{
|
{
|
||||||
threads_.reserve(concurrency);
|
threads_.reserve(concurrency);
|
||||||
while ((concurrency--) != 0u)
|
for (std::size_t i = 0; i < concurrency; ++i)
|
||||||
|
{
|
||||||
threads_.emplace_back([&] { ios_.run(); });
|
threads_.emplace_back([&] { ios_.run(); });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
~enable_yield_to()
|
~enable_yield_to()
|
||||||
@@ -125,5 +126,4 @@ enable_yield_to::spawn(F0&& f, FN&&... fn)
|
|||||||
spawn(fn...);
|
spawn(fn...);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace test
|
} // namespace beast::test
|
||||||
} // namespace beast
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ template <typename T>
|
|||||||
std::string
|
std::string
|
||||||
type_name()
|
type_name()
|
||||||
{
|
{
|
||||||
using TR = typename std::remove_reference<T>::type;
|
using TR = std::remove_reference_t<T>;
|
||||||
|
|
||||||
std::string name = typeid(TR).name();
|
std::string name = typeid(TR).name();
|
||||||
|
|
||||||
@@ -27,15 +27,15 @@ type_name()
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (std::is_const<TR>::value)
|
if (std::is_const_v<TR>)
|
||||||
name += " const";
|
name += " const";
|
||||||
if (std::is_volatile<TR>::value)
|
if (std::is_volatile_v<TR>)
|
||||||
name += " volatile";
|
name += " volatile";
|
||||||
if (std::is_lvalue_reference<T>::value)
|
if (std::is_lvalue_reference_v<T>)
|
||||||
{
|
{
|
||||||
name += "&";
|
name += "&";
|
||||||
}
|
}
|
||||||
else if (std::is_rvalue_reference<T>::value)
|
else if (std::is_rvalue_reference_v<T>)
|
||||||
{
|
{
|
||||||
name += "&&";
|
name += "&&";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,8 +8,7 @@
|
|||||||
#include <ostream>
|
#include <ostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace beast {
|
namespace beast::unit_test {
|
||||||
namespace unit_test {
|
|
||||||
|
|
||||||
/** Utility for producing nicely composed output of amounts with units. */
|
/** Utility for producing nicely composed output of amounts with units. */
|
||||||
class amount
|
class amount
|
||||||
@@ -42,5 +41,4 @@ operator<<(std::ostream& s, amount const& t)
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace unit_test
|
} // namespace beast::unit_test
|
||||||
} // namespace beast
|
|
||||||
|
|||||||
@@ -4,9 +4,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
namespace beast {
|
namespace beast::unit_test::detail {
|
||||||
namespace unit_test {
|
|
||||||
namespace detail {
|
|
||||||
|
|
||||||
/** Adapter to constrain a container interface.
|
/** Adapter to constrain a container interface.
|
||||||
The interface allows for limited read only operations. Derived classes
|
The interface allows for limited read only operations. Derived classes
|
||||||
@@ -27,7 +25,7 @@ protected:
|
|||||||
return m_cont;
|
return m_cont;
|
||||||
}
|
}
|
||||||
|
|
||||||
cont_type const&
|
[[nodiscard]] cont_type const&
|
||||||
cont() const
|
cont() const
|
||||||
{
|
{
|
||||||
return m_cont;
|
return m_cont;
|
||||||
@@ -41,14 +39,14 @@ public:
|
|||||||
using const_iterator = typename cont_type::const_iterator;
|
using const_iterator = typename cont_type::const_iterator;
|
||||||
|
|
||||||
/** Returns `true` if the container is empty. */
|
/** Returns `true` if the container is empty. */
|
||||||
bool
|
[[nodiscard]] bool
|
||||||
empty() const
|
empty() const
|
||||||
{
|
{
|
||||||
return m_cont.empty();
|
return m_cont.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the number of items in the container. */
|
/** Returns the number of items in the container. */
|
||||||
size_type
|
[[nodiscard]] size_type
|
||||||
size() const
|
size() const
|
||||||
{
|
{
|
||||||
return m_cont.size();
|
return m_cont.size();
|
||||||
@@ -56,25 +54,25 @@ public:
|
|||||||
|
|
||||||
/** Returns forward iterators for traversal. */
|
/** Returns forward iterators for traversal. */
|
||||||
/** @{ */
|
/** @{ */
|
||||||
const_iterator
|
[[nodiscard]] const_iterator
|
||||||
begin() const
|
begin() const
|
||||||
{
|
{
|
||||||
return m_cont.cbegin();
|
return m_cont.cbegin();
|
||||||
}
|
}
|
||||||
|
|
||||||
const_iterator
|
[[nodiscard]] const_iterator
|
||||||
cbegin() const
|
cbegin() const
|
||||||
{
|
{
|
||||||
return m_cont.cbegin();
|
return m_cont.cbegin();
|
||||||
}
|
}
|
||||||
|
|
||||||
const_iterator
|
[[nodiscard]] const_iterator
|
||||||
end() const
|
end() const
|
||||||
{
|
{
|
||||||
return m_cont.cend();
|
return m_cont.cend();
|
||||||
}
|
}
|
||||||
|
|
||||||
const_iterator
|
[[nodiscard]] const_iterator
|
||||||
cend() const
|
cend() const
|
||||||
{
|
{
|
||||||
return m_cont.cend();
|
return m_cont.cend();
|
||||||
@@ -82,6 +80,4 @@ public:
|
|||||||
/** @} */
|
/** @} */
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace detail
|
} // namespace beast::unit_test::detail
|
||||||
} // namespace unit_test
|
|
||||||
} // namespace beast
|
|
||||||
|
|||||||
@@ -6,8 +6,7 @@
|
|||||||
|
|
||||||
#include <xrpl/beast/unit_test/suite_list.h>
|
#include <xrpl/beast/unit_test/suite_list.h>
|
||||||
|
|
||||||
namespace beast {
|
namespace beast::unit_test {
|
||||||
namespace unit_test {
|
|
||||||
|
|
||||||
namespace detail {
|
namespace detail {
|
||||||
|
|
||||||
@@ -42,5 +41,4 @@ global_suites()
|
|||||||
return detail::global_suites();
|
return detail::global_suites();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace unit_test
|
} // namespace beast::unit_test
|
||||||
} // namespace beast
|
|
||||||
|
|||||||
@@ -8,8 +8,7 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace beast {
|
namespace beast::unit_test {
|
||||||
namespace unit_test {
|
|
||||||
|
|
||||||
// Predicate for implementing matches
|
// Predicate for implementing matches
|
||||||
class selector
|
class selector
|
||||||
@@ -163,5 +162,4 @@ match_library(std::string const& name)
|
|||||||
return selector(selector::library, name);
|
return selector(selector::library, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace unit_test
|
} // namespace beast::unit_test
|
||||||
} // namespace beast
|
|
||||||
|
|||||||
@@ -7,8 +7,7 @@
|
|||||||
#include <xrpl/beast/unit_test/results.h>
|
#include <xrpl/beast/unit_test/results.h>
|
||||||
#include <xrpl/beast/unit_test/runner.h>
|
#include <xrpl/beast/unit_test/runner.h>
|
||||||
|
|
||||||
namespace beast {
|
namespace beast::unit_test {
|
||||||
namespace unit_test {
|
|
||||||
|
|
||||||
/** A test runner that stores the results. */
|
/** A test runner that stores the results. */
|
||||||
class recorder : public runner
|
class recorder : public runner
|
||||||
@@ -22,56 +21,55 @@ public:
|
|||||||
recorder() = default;
|
recorder() = default;
|
||||||
|
|
||||||
/** Returns a report with the results of all completed suites. */
|
/** Returns a report with the results of all completed suites. */
|
||||||
results const&
|
[[nodiscard]] results const&
|
||||||
report() const
|
report() const
|
||||||
{
|
{
|
||||||
return m_results;
|
return m_results;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual void
|
void
|
||||||
on_suite_begin(suite_info const& info) override
|
on_suite_begin(suite_info const& info) override
|
||||||
{
|
{
|
||||||
m_suite = suite_results(info.full_name());
|
m_suite = suite_results(info.full_name());
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void
|
void
|
||||||
on_suite_end() override
|
on_suite_end() override
|
||||||
{
|
{
|
||||||
m_results.insert(std::move(m_suite));
|
m_results.insert(std::move(m_suite));
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void
|
void
|
||||||
on_case_begin(std::string const& name) override
|
on_case_begin(std::string const& name) override
|
||||||
{
|
{
|
||||||
m_case = case_results(name);
|
m_case = case_results(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void
|
void
|
||||||
on_case_end() override
|
on_case_end() override
|
||||||
{
|
{
|
||||||
if (!m_case.tests.empty())
|
if (!m_case.tests.empty())
|
||||||
m_suite.insert(std::move(m_case));
|
m_suite.insert(std::move(m_case));
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void
|
void
|
||||||
on_pass() override
|
on_pass() override
|
||||||
{
|
{
|
||||||
m_case.tests.pass();
|
m_case.tests.pass();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void
|
void
|
||||||
on_fail(std::string const& reason) override
|
on_fail(std::string const& reason) override
|
||||||
{
|
{
|
||||||
m_case.tests.fail(reason);
|
m_case.tests.fail(reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void
|
void
|
||||||
on_log(std::string const& s) override
|
on_log(std::string const& s) override
|
||||||
{
|
{
|
||||||
m_case.log.insert(s);
|
m_case.log.insert(s);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace unit_test
|
} // namespace beast::unit_test
|
||||||
} // namespace beast
|
|
||||||
|
|||||||
@@ -18,8 +18,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
namespace beast {
|
namespace beast::unit_test {
|
||||||
namespace unit_test {
|
|
||||||
|
|
||||||
namespace detail {
|
namespace detail {
|
||||||
|
|
||||||
@@ -86,7 +85,7 @@ public:
|
|||||||
reporter&
|
reporter&
|
||||||
operator=(reporter const&) = delete;
|
operator=(reporter const&) = delete;
|
||||||
|
|
||||||
~reporter();
|
~reporter() override;
|
||||||
|
|
||||||
explicit reporter(std::ostream& os = std::cout);
|
explicit reporter(std::ostream& os = std::cout);
|
||||||
|
|
||||||
@@ -94,25 +93,25 @@ private:
|
|||||||
static std::string
|
static std::string
|
||||||
fmtdur(typename clock_type::duration const& d);
|
fmtdur(typename clock_type::duration const& d);
|
||||||
|
|
||||||
virtual void
|
void
|
||||||
on_suite_begin(suite_info const& info) override;
|
on_suite_begin(suite_info const& info) override;
|
||||||
|
|
||||||
virtual void
|
void
|
||||||
on_suite_end() override;
|
on_suite_end() override;
|
||||||
|
|
||||||
virtual void
|
void
|
||||||
on_case_begin(std::string const& name) override;
|
on_case_begin(std::string const& name) override;
|
||||||
|
|
||||||
virtual void
|
void
|
||||||
on_case_end() override;
|
on_case_end() override;
|
||||||
|
|
||||||
virtual void
|
void
|
||||||
on_pass() override;
|
on_pass() override;
|
||||||
|
|
||||||
virtual void
|
void
|
||||||
on_fail(std::string const& reason) override;
|
on_fail(std::string const& reason) override;
|
||||||
|
|
||||||
virtual void
|
void
|
||||||
on_log(std::string const& s) override;
|
on_log(std::string const& s) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -251,5 +250,4 @@ reporter<Unused>::on_log(std::string const& s)
|
|||||||
|
|
||||||
using reporter = detail::reporter<>;
|
using reporter = detail::reporter<>;
|
||||||
|
|
||||||
} // namespace unit_test
|
} // namespace beast::unit_test
|
||||||
} // namespace beast
|
|
||||||
|
|||||||
@@ -7,10 +7,10 @@
|
|||||||
#include <xrpl/beast/unit_test/detail/const_container.h>
|
#include <xrpl/beast/unit_test/detail/const_container.h>
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace beast {
|
namespace beast::unit_test {
|
||||||
namespace unit_test {
|
|
||||||
|
|
||||||
/** Holds a set of test condition outcomes in a testcase. */
|
/** Holds a set of test condition outcomes in a testcase. */
|
||||||
class case_results
|
class case_results
|
||||||
@@ -23,7 +23,7 @@ public:
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
test(bool pass_, std::string const& reason_) : pass(pass_), reason(reason_)
|
test(bool pass_, std::string reason_) : pass(pass_), reason(std::move(reason_))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -38,19 +38,17 @@ private:
|
|||||||
std::size_t failed_{0};
|
std::size_t failed_{0};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
tests_t()
|
tests_t() = default;
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Returns the total number of test conditions. */
|
/** Returns the total number of test conditions. */
|
||||||
std::size_t
|
[[nodiscard]] std::size_t
|
||||||
total() const
|
total() const
|
||||||
{
|
{
|
||||||
return cont().size();
|
return cont().size();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the number of failed test conditions. */
|
/** Returns the number of failed test conditions. */
|
||||||
std::size_t
|
[[nodiscard]] std::size_t
|
||||||
failed() const
|
failed() const
|
||||||
{
|
{
|
||||||
return failed_;
|
return failed_;
|
||||||
@@ -86,12 +84,12 @@ private:
|
|||||||
std::string name_;
|
std::string name_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit case_results(std::string const& name = "") : name_(name)
|
explicit case_results(std::string name = "") : name_(std::move(name))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the name of this testcase. */
|
/** Returns the name of this testcase. */
|
||||||
std::string const&
|
[[nodiscard]] std::string const&
|
||||||
name() const
|
name() const
|
||||||
{
|
{
|
||||||
return name_;
|
return name_;
|
||||||
@@ -115,26 +113,26 @@ private:
|
|||||||
std::size_t failed_ = 0;
|
std::size_t failed_ = 0;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit suite_results(std::string const& name = "") : name_(name)
|
explicit suite_results(std::string name = "") : name_(std::move(name))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the name of this suite. */
|
/** Returns the name of this suite. */
|
||||||
std::string const&
|
[[nodiscard]] std::string const&
|
||||||
name() const
|
name() const
|
||||||
{
|
{
|
||||||
return name_;
|
return name_;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the total number of test conditions. */
|
/** Returns the total number of test conditions. */
|
||||||
std::size_t
|
[[nodiscard]] std::size_t
|
||||||
total() const
|
total() const
|
||||||
{
|
{
|
||||||
return total_;
|
return total_;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the number of failures. */
|
/** Returns the number of failures. */
|
||||||
std::size_t
|
[[nodiscard]] std::size_t
|
||||||
failed() const
|
failed() const
|
||||||
{
|
{
|
||||||
return failed_;
|
return failed_;
|
||||||
@@ -172,26 +170,24 @@ private:
|
|||||||
std::size_t failed_{0};
|
std::size_t failed_{0};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
results()
|
results() = default;
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Returns the total number of test cases. */
|
/** Returns the total number of test cases. */
|
||||||
std::size_t
|
[[nodiscard]] std::size_t
|
||||||
cases() const
|
cases() const
|
||||||
{
|
{
|
||||||
return m_cases;
|
return m_cases;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the total number of test conditions. */
|
/** Returns the total number of test conditions. */
|
||||||
std::size_t
|
[[nodiscard]] std::size_t
|
||||||
total() const
|
total() const
|
||||||
{
|
{
|
||||||
return total_;
|
return total_;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the number of failures. */
|
/** Returns the number of failures. */
|
||||||
std::size_t
|
[[nodiscard]] std::size_t
|
||||||
failed() const
|
failed() const
|
||||||
{
|
{
|
||||||
return failed_;
|
return failed_;
|
||||||
@@ -219,5 +215,4 @@ public:
|
|||||||
/** @} */
|
/** @} */
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace unit_test
|
} // namespace beast::unit_test
|
||||||
} // namespace beast
|
|
||||||
|
|||||||
@@ -11,8 +11,7 @@
|
|||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace beast {
|
namespace beast::unit_test {
|
||||||
namespace unit_test {
|
|
||||||
|
|
||||||
/** Unit test runner interface.
|
/** Unit test runner interface.
|
||||||
|
|
||||||
@@ -48,7 +47,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the argument string. */
|
/** Returns the argument string. */
|
||||||
std::string const&
|
[[nodiscard]] std::string const&
|
||||||
arg() const
|
arg() const
|
||||||
{
|
{
|
||||||
return arg_;
|
return arg_;
|
||||||
@@ -277,5 +276,4 @@ runner::log(std::string const& s)
|
|||||||
on_log(s);
|
on_log(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace unit_test
|
} // namespace beast::unit_test
|
||||||
} // namespace beast
|
|
||||||
|
|||||||
@@ -14,8 +14,7 @@
|
|||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace beast {
|
namespace beast::unit_test {
|
||||||
namespace unit_test {
|
|
||||||
|
|
||||||
namespace detail {
|
namespace detail {
|
||||||
|
|
||||||
@@ -58,7 +57,7 @@ private:
|
|||||||
// in the event of a failure, if the option to stop is set.
|
// in the event of a failure, if the option to stop is set.
|
||||||
struct abort_exception : public std::exception
|
struct abort_exception : public std::exception
|
||||||
{
|
{
|
||||||
char const*
|
[[nodiscard]] char const*
|
||||||
what() const noexcept override
|
what() const noexcept override
|
||||||
{
|
{
|
||||||
return "test suite aborted";
|
return "test suite aborted";
|
||||||
@@ -75,7 +74,7 @@ private:
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
~log_buf()
|
~log_buf() override
|
||||||
{
|
{
|
||||||
sync();
|
sync();
|
||||||
}
|
}
|
||||||
@@ -573,8 +572,7 @@ suite::run(runner& r)
|
|||||||
((cond) ? (pass(), true) : (fail((reason), __FILE__, __LINE__), false))
|
((cond) ? (pass(), true) : (fail((reason), __FILE__, __LINE__), false))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
} // namespace unit_test
|
} // namespace beast::unit_test
|
||||||
} // namespace beast
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|||||||
@@ -9,8 +9,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
namespace beast {
|
namespace beast::unit_test {
|
||||||
namespace unit_test {
|
|
||||||
|
|
||||||
class runner;
|
class runner;
|
||||||
|
|
||||||
@@ -43,33 +42,33 @@ public:
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string const&
|
[[nodiscard]] std::string const&
|
||||||
name() const
|
name() const
|
||||||
{
|
{
|
||||||
return name_;
|
return name_;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string const&
|
[[nodiscard]] std::string const&
|
||||||
module() const
|
module() const
|
||||||
{
|
{
|
||||||
return module_;
|
return module_;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string const&
|
[[nodiscard]] std::string const&
|
||||||
library() const
|
library() const
|
||||||
{
|
{
|
||||||
return library_;
|
return library_;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns `true` if this suite only runs manually.
|
/// Returns `true` if this suite only runs manually.
|
||||||
bool
|
[[nodiscard]] bool
|
||||||
manual() const
|
manual() const
|
||||||
{
|
{
|
||||||
return manual_;
|
return manual_;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return the canonical suite name as a string.
|
/// Return the canonical suite name as a string.
|
||||||
std::string
|
[[nodiscard]] std::string
|
||||||
full_name() const
|
full_name() const
|
||||||
{
|
{
|
||||||
return library_ + "." + module_ + "." + name_;
|
return library_ + "." + module_ + "." + name_;
|
||||||
@@ -110,5 +109,4 @@ make_suite_info(
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace unit_test
|
} // namespace beast::unit_test
|
||||||
} // namespace beast
|
|
||||||
|
|||||||
@@ -13,8 +13,7 @@
|
|||||||
#include <typeindex>
|
#include <typeindex>
|
||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
|
|
||||||
namespace beast {
|
namespace beast::unit_test {
|
||||||
namespace unit_test {
|
|
||||||
|
|
||||||
/// A container of test suites.
|
/// A container of test suites.
|
||||||
class suite_list : public detail::const_container<std::set<suite_info>>
|
class suite_list : public detail::const_container<std::set<suite_info>>
|
||||||
@@ -62,5 +61,4 @@ suite_list::insert(
|
|||||||
cont().emplace(make_suite_info<Suite>(name, module, library, manual, priority));
|
cont().emplace(make_suite_info<Suite>(name, module, library, manual, priority));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace unit_test
|
} // namespace beast::unit_test
|
||||||
} // namespace beast
|
|
||||||
|
|||||||
@@ -10,8 +10,7 @@
|
|||||||
#include <thread>
|
#include <thread>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
namespace beast {
|
namespace beast::unit_test {
|
||||||
namespace unit_test {
|
|
||||||
|
|
||||||
/** Replacement for std::thread that handles exceptions in unit tests. */
|
/** Replacement for std::thread that handles exceptions in unit tests. */
|
||||||
class Thread
|
class Thread
|
||||||
@@ -48,13 +47,13 @@ public:
|
|||||||
t_ = std::thread(&Thread::run, this, std::move(b));
|
t_ = std::thread(&Thread::run, this, std::move(b));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
[[nodiscard]] bool
|
||||||
joinable() const
|
joinable() const
|
||||||
{
|
{
|
||||||
return t_.joinable();
|
return t_.joinable();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::thread::id
|
[[nodiscard]] std::thread::id
|
||||||
get_id() const
|
get_id() const
|
||||||
{
|
{
|
||||||
return t_.get_id();
|
return t_.get_id();
|
||||||
@@ -108,5 +107,4 @@ private:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace unit_test
|
} // namespace beast::unit_test
|
||||||
} // namespace beast
|
|
||||||
|
|||||||
@@ -55,22 +55,23 @@ public:
|
|||||||
class Sink
|
class Sink
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
Sink() = delete;
|
|
||||||
explicit Sink(Sink const& sink) = default;
|
explicit Sink(Sink const& sink) = default;
|
||||||
Sink(Severity thresh, bool console);
|
Sink(Severity thresh, bool console);
|
||||||
Sink&
|
|
||||||
operator=(Sink const& lhs) = delete;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual ~Sink() = 0;
|
virtual ~Sink() = 0;
|
||||||
|
|
||||||
|
Sink() = delete;
|
||||||
|
Sink&
|
||||||
|
operator=(Sink const& lhs) = delete;
|
||||||
|
|
||||||
/** Returns `true` if text at the passed severity produces output. */
|
/** Returns `true` if text at the passed severity produces output. */
|
||||||
virtual bool
|
[[nodiscard]] virtual bool
|
||||||
active(Severity level) const;
|
active(Severity level) const;
|
||||||
|
|
||||||
/** Returns `true` if a message is also written to the Output Window
|
/** Returns `true` if a message is also written to the Output Window
|
||||||
* (MSVC). */
|
* (MSVC). */
|
||||||
virtual bool
|
[[nodiscard]] virtual bool
|
||||||
console() const;
|
console() const;
|
||||||
|
|
||||||
/** Set whether messages are also written to the Output Window (MSVC).
|
/** Set whether messages are also written to the Output Window (MSVC).
|
||||||
@@ -79,7 +80,7 @@ public:
|
|||||||
console(bool output);
|
console(bool output);
|
||||||
|
|
||||||
/** Returns the minimum severity level this sink will report. */
|
/** Returns the minimum severity level this sink will report. */
|
||||||
virtual Severity
|
[[nodiscard]] virtual Severity
|
||||||
threshold() const;
|
threshold() const;
|
||||||
|
|
||||||
/** Set the minimum severity this sink will report. */
|
/** Set the minimum severity this sink will report. */
|
||||||
@@ -203,14 +204,14 @@ public:
|
|||||||
operator=(Stream const& other) = delete;
|
operator=(Stream const& other) = delete;
|
||||||
|
|
||||||
/** Returns the Sink that this Stream writes to. */
|
/** Returns the Sink that this Stream writes to. */
|
||||||
Sink&
|
[[nodiscard]] Sink&
|
||||||
sink() const
|
sink() const
|
||||||
{
|
{
|
||||||
return m_sink;
|
return m_sink;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the Severity level of messages this Stream reports. */
|
/** Returns the Severity level of messages this Stream reports. */
|
||||||
Severity
|
[[nodiscard]] Severity
|
||||||
level() const
|
level() const
|
||||||
{
|
{
|
||||||
return m_level;
|
return m_level;
|
||||||
@@ -218,7 +219,7 @@ public:
|
|||||||
|
|
||||||
/** Returns `true` if sink logs anything at this stream's level. */
|
/** Returns `true` if sink logs anything at this stream's level. */
|
||||||
/** @{ */
|
/** @{ */
|
||||||
bool
|
[[nodiscard]] bool
|
||||||
active() const
|
active() const
|
||||||
{
|
{
|
||||||
return m_sink.active(m_level);
|
return m_sink.active(m_level);
|
||||||
@@ -266,14 +267,14 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the Sink associated with this Journal. */
|
/** Returns the Sink associated with this Journal. */
|
||||||
Sink&
|
[[nodiscard]] Sink&
|
||||||
sink() const
|
sink() const
|
||||||
{
|
{
|
||||||
return *m_sink;
|
return *m_sink;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns a stream for this sink, with the specified severity level. */
|
/** Returns a stream for this sink, with the specified severity level. */
|
||||||
Stream
|
[[nodiscard]] Stream
|
||||||
stream(Severity level) const
|
stream(Severity level) const
|
||||||
{
|
{
|
||||||
return Stream(*m_sink, level);
|
return Stream(*m_sink, level);
|
||||||
@@ -283,7 +284,7 @@ public:
|
|||||||
For a message to be logged, the severity must be at or above the
|
For a message to be logged, the severity must be at or above the
|
||||||
sink's severity threshold.
|
sink's severity threshold.
|
||||||
*/
|
*/
|
||||||
bool
|
[[nodiscard]] bool
|
||||||
active(Severity level) const
|
active(Severity level) const
|
||||||
{
|
{
|
||||||
return m_sink->active(level);
|
return m_sink->active(level);
|
||||||
@@ -291,37 +292,37 @@ public:
|
|||||||
|
|
||||||
/** Severity stream access functions. */
|
/** Severity stream access functions. */
|
||||||
/** @{ */
|
/** @{ */
|
||||||
Stream
|
[[nodiscard]] Stream
|
||||||
trace() const
|
trace() const
|
||||||
{
|
{
|
||||||
return {*m_sink, severities::kTrace};
|
return {*m_sink, severities::kTrace};
|
||||||
}
|
}
|
||||||
|
|
||||||
Stream
|
[[nodiscard]] Stream
|
||||||
debug() const
|
debug() const
|
||||||
{
|
{
|
||||||
return {*m_sink, severities::kDebug};
|
return {*m_sink, severities::kDebug};
|
||||||
}
|
}
|
||||||
|
|
||||||
Stream
|
[[nodiscard]] Stream
|
||||||
info() const
|
info() const
|
||||||
{
|
{
|
||||||
return {*m_sink, severities::kInfo};
|
return {*m_sink, severities::kInfo};
|
||||||
}
|
}
|
||||||
|
|
||||||
Stream
|
[[nodiscard]] Stream
|
||||||
warn() const
|
warn() const
|
||||||
{
|
{
|
||||||
return {*m_sink, severities::kWarning};
|
return {*m_sink, severities::kWarning};
|
||||||
}
|
}
|
||||||
|
|
||||||
Stream
|
[[nodiscard]] Stream
|
||||||
error() const
|
error() const
|
||||||
{
|
{
|
||||||
return {*m_sink, severities::kError};
|
return {*m_sink, severities::kError};
|
||||||
}
|
}
|
||||||
|
|
||||||
Stream
|
[[nodiscard]] Stream
|
||||||
fatal() const
|
fatal() const
|
||||||
{
|
{
|
||||||
return {*m_sink, severities::kFatal};
|
return {*m_sink, severities::kFatal};
|
||||||
@@ -371,10 +372,6 @@ class logstream_buf : public std::basic_stringbuf<CharT, Traits>
|
|||||||
{
|
{
|
||||||
beast::Journal::Stream strm_;
|
beast::Journal::Stream strm_;
|
||||||
|
|
||||||
template <class T>
|
|
||||||
void
|
|
||||||
write(T const*) = delete;
|
|
||||||
|
|
||||||
void
|
void
|
||||||
write(char const* s)
|
write(char const* s)
|
||||||
{
|
{
|
||||||
@@ -394,7 +391,7 @@ public:
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
~logstream_buf()
|
~logstream_buf() override
|
||||||
{
|
{
|
||||||
sync();
|
sync();
|
||||||
}
|
}
|
||||||
@@ -406,6 +403,10 @@ public:
|
|||||||
this->str("");
|
this->str("");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
void
|
||||||
|
write(T const*) = delete;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
@@ -413,11 +414,11 @@ public:
|
|||||||
template <class CharT, class Traits = std::char_traits<CharT>>
|
template <class CharT, class Traits = std::char_traits<CharT>>
|
||||||
class basic_logstream : public std::basic_ostream<CharT, Traits>
|
class basic_logstream : public std::basic_ostream<CharT, Traits>
|
||||||
{
|
{
|
||||||
typedef CharT char_type;
|
using char_type = CharT;
|
||||||
typedef Traits traits_type;
|
using traits_type = Traits;
|
||||||
typedef typename traits_type::int_type int_type;
|
using int_type = typename traits_type::int_type;
|
||||||
typedef typename traits_type::pos_type pos_type;
|
using pos_type = typename traits_type::pos_type;
|
||||||
typedef typename traits_type::off_type off_type;
|
using off_type = typename traits_type::off_type;
|
||||||
|
|
||||||
detail::logstream_buf<CharT, Traits> buf_;
|
detail::logstream_buf<CharT, Traits> buf_;
|
||||||
|
|
||||||
|
|||||||
@@ -149,7 +149,7 @@ class PropertyStream::Item : public List<Item>::Node
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit Item(Source* source);
|
explicit Item(Source* source);
|
||||||
Source&
|
[[nodiscard]] Source&
|
||||||
source() const;
|
source() const;
|
||||||
Source*
|
Source*
|
||||||
operator->() const;
|
operator->() const;
|
||||||
@@ -174,7 +174,7 @@ private:
|
|||||||
std::ostringstream mutable m_ostream;
|
std::ostringstream mutable m_ostream;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Proxy(Map const& map, std::string const& key);
|
Proxy(Map const& map, std::string key);
|
||||||
Proxy(Proxy const& other);
|
Proxy(Proxy const& other);
|
||||||
~Proxy();
|
~Proxy();
|
||||||
|
|
||||||
@@ -217,7 +217,7 @@ public:
|
|||||||
|
|
||||||
PropertyStream&
|
PropertyStream&
|
||||||
stream();
|
stream();
|
||||||
PropertyStream const&
|
[[nodiscard]] PropertyStream const&
|
||||||
stream() const;
|
stream() const;
|
||||||
|
|
||||||
template <typename Value>
|
template <typename Value>
|
||||||
@@ -287,7 +287,7 @@ public:
|
|||||||
|
|
||||||
PropertyStream&
|
PropertyStream&
|
||||||
stream();
|
stream();
|
||||||
PropertyStream const&
|
[[nodiscard]] PropertyStream const&
|
||||||
stream() const;
|
stream() const;
|
||||||
|
|
||||||
template <typename Value>
|
template <typename Value>
|
||||||
@@ -315,7 +315,7 @@ private:
|
|||||||
List<Item> children_;
|
List<Item> children_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit Source(std::string const& name);
|
explicit Source(std::string name);
|
||||||
virtual ~Source();
|
virtual ~Source();
|
||||||
|
|
||||||
Source(Source const&) = delete;
|
Source(Source const&) = delete;
|
||||||
@@ -323,7 +323,7 @@ public:
|
|||||||
operator=(Source const&) = delete;
|
operator=(Source const&) = delete;
|
||||||
|
|
||||||
/** Returns the name of this source. */
|
/** Returns the name of this source. */
|
||||||
std::string const&
|
[[nodiscard]] std::string const&
|
||||||
name() const;
|
name() const;
|
||||||
|
|
||||||
/** Add a child source. */
|
/** Add a child source. */
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user