Merge branch 'develop' into pratik/Retire_fixUniversalNumber_amendment

# Conflicts:
#	include/xrpl/basics/CountedObject.h
#	include/xrpl/basics/Expected.h
#	include/xrpl/basics/IntrusivePointer.ipp
#	include/xrpl/basics/IntrusiveRefCounts.h
#	include/xrpl/basics/Log.h
#	include/xrpl/basics/Number.h
#	include/xrpl/basics/SlabAllocator.h
#	include/xrpl/basics/TaggedCache.h
#	include/xrpl/basics/TaggedCache.ipp
#	include/xrpl/basics/UptimeClock.h
#	include/xrpl/basics/base_uint.h
#	include/xrpl/basics/chrono.h
#	include/xrpl/basics/hardened_hash.h
#	include/xrpl/basics/partitioned_unordered_map.h
#	include/xrpl/basics/tagged_integer.h
#	include/xrpl/beast/clock/abstract_clock.h
#	include/xrpl/beast/clock/basic_seconds_clock.h
#	include/xrpl/beast/container/aged_unordered_map.h
#	include/xrpl/beast/container/detail/aged_container_iterator.h
#	include/xrpl/beast/container/detail/aged_unordered_container.h
#	include/xrpl/beast/core/List.h
#	include/xrpl/beast/core/LockFreeStack.h
#	include/xrpl/beast/hash/hash_append.h
#	include/xrpl/beast/insight/Counter.h
#	include/xrpl/beast/insight/Event.h
#	include/xrpl/beast/insight/Gauge.h
#	include/xrpl/beast/insight/Hook.h
#	include/xrpl/beast/insight/Meter.h
#	include/xrpl/beast/net/IPEndpoint.h
#	include/xrpl/beast/unit_test/detail/const_container.h
#	include/xrpl/beast/unit_test/global_suites.h
#	include/xrpl/beast/unit_test/match.h
#	include/xrpl/beast/unit_test/recorder.h
#	include/xrpl/beast/unit_test/reporter.h
#	include/xrpl/beast/unit_test/results.h
#	include/xrpl/beast/unit_test/suite.h
#	include/xrpl/beast/unit_test/suite_info.h
#	include/xrpl/beast/utility/Journal.h
#	include/xrpl/beast/utility/PropertyStream.h
#	include/xrpl/core/ClosureCounter.h
#	include/xrpl/core/Coro.ipp
#	include/xrpl/core/Job.h
#	include/xrpl/core/JobQueue.h
#	include/xrpl/core/JobTypeData.h
#	include/xrpl/core/JobTypeInfo.h
#	include/xrpl/core/JobTypes.h
#	include/xrpl/core/LoadMonitor.h
#	include/xrpl/core/detail/Workers.h
#	include/xrpl/core/detail/semaphore.h
#	include/xrpl/json/json_value.h
#	include/xrpl/json/json_writer.h
#	include/xrpl/ledger/Ledger.h
#	include/xrpl/ledger/helpers/TokenHelpers.h
#	include/xrpl/nodestore/NodeObject.h
#	include/xrpl/protocol/AmountConversions.h
#	include/xrpl/protocol/ApiVersion.h
#	include/xrpl/protocol/Book.h
#	include/xrpl/protocol/ErrorCodes.h
#	include/xrpl/protocol/Feature.h
#	include/xrpl/protocol/Indexes.h
#	include/xrpl/protocol/Quality.h
#	include/xrpl/protocol/SField.h
#	include/xrpl/protocol/STAmount.h
#	include/xrpl/protocol/STArray.h
#	include/xrpl/protocol/STBase.h
#	include/xrpl/protocol/STLedgerEntry.h
#	include/xrpl/protocol/STObject.h
#	include/xrpl/protocol/STPathSet.h
#	include/xrpl/protocol/STTx.h
#	include/xrpl/protocol/STValidation.h
#	include/xrpl/protocol/STVector256.h
#	include/xrpl/protocol/Serializer.h
#	include/xrpl/protocol/XRPAmount.h
#	include/xrpl/protocol/detail/features.macro
#	include/xrpl/protocol/json_get_or_throw.h
#	include/xrpl/resource/Charge.h
#	include/xrpl/resource/Consumer.h
#	include/xrpl/server/InfoSub.h
#	include/xrpl/shamap/FullBelowCache.h
#	include/xrpl/shamap/SHAMapAddNode.h
#	src/libxrpl/protocol/AMMCore.cpp
#	src/libxrpl/protocol/IOUAmount.cpp
#	src/libxrpl/protocol/STAmount.cpp
#	src/libxrpl/tx/Transactor.cpp
#	src/libxrpl/tx/applySteps.cpp
#	src/test/app/AMM_test.cpp
#	src/test/app/NFToken_test.cpp
#	src/test/app/OfferMPT_test.cpp
#	src/test/app/Offer_test.cpp
#	src/test/jtx/AMM.h
#	src/test/jtx/AMMTest.h
#	src/test/jtx/Env.h
#	src/test/jtx/Env_ss.h
#	src/test/jtx/JTx.h
#	src/test/jtx/PathSet.h
#	src/test/jtx/TestHelpers.h
#	src/test/jtx/amount.h
#	src/test/jtx/balance.h
#	src/test/jtx/batch.h
#	src/test/jtx/credentials.h
#	src/test/jtx/deposit.h
#	src/test/jtx/escrow.h
#	src/test/jtx/jtx_json.h
#	src/test/jtx/mpt.h
#	src/test/jtx/multisign.h
#	src/test/jtx/paths.h
#	src/test/jtx/prop.h
#	src/test/jtx/regkey.h
#	src/test/jtx/tags.h
#	src/xrpld/app/misc/TxQ.h
#	src/xrpld/app/misc/detail/TxQ.cpp
#	src/xrpld/rpc/detail/AssetCache.h
#	src/xrpld/rpc/detail/Pathfinder.h
#	src/xrpld/rpc/detail/TrustLine.h
This commit is contained in:
Pratik Mankawde
2026-05-05 13:49:14 +01:00
1354 changed files with 54750 additions and 54700 deletions

View File

@@ -5,6 +5,8 @@
# This file is sorted in reverse chronological order, with the most recent commits at the top.
# The commits listed here are ignored by git blame, which is useful for formatting-only commits that would otherwise obscure the history of changes to a file.
# refactor: Enable clang-tidy `readability-identifier-naming` check (#6571)
8995564ed6b9e453e144bb663303072a3c1ba305
# refactor: Enable remaining clang-tidy `cppcoreguidelines` checks (#6538)
72f4cb097f626b08b02fc3efcb4aa11cb2e7adb8
# refactor: Rename system name from 'ripple' to 'xrpld' (#6347)

View File

@@ -62,7 +62,7 @@ ${SED_COMMAND} -i 's@ripple/@xrpld/@g' src/test/core/Config_test.cpp
${SED_COMMAND} -i 's/Rippled/File/g' src/test/core/Config_test.cpp
# Restore the old config file name in the code that maintains support for now.
${SED_COMMAND} -i 's/configLegacyName = "xrpld.cfg"/configLegacyName = "rippled.cfg"/g' src/xrpld/core/detail/Config.cpp
${SED_COMMAND} -i 's/kCONFIG_LEGACY_NAME = "xrpld.cfg"/kCONFIG_LEGACY_NAME = "rippled.cfg"/g' src/xrpld/core/detail/Config.cpp
# Restore an URL.
${SED_COMMAND} -i 's/connect-your-xrpld-to-the-xrp-test-net.html/connect-your-rippled-to-the-xrp-test-net.html/g' cfg/xrpld-example.cfg

View File

@@ -90,7 +90,7 @@ ${SED_COMMAND} -i 's/www.ripple.com/www.xrpl.org/g' src/test/protocol/Seed_test.
# Restore specific changes.
${SED_COMMAND} -i 's@b5efcc/src/xrpld@b5efcc/src/ripple@' include/xrpl/protocol/README.md
${SED_COMMAND} -i 's/dbPrefix_ = "xrpldb"/dbPrefix_ = "rippledb"/' src/xrpld/app/misc/SHAMapStoreImp.h # cspell: disable-line
${SED_COMMAND} -i 's/configLegacyName = "xrpld.cfg"/configLegacyName = "rippled.cfg"/' src/xrpld/core/detail/Config.cpp
${SED_COMMAND} -i 's/kCONFIG_LEGACY_NAME = "xrpld.cfg"/kCONFIG_LEGACY_NAME = "rippled.cfg"/' src/xrpld/core/detail/Config.cpp
popd
echo "Renaming complete."

View File

@@ -58,15 +58,12 @@ jobs:
# Keep the paths below in sync with those in `on-trigger.yml`.
.github/actions/build-deps/**
.github/actions/build-test/**
.github/actions/generate-version/**
.github/actions/setup-conan/**
.github/scripts/strategy-matrix/**
.github/workflows/reusable-build.yml
.github/workflows/reusable-build-test-config.yml
.github/workflows/reusable-build-test.yml
.github/workflows/reusable-clang-tidy.yml
.github/workflows/reusable-clang-tidy-files.yml
.github/workflows/reusable-strategy-matrix.yml
.github/workflows/reusable-test.yml
.github/workflows/reusable-upload-recipe.yml
@@ -176,4 +173,4 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Fail
run: false
run: exit 1

View File

@@ -15,15 +15,12 @@ on:
# Keep the paths below in sync with those in `on-pr.yml`.
- ".github/actions/build-deps/**"
- ".github/actions/build-test/**"
- ".github/actions/generate-version/**"
- ".github/actions/setup-conan/**"
- ".github/scripts/strategy-matrix/**"
- ".github/workflows/reusable-build.yml"
- ".github/workflows/reusable-build-test-config.yml"
- ".github/workflows/reusable-build-test.yml"
- ".github/workflows/reusable-clang-tidy.yml"
- ".github/workflows/reusable-clang-tidy-files.yml"
- ".github/workflows/reusable-strategy-matrix.yml"
- ".github/workflows/reusable-test.yml"
- ".github/workflows/reusable-upload-recipe.yml"

View File

@@ -1,175 +0,0 @@
name: Run clang-tidy on files
on:
workflow_call:
inputs:
files:
description: "List of files to check (empty means check all files)"
type: string
default: ""
create_issue_on_failure:
description: "Whether to create an issue if the check failed"
type: boolean
default: false
defaults:
run:
shell: bash
env:
# Conan installs the generators in the build/generators directory, see the
# layout() method in conanfile.py. We then run CMake from the build directory.
BUILD_DIR: build
BUILD_TYPE: Release
jobs:
run-clang-tidy:
name: Run clang tidy
runs-on: ["self-hosted", "Linux", "X64", "heavy"]
container: "ghcr.io/xrplf/ci/debian-trixie:clang-21-sha-53033a2"
permissions:
issues: write
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Prepare runner
uses: XRPLF/actions/prepare-runner@90f11ee655d1687824fb8793db770477d52afbab
with:
enable_ccache: false
- name: Print build environment
uses: XRPLF/actions/print-build-env@59dec886e4afb05a1724443af08baccbc045b574
- name: Get number of processors
uses: XRPLF/actions/get-nproc@cf0433aa74563aead044a1e395610c96d65a37cf
id: nproc
- name: Setup Conan
uses: ./.github/actions/setup-conan
- name: Build dependencies
uses: ./.github/actions/build-deps
with:
build_nproc: ${{ steps.nproc.outputs.nproc }}
build_type: ${{ env.BUILD_TYPE }}
log_verbosity: verbose
- name: Configure CMake
working-directory: ${{ env.BUILD_DIR }}
run: |
cmake \
-G 'Ninja' \
-DCMAKE_TOOLCHAIN_FILE:FILEPATH=build/generators/conan_toolchain.cmake \
-DCMAKE_BUILD_TYPE="${BUILD_TYPE}" \
-Dtests=ON \
-Dwerr=ON \
-Dxrpld=ON \
..
# clang-tidy needs headers generated from proto files
- name: Build libxrpl.libpb
working-directory: ${{ env.BUILD_DIR }}
run: |
ninja -j ${{ steps.nproc.outputs.nproc }} xrpl.libpb
- name: Run clang tidy
id: run_clang_tidy
continue-on-error: true
env:
TARGETS: ${{ inputs.files != '' && inputs.files || 'src tests' }}
run: |
run-clang-tidy -j ${{ steps.nproc.outputs.nproc }} -p "${BUILD_DIR}" -quiet -fix -allow-no-checks ${TARGETS} 2>&1 | tee clang-tidy-output.txt
- name: Upload clang-tidy 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-results
path: clang-tidy-output.txt
retention-days: 30
- name: Generate git diff
if: ${{ steps.run_clang_tidy.outcome != 'success' }}
run: |
git diff | tee clang-tidy-git-diff.txt
- name: Upload clang-tidy diff output
if: ${{ github.event.repository.visibility == 'public' && steps.run_clang_tidy.outcome != 'success' }}
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: clang-tidy-git-diff
path: clang-tidy-git-diff.txt
retention-days: 30
- name: Create an issue
if: ${{ steps.run_clang_tidy.outcome != 'success' && inputs.create_issue_on_failure }}
id: create_issue
shell: bash
env:
GH_TOKEN: ${{ github.token }}
run: |
# Prepare issue body with clang-tidy output
cat > issue.md <<EOF
## Clang-tidy Check Failed
**Workflow:** ${{ github.workflow }}
**Run ID:** ${{ github.run_id }}
**Commit:** ${{ github.sha }}
**Branch/Ref:** ${{ github.ref }}
**Triggered by:** ${{ github.actor }}
### Clang-tidy Output:
\`\`\`
EOF
# Append clang-tidy output (filter for errors and warnings)
if [ -f clang-tidy-output.txt ]; then
# Extract lines containing 'error:', 'warning:', or 'note:'
grep -E '(error:|warning:|note:)' clang-tidy-output.txt > filtered-output.txt || true
# If filtered output is empty, use original (might be a different error format)
if [ ! -s filtered-output.txt ]; then
cp clang-tidy-output.txt filtered-output.txt
fi
# Truncate if too large
head -c 60000 filtered-output.txt >> issue.md
if [ "$(wc -c < filtered-output.txt)" -gt 60000 ]; then
echo "" >> issue.md
echo "... (output truncated, see artifacts for full output)" >> issue.md
fi
rm filtered-output.txt
else
echo "No output file found" >> issue.md
fi
cat >> issue.md <<EOF
\`\`\`
**Workflow run:** ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
---
*This issue was automatically created by the clang-tidy workflow.*
EOF
# Create the issue
gh issue create \
--label "Bug,Clang-tidy" \
--title "Clang-tidy check failed" \
--body-file ./issue.md \
> create_issue.log
created_issue="$(sed 's|.*/||' create_issue.log)"
echo "created_issue=$created_issue" >> $GITHUB_OUTPUT
echo "Created issue #$created_issue"
rm -f create_issue.log issue.md clang-tidy-output.txt
- name: Fail the workflow if clang-tidy failed
if: ${{ steps.run_clang_tidy.outcome != 'success' }}
run: |
echo "Clang-tidy check failed!"
exit 1

View File

@@ -1,4 +1,4 @@
name: Clang-tidy check
name: Run clang-tidy on files
on:
workflow_call:
@@ -16,40 +16,198 @@ defaults:
run:
shell: bash
env:
BUILD_DIR: build
BUILD_TYPE: Debug # Debug so that ASSERTS and such participate in clang-tidy check
OUTPUT_FILE: clang-tidy-output.txt
DIFF_FILE: clang-tidy-git-diff.txt
ISSUE_FILE: clang-tidy-issue.md
jobs:
determine-files:
name: Determine files to check
if: ${{ inputs.check_only_changed }}
runs-on: ubuntu-latest
outputs:
clang_tidy_config_changed: ${{ steps.changed_clang_tidy.outputs.any_changed }}
any_cpp_changed: ${{ steps.changed_files.outputs.any_changed }}
all_changed_files: ${{ steps.changed_files.outputs.all_changed_files }}
permissions:
contents: read
uses: XRPLF/actions/.github/workflows/determine-tidy-files.yml@12f5dbc98a2260259a66970e57fa4d26fb7f285c
run-clang-tidy:
name: Run clang tidy
needs: [determine-files]
if: ${{ always() && !cancelled() && (!inputs.check_only_changed || needs.determine-files.outputs.cpp_changed_files != '' || needs.determine-files.outputs.clang_tidy_config_changed == 'true') }}
runs-on: ["self-hosted", "Linux", "X64", "heavy"]
container: "ghcr.io/xrplf/ci/debian-trixie:clang-21-sha-53033a2"
permissions:
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Get changed C++ files
id: changed_files
uses: tj-actions/changed-files@9426d40962ed5378910ee2e21d5f8c6fcbf2dd96 # v47.0.6
- name: Prepare runner
uses: XRPLF/actions/prepare-runner@90f11ee655d1687824fb8793db770477d52afbab
with:
files: |
**/*.cpp
**/*.h
**/*.ipp
separator: " "
enable_ccache: false
- name: Get changed clang-tidy configuration
id: changed_clang_tidy
uses: tj-actions/changed-files@9426d40962ed5378910ee2e21d5f8c6fcbf2dd96 # v47.0.6
- name: Print build environment
uses: XRPLF/actions/print-build-env@59dec886e4afb05a1724443af08baccbc045b574
- name: Get number of processors
uses: XRPLF/actions/get-nproc@cf0433aa74563aead044a1e395610c96d65a37cf
id: nproc
- name: Setup Conan
uses: ./.github/actions/setup-conan
- name: Build dependencies
uses: ./.github/actions/build-deps
with:
files: |
.clang-tidy
build_nproc: ${{ steps.nproc.outputs.nproc }}
build_type: ${{ env.BUILD_TYPE }}
log_verbosity: verbose
run-clang-tidy:
needs: [determine-files]
if: ${{ always() && !cancelled() && (!inputs.check_only_changed || needs.determine-files.outputs.any_cpp_changed == 'true' || needs.determine-files.outputs.clang_tidy_config_changed == 'true') }}
uses: ./.github/workflows/reusable-clang-tidy-files.yml
with:
files: ${{ (needs.determine-files.outputs.clang_tidy_config_changed != 'true' && inputs.check_only_changed) && needs.determine-files.outputs.all_changed_files || '' }}
create_issue_on_failure: ${{ inputs.create_issue_on_failure }}
- name: Configure CMake
working-directory: ${{ env.BUILD_DIR }}
run: |
cmake \
-G 'Ninja' \
-DCMAKE_TOOLCHAIN_FILE:FILEPATH=build/generators/conan_toolchain.cmake \
-DCMAKE_BUILD_TYPE="${BUILD_TYPE}" \
-Dtests=ON \
-Dwerr=ON \
-Dxrpld=ON \
..
# clang-tidy needs headers generated from proto files
- name: Build libxrpl.libpb
working-directory: ${{ env.BUILD_DIR }}
run: |
ninja -j ${{ steps.nproc.outputs.nproc }} xrpl.libpb
- name: Run clang tidy
id: run_clang_tidy
continue-on-error: true
env:
TARGETS: ${{ (needs.determine-files.outputs.clang_tidy_config_changed != 'true' && inputs.check_only_changed) && needs.determine-files.outputs.cpp_changed_files || 'src tests' }}
run: |
set -o pipefail
run-clang-tidy -j ${{ steps.nproc.outputs.nproc }} -p "${BUILD_DIR}" -quiet -fix -allow-no-checks ${TARGETS} 2>&1 | tee "${OUTPUT_FILE}"
- name: Upload clang-tidy output
if: ${{ github.event.repository.visibility == 'public' && steps.run_clang_tidy.outcome != 'success' }}
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
path: ${{ env.OUTPUT_FILE }}
archive: false
retention-days: 30
- name: Generate git diff
if: ${{ steps.run_clang_tidy.outcome != 'success' }}
run: |
git diff | tee "${DIFF_FILE}"
- 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:
path: ${{ env.DIFF_FILE }}
archive: false
retention-days: 30
- name: Write issue header
if: ${{ steps.run_clang_tidy.outcome != 'success' }}
run: |
# Prepare issue body with clang-tidy output
cat > "${ISSUE_FILE}" <<EOF
## Clang-tidy Check Failed
**Workflow:** ${{ github.workflow }}
**Run ID:** ${{ github.run_id }}
**Commit:** ${{ github.sha }}
**Branch/Ref:** ${{ github.ref }}
**Triggered by:** ${{ github.actor }}
### Clang-tidy Output:
\`\`\`
EOF
- name: Append clang-tidy output to issue body
if: ${{ steps.run_clang_tidy.outcome != 'success' }}
run: |
# Append clang-tidy output (filter for errors and warnings)
if [ -f "${OUTPUT_FILE}" ]; then
# Extract lines containing 'error:', 'warning:', or 'note:'
grep -E '(error:|warning:|note:)' "${OUTPUT_FILE}" > filtered-output.txt || true
# If filtered output is empty, use original (might be a different error format)
if [ ! -s filtered-output.txt ]; then
cp "${OUTPUT_FILE}" filtered-output.txt
fi
# Truncate if too large
head -c 60000 filtered-output.txt >> "${ISSUE_FILE}"
if [ "$(wc -c < filtered-output.txt)" -gt 60000 ]; then
echo "" >> "${ISSUE_FILE}"
echo "... (output truncated, see artifacts for full output)" >> "${ISSUE_FILE}"
fi
rm filtered-output.txt
else
echo "No output file found" >> "${ISSUE_FILE}"
fi
- name: Append issue footer
if: ${{ steps.run_clang_tidy.outcome != 'success' }}
run: |
cat >> "${ISSUE_FILE}" <<EOF
\`\`\`
**Workflow run:** ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
---
*This issue was automatically created by the clang-tidy workflow.*
EOF
- name: Upload issue body artifact
if: ${{ github.event.repository.visibility == 'public' && steps.run_clang_tidy.outcome != 'success' }}
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
path: ${{ env.ISSUE_FILE }}
archive: false
retention-days: 30
- name: Fail if clang-tidy found issues
if: ${{ steps.run_clang_tidy.outcome != 'success' }}
run: |
echo "Clang-tidy check failed!"
exit 1
create-issue-on-failure:
name: Create GitHub issue on failure
runs-on: ubuntu-latest
needs: [run-clang-tidy]
if: ${{ always() && !cancelled() && inputs.create_issue_on_failure && needs.run-clang-tidy.result == 'failure' && github.event.repository.visibility == 'public' }}
permissions:
issues: write
contents: read
steps:
- name: Download clang-tidy-issue.md
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: ${{ env.ISSUE_FILE }}
- name: Create GitHub issue
env:
GH_TOKEN: ${{ github.token }}
run: |
# Create the issue
gh issue create \
--label "Bug,Clang-tidy" \
--title "Clang-tidy check failed" \
--body-file ./"${ISSUE_FILE}" \
> create_issue.log
- name: Output created issue number
run: |
created_issue="$(sed 's|.*/||' create_issue.log)"
echo "created_issue=$created_issue" >> $GITHUB_OUTPUT
echo "Created issue #$created_issue"

View File

@@ -348,8 +348,8 @@ For this reason:
- Contract description for `UNREACHABLE` should describe the _unexpected_
situation which caused the line to have been reached.
- Example good name for an
`UNREACHABLE` macro `"Json::operator==(Value, Value) : invalid type"`; example
good name for an `XRPL_ASSERT` macro `"Json::Value::asCString : valid type"`.
`UNREACHABLE` macro `"json::operator==(Value, Value) : invalid type"`; example
good name for an `XRPL_ASSERT` macro `"json::Value::asCString : valid type"`.
- Example **bad** name
`"RFC1751::insert(char* s, int x, int start, int length) : length is greater than or equal zero"`
(missing namespace, unnecessary full function signature, description too verbose).

View File

@@ -152,10 +152,10 @@ def parse_sfields_macro(sfields_path):
def create_field_list_parser():
"""Create a pyparsing parser for field lists like '({...})'."""
# A field identifier (e.g., sfDestination, soeREQUIRED, soeMPTSupported)
# A field identifier (e.g., sfDestination, SoeRequired, SoeMptSupported)
field_identifier = pp.Word(pp.alphas + "_", pp.alphanums + "_")
# A single field definition: {sfName, soeREQUIRED, ...}
# A single field definition: {sfName, SoeRequired, ...}
# Allow optional trailing comma inside the braces
field_def = (
pp.Suppress("{")
@@ -185,8 +185,8 @@ def parse_field_list(fields_str):
Args:
fields_str: A string like '({
{sfDestination, soeREQUIRED},
{sfAmount, soeREQUIRED, soeMPTSupported}
{sfDestination, SoeRequired},
{sfAmount, SoeRequired, SoeMptSupported}
})'
Returns:
@@ -205,7 +205,7 @@ def parse_field_list(fields_str):
field_name = field_parts[0]
requirement = field_parts[1]
flags = list(field_parts[2:]) if len(field_parts) > 2 else []
supports_mpt = "soeMPTSupported" in flags
supports_mpt = "SoeMptSupported" in flags
fields.append(
{

View File

@@ -52,13 +52,13 @@ public:
% if field.get('mpt_support'):
* MPT Support: ${field['mpt_support']}
% endif
% if field['requirement'] == 'soeREQUIRED':
% if field['requirement'] == 'SoeRequired':
* @return The field value.
% else:
* @return The field value, or std::nullopt if not present.
% endif
*/
% if field['requirement'] == 'soeREQUIRED':
% if field['requirement'] == 'SoeRequired':
[[nodiscard]]
${field['typeData']['return_type']}
get${field['name'][2:]}() const
@@ -94,13 +94,13 @@ public:
* MPT Support: ${field['mpt_support']}
% endif
* @note This is an untyped field (${field.get('cppType', 'unknown')}).
% if field['requirement'] == 'soeREQUIRED':
% if field['requirement'] == 'SoeRequired':
* @return The field value.
% else:
* @return The field value, or std::nullopt if not present.
% endif
*/
% if field['requirement'] == 'soeREQUIRED':
% if field['requirement'] == 'SoeRequired':
[[nodiscard]]
${field['typeData']['return_type']}
get${field['name'][2:]}() const
@@ -133,13 +133,13 @@ public:
};
<%
required_fields = [f for f in fields if f['requirement'] == 'soeREQUIRED']
required_fields = [f for f in fields if f['requirement'] == 'SoeRequired']
%>\
/**
* @brief Builder for ${name} ledger entries.
*
* Provides a fluent interface for constructing ledger entries with method chaining.
* Uses Json::Value internally for flexible ledger entry construction.
* Uses STObject internally for flexible ledger entry construction.
* Inherits common field setters from LedgerEntryBuilderBase.
*/
class ${name}Builder : public LedgerEntryBuilderBase<${name}Builder>

View File

@@ -1,7 +1,7 @@
// Auto-generated unit tests for ledger entry ${name}
<%
required_fields = [f for f in fields if f["requirement"] == "soeREQUIRED"]
optional_fields = [f for f in fields if f["requirement"] != "soeREQUIRED"]
required_fields = [f for f in fields if f["requirement"] == "SoeRequired"]
optional_fields = [f for f in fields if f["requirement"] != "SoeRequired"]
def canonical_expr(field):
return f"canonical_{field['stiSuffix']}()"

View File

@@ -54,13 +54,13 @@ public:
% if field.get('supports_mpt'):
* @note This field supports MPT (Multi-Purpose Token) amounts.
% endif
% if field['requirement'] == 'soeREQUIRED':
% if field['requirement'] == 'SoeRequired':
* @return The field value.
% else:
* @return The field value, or std::nullopt if not present.
% endif
*/
% if field['requirement'] == 'soeREQUIRED':
% if field['requirement'] == 'SoeRequired':
[[nodiscard]]
${field['typeData']['return_type']}
get${field['name'][2:]}() const
@@ -97,13 +97,13 @@ public:
* @note This field supports MPT (Multi-Purpose Token) amounts.
% endif
* @note This is an untyped field.
% if field['requirement'] == 'soeREQUIRED':
% if field['requirement'] == 'SoeRequired':
* @return The field value.
% else:
* @return The field value, or std::nullopt if not present.
% endif
*/
% if field['requirement'] == 'soeREQUIRED':
% if field['requirement'] == 'SoeRequired':
[[nodiscard]]
${field['typeData']['return_type']}
get${field['name'][2:]}() const
@@ -136,13 +136,13 @@ public:
};
<%
required_fields = [f for f in fields if f['requirement'] == 'soeREQUIRED']
required_fields = [f for f in fields if f['requirement'] == 'SoeRequired']
%>\
/**
* @brief Builder for ${name} transactions.
*
* Provides a fluent interface for constructing transactions with method chaining.
* Uses Json::Value internally for flexible transaction construction.
* Uses STObject internally for flexible transaction construction.
* Inherits common field setters from TransactionBuilderBase.
*/
class ${name}Builder : public TransactionBuilderBase<${name}Builder>

View File

@@ -1,7 +1,7 @@
// Auto-generated unit tests for transaction ${name}
<%
required_fields = [f for f in fields if f["requirement"] == "soeREQUIRED"]
optional_fields = [f for f in fields if f["requirement"] != "soeREQUIRED"]
required_fields = [f for f in fields if f["requirement"] == "SoeRequired"]
optional_fields = [f for f in fields if f["requirement"] != "SoeRequired"]
def canonical_expr(field):
return f"canonical_{field['stiSuffix']}()"
@@ -33,7 +33,7 @@ TEST(Transactions${name}Tests, BuilderSettersRoundTrip)
{
// Generate a deterministic keypair for signing
auto const [publicKey, secretKey] =
generateKeyPair(KeyType::secp256k1, generateSeed("test${name}"));
generateKeyPair(KeyType::Secp256k1, generateSeed("test${name}"));
// Common transaction fields
auto const accountValue = calcAccountID(publicKey);
@@ -101,7 +101,7 @@ TEST(Transactions${name}Tests, BuilderFromStTxRoundTrip)
{
// Generate a deterministic keypair for signing
auto const [publicKey, secretKey] =
generateKeyPair(KeyType::secp256k1, generateSeed("test${name}FromTx"));
generateKeyPair(KeyType::Secp256k1, generateSeed("test${name}FromTx"));
// Common transaction fields
auto const accountValue = calcAccountID(publicKey);
@@ -168,7 +168,7 @@ TEST(Transactions${name}Tests, WrapperThrowsOnWrongTxType)
{
// Build a valid transaction of a different type
auto const [pk, sk] =
generateKeyPair(KeyType::secp256k1, generateSeed("testWrongType"));
generateKeyPair(KeyType::Secp256k1, generateSeed("testWrongType"));
auto const account = calcAccountID(pk);
% if wrong_tx_include == "AccountSet":
@@ -186,7 +186,7 @@ TEST(Transactions${name}Tests, BuilderThrowsOnWrongTxType)
{
// Build a valid transaction of a different type
auto const [pk, sk] =
generateKeyPair(KeyType::secp256k1, generateSeed("testWrongTypeBuilder"));
generateKeyPair(KeyType::Secp256k1, generateSeed("testWrongTypeBuilder"));
auto const account = calcAccountID(pk);
% if wrong_tx_include == "AccountSet":
@@ -205,7 +205,7 @@ TEST(Transactions${name}Tests, OptionalFieldsReturnNullopt)
{
// Generate a deterministic keypair for signing
auto const [publicKey, secretKey] =
generateKeyPair(KeyType::secp256k1, generateSeed("test${name}Nullopt"));
generateKeyPair(KeyType::Secp256k1, generateSeed("test${name}Nullopt"));
// Common transaction fields
auto const accountValue = calcAccountID(publicKey);

View File

@@ -151,6 +151,7 @@ words:
- lseq
- lsmf
- ltype
- mathbunnyru
- mcmodel
- MEMORYSTATUSEX
- MPTAMM

View File

@@ -98,7 +98,7 @@ export LSAN_OPTIONS="include=sanitizers/suppressions/runtime-lsan-options.txt:su
**Why `detect_container_overflow=0`?**
- Boost intrusive containers (used in `aged_unordered_container`) trigger false positives
- Boost intrusive containers (used in `AgedUnorderedContainer`) trigger false positives
- Boost context switching (used in `Workers.cpp`) confuses ASAN's stack tracking
- Since we usually don't build Boost (because we don't want to instrument Boost and detect issues in Boost code) with ASAN but use Boost containers in ASAN instrumented xrpld code, it generates false positives.
- Building dependencies with ASAN instrumentation reduces false positives. But we don't want to instrument dependencies like Boost with ASAN because it is slow (to compile as well as run tests) and not necessary.

View File

@@ -477,7 +477,7 @@ struct Ledger
// The parent ledger's close time
NetClock::time_point parentCloseTime() const;
Json::Value getJson() const;
json::Value getJson() const;
//... implementation specific
};

View File

@@ -27,7 +27,7 @@ private:
std::unordered_map<std::string, std::string> lookup_;
std::vector<std::string> lines_;
std::vector<std::string> values_;
bool had_trailing_comments_ = false;
bool hadTrailingComments_ = false;
using const_iterator = decltype(lookup_)::const_iterator;
@@ -144,7 +144,7 @@ public:
[[nodiscard]] bool
hadTrailingComments() const
{
return had_trailing_comments_;
return hadTrailingComments_;
}
friend std::ostream&
@@ -275,7 +275,7 @@ public:
[[nodiscard]] bool
hadTrailingComments() const
{
return std::ranges::any_of(map_, [](auto s) { return s.second.had_trailing_comments(); });
return std::ranges::any_of(map_, [](auto s) { return s.second.hadTrailingComments(); });
}
protected:
@@ -333,7 +333,7 @@ get(Section const& section, std::string const& name, T const& defaultValue = T{}
{
try
{
return section.value_or<T>(name, defaultValue);
return section.valueOr<T>(name, defaultValue);
}
catch (boost::bad_lexical_cast const&) // NOLINT(bugprone-empty-catch)
{
@@ -358,17 +358,17 @@ get(Section const& section, std::string const& name, char const* defaultValue)
template <class T>
bool
get_if_exists(Section const& section, std::string const& name, T& v)
getIfExists(Section const& section, std::string const& name, T& v)
{
return set<T>(v, name, section);
}
template <>
inline bool
get_if_exists<bool>(Section const& section, std::string const& name, bool& v)
getIfExists<bool>(Section const& section, std::string const& name, bool& v)
{
int intVal = 0;
auto stat = get_if_exists(section, name, intVal);
auto stat = getIfExists(section, name, intVal);
if (stat)
v = bool(intVal);
return stat;

View File

@@ -38,11 +38,11 @@ public:
do
{
head = instance.m_head_.load();
head = instance.head_.load();
next_ = head;
} while (instance.m_head_.exchange(this) != head);
} while (instance.head_.exchange(this) != head);
++instance.m_count_;
++instance.count_;
}
~Counter() noexcept = default;
@@ -88,8 +88,8 @@ private:
~CountedObjects() noexcept = default;
private:
std::atomic<int> m_count_;
std::atomic<Counter*> m_head_;
std::atomic<int> count_;
std::atomic<Counter*> head_;
};
//------------------------------------------------------------------------------
@@ -108,7 +108,7 @@ private:
static auto&
getCounter() noexcept
{
static CountedObjects::Counter kC{beast::type_name<Object>()};
static CountedObjects::Counter kC{beast::typeName<Object>()};
return kC;
}

View File

@@ -20,7 +20,7 @@ public:
/**
@param now Start time of DecayingSample.
*/
explicit DecayingSample(time_point now) : m_value(value_type()), m_when(now)
explicit DecayingSample(time_point now) : value_(value_type()), when_(now)
{
}
@@ -31,8 +31,8 @@ public:
add(value_type value, time_point now)
{
decay(now);
m_value += value;
return m_value / Window;
value_ += value;
return value_ / Window;
}
/** Retrieve the current value in normalized units.
@@ -42,7 +42,7 @@ public:
value(time_point now)
{
decay(now);
return m_value / Window;
return value_ / Window;
}
private:
@@ -50,38 +50,38 @@ private:
void
decay(time_point now)
{
if (now == m_when)
if (now == when_)
return;
if (m_value != value_type())
if (value_ != value_type())
{
std::size_t elapsed =
std::chrono::duration_cast<std::chrono::seconds>(now - m_when).count();
std::chrono::duration_cast<std::chrono::seconds>(now - when_).count();
// A span larger than four times the window decays the
// value to an insignificant amount so just reset it.
//
if (elapsed > 4 * Window)
{
m_value = value_type();
value_ = value_type();
}
else
{
for (; elapsed > 0; --elapsed)
{
m_value -= (m_value + Window - 1) / Window;
value_ -= (value_ + Window - 1) / Window;
}
}
}
m_when = now;
when_ = now;
}
// Current value in exponential units
value_type m_value;
value_type value_;
// Last time the aging function was applied
time_point m_when;
time_point when_;
};
//------------------------------------------------------------------------------

View File

@@ -30,7 +30,8 @@ struct ThrowPolicy : public boost::outcome_v2::policy::base
{
template <class Impl>
static constexpr void
wideValueCheck(Impl&& self)
// NOLINTNEXTLINE(readability-identifier-naming)
wide_value_check(Impl&& self)
{
if (!base::_has_value(std::forward<Impl>(self)))
Throw<BadExpectedAccess>();
@@ -38,7 +39,8 @@ struct ThrowPolicy : public boost::outcome_v2::policy::base
template <class Impl>
static constexpr void
wideErrorCheck(Impl&& self)
// NOLINTNEXTLINE(readability-identifier-naming)
wide_error_check(Impl&& self)
{
if (!base::_has_error(std::forward<Impl>(self)))
Throw<BadExpectedAccess>();
@@ -46,7 +48,8 @@ struct ThrowPolicy : public boost::outcome_v2::policy::base
template <class Impl>
static constexpr void
wideExceptionCheck(Impl&& self)
// NOLINTNEXTLINE(readability-identifier-naming)
wide_exception_check(Impl&& self)
{
if (!base::_has_exception(std::forward<Impl>(self)))
Throw<BadExpectedAccess>();
@@ -126,7 +129,8 @@ public:
}
[[nodiscard]] constexpr bool
hasValue() const
// NOLINTNEXTLINE(readability-identifier-naming)
has_value() const
{
return Base::has_value();
}
@@ -158,7 +162,7 @@ public:
constexpr explicit
operator bool() const
{
return hasValue();
return has_value();
}
// Add operator* and operator-> so the Expected API looks a bit more like

View File

@@ -168,7 +168,7 @@ public:
template <class TT, class... Args>
friend SharedIntrusive<TT>
make_SharedIntrusive(Args&&... args);
makeSharedIntrusive(Args&&... args);
template <class TT>
friend class SharedIntrusive;
@@ -442,7 +442,7 @@ private:
*/
template <class TT, class... Args>
SharedIntrusive<TT>
make_SharedIntrusive(Args&&... args)
makeSharedIntrusive(Args&&... args)
{
auto p = new TT(std::forward<Args>(args)...);
@@ -469,21 +469,21 @@ using SharedWeakUnionPtr = SharedWeakUnion<T>;
template <class T, class... A>
SharedPtr<T>
make_shared(A&&... args)
makeShared(A&&... args)
{
return make_SharedIntrusive<T>(std::forward<A>(args)...);
return makeSharedIntrusive<T>(std::forward<A>(args)...);
}
template <class T, class TT>
SharedPtr<T>
static_pointer_cast(TT const& v)
staticPointerCast(TT const& v)
{
return SharedPtr<T>(StaticCastTagSharedIntrusive{}, v);
}
template <class T, class TT>
SharedPtr<T>
dynamic_pointer_cast(TT const& v)
dynamicPointerCast(TT const& v)
{
return SharedPtr<T>(DynamicCastTagSharedIntrusive{}, v);
}

View File

@@ -43,14 +43,16 @@ SharedIntrusive<T>::SharedIntrusive(SharedIntrusive<TT> const& rhs)
}
template <class T>
SharedIntrusive<T>::SharedIntrusive(SharedIntrusive&& rhs) : ptr_{rhs.unsafeExchange(nullptr)}
SharedIntrusive<T>::SharedIntrusive(SharedIntrusive&& rhs)
: ptr_{std::move(rhs).unsafeExchange(nullptr)}
{
}
template <class T>
template <class TT>
requires std::convertible_to<TT*, T*>
SharedIntrusive<T>::SharedIntrusive(SharedIntrusive<TT>&& rhs) : ptr_{rhs.unsafeExchange(nullptr)}
SharedIntrusive<T>::SharedIntrusive(SharedIntrusive<TT>&& rhs)
: ptr_{std::move(rhs).unsafeExchange(nullptr)}
{
}
template <class T>
@@ -93,7 +95,7 @@ SharedIntrusive<T>::operator=(SharedIntrusive&& rhs)
if (this == &rhs)
return *this;
unsafeReleaseAndStore(rhs.unsafeExchange(nullptr));
unsafeReleaseAndStore(std::move(rhs).unsafeExchange(nullptr));
return *this;
}
@@ -105,7 +107,7 @@ SharedIntrusive<T>::operator=(SharedIntrusive<TT>&& rhs)
{
static_assert(!std::is_same_v<T, TT>, "This overload should not be instantiated for T == TT");
unsafeReleaseAndStore(rhs.unsafeExchange(nullptr));
unsafeReleaseAndStore(std::move(rhs).unsafeExchange(nullptr));
return *this;
}
@@ -157,7 +159,7 @@ SharedIntrusive<T>::SharedIntrusive(StaticCastTagSharedIntrusive, SharedIntrusiv
template <class T>
template <class TT>
SharedIntrusive<T>::SharedIntrusive(StaticCastTagSharedIntrusive, SharedIntrusive<TT>&& rhs)
: ptr_{static_cast<T*>(rhs.unsafeExchange(nullptr))}
: ptr_{static_cast<T*>(std::move(rhs).unsafeExchange(nullptr))}
{
}
@@ -184,8 +186,10 @@ SharedIntrusive<T>::SharedIntrusive(DynamicCastTagSharedIntrusive, SharedIntrusi
{
ptr_ = dynamic_cast<T*>(toSet);
if (!ptr_)
{
// need to set the pointer back or will leak
rhs.unsafeExchange(toSet);
std::move(rhs).unsafeExchange(toSet);
}
}
}
@@ -229,7 +233,7 @@ std::size_t
SharedIntrusive<T>::useCount() const
{
if (auto p = unsafeGetRawPtr())
return p->use_count();
return p->useCount();
return 0;
}
@@ -266,7 +270,7 @@ SharedIntrusive<T>::unsafeReleaseAndStore(T* next)
auto action = prev->releaseStrongRef();
switch (action)
{
case Noop:
case NoOp:
break;
case Destroy:
delete prev;
@@ -345,7 +349,7 @@ template <class T>
bool
WeakIntrusive<T>::expired() const
{
return (!ptr_ || ptr_->expired());
return ((ptr_ == nullptr) || ptr_->expired());
}
template <class T>
@@ -360,14 +364,14 @@ template <class T>
void
WeakIntrusive<T>::unsafeReleaseNoStore()
{
if (!ptr_)
if (ptr_ == nullptr)
return;
using enum ReleaseWeakRefAction;
auto action = ptr_->releaseWeakRef();
switch (action)
{
case Noop:
case NoOp:
break;
case Destroy:
delete ptr_;
@@ -385,9 +389,13 @@ SharedWeakUnion<T>::SharedWeakUnion(SharedWeakUnion const& rhs) : tp_{rhs.tp_}
return;
if (rhs.isStrong())
{
p->addStrongRef();
}
else
{
p->addWeakRef();
}
}
template <class T>
@@ -398,7 +406,7 @@ SharedWeakUnion<T>::SharedWeakUnion(SharedIntrusive<TT> const& rhs)
auto p = rhs.unsafeGetRawPtr();
if (p)
p->addStrongRef();
unsafeSetRawPtr(p, RefStrength::strong);
unsafeSetRawPtr(p, RefStrength::Strong);
}
template <class T>
@@ -414,8 +422,8 @@ SharedWeakUnion<T>::SharedWeakUnion(SharedIntrusive<TT>&& rhs)
{
auto p = rhs.unsafeGetRawPtr();
if (p)
unsafeSetRawPtr(p, RefStrength::strong);
rhs.unsafeSetRawPtr(nullptr);
unsafeSetRawPtr(p, RefStrength::Strong);
std::move(rhs).unsafeSetRawPtr(nullptr);
}
template <class T>
@@ -431,12 +439,12 @@ SharedWeakUnion<T>::operator=(SharedWeakUnion const& rhs)
if (rhs.isStrong())
{
p->addStrongRef();
unsafeSetRawPtr(p, RefStrength::strong);
unsafeSetRawPtr(p, RefStrength::Strong);
}
else
{
p->addWeakRef();
unsafeSetRawPtr(p, RefStrength::weak);
unsafeSetRawPtr(p, RefStrength::Weak);
}
}
else
@@ -456,7 +464,7 @@ SharedWeakUnion<T>::operator=(SharedIntrusive<TT> const& rhs)
auto p = rhs.unsafeGetRawPtr();
if (p)
p->addStrongRef();
unsafeSetRawPtr(p, RefStrength::strong);
unsafeSetRawPtr(p, RefStrength::Strong);
return *this;
}
@@ -467,8 +475,8 @@ SharedWeakUnion<T>&
SharedWeakUnion<T>::operator=(SharedIntrusive<TT>&& rhs)
{
unsafeReleaseNoStore();
unsafeSetRawPtr(rhs.unsafeGetRawPtr(), RefStrength::strong);
rhs.unsafeSetRawPtr(nullptr);
unsafeSetRawPtr(rhs.unsafeGetRawPtr(), RefStrength::Strong);
std::move(rhs).unsafeSetRawPtr(nullptr);
return *this;
}
@@ -520,7 +528,7 @@ std::size_t
SharedWeakUnion<T>::useCount() const
{
if (auto p = get())
return p->use_count();
return p->useCount();
return 0;
}
@@ -559,14 +567,14 @@ template <class T>
bool
SharedWeakUnion<T>::isStrong() const
{
return !(tp_ & kTAG_MASK);
return (tp_ & kTAG_MASK) == 0u;
}
template <class T>
bool
SharedWeakUnion<T>::isWeak() const
{
return tp_ & kTAG_MASK;
return (tp_ & kTAG_MASK) != 0u;
}
template <class T>
@@ -581,10 +589,10 @@ SharedWeakUnion<T>::convertToStrong()
{
[[maybe_unused]] auto action = p->releaseWeakRef();
XRPL_ASSERT(
(action == ReleaseWeakRefAction::Noop),
(action == ReleaseWeakRefAction::NoOp),
"xrpl::SharedWeakUnion::convertToStrong : "
"action is noop");
unsafeSetRawPtr(p, RefStrength::strong);
unsafeSetRawPtr(p, RefStrength::Strong);
return true;
}
return false;
@@ -605,7 +613,7 @@ SharedWeakUnion<T>::convertToWeak()
auto action = p->addWeakReleaseStrongRef();
switch (action)
{
case Noop:
case NoOp:
break;
case Destroy:
// We just added a weak ref. How could we destroy?
@@ -625,7 +633,7 @@ SharedWeakUnion<T>::convertToWeak()
// p is null and may no longer be used
break;
}
unsafeSetRawPtr(p, RefStrength::weak);
unsafeSetRawPtr(p, RefStrength::Weak);
return true;
}
@@ -641,7 +649,7 @@ void
SharedWeakUnion<T>::unsafeSetRawPtr(T* p, RefStrength rs)
{
tp_ = reinterpret_cast<std::uintptr_t>(p);
if (tp_ && rs == RefStrength::weak)
if (tp_ && rs == RefStrength::Weak)
tp_ |= kTAG_MASK;
}
@@ -666,7 +674,7 @@ SharedWeakUnion<T>::unsafeReleaseNoStore()
auto strongAction = p->releaseStrongRef();
switch (strongAction)
{
case Noop:
case NoOp:
break;
case Destroy:
delete p;
@@ -684,7 +692,7 @@ SharedWeakUnion<T>::unsafeReleaseNoStore()
auto weakAction = p->releaseWeakRef();
switch (weakAction)
{
case Noop:
case NoOp:
break;
case Destroy:
delete p;

View File

@@ -18,7 +18,7 @@ namespace xrpl {
destroy: Run the destructor. This action will occur when either the strong
count or weak count is decremented and the other count is also zero.
*/
enum class ReleaseStrongRefAction { Noop, PartialDestroy, Destroy };
enum class ReleaseStrongRefAction { NoOp, PartialDestroy, Destroy };
/** Action to perform when releasing a weak pointer.
@@ -28,7 +28,7 @@ enum class ReleaseStrongRefAction { Noop, PartialDestroy, Destroy };
destroy: Run the destructor. This action will occur when either the strong
count or weak count is decremented and the other count is also zero.
*/
enum class ReleaseWeakRefAction { Noop, Destroy };
enum class ReleaseWeakRefAction { NoOp, Destroy };
/** Implement the strong count, weak count, and bit flags for an intrusive
pointer.
@@ -256,7 +256,7 @@ IntrusiveRefCounts::releaseStrongRef() const
"xrpl::IntrusiveRefCounts::releaseStrongRef : previous ref "
"higher than new");
auto nextIntVal = prevIntVal - kSTRONG_DELTA;
ReleaseStrongRefAction action = Noop;
ReleaseStrongRefAction action = NoOp;
if (prevVal.strong == 1)
{
if (prevVal.weak == 0)
@@ -276,7 +276,7 @@ IntrusiveRefCounts::releaseStrongRef() const
// count to zero can start a partial destroy, and that can't happen
// twice.
XRPL_ASSERT(
(action == Noop) || !(prevIntVal & kPARTIAL_DESTROY_STARTED_MASK),
(action == NoOp) || !(prevIntVal & kPARTIAL_DESTROY_STARTED_MASK),
"xrpl::IntrusiveRefCounts::releaseStrongRef : not in partial "
"destroy");
return action;
@@ -313,12 +313,12 @@ IntrusiveRefCounts::addWeakReleaseStrongRef() const
"partial destroy");
auto nextIntVal = prevIntVal + kDELTA;
ReleaseStrongRefAction action = Noop;
ReleaseStrongRefAction action = NoOp;
if (prevVal.strong == 1)
{
if (prevVal.weak == 0)
{
action = Noop;
action = NoOp;
}
else
{
@@ -361,7 +361,7 @@ IntrusiveRefCounts::releaseWeakRef() const
}
return ReleaseWeakRefAction::Destroy;
}
return ReleaseWeakRefAction::Noop;
return ReleaseWeakRefAction::NoOp;
}
inline bool

View File

@@ -17,15 +17,15 @@ namespace xrpl {
// DEPRECATED use beast::severities::Severity instead
// NOLINTNEXTLINE(cppcoreguidelines-use-enum-class)
enum LogSeverity {
LsInvalid = -1, // used to indicate an invalid severity
LsTrace = 0, // Very low-level progress information, details inside
LSInvalid = -1, // used to indicate an invalid severity
LSTrace = 0, // Very low-level progress information, details inside
// an operation
LsDebug = 1, // Function-level progress information, operations
LsInfo = 2, // Server-level progress information, major operations
LsWarning = 3, // Conditions that warrant human attention, may indicate
LSDebug = 1, // Function-level progress information, operations
LSInfo = 2, // Server-level progress information, major operations
LSWarning = 3, // Conditions that warrant human attention, may indicate
// a problem
LsError = 4, // A condition that indicates a problem
LsFatal = 5 // A severe condition that indicates a server problem
LSError = 4, // A condition that indicates a problem
LSFatal = 5 // A severe condition that indicates a server problem
};
/** Manages partitions for logging. */
@@ -130,8 +130,8 @@ private:
/** @} */
private:
std::unique_ptr<std::ofstream> m_stream_;
boost::filesystem::path m_path_;
std::unique_ptr<std::ofstream> stream_;
boost::filesystem::path path_;
};
std::mutex mutable mutex_;

View File

@@ -385,11 +385,12 @@ public:
// Thread local rounding control. Default is to_nearest
enum class RoundingMode { ToNearest, TowardsZero, Downward, Upward };
static RoundingMode
getround();
// Returns previously set mode
static RoundingMode
setround(RoundingMode mode);
setround(RoundingMode inMode);
/** Returns which mantissa scale is currently in use for normalization.
*
@@ -397,6 +398,7 @@ public:
*/
static MantissaRange::MantissaScale
getMantissaScale();
/** Changes which mantissa scale is used for normalization.
*
* If you think you need to call this outside of unit tests, no you don't.
@@ -407,19 +409,19 @@ public:
static internalrep
minMantissa()
{
return range.get().min;
return kRANGE.get().min;
}
static internalrep
maxMantissa()
{
return range.get().max;
return kRANGE.get().max;
}
static int
mantissaLog()
{
return range.get().log;
return kRANGE.get().log;
}
/// oneSmall is needed because the ranges are private
@@ -461,7 +463,7 @@ private:
// The range for the mantissa when normalized.
// Use reference_wrapper to avoid making copies, and prevent accidentally
// changing the values inside the range.
static thread_local std::reference_wrapper<MantissaRange const> range;
static thread_local std::reference_wrapper<MantissaRange const> kRANGE;
void
normalize();
@@ -469,7 +471,7 @@ private:
/** Normalize Number components to an arbitrary range.
*
* min/maxMantissa are parameters because this function is used by both
* normalize(), which reads from range_, and by normalizeToRange,
* normalize(), which reads from kRANGE, and by normalizeToRange,
* which is public and can accept an arbitrary range from the caller.
*/
template <class T>
@@ -669,25 +671,25 @@ operator/(Number const& x, Number const& y)
inline Number
Number::min() noexcept
{
return Number{false, range.get().min, kMIN_EXPONENT, Unchecked{}};
return Number{false, kRANGE.get().min, kMIN_EXPONENT, Unchecked{}};
}
inline Number
Number::max() noexcept
{
return Number{false, std::min(range.get().max, kMAX_REP), kMAX_EXPONENT, Unchecked{}};
return Number{false, std::min(kRANGE.get().max, kMAX_REP), kMAX_EXPONENT, Unchecked{}};
}
inline Number
Number::lowest() noexcept
{
return Number{true, std::min(range.get().max, kMAX_REP), kMAX_EXPONENT, Unchecked{}};
return Number{true, std::min(kRANGE.get().max, kMAX_REP), kMAX_EXPONENT, Unchecked{}};
}
inline bool
Number::isnormal() const noexcept
{
MantissaRange const& range = range;
MantissaRange const& range = kRANGE;
auto const absM = mantissa_;
return *this == Number{} ||
(range.min <= absM && absM <= range.max && (absM <= kMAX_REP || absM % 10 == 0) &&

View File

@@ -101,7 +101,7 @@ to_string(RangeSet<T> const& rs)
*/
template <class T>
[[nodiscard]] bool
from_string(RangeSet<T>& rs, std::string const& s)
fromString(RangeSet<T>& rs, std::string const& s)
{
std::vector<std::string> intervals;
std::vector<std::string> tokens;

View File

@@ -16,7 +16,7 @@ public:
/** Issue an asynchronous stop request. */
virtual void
stop_async() = 0;
stopAsync() = 0;
/** Issue a synchronous stop request. */
virtual void

View File

@@ -13,7 +13,7 @@ public:
explicit ResolverAsio() = default;
static std::unique_ptr<ResolverAsio>
New(boost::asio::io_context&, beast::Journal);
make(boost::asio::io_context&, beast::Journal);
};
} // namespace xrpl

View File

@@ -81,9 +81,9 @@ class SlabAllocator
/** Determines whether the given pointer belongs to this allocator */
bool
own(std::uint8_t const* p) const noexcept
own(std::uint8_t const* pIn) const noexcept
{
return (p >= p) && (p < p + size);
return (pIn >= p) && (pIn < p + size);
}
std::uint8_t*
@@ -92,8 +92,7 @@ class SlabAllocator
std::uint8_t* ret = nullptr; // NOLINT(misc-const-correctness)
{
std::scoped_lock const l(m);
std::scoped_lock const lock(m);
ret = l;
if (ret != nullptr)
@@ -121,7 +120,7 @@ class SlabAllocator
{
XRPL_ASSERT(own(ptr), "xrpl::SlabAllocator::SlabBlock::deallocate : own input");
std::scoped_lock const l(m);
std::scoped_lock const lock(m);
// Use memcpy to avoid unaligned UB
// (will optimize to equivalent code)
@@ -323,7 +322,7 @@ public:
}) != cfg.end())
{
throw std::runtime_error(
"SlabAllocatorSet<" + beast::type_name<Type>() + ">: duplicate slab size");
"SlabAllocatorSet<" + beast::typeName<Type>() + ">: duplicate slab size");
}
for (auto const& c : cfg)

View File

@@ -117,10 +117,10 @@ bool
parseUrl(ParsedUrl& pUrl, std::string const& strUrl);
std::string
trim_whitespace(std::string str);
trimWhitespace(std::string str);
std::optional<std::uint64_t>
to_uint64(std::string const& s);
toUint64(std::string const& s);
/** Determines if the given string looks like a TOML-file hosting domain.

View File

@@ -55,7 +55,7 @@ public:
clock_type::duration expiration,
clock_type& clock,
beast::Journal journal,
beast::insight::Collector::ptr const& collector = beast::insight::NullCollector::New());
beast::insight::Collector::ptr const& collector = beast::insight::NullCollector::make());
public:
/** Return the clock associated with the cache. */
@@ -276,26 +276,26 @@ private:
std::atomic<int>& allRemovals,
std::scoped_lock<std::recursive_mutex> const&);
beast::Journal m_journal_;
clock_type& m_clock_;
Stats m_stats_;
beast::Journal journal_;
clock_type& clock_;
Stats stats_;
mutex_type mutable m_mutex_;
mutex_type mutable mutex_;
// Used for logging
std::string m_name_;
std::string name_;
// Desired number of cache entries (0 = ignore)
int const m_target_size_;
int const target_size_;
// Desired maximum cache age
clock_type::duration const m_target_age_;
clock_type::duration const target_age_;
// Number of items cached
int m_cache_count_{0};
cache_type m_cache_; // Hold strong reference to recent objects
std::uint64_t m_hits_{0};
std::uint64_t m_misses_{0};
int cache_count_{0};
cache_type cache_; // Hold strong reference to recent objects
std::uint64_t hits_{0};
std::uint64_t misses_{0};
};
} // namespace xrpl

View File

@@ -30,13 +30,12 @@ inline TaggedCache<
clock_type& clock,
beast::Journal journal,
beast::insight::Collector::ptr const& collector)
: m_journal_(journal)
, m_clock_(clock)
, m_stats_(name, std::bind(&TaggedCache::collectMetrics, this), collector)
, m_name_(name)
, m_target_size_(size)
, m_target_age_(expiration)
: journal_(journal)
, clock_(clock)
, stats_(name, std::bind(&TaggedCache::collectMetrics, this), collector)
, name_(name)
, target_size_(size)
, target_age_(expiration)
{
}
@@ -53,7 +52,7 @@ inline auto
TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::
clock() -> clock_type&
{
return m_clock_;
return clock_;
}
template <
@@ -69,8 +68,8 @@ inline std::size_t
TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::
size() const
{
std::scoped_lock lock(m_mutex_);
return m_cache_.size();
std::scoped_lock const lock(mutex_);
return cache_.size();
}
template <
@@ -86,8 +85,8 @@ inline int
TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::
getCacheSize() const
{
std::scoped_lock lock(m_mutex_);
return m_cache_count_;
std::scoped_lock const lock(mutex_);
return cache_count_;
}
template <
@@ -103,8 +102,8 @@ inline int
TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::
getTrackSize() const
{
std::scoped_lock lock(m_mutex_);
return m_cache_.size();
std::scoped_lock const lock(mutex_);
return cache_.size();
}
template <
@@ -120,9 +119,9 @@ inline float
TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::
getHitRate()
{
std::scoped_lock lock(m_mutex_);
auto const total = static_cast<float>(m_hits_ + m_misses_);
return m_hits_ * (100.0f / std::max(1.0f, total));
std::scoped_lock const lock(mutex_);
auto const total = static_cast<float>(hits_ + misses_);
return hits_ * (100.0f / std::max(1.0f, total));
}
template <
@@ -138,9 +137,9 @@ inline void
TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::
clear()
{
std::scoped_lock lock(m_mutex_);
m_cache_.clear();
m_cache_count_ = 0;
std::scoped_lock const lock(mutex_);
cache_.clear();
cache_count_ = 0;
}
template <
@@ -156,11 +155,11 @@ inline void
TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::
reset()
{
std::scoped_lock lock(m_mutex_);
m_cache_.clear();
m_cache_count_ = 0;
m_hits_ = 0;
m_misses_ = 0;
std::scoped_lock const lock(mutex_);
cache_.clear();
cache_count_ = 0;
hits_ = 0;
misses_ = 0;
}
template <
@@ -177,15 +176,15 @@ inline bool
TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::
touchIfExists(KeyComparable const& key)
{
std::scoped_lock lock(m_mutex_);
auto const iter(m_cache_.find(key));
if (iter == m_cache_.end())
std::scoped_lock const lock(mutex_);
auto const iter(cache_.find(key));
if (iter == cache_.end())
{
++m_stats_.misses;
++stats_.misses;
return false;
}
iter->second.touch(m_clock_.now());
++m_stats_.hits;
iter->second.touch(clock_.now());
++stats_.hits;
return true;
}
@@ -205,53 +204,53 @@ TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash,
// Keep references to all the stuff we sweep
// For performance, each worker thread should exit before the swept data
// is destroyed but still within the main cache lock.
std::vector<SweptPointersVector> allStuffToSweep(m_cache_.partitions());
std::vector<SweptPointersVector> allStuffToSweep(cache_.partitions());
clock_type::time_point const now(m_clock_.now());
clock_type::time_point const now(clock_.now());
clock_type::time_point whenExpire;
auto const start = std::chrono::steady_clock::now();
{
std::scoped_lock lock(m_mutex_);
std::scoped_lock const lock(mutex_);
if (m_target_size_ == 0 || (static_cast<int>(m_cache_.size()) <= m_target_size_))
if (target_size_ == 0 || (static_cast<int>(cache_.size()) <= target_size_))
{
whenExpire = now - m_target_age_;
whenExpire = now - target_age_;
}
else
{
whenExpire = now - m_target_age_ * m_target_size_ / m_cache_.size();
whenExpire = now - (target_age_ * target_size_ / cache_.size());
clock_type::duration const minimumAge(std::chrono::seconds(1));
if (whenExpire > (now - minimumAge))
whenExpire = now - minimumAge;
JLOG(m_journal_.trace())
<< m_name_ << " is growing fast " << m_cache_.size() << " of " << m_target_size_
<< " aging at " << (now - whenExpire).count() << " of " << m_target_age_.count();
JLOG(journal_.trace())
<< name_ << " is growing fast " << cache_.size() << " of " << target_size_
<< " aging at " << (now - whenExpire).count() << " of " << target_age_.count();
}
std::vector<std::thread> workers;
workers.reserve(m_cache_.partitions());
workers.reserve(cache_.partitions());
std::atomic<int> allRemovals = 0;
for (std::size_t p = 0; p < m_cache_.partitions(); ++p)
for (std::size_t p = 0; p < cache_.partitions(); ++p)
{
workers.push_back(sweepHelper(
whenExpire, now, m_cache_.map()[p], allStuffToSweep[p], allRemovals, lock));
whenExpire, now, cache_.map()[p], allStuffToSweep[p], allRemovals, lock));
}
for (std::thread& worker : workers)
worker.join();
m_cache_count_ -= allRemovals;
cache_count_ -= allRemovals;
}
// At this point allStuffToSweep will go out of scope outside the lock
// and decrement the reference count on each strong pointer.
JLOG(m_journal_.debug()) << m_name_ << " TaggedCache sweep lock duration "
<< std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::steady_clock::now() - start)
.count()
<< "ms";
JLOG(journal_.debug()) << name_ << " TaggedCache sweep lock duration "
<< std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::steady_clock::now() - start)
.count()
<< "ms";
}
template <
@@ -267,13 +266,12 @@ inline bool
TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::
del(key_type const& key, bool valid)
{
// Remove from cache, if !valid, remove from map too. Returns true if
// removed from cache
std::scoped_lock lock(m_mutex_);
// Remove from cache, if !valid, remove from map too. Returns true if removed from cache
std::scoped_lock const lock(mutex_);
auto cit = m_cache_.find(key);
auto cit = cache_.find(key);
if (cit == m_cache_.end())
if (cit == cache_.end())
return false;
Entry& entry = cit->second;
@@ -282,13 +280,13 @@ TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash,
if (entry.isCached())
{
--m_cache_count_;
--cache_count_;
entry.ptr.convertToWeak();
ret = true;
}
if (!valid || entry.isExpired())
m_cache_.erase(cit);
cache_.erase(cit);
return ret;
}
@@ -309,22 +307,22 @@ TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash,
{
// Return canonical value, store if needed, refresh in cache
// Return values: true=we had the data already
std::scoped_lock lock(m_mutex_);
std::scoped_lock const lock(mutex_);
auto cit = m_cache_.find(key);
auto cit = cache_.find(key);
if (cit == m_cache_.end())
if (cit == cache_.end())
{
m_cache_.emplace(
cache_.emplace(
std::piecewise_construct,
std::forward_as_tuple(key),
std::forward_as_tuple(m_clock_.now(), data));
++m_cache_count_;
std::forward_as_tuple(clock_.now(), data));
++cache_count_;
return false;
}
Entry& entry = cit->second;
entry.touch(m_clock_.now());
entry.touch(clock_.now());
auto shouldReplace = [&] {
if constexpr (std::is_invocable_r_v<bool, R>)
@@ -368,12 +366,12 @@ TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash,
data = cachedData;
}
++m_cache_count_;
++cache_count_;
return true;
}
entry.ptr = data;
++m_cache_count_;
++cache_count_;
return false;
}
@@ -423,10 +421,10 @@ inline SharedPointerType
TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::
fetch(key_type const& key)
{
std::scoped_lock<mutex_type> l(m_mutex_);
std::scoped_lock<mutex_type> const l(mutex_);
auto ret = initialFetch(key, l);
if (!ret)
++m_misses_;
++misses_;
return ret;
}
@@ -455,7 +453,7 @@ TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash,
}
if constexpr (std::is_same_v<intr_ptr::SharedPtr<T>, SharedPointerType>)
{
auto p = intr_ptr::make_shared<T>(std::cref(value));
auto p = intr_ptr::makeShared<T>(std::cref(value));
return canonicalizeReplaceClient(key, p);
}
}
@@ -474,9 +472,9 @@ inline auto
TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::
insert(key_type const& key) -> std::enable_if_t<IsKeyCache, ReturnType>
{
std::scoped_lock lock(m_mutex_);
clock_type::time_point const now(m_clock_.now());
auto [it, inserted] = m_cache_.emplace(
std::scoped_lock const lock(mutex_);
clock_type::time_point const now(clock_.now());
auto [it, inserted] = cache_.emplace(
std::piecewise_construct, std::forward_as_tuple(key), std::forward_as_tuple(now));
if (!inserted)
it->second.last_access = now;
@@ -519,7 +517,7 @@ inline auto
TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::
peekMutex() -> mutex_type&
{
return m_mutex_;
return mutex_;
}
template <
@@ -538,9 +536,9 @@ TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash,
std::vector<key_type> v;
{
std::scoped_lock lock(m_mutex_);
v.reserve(m_cache_.size());
for (auto const& _ : m_cache_)
std::scoped_lock const lock(mutex_);
v.reserve(cache_.size());
for (auto const& _ : cache_)
v.push_back(_.first);
}
@@ -560,11 +558,11 @@ inline double
TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::
rate() const
{
std::scoped_lock lock(m_mutex_);
auto const tot = m_hits_ + m_misses_;
std::scoped_lock const lock(mutex_);
auto const tot = hits_ + misses_;
if (tot == 0)
return 0;
return double(m_hits_) / tot;
return double(hits_) / tot;
}
template <
@@ -582,7 +580,7 @@ TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash,
fetch(key_type const& digest, Handler const& h)
{
{
std::scoped_lock l(m_mutex_);
std::scoped_lock const l(mutex_);
if (auto ret = initialFetch(digest, l))
return ret;
}
@@ -591,11 +589,11 @@ TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash,
if (!sle)
return {};
std::scoped_lock l(m_mutex_);
++m_misses_;
auto const [it, inserted] = m_cache_.emplace(digest, Entry(m_clock_.now(), std::move(sle)));
std::scoped_lock const l(mutex_);
++misses_;
auto const [it, inserted] = cache_.emplace(digest, Entry(clock_.now(), std::move(sle)));
if (!inserted)
it->second.touch(m_clock_.now());
it->second.touch(clock_.now());
return it->second.ptr.getStrong();
}
// End CachedSLEs functions.
@@ -613,27 +611,27 @@ inline SharedPointerType
TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::
initialFetch(key_type const& key, std::scoped_lock<mutex_type> const& l)
{
auto cit = m_cache_.find(key);
if (cit == m_cache_.end())
auto cit = cache_.find(key);
if (cit == cache_.end())
return {};
Entry& entry = cit->second;
if (entry.isCached())
{
++m_hits_;
entry.touch(m_clock_.now());
++hits_;
entry.touch(clock_.now());
return entry.ptr.getStrong();
}
entry.ptr = entry.lock();
if (entry.isCached())
{
// independent of cache size, so not counted as a hit
++m_cache_count_;
entry.touch(m_clock_.now());
++cache_count_;
entry.touch(clock_.now());
return entry.ptr.getStrong();
}
m_cache_.erase(cit);
cache_.erase(cit);
return {};
}
@@ -650,17 +648,17 @@ inline void
TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::
collectMetrics()
{
m_stats_.size.set(getCacheSize());
stats_.size.set(getCacheSize());
{
beast::insight::Gauge::value_type hitRate(0);
{
std::scoped_lock lock(m_mutex_);
auto const total(m_hits_ + m_misses_);
std::scoped_lock const lock(mutex_);
auto const total(hits_ + misses_);
if (total != 0)
hitRate = (m_hits_ * 100) / total;
hitRate = (hits_ * 100) / total;
}
m_stats_.hit_rate.set(hitRate);
stats_.hit_rate.set(hitRate);
}
}
@@ -712,7 +710,7 @@ TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash,
{
// strong, expired
++cacheRemovals;
if (cit->second.ptr.use_count() == 1)
if (cit->second.ptr.useCount() == 1)
{
stuffToSweep.emplace_back(std::move(cit->second.ptr));
++mapRemovals;
@@ -735,8 +733,8 @@ TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash,
if (mapRemovals || cacheRemovals)
{
JLOG(m_journal_.debug())
<< "TaggedCache partition sweep " << m_name_ << ": cache = " << partition.size()
JLOG(journal_.debug())
<< "TaggedCache partition sweep " << name_ << ": cache = " << partition.size()
<< "-" << cacheRemovals << ", map-=" << mapRemovals;
}
@@ -756,7 +754,7 @@ template <
inline std::thread
TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::
sweepHelper(
clock_type::time_point const& when_expire,
clock_type::time_point const& whenExpire,
clock_type::time_point const& now,
typename KeyOnlyCacheType::map_type& partition,
SweptPointersVector&,
@@ -764,8 +762,10 @@ TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash,
std::scoped_lock<std::recursive_mutex> const&)
{
return std::thread([&, this]() {
// NOLINTBEGIN https://github.com/XRPLF/rippled/issues/7056
int cacheRemovals = 0;
int mapRemovals = 0;
// NOLINTEND
// Keep references to all the stuff we sweep
// so that we can destroy them outside the lock.
@@ -778,7 +778,7 @@ TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash,
cit->second.last_access = now;
++cit;
}
else if (cit->second.last_access <= when_expire)
else if (cit->second.last_access <= whenExpire)
{
cit = partition.erase(cit);
}
@@ -789,10 +789,10 @@ TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash,
}
}
if (mapRemovals || cacheRemovals)
if (mapRemovals > 0 || cacheRemovals > 0)
{
JLOG(m_journal_.debug())
<< "TaggedCache partition sweep " << m_name_ << ": cache = " << partition.size()
JLOG(journal_.debug())
<< "TaggedCache partition sweep " << name_ << ": cache = " << partition.size()
<< "-" << cacheRemovals << ", map-=" << mapRemovals;
}

View File

@@ -13,31 +13,31 @@ namespace xrpl {
template <class T>
std::enable_if_t<std::is_arithmetic_v<T>, std::string>
to_string(T t)
to_string(T t) // NOLINT(readability-identifier-naming)
{
return std::to_string(t);
}
inline std::string
to_string(bool b)
to_string(bool b) // NOLINT(readability-identifier-naming)
{
return b ? "true" : "false";
}
inline std::string
to_string(char c)
to_string(char c) // NOLINT(readability-identifier-naming)
{
return std::string(1, c);
}
inline std::string
to_string(std::string s)
to_string(std::string s) // NOLINT(readability-identifier-naming)
{
return s;
}
inline std::string
to_string(char const* s)
to_string(char const* s) // NOLINT(readability-identifier-naming)
{
return s;
}

View File

@@ -21,7 +21,8 @@ public:
using period = std::ratio<1>;
using duration = std::chrono::duration<rep, period>;
using time_point = std::chrono::time_point<UptimeClock>;
static constexpr bool kIS_STEADY = std::chrono::system_clock::is_steady;
static constexpr bool is_steady = // NOLINT(readability-identifier-naming)
std::chrono::system_clock::is_steady;
explicit UptimeClock() = default;
@@ -29,8 +30,8 @@ public:
now(); // seconds since xrpld program start
private:
static std::atomic<rep> now;
static std::atomic<bool> stop;
static std::atomic<rep> kNOW;
static std::atomic<bool> kSTOP;
struct UpdateThread : private std::thread
{

View File

@@ -13,7 +13,7 @@ namespace xrpl {
// Note: This algorithm is evolved from std::set_intersection.
template <class InputIter1, class InputIter2, class Action, class Comp>
void
generalized_set_intersection(
generalizedSetIntersection(
InputIter1 first1,
InputIter1 last1,
InputIter2 first2,
@@ -53,7 +53,7 @@ generalized_set_intersection(
// std::set_intersection.
template <class FwdIter1, class InputIter2, class Pred, class Comp>
FwdIter1
remove_if_intersect_or_match(
removeIfIntersectOrMatch(
FwdIter1 first1,
FwdIter1 last1,
InputIter2 first2,

View File

@@ -40,15 +40,15 @@
namespace xrpl {
std::string
base64_encode(std::uint8_t const* data, std::size_t len);
base64Encode(std::uint8_t const* data, std::size_t len);
inline std::string
base64_encode(std::string const& s)
base64Encode(std::string const& s)
{
return base64_encode(reinterpret_cast<std::uint8_t const*>(s.data()), s.size());
return base64Encode(reinterpret_cast<std::uint8_t const*>(s.data()), s.size());
}
std::string
base64_decode(std::string_view data);
base64Decode(std::string_view data);
} // namespace xrpl

View File

@@ -32,7 +32,7 @@ struct IsContiguousContainer : std::false_type
};
template <class Container>
struct is_contiguous_container<
struct IsContiguousContainer<
Container,
std::void_t<
decltype(std::declval<Container const>().size()),
@@ -42,7 +42,7 @@ struct is_contiguous_container<
};
template <>
struct is_contiguous_container<Slice> : std::true_type
struct IsContiguousContainer<Slice> : std::true_type
{
};
@@ -235,7 +235,7 @@ private:
auto const result = parseFromStringView(sv);
if (!result)
{
if (result.error() == ParseResult::badLength)
if (result.error() == ParseResult::BadLength)
Throw<std::invalid_argument>("invalid length for hex string");
Throw<std::range_error>("invalid hex character");
@@ -614,7 +614,7 @@ to_string(BaseUint<Bits, Tag> const& a)
template <std::size_t Bits, class Tag>
inline std::string
to_short_string(BaseUint<Bits, Tag> const& a)
toShortString(BaseUint<Bits, Tag> const& a)
{
static_assert(BaseUint<Bits, Tag>::kBYTES > 4, "For 4 bytes or less, use a native type");
return strHex(a.cbegin(), a.cbegin() + 4) + "...";
@@ -650,9 +650,9 @@ static_assert(sizeof(uint256) == 256 / 8, "There should be no padding bytes");
namespace beast {
template <std::size_t Bits, class Tag>
struct is_uniquely_represented<xrpl::BaseUint<Bits, Tag>> : public std::true_type
struct IsUniquelyRepresented<xrpl::BaseUint<Bits, Tag>> : public std::true_type
{
explicit is_uniquely_represented() = default;
explicit IsUniquelyRepresented() = default;
};
} // namespace beast

View File

@@ -45,7 +45,7 @@ public:
using duration = std::chrono::duration<rep, period>;
using time_point = std::chrono::time_point<NetClock>;
static bool const kIS_STEADY = false;
static bool const is_steady = false; // NOLINT(readability-identifier-naming)
};
template <class Duration>
@@ -65,19 +65,19 @@ to_string(NetClock::time_point tp)
template <class Duration>
std::string
to_string_iso(date::sys_time<Duration> tp)
toStringIso(date::sys_time<Duration> tp)
{
using namespace std::chrono;
return date::format("%FT%TZ", tp);
}
inline std::string
to_string_iso(NetClock::time_point tp)
toStringIso(NetClock::time_point tp)
{
// 2000-01-01 00:00:00 UTC is 946684800s from 1970-01-01 00:00:00 UTC
// Note, NetClock::duration is seconds, as checked by static_assert
static_assert(std::is_same_v<NetClock::duration::period, std::ratio<1>>);
return to_string_iso(date::sys_time<NetClock::duration>{tp.time_since_epoch() + kEPOCH_OFFSET});
return toStringIso(date::sys_time<NetClock::duration>{tp.time_since_epoch() + kEPOCH_OFFSET});
}
/** A clock for measuring elapsed time.
@@ -95,7 +95,7 @@ stopwatch()
{
using Clock = beast::BasicSecondsClock;
using Facade = Clock::Clock;
return beast::get_abstract_clock<Facade, Clock>();
return beast::getAbstractClock<Facade, Clock>();
}
} // namespace xrpl

View File

@@ -17,7 +17,7 @@ namespace xrpl {
/** Generates and logs a call stack */
void
LogThrow(std::string const& title);
logThrow(std::string const& title);
/** Rethrow the exception currently being handled.
@@ -30,9 +30,9 @@ LogThrow(std::string const& title);
triggering false positives, since it throws.
*/
[[noreturn]] XRPL_NO_SANITIZE_ADDRESS inline void
Rethrow()
rethrow()
{
LogThrow("Re-throwing exception");
logThrow("Re-throwing exception");
throw;
}
@@ -52,12 +52,12 @@ Throw(Args&&... args)
std::is_convertible_v<E*, std::exception*>, "Exception must derive from std::exception.");
E e(std::forward<Args>(args)...);
LogThrow(std::string("Throwing exception of type " + beast::type_name<E>() + ": ") + e.what());
logThrow(std::string("Throwing exception of type " + beast::typeName<E>() + ": ") + e.what());
throw std::move(e);
}
/** Called when faulty logic causes a broken invariant. */
[[noreturn]] void
LogicError(std::string const& how) noexcept;
logicError(std::string const& how) noexcept;
} // namespace xrpl

View File

@@ -16,7 +16,7 @@ using seed_pair = std::pair<std::uint64_t, std::uint64_t>;
template <bool = true>
seed_pair
make_seed_pair() noexcept
makeSeedPair() noexcept
{
struct StateT
{
@@ -72,7 +72,7 @@ template <class HashAlgorithm = beast::Xxhasher>
class HardenedHash
{
private:
detail::seed_pair m_seeds_{detail::make_seed_pair<>()};
detail::seed_pair seeds_{detail::makeSeedPair<>()};
public:
using result_type = typename HashAlgorithm::result_type;
@@ -83,7 +83,7 @@ public:
result_type
operator()(T const& t) const noexcept
{
HashAlgorithm h(m_seeds_.first, m_seeds_.second);
HashAlgorithm h(seeds_.first, seeds_.second);
hash_append(h, t);
return static_cast<result_type>(h);
}

View File

@@ -8,11 +8,11 @@ namespace xrpl {
/** Create a self-signed SSL context that allows anonymous Diffie Hellman. */
std::shared_ptr<boost::asio::ssl::context>
make_SSLContext(std::string const& cipherList);
makeSslContext(std::string const& cipherList);
/** Create an authenticated SSL context using the specified files. */
std::shared_ptr<boost::asio::ssl::context>
make_SSLContextAuthed(
makeSslContextAuthed(
std::string const& keyFile,
std::string const& certFile,
std::string const& chainFile,

View File

@@ -62,7 +62,7 @@ public:
Iterator() = default;
Iterator(partition_map_type* map) : map(map)
Iterator(partition_map_type* m) : map(m)
{
}
@@ -131,7 +131,7 @@ public:
ConstIterator() = default;
ConstIterator(partition_map_type* map) : map(map)
ConstIterator(partition_map_type* m) : map(m)
{
}
@@ -216,11 +216,11 @@ private:
static void
begin(T& it)
{
for (it.ait_ = it.map_->begin(); it.ait_ != it.map_->end(); ++it.ait_)
for (it.ait = it.map->begin(); it.ait != it.map->end(); ++it.ait)
{
if (it.ait_->begin() == it.ait_->end())
if (it.ait->begin() == it.ait->end())
continue;
it.mit_ = it.ait_->begin();
it.mit = it.ait->begin();
return;
}
end(it);

View File

@@ -44,7 +44,7 @@ using is_engine = std::is_invocable_r<Result, Engine>;
will be randomly seeded.
*/
inline beast::xor_shift_engine&
default_prng()
defaultPrng()
{
// This is used to seed the thread-specific PRNGs on demand
static beast::xor_shift_engine kSEEDER = [] {
@@ -92,7 +92,7 @@ default_prng()
/** @{ */
template <class Engine, class Integral>
std::enable_if_t<std::is_integral_v<Integral> && detail::is_engine<Engine>::value, Integral>
rand_int(Engine& engine, Integral min, Integral max)
randInt(Engine& engine, Integral min, Integral max)
{
XRPL_ASSERT(max > min, "xrpl::rand_int : max over min inputs");
@@ -104,37 +104,37 @@ rand_int(Engine& engine, Integral min, Integral max)
template <class Integral>
std::enable_if_t<std::is_integral_v<Integral>, Integral>
rand_int(Integral min, Integral max)
randInt(Integral min, Integral max)
{
return rand_int(default_prng(), min, max);
return randInt(defaultPrng(), min, max);
}
template <class Engine, class Integral>
std::enable_if_t<std::is_integral_v<Integral> && detail::is_engine<Engine>::value, Integral>
rand_int(Engine& engine, Integral max)
randInt(Engine& engine, Integral max)
{
return rand_int(engine, Integral(0), max);
return randInt(engine, Integral(0), max);
}
template <class Integral>
std::enable_if_t<std::is_integral_v<Integral>, Integral>
rand_int(Integral max)
randInt(Integral max)
{
return rand_int(default_prng(), max);
return randInt(defaultPrng(), max);
}
template <class Integral, class Engine>
std::enable_if_t<std::is_integral_v<Integral> && detail::is_engine<Engine>::value, Integral>
rand_int(Engine& engine)
randInt(Engine& engine)
{
return rand_int(engine, std::numeric_limits<Integral>::max());
return randInt(engine, std::numeric_limits<Integral>::max());
}
template <class Integral = int>
std::enable_if_t<std::is_integral_v<Integral>, Integral>
rand_int()
randInt()
{
return rand_int(default_prng(), std::numeric_limits<Integral>::max());
return randInt(defaultPrng(), std::numeric_limits<Integral>::max());
}
/** @} */
@@ -145,17 +145,17 @@ std::enable_if_t<
(std::is_same_v<Byte, unsigned char> || std::is_same_v<Byte, std::uint8_t>) &&
detail::is_engine<Engine>::value,
Byte>
rand_byte(Engine& engine)
randByte(Engine& engine)
{
return static_cast<Byte>(rand_int<Engine, std::uint32_t>(
return static_cast<Byte>(randInt<Engine, std::uint32_t>(
engine, std::numeric_limits<Byte>::min(), std::numeric_limits<Byte>::max()));
}
template <class Byte = std::uint8_t>
std::enable_if_t<(std::is_same_v<Byte, unsigned char> || std::is_same_v<Byte, std::uint8_t>), Byte>
rand_byte()
randByte()
{
return rand_byte<Byte>(default_prng());
return randByte<Byte>(defaultPrng());
}
/** @} */
@@ -163,15 +163,15 @@ rand_byte()
/** @{ */
template <class Engine>
inline bool
rand_bool(Engine& engine)
randBool(Engine& engine)
{
return rand_int(engine, 1) == 1;
return randInt(engine, 1) == 1;
}
inline bool
rand_bool()
randBool()
{
return rand_bool(default_prng());
return randBool(defaultPrng());
}
/** @} */

View File

@@ -62,20 +62,20 @@ template <class Dest, class Src>
constexpr std::enable_if_t<std::is_enum_v<Dest> && std::is_integral_v<Src>, Dest>
unsafeCast(Src s) noexcept
{
return static_cast<Dest>(unsafe_cast<std::underlying_type_t<Dest>>(s));
return static_cast<Dest>(unsafeCast<std::underlying_type_t<Dest>>(s));
}
template <class Dest, class Src>
constexpr std::enable_if_t<std::is_integral_v<Dest> && std::is_enum_v<Src>, Dest>
unsafeCast(Src s) noexcept
{
return unsafe_cast<Dest>(static_cast<std::underlying_type_t<Src>>(s));
return unsafeCast<Dest>(static_cast<std::underlying_type_t<Src>>(s));
}
template <class Dest, class Src>
requires std::is_pointer_v<Dest>
inline Dest
safe_downcast(Src* s) noexcept
safeDowncast(Src* s) noexcept
{
#ifdef NDEBUG
return static_cast<Dest>(s); // NOLINT(cppcoreguidelines-pro-type-static-cast-downcast)
@@ -89,7 +89,7 @@ safe_downcast(Src* s) noexcept
template <class Dest, class Src>
requires std::is_lvalue_reference_v<Dest>
inline Dest
safe_downcast(Src& s) noexcept
safeDowncast(Src& s) noexcept
{
#ifndef NDEBUG
XRPL_ASSERT(

View File

@@ -22,19 +22,19 @@ namespace xrpl {
// to enforce this restriction.
template <class EF>
class scope_exit
class ScopeExit
{
EF exit_function_;
bool execute_on_destruction_{true};
public:
~scope_exit()
~ScopeExit()
{
if (execute_on_destruction_)
exit_function_();
}
scope_exit(scope_exit&& rhs) noexcept(
ScopeExit(ScopeExit&& rhs) noexcept(
std::is_nothrow_move_constructible_v<EF> || std::is_nothrow_copy_constructible_v<EF>)
: exit_function_{std::forward<EF>(rhs.exit_function_)}
, execute_on_destruction_{rhs.execute_on_destruction_}
@@ -42,14 +42,14 @@ public:
rhs.release();
}
scope_exit&
operator=(scope_exit&&) = delete;
ScopeExit&
operator=(ScopeExit&&) = delete;
template <class EFP>
explicit scope_exit(
explicit ScopeExit(
EFP&& f,
std::enable_if_t<
!std::is_same_v<std::remove_cv_t<EFP>, scope_exit> &&
!std::is_same_v<std::remove_cv_t<EFP>, ScopeExit> &&
std::is_constructible_v<EF, EFP>>* = 0) noexcept
: exit_function_{std::forward<EFP>(f)}
{
@@ -64,23 +64,23 @@ public:
};
template <class EF>
scope_exit(EF) -> scope_exit<EF>;
ScopeExit(EF) -> ScopeExit<EF>;
template <class EF>
class scope_fail
class ScopeFail
{
EF exit_function_;
bool execute_on_destruction_{true};
int uncaught_on_creation_{std::uncaught_exceptions()};
public:
~scope_fail()
~ScopeFail()
{
if (execute_on_destruction_ && std::uncaught_exceptions() > uncaught_on_creation_)
exit_function_();
}
scope_fail(scope_fail&& rhs) noexcept(
ScopeFail(ScopeFail&& rhs) noexcept(
std::is_nothrow_move_constructible_v<EF> || std::is_nothrow_copy_constructible_v<EF>)
: exit_function_{std::forward<EF>(rhs.exit_function_)}
, execute_on_destruction_{rhs.execute_on_destruction_}
@@ -89,14 +89,14 @@ public:
rhs.release();
}
scope_fail&
operator=(scope_fail&&) = delete;
ScopeFail&
operator=(ScopeFail&&) = delete;
template <class EFP>
explicit scope_fail(
explicit ScopeFail(
EFP&& f,
std::enable_if_t<
!std::is_same_v<std::remove_cv_t<EFP>, scope_fail> &&
!std::is_same_v<std::remove_cv_t<EFP>, ScopeFail> &&
std::is_constructible_v<EF, EFP>>* = 0) noexcept
: exit_function_{std::forward<EFP>(f)}
{
@@ -111,23 +111,23 @@ public:
};
template <class EF>
scope_fail(EF) -> scope_fail<EF>;
ScopeFail(EF) -> ScopeFail<EF>;
template <class EF>
class scope_success
class ScopeSuccess
{
EF exit_function_;
bool execute_on_destruction_{true};
int uncaught_on_creation_{std::uncaught_exceptions()};
public:
~scope_success() noexcept(noexcept(exit_function_()))
~ScopeSuccess() noexcept(noexcept(exit_function_()))
{
if (execute_on_destruction_ && std::uncaught_exceptions() <= uncaught_on_creation_)
exit_function_();
}
scope_success(scope_success&& rhs) noexcept(
ScopeSuccess(ScopeSuccess&& rhs) noexcept(
std::is_nothrow_move_constructible_v<EF> || std::is_nothrow_copy_constructible_v<EF>)
: exit_function_{std::forward<EF>(rhs.exit_function_)}
, execute_on_destruction_{rhs.execute_on_destruction_}
@@ -136,14 +136,14 @@ public:
rhs.release();
}
scope_success&
operator=(scope_success&&) = delete;
ScopeSuccess&
operator=(ScopeSuccess&&) = delete;
template <class EFP>
explicit scope_success(
explicit ScopeSuccess(
EFP&& f,
std::enable_if_t<
!std::is_same_v<std::remove_cv_t<EFP>, scope_success> &&
!std::is_same_v<std::remove_cv_t<EFP>, ScopeSuccess> &&
std::is_constructible_v<EF, EFP>>* =
0) noexcept(std::is_nothrow_constructible_v<EF, EFP> || std::is_nothrow_constructible_v<EF, EFP&>)
: exit_function_{std::forward<EFP>(f)}
@@ -158,7 +158,7 @@ public:
};
template <class EF>
scope_success(EF) -> scope_success<EF>;
ScopeSuccess(EF) -> ScopeSuccess<EF>;
/**
Automatically unlocks and re-locks a unique_lock object.
@@ -198,29 +198,29 @@ scope_success(EF) -> scope_success<EF>;
*/
template <class Mutex>
class scope_unlock
class ScopeUnlock
{
std::unique_lock<Mutex>* plock;
std::unique_lock<Mutex>* plock_;
public:
explicit scope_unlock(std::unique_lock<Mutex>& lock) noexcept(true) : plock(&lock)
explicit ScopeUnlock(std::unique_lock<Mutex>& lock) noexcept(true) : plock_(&lock)
{
XRPL_ASSERT(plock->owns_lock(), "xrpl::scope_unlock::scope_unlock : mutex must be locked");
plock->unlock();
XRPL_ASSERT(plock_->owns_lock(), "xrpl::scope_unlock::scope_unlock : mutex must be locked");
plock_->unlock();
}
// Immovable type
scope_unlock(scope_unlock const&) = delete;
scope_unlock&
operator=(scope_unlock const&) = delete;
ScopeUnlock(ScopeUnlock const&) = delete;
ScopeUnlock&
operator=(ScopeUnlock const&) = delete;
~scope_unlock() noexcept(true)
~ScopeUnlock() noexcept(true)
{
plock->lock();
plock_->lock();
}
};
template <class Mutex>
scope_unlock(std::unique_lock<Mutex>&) -> scope_unlock<Mutex>;
ScopeUnlock(std::unique_lock<Mutex>&) -> ScopeUnlock<Mutex>;
} // namespace xrpl

View File

@@ -26,7 +26,7 @@ namespace detail {
specific amount of time, to prevent this.
*/
inline void
spin_pause() noexcept
spinPause() noexcept
{
#ifdef __aarch64__
asm volatile("yield");
@@ -71,7 +71,7 @@ spin_pause() noexcept
https://en.cppreference.com/w/cpp/named_req/Lockable
*/
template <class T>
class packed_spinlock
class PackedSpinlock
{
// clang-format off
static_assert(std::is_unsigned_v<T>);
@@ -87,9 +87,9 @@ private:
T const mask_;
public:
packed_spinlock(packed_spinlock const&) = delete;
packed_spinlock&
operator=(packed_spinlock const&) = delete;
PackedSpinlock(PackedSpinlock const&) = delete;
PackedSpinlock&
operator=(PackedSpinlock const&) = delete;
/** A single spinlock packed inside the specified atomic
@@ -99,8 +99,7 @@ public:
@note For performance reasons, you should strive to have `lock` be
on a cacheline by itself.
*/
packed_spinlock(std::atomic<T>& lock, int index)
: bits_(lock), mask_(static_cast<T>(1) << index)
PackedSpinlock(std::atomic<T>& lock, int index) : bits_(lock), mask_(static_cast<T>(1) << index)
{
XRPL_ASSERT(
index >= 0 && (mask_ != 0),
@@ -108,7 +107,7 @@ public:
}
[[nodiscard]] bool
try_lock()
try_lock() // NOLINT(readability-identifier-naming)
{
return (bits_.fetch_or(mask_, std::memory_order_acquire) & mask_) == 0;
}
@@ -123,7 +122,7 @@ public:
// of contention by avoiding writes that would definitely not
// result in the lock being acquired.
while ((bits_.load(std::memory_order_relaxed) & mask_) != 0)
detail::spin_pause();
detail::spinPause();
}
}
@@ -147,7 +146,7 @@ public:
https://en.cppreference.com/w/cpp/named_req/Lockable
*/
template <class T>
class spinlock
class Spinlock
{
static_assert(std::is_unsigned_v<T>);
static_assert(std::atomic<T>::is_always_lock_free);
@@ -156,9 +155,9 @@ private:
std::atomic<T>& lock_;
public:
spinlock(spinlock const&) = delete;
spinlock&
operator=(spinlock const&) = delete;
Spinlock(Spinlock const&) = delete;
Spinlock&
operator=(Spinlock const&) = delete;
/** Grabs the
@@ -167,12 +166,12 @@ public:
@note For performance reasons, you should strive to have `lock` be
on a cacheline by itself.
*/
spinlock(std::atomic<T>& lock) : lock_(lock)
Spinlock(std::atomic<T>& lock) : lock_(lock)
{
}
[[nodiscard]] bool
try_lock()
try_lock() // NOLINT(readability-identifier-naming)
{
T expected = 0;
@@ -193,7 +192,7 @@ public:
// of contention by avoiding writes that would definitely not
// result in the lock being acquired.
while (lock_.load(std::memory_order_relaxed) != 0)
detail::spin_pause();
detail::spinPause();
}
}

View File

@@ -34,7 +34,7 @@ class TaggedInteger : boost::totally_ordered<
boost::shiftable<TaggedInteger<Int, Tag>>>>>>
{
private:
Int m_value_;
Int value_;
public:
using value_type = Int;
@@ -45,7 +45,7 @@ public:
template <
class OtherInt,
class = std::enable_if_t<std::is_integral_v<OtherInt> && sizeof(OtherInt) <= sizeof(Int)>>
explicit constexpr TaggedInteger(OtherInt value) noexcept : m_value_(value)
explicit constexpr TaggedInteger(OtherInt value) noexcept : value_(value)
{
static_assert(sizeof(TaggedInteger) == sizeof(Int), "tagged_integer is adding padding");
}
@@ -53,89 +53,89 @@ public:
bool
operator<(TaggedInteger const& rhs) const noexcept
{
return m_value_ < rhs.m_value_;
return value_ < rhs.value_;
}
bool
operator==(TaggedInteger const& rhs) const noexcept
{
return m_value_ == rhs.m_value_;
return value_ == rhs.value_;
}
TaggedInteger&
operator+=(TaggedInteger const& rhs) noexcept
{
m_value_ += rhs.m_value_;
value_ += rhs.value_;
return *this;
}
TaggedInteger&
operator-=(TaggedInteger const& rhs) noexcept
{
m_value_ -= rhs.m_value_;
value_ -= rhs.value_;
return *this;
}
TaggedInteger&
operator*=(TaggedInteger const& rhs) noexcept
{
m_value_ *= rhs.m_value_;
value_ *= rhs.value_;
return *this;
}
TaggedInteger&
operator/=(TaggedInteger const& rhs) noexcept
{
m_value_ /= rhs.m_value_;
value_ /= rhs.value_;
return *this;
}
TaggedInteger&
operator%=(TaggedInteger const& rhs) noexcept
{
m_value_ %= rhs.m_value_;
value_ %= rhs.value_;
return *this;
}
TaggedInteger&
operator|=(TaggedInteger const& rhs) noexcept
{
m_value_ |= rhs.m_value_;
value_ |= rhs.value_;
return *this;
}
TaggedInteger&
operator&=(TaggedInteger const& rhs) noexcept
{
m_value_ &= rhs.m_value_;
value_ &= rhs.value_;
return *this;
}
TaggedInteger&
operator^=(TaggedInteger const& rhs) noexcept
{
m_value_ ^= rhs.m_value_;
value_ ^= rhs.value_;
return *this;
}
TaggedInteger&
operator<<=(TaggedInteger const& rhs) noexcept
{
m_value_ <<= rhs.m_value_;
value_ <<= rhs.value_;
return *this;
}
TaggedInteger&
operator>>=(TaggedInteger const& rhs) noexcept
{
m_value_ >>= rhs.m_value_;
value_ >>= rhs.value_;
return *this;
}
TaggedInteger
operator~() const noexcept
{
return TaggedInteger{~m_value_};
return TaggedInteger{~value_};
}
TaggedInteger
@@ -147,47 +147,47 @@ public:
TaggedInteger
operator-() const noexcept
{
return TaggedInteger{-m_value_};
return TaggedInteger{-value_};
}
TaggedInteger&
operator++() noexcept
{
++m_value_;
++value_;
return *this;
}
TaggedInteger&
operator--() noexcept
{
--m_value_;
--value_;
return *this;
}
explicit
operator Int() const noexcept
{
return m_value_;
return value_;
}
friend std::ostream&
operator<<(std::ostream& s, TaggedInteger const& t)
{
s << t.m_value_;
s << t.value_;
return s;
}
friend std::istream&
operator>>(std::istream& s, TaggedInteger& t)
{
s >> t.m_value_;
s >> t.value_;
return s;
}
friend std::string
to_string(TaggedInteger const& t)
{
return std::to_string(t.m_value_);
return std::to_string(t.value_);
}
};
@@ -195,10 +195,10 @@ public:
namespace beast {
template <class Int, class Tag, class HashAlgorithm>
struct is_contiguously_hashable<xrpl::TaggedInteger<Int, Tag>, HashAlgorithm>
struct IsContiguouslyHashable<xrpl::TaggedInteger<Int, Tag>, HashAlgorithm>
: public IsContiguouslyHashable<Int, HashAlgorithm>
{
explicit is_contiguously_hashable() = default;
explicit IsContiguouslyHashable() = default;
};
} // namespace beast

View File

@@ -15,44 +15,44 @@ namespace beast {
/** Measures handler latency on an io_context queue. */
template <class Clock>
class io_latency_probe
class IoLatencyProbe
{
private:
using duration = typename Clock::duration;
using time_point = typename Clock::time_point;
std::recursive_mutex m_mutex;
std::condition_variable_any m_cond;
std::size_t m_count{1};
duration const m_period;
boost::asio::io_context& m_ios;
boost::asio::basic_waitable_timer<std::chrono::steady_clock> m_timer;
bool m_cancel{false};
std::recursive_mutex mutex_;
std::condition_variable_any cond_;
std::size_t count_{1};
duration const period_;
boost::asio::io_context& ios_;
boost::asio::basic_waitable_timer<std::chrono::steady_clock> timer_;
bool cancel_{false};
public:
io_latency_probe(duration const& period, boost::asio::io_context& ios)
: m_period(period), m_ios(ios), m_timer(m_ios)
IoLatencyProbe(duration const& period, boost::asio::io_context& ios)
: period_(period), ios_(ios), timer_(ios_)
{
}
~io_latency_probe()
~IoLatencyProbe()
{
std::unique_lock<decltype(m_mutex)> lock(m_mutex);
std::unique_lock<decltype(mutex_)> lock(mutex_);
cancel(lock, true);
}
/** Return the io_context associated with the latency probe. */
/** @{ */
boost::asio::io_context&
get_io_context()
getIoContext()
{
return m_ios;
return ios_;
}
[[nodiscard]] boost::asio::io_context const&
get_io_context() const
getIoContext() const
{
return m_ios;
return ios_;
}
/** @} */
@@ -63,14 +63,14 @@ public:
void
cancel()
{
std::unique_lock<decltype(m_mutex)> lock(m_mutex);
std::unique_lock<decltype(mutex_)> lock(mutex_);
cancel(lock, true);
}
void
cancel_async()
cancelAsync()
{
std::unique_lock<decltype(m_mutex)> lock(m_mutex);
std::unique_lock<decltype(mutex_)> lock(mutex_);
cancel(lock, false);
}
/** @} */
@@ -81,13 +81,13 @@ public:
*/
template <class Handler>
void
sample_one(Handler&& handler)
sampleOne(Handler&& handler)
{
std::scoped_lock const lock(m_mutex);
if (m_cancel)
std::scoped_lock const lock(mutex_);
if (cancel_)
throw std::logic_error("io_latency_probe is canceled");
boost::asio::post(
m_ios, sample_op<Handler>(std::forward<Handler>(handler), Clock::now(), false, this));
ios_, SampleOp<Handler>(std::forward<Handler>(handler), Clock::now(), false, this));
}
/** Initiate continuous i/o latency sampling.
@@ -98,125 +98,123 @@ public:
void
sample(Handler&& handler)
{
std::scoped_lock const lock(m_mutex);
if (m_cancel)
std::scoped_lock const lock(mutex_);
if (cancel_)
throw std::logic_error("io_latency_probe is canceled");
boost::asio::post(
m_ios, sample_op<Handler>(std::forward<Handler>(handler), Clock::now(), true, this));
ios_, SampleOp<Handler>(std::forward<Handler>(handler), Clock::now(), true, this));
}
private:
void
cancel(std::unique_lock<decltype(m_mutex)>& lock, bool wait)
cancel(std::unique_lock<decltype(mutex_)>& lock, bool wait)
{
if (!m_cancel)
if (!cancel_)
{
--m_count;
m_cancel = true;
--count_;
cancel_ = true;
}
if (wait)
m_cond.wait(lock, [this] { return this->m_count == 0; });
cond_.wait(lock, [this] { return this->count_ == 0; });
}
void
addref()
{
std::scoped_lock const lock(m_mutex);
++m_count;
std::scoped_lock const lock(mutex_);
++count_;
}
void
release()
{
std::scoped_lock const lock(m_mutex);
if (--m_count == 0)
m_cond.notify_all();
std::scoped_lock const lock(mutex_);
if (--count_ == 0)
cond_.notify_all();
}
template <class Handler>
struct sample_op
struct SampleOp
{
Handler m_handler;
time_point m_start;
bool m_repeat;
io_latency_probe* m_probe;
Handler handler;
time_point start;
bool repeat;
IoLatencyProbe* probe;
sample_op(
SampleOp(
Handler const& handler,
time_point const& start,
bool repeat,
io_latency_probe* probe)
: m_handler(handler), m_start(start), m_repeat(repeat), m_probe(probe)
IoLatencyProbe* probe)
: handler(handler), start(start), repeat(repeat), probe(probe)
{
XRPL_ASSERT(
m_probe,
probe,
"beast::io_latency_probe::sample_op::sample_op : non-null "
"probe input");
m_probe->addref();
probe->addref();
}
sample_op(sample_op&& from) noexcept
: m_handler(std::move(from.m_handler))
, m_start(from.m_start)
, m_repeat(from.m_repeat)
, m_probe(from.m_probe)
SampleOp(SampleOp&& from) noexcept
: handler(std::move(from.handler))
, start(from.start)
, repeat(from.repeat)
, probe(from.probe)
{
XRPL_ASSERT(
m_probe,
probe,
"beast::io_latency_probe::sample_op::sample_op(sample_op&&) : "
"non-null probe input");
from.m_probe = nullptr;
from.probe = nullptr;
}
sample_op(sample_op const&) = delete;
sample_op
operator=(sample_op const&) = delete;
sample_op&
operator=(sample_op&&) = delete;
SampleOp(SampleOp const&) = delete;
SampleOp
operator=(SampleOp const&) = delete;
SampleOp&
operator=(SampleOp&&) = delete;
~sample_op()
~SampleOp()
{
if (m_probe)
m_probe->release();
if (probe)
probe->release();
}
void
operator()() const
{
if (m_probe == nullptr)
if (probe == nullptr)
return;
typename Clock::time_point const now(Clock::now());
typename Clock::duration const elapsed(now - m_start);
typename Clock::duration const elapsed(now - start);
m_handler(elapsed);
handler(elapsed);
{
std::scoped_lock const lock(m_probe->m_mutex);
if (m_probe->m_cancel)
std::scoped_lock const lock(probe->mutex_);
if (probe->cancel_)
return;
}
if (m_repeat)
if (repeat)
{
// Calculate when we want to sample again, and
// adjust for the expected latency.
//
typename Clock::time_point const when(now + m_probe->m_period - (2 * elapsed));
typename Clock::time_point const when(now + probe->period_ - (2 * elapsed));
if (when <= now)
{
// The latency is too high to maintain the desired
// period so don't bother with a timer.
//
boost::asio::post(
m_probe->m_ios, sample_op<Handler>(m_handler, now, m_repeat, m_probe));
boost::asio::post(probe->ios_, SampleOp<Handler>(handler, now, repeat, probe));
}
else
{
m_probe->m_timer.expires_after(when - now);
m_probe->m_timer.async_wait(
sample_op<Handler>(m_handler, now, m_repeat, m_probe));
probe->timer_.expires_after(when - now);
probe->timer_.async_wait(SampleOp<Handler>(handler, now, repeat, probe));
}
}
}
@@ -224,11 +222,10 @@ private:
void
operator()(boost::system::error_code const& ec)
{
if (m_probe == nullptr)
if (probe == nullptr)
return;
typename Clock::time_point const now(Clock::now());
boost::asio::post(
m_probe->m_ios, sample_op<Handler>(m_handler, now, m_repeat, m_probe));
boost::asio::post(probe->ios_, SampleOp<Handler>(handler, now, repeat, probe));
}
};
};

View File

@@ -40,7 +40,7 @@ public:
using time_point = typename Clock::time_point;
using clock_type = Clock;
static bool const kIS_STEADY = Clock::kIS_STEADY;
static bool const is_steady = Clock::is_steady; // NOLINT(readability-identifier-naming)
virtual ~AbstractClock() = default;
AbstractClock() = default;
@@ -81,7 +81,7 @@ struct AbstractClockWrapper : public AbstractClock<Facade>
*/
template <class Facade, class Clock = Facade>
AbstractClock<Facade>&
get_abstract_clock()
getAbstractClock()
{
static detail::AbstractClockWrapper<Facade, Clock> kCLOCK;
return kCLOCK;

View File

@@ -25,7 +25,8 @@ public:
using duration = typename Clock::duration;
using time_point = typename Clock::time_point;
static bool const kIS_STEADY = Clock::is_steady;
static bool const is_steady = // NOLINT(readability-identifier-naming)
Clock::is_steady;
static time_point
now();

View File

@@ -44,7 +44,7 @@ public:
{
XRPL_ASSERT(
!Clock::is_steady || when >= now_,
"beast::manual_clock::set(time_point) : forward input");
"beast::ManualClock::set(time_point) : forward input");
now_ = when;
}
@@ -63,7 +63,7 @@ public:
{
XRPL_ASSERT(
!Clock::is_steady || (now_ + elapsed) >= now_,
"beast::manual_clock::advance(duration) : forward input");
"beast::ManualClock::advance(duration) : forward input");
now_ += elapsed;
}

View File

@@ -9,7 +9,7 @@ namespace beast {
/** Expire aged container items past the specified age. */
template <class AgedContainer, class Rep, class Period>
std::enable_if_t<is_aged_container<AgedContainer>::value, std::size_t>
std::enable_if_t<IsAgedContainer<AgedContainer>::value, std::size_t>
expire(AgedContainer& c, std::chrono::duration<Rep, Period> const& age)
{
std::size_t n(0);

View File

@@ -14,6 +14,6 @@ template <
class Clock = std::chrono::steady_clock,
class Compare = std::less<Key>,
class Allocator = std::allocator<std::pair<Key const, T>>>
using aged_map = detail::aged_ordered_container<false, true, Key, T, Clock, Compare, Allocator>;
using aged_map = detail::AgedOrderedContainer<false, true, Key, T, Clock, Compare, Allocator>;
} // namespace beast

View File

@@ -14,6 +14,6 @@ template <
class Clock = std::chrono::steady_clock,
class Compare = std::less<Key>,
class Allocator = std::allocator<std::pair<Key const, T>>>
using aged_multimap = detail::aged_ordered_container<true, true, Key, T, Clock, Compare, Allocator>;
using aged_multimap = detail::AgedOrderedContainer<true, true, Key, T, Clock, Compare, Allocator>;
} // namespace beast

View File

@@ -14,5 +14,6 @@ template <
class Compare = std::less<Key>,
class Allocator = std::allocator<Key>>
using aged_multiset =
detail::aged_ordered_container<true, false, Key, void, Clock, Compare, Allocator>;
detail::AgedOrderedContainer<true, false, Key, void, Clock, Compare, Allocator>;
} // namespace beast

View File

@@ -13,6 +13,6 @@ template <
class Clock = std::chrono::steady_clock,
class Compare = std::less<Key>,
class Allocator = std::allocator<Key>>
using aged_set = detail::aged_ordered_container<false, false, Key, void, Clock, Compare, Allocator>;
using aged_set = detail::AgedOrderedContainer<false, false, Key, void, Clock, Compare, Allocator>;
} // namespace beast

View File

@@ -17,4 +17,5 @@ template <
class Allocator = std::allocator<std::pair<Key const, T>>>
using aged_unordered_map =
detail::AgedUnorderedContainer<false, true, Key, T, Clock, Hash, KeyEqual, Allocator>;
} // namespace beast

View File

@@ -16,5 +16,6 @@ template <
class KeyEqual = std::equal_to<Key>,
class Allocator = std::allocator<std::pair<Key const, T>>>
using aged_unordered_multimap =
detail::aged_unordered_container<true, true, Key, T, Clock, Hash, KeyEqual, Allocator>;
detail::AgedUnorderedContainer<true, true, Key, T, Clock, Hash, KeyEqual, Allocator>;
} // namespace beast

View File

@@ -15,6 +15,6 @@ template <
class KeyEqual = std::equal_to<Key>,
class Allocator = std::allocator<Key>>
using aged_unordered_multiset =
detail::aged_unordered_container<true, false, Key, void, Clock, Hash, KeyEqual, Allocator>;
detail::AgedUnorderedContainer<true, false, Key, void, Clock, Hash, KeyEqual, Allocator>;
} // namespace beast

View File

@@ -15,5 +15,6 @@ template <
class KeyEqual = std::equal_to<Key>,
class Allocator = std::allocator<Key>>
using aged_unordered_set =
detail::aged_unordered_container<false, false, Key, void, Clock, Hash, KeyEqual, Allocator>;
detail::AgedUnorderedContainer<false, false, Key, void, Clock, Hash, KeyEqual, Allocator>;
} // namespace beast

View File

@@ -17,9 +17,9 @@ struct AgedAssociativeContainerExtractT
};
template <>
struct aged_associative_container_extract_t<false>
struct AgedAssociativeContainerExtractT<false>
{
explicit aged_associative_container_extract_t() = default;
explicit AgedAssociativeContainerExtractT() = default;
template <class Value>
Value const&

View File

@@ -19,12 +19,12 @@ public:
using iterator_category = typename std::iterator_traits<Iterator>::iterator_category;
using value_type = std::conditional_t<
IsConst,
typename Iterator::value_type::stashed::value_type const,
typename Iterator::value_type::stashed::value_type>;
typename Iterator::value_type::Stashed::value_type const,
typename Iterator::value_type::Stashed::value_type>;
using difference_type = typename std::iterator_traits<Iterator>::difference_type;
using pointer = value_type*;
using reference = value_type&;
using time_point = typename Iterator::value_type::stashed::time_point;
using time_point = typename Iterator::value_type::Stashed::time_point;
AgedContainerIterator() = default;
@@ -37,14 +37,14 @@ public:
(!OtherIsConst || IsConst) &&
!static_cast<bool>(std::is_same_v<Iterator, OtherIterator>)>>
explicit AgedContainerIterator(AgedContainerIterator<OtherIsConst, OtherIterator> const& other)
: m_iter_(other.m_iter)
: iter_(other.iter_)
{
}
// Disable constructing a const_iterator from a non-const_iterator.
template <bool OtherIsConst, class = std::enable_if_t<!OtherIsConst || IsConst>>
AgedContainerIterator(AgedContainerIterator<OtherIsConst, Iterator> const& other)
: m_iter_(other.m_iter)
: iter_(other.iter_)
{
}
@@ -54,7 +54,7 @@ public:
operator=(AgedContainerIterator<OtherIsConst, OtherIterator> const& other)
-> std::enable_if_t<!OtherIsConst || IsConst, AgedContainerIterator&>
{
m_iter_ = other.m_iter;
iter_ = other.iter_;
return *this;
}
@@ -62,20 +62,20 @@ public:
bool
operator==(AgedContainerIterator<OtherIsConst, OtherIterator> const& other) const
{
return m_iter_ == other.m_iter;
return iter_ == other.iter_;
}
template <bool OtherIsConst, class OtherIterator>
bool
operator!=(AgedContainerIterator<OtherIsConst, OtherIterator> const& other) const
{
return m_iter_ != other.m_iter;
return iter_ != other.iter_;
}
AgedContainerIterator&
operator++()
{
++m_iter_;
++iter_;
return *this;
}
@@ -83,14 +83,14 @@ public:
operator++(int)
{
AgedContainerIterator const prev(*this);
++m_iter_;
++iter_;
return prev;
}
AgedContainerIterator&
operator--()
{
--m_iter_;
--iter_;
return *this;
}
@@ -98,50 +98,50 @@ public:
operator--(int)
{
AgedContainerIterator const prev(*this);
--m_iter_;
--iter_;
return prev;
}
reference
operator*() const
{
return m_iter_->value;
return iter_->value;
}
pointer
operator->() const
{
return &m_iter_->value;
return &iter_->value;
}
[[nodiscard]] time_point const&
when() const
{
return m_iter_->when;
return iter_->when;
}
private:
template <bool, bool, class, class, class, class, class>
friend class aged_ordered_container;
friend class AgedOrderedContainer;
template <bool, bool, class, class, class, class, class, class>
friend class aged_unordered_container;
friend class AgedUnorderedContainer;
template <bool, class>
friend class aged_container_iterator;
friend class AgedContainerIterator;
template <class OtherIterator>
AgedContainerIterator(OtherIterator iter) : m_iter_(std::move(iter))
AgedContainerIterator(OtherIterator iter) : iter_(std::move(iter))
{
}
[[nodiscard]] Iterator const&
iterator() const
{
return m_iter_;
return iter_;
}
Iterator m_iter_;
Iterator iter_;
};
} // namespace detail

File diff suppressed because it is too large Load Diff

View File

@@ -53,21 +53,21 @@ public:
//------------------------------------------------------------------------------
template <class T, int UniqueID>
class empty_base_optimization<T, UniqueID, false>
class EmptyBaseOptimization<T, UniqueID, false>
{
T t_;
public:
empty_base_optimization() = default;
empty_base_optimization(empty_base_optimization&&) = default;
empty_base_optimization(empty_base_optimization const&) = default;
empty_base_optimization&
operator=(empty_base_optimization&&) = default;
empty_base_optimization&
operator=(empty_base_optimization const&) = default;
EmptyBaseOptimization() = default;
EmptyBaseOptimization(EmptyBaseOptimization&&) = default;
EmptyBaseOptimization(EmptyBaseOptimization const&) = default;
EmptyBaseOptimization&
operator=(EmptyBaseOptimization&&) = default;
EmptyBaseOptimization&
operator=(EmptyBaseOptimization const&) = default;
template <class Arg1, class... ArgN>
explicit empty_base_optimization(Arg1&& arg1, ArgN&&... argn)
explicit EmptyBaseOptimization(Arg1&& arg1, ArgN&&... argn)
: t_(std::forward<Arg1>(arg1), std::forward<ArgN>(argn)...)
{
}

View File

@@ -21,7 +21,7 @@ setCurrentThreadName(std::string_view newThreadName);
// On Linux, thread names are limited to 16 bytes including the null terminator.
// Maximum number of characters is therefore 15.
constexpr std::size_t maxThreadNameLength = 15;
constexpr std::size_t kMAX_THREAD_NAME_LENGTH = 15;
/** Sets the name of the caller thread with compile-time size checking.
@tparam N The size of the string literal including null terminator
@@ -34,7 +34,7 @@ template <std::size_t N>
void
setCurrentThreadName(char const (&newThreadName)[N])
{
static_assert(N <= maxThreadNameLength + 1, "Thread name cannot exceed 15 characters");
static_assert(N <= kMAX_THREAD_NAME_LENGTH + 1, "Thread name cannot exceed 15 characters");
setCurrentThreadName(std::string_view(newThreadName, N - 1));
}

View File

@@ -45,8 +45,8 @@ class ListNode
template <typename>
friend class ListIterator;
ListNode* m_next_ = nullptr;
ListNode* m_prev_ = nullptr;
ListNode* next_ = nullptr;
ListNode* prev_ = nullptr;
};
//------------------------------------------------------------------------------
@@ -62,12 +62,12 @@ public:
using reference = value_type&;
using size_type = std::size_t;
ListIterator(N* node = nullptr) noexcept : m_node_(node)
ListIterator(N* node = nullptr) noexcept : node_(node)
{
}
template <typename M>
ListIterator(ListIterator<M> const& other) noexcept : m_node_(other.m_node)
ListIterator(ListIterator<M> const& other) noexcept : node_(other.node_)
{
}
@@ -75,7 +75,7 @@ public:
bool
operator==(ListIterator<M> const& other) const noexcept
{
return m_node_ == other.m_node;
return node_ == other.node_;
}
template <typename M>
@@ -131,22 +131,22 @@ private:
[[nodiscard]] reference
dereference() const noexcept
{
return static_cast<reference>(*m_node_);
return static_cast<reference>(*node_);
}
void
increment() noexcept
{
m_node_ = m_node_->m_next;
node_ = node_->next_;
}
void
decrement() noexcept
{
m_node_ = m_node_->m_prev;
node_ = node_->prev_;
}
N* m_node_;
N* node_;
};
} // namespace detail
@@ -161,11 +161,11 @@ private:
struct Object : List <Object>::Node
{
explicit Object (int value) : m_value (value)
explicit Object (int value) : value_ (value)
{
}
int m_value;
int value_;
};
@endcode
@@ -190,7 +190,7 @@ private:
@code
for (List <Object>::iterator iter = list.begin(); iter != list.end; ++iter)
std::cout << iter->m_value;
std::cout << iter->value_;
@endcode
@@ -199,10 +199,10 @@ private:
@code
BOOST_FOREACH (Object& object, list) // boost only
std::cout << object.m_value;
std::cout << object.value_;
for (Object& object : list) // C++11 only
std::cout << object.m_value;
std::cout << object.value_;
@endcode
@@ -275,8 +275,8 @@ public:
/** Create an empty list. */
List()
{
m_head_.m_prev = nullptr; // identifies the head
m_tail_.m_next = nullptr; // identifies the tail
head_.prev_ = nullptr; // identifies the head
tail_.next_ = nullptr; // identifies the tail
clear();
}
@@ -297,7 +297,7 @@ public:
[[nodiscard]] size_type
size() const noexcept
{
return m_size_;
return size_;
}
/** Obtain a reference to the first element.
@@ -307,7 +307,7 @@ public:
reference
front() noexcept
{
return element_from(m_head_.m_next);
return element_from(head_.next_);
}
/** Obtain a const reference to the first element.
@@ -317,7 +317,7 @@ public:
[[nodiscard]] const_reference
front() const noexcept
{
return element_from(m_head_.m_next);
return element_from(head_.next_);
}
/** Obtain a reference to the last element.
@@ -327,7 +327,7 @@ public:
reference
back() noexcept
{
return element_from(m_tail_.m_prev);
return element_from(tail_.prev_);
}
/** Obtain a const reference to the last element.
@@ -337,7 +337,7 @@ public:
[[nodiscard]] const_reference
back() const noexcept
{
return element_from(m_tail_.m_prev);
return element_from(tail_.prev_);
}
/** Obtain an iterator to the beginning of the list.
@@ -346,7 +346,7 @@ public:
iterator
begin() noexcept
{
return iterator(m_head_.m_next);
return iterator(head_.next_);
}
/** Obtain a const iterator to the beginning of the list.
@@ -355,7 +355,7 @@ public:
[[nodiscard]] const_iterator
begin() const noexcept
{
return const_iterator(m_head_.m_next);
return const_iterator(head_.next_);
}
/** Obtain a const iterator to the beginning of the list.
@@ -364,7 +364,7 @@ public:
[[nodiscard]] const_iterator
cbegin() const noexcept
{
return const_iterator(m_head_.m_next);
return const_iterator(head_.next_);
}
/** Obtain a iterator to the end of the list.
@@ -373,7 +373,7 @@ public:
iterator
end() noexcept
{
return iterator(&m_tail_);
return iterator(&tail_);
}
/** Obtain a const iterator to the end of the list.
@@ -382,7 +382,7 @@ public:
[[nodiscard]] const_iterator
end() const noexcept
{
return const_iterator(&m_tail_);
return const_iterator(&tail_);
}
/** Obtain a const iterator to the end of the list
@@ -391,7 +391,7 @@ public:
[[nodiscard]] const_iterator
cend() const noexcept
{
return const_iterator(&m_tail_);
return const_iterator(&tail_);
}
/** Clear the list.
@@ -400,9 +400,9 @@ public:
void
clear() noexcept
{
m_head_.m_next = &m_tail_;
m_tail_.m_prev = &m_head_;
m_size_ = 0;
head_.next_ = &tail_;
tail_.prev_ = &head_;
size_ = 0;
}
/** Insert an element.
@@ -415,11 +415,11 @@ public:
insert(iterator pos, T& element) noexcept
{
Node* node = static_cast<Node*>(&element);
node->m_next = &*pos;
node->m_prev = node->m_next->m_prev;
node->m_next->m_prev = node;
node->m_prev->m_next = node;
++m_size_;
node->next_ = &*pos;
node->prev_ = node->next_->prev_;
node->next_->prev_ = node;
node->prev_->next_ = node;
++size_;
return iterator(node);
}
@@ -434,11 +434,11 @@ public:
if (!other.empty())
{
Node* before = &*pos;
other.m_head_.m_next->m_prev = before->m_prev;
before->m_prev->m_next = other.m_head_.m_next;
other.m_tail_.m_prev->m_next = before;
before->m_prev = other.m_tail_.m_prev;
m_size_ += other.m_size_;
other.head_.next_->prev_ = before->prev_;
before->prev_->next_ = other.head_.next_;
other.tail_.prev_->next_ = before;
before->prev_ = other.tail_.prev_;
size_ += other.size_;
other.clear();
}
}
@@ -453,9 +453,9 @@ public:
{
Node const* node = &*pos;
++pos;
node->m_next->m_prev = node->m_prev;
node->m_prev->m_next = node->m_next;
--m_size_;
node->next_->prev_ = node->prev_;
node->prev_->next_ = node->next_;
--size_;
return pos;
}
@@ -569,9 +569,9 @@ private:
}
private:
size_type m_size_ = 0u;
Node m_head_;
Node m_tail_;
size_type size_ = 0u;
Node head_;
Node tail_;
};
} // namespace beast

View File

@@ -26,27 +26,27 @@ public:
LockFreeStackIterator() = default;
LockFreeStackIterator(NodePtr node) : m_node_(node)
LockFreeStackIterator(NodePtr node) : node_(node)
{
}
template <bool OtherIsConst>
explicit LockFreeStackIterator(LockFreeStackIterator<Container, OtherIsConst> const& other)
: m_node_(other.m_node)
: node_(other.node_)
{
}
LockFreeStackIterator&
operator=(NodePtr node)
{
m_node_ = node;
node_ = node;
return static_cast<LockFreeStackIterator&>(*this);
}
LockFreeStackIterator&
operator++()
{
m_node_ = m_node_->m_next.load();
node_ = node_->next_.load();
return static_cast<LockFreeStackIterator&>(*this);
}
@@ -54,14 +54,14 @@ public:
operator++(int)
{
LockFreeStackIterator result(*this);
m_node_ = m_node_->m_next;
node_ = node_->next_;
return result;
}
NodePtr
node() const
{
return m_node_;
return node_;
}
reference
@@ -73,11 +73,11 @@ public:
pointer
operator->() const
{
return static_cast<pointer>(m_node_);
return static_cast<pointer>(node_);
}
private:
NodePtr m_node_{};
NodePtr node_{};
};
//------------------------------------------------------------------------------
@@ -121,11 +121,11 @@ public:
class Node
{
public:
Node() : m_next_(nullptr)
Node() : next_(nullptr)
{
}
explicit Node(Node* next) : m_next_(next)
explicit Node(Node* next) : next_(next)
{
}
@@ -139,7 +139,7 @@ public:
template <class Container, bool IsConst>
friend class LockFreeStackIterator;
std::atomic<Node*> m_next_;
std::atomic<Node*> next_;
};
public:
@@ -153,7 +153,7 @@ public:
using iterator = LockFreeStackIterator<LockFreeStack<Element, Tag>, false>;
using const_iterator = LockFreeStackIterator<LockFreeStack<Element, Tag>, true>;
LockFreeStack() : m_end_(nullptr), m_head_(&m_end_)
LockFreeStack() : end_(nullptr), head_(&end_)
{
}
@@ -165,7 +165,7 @@ public:
[[nodiscard]] bool
empty() const
{
return m_head_.load() == &m_end_;
return head_.load() == &end_;
}
/** Push a node onto the stack.
@@ -184,12 +184,12 @@ public:
pushFront(Node* node)
{
bool first = false;
Node* oldHead = m_head_.load(std::memory_order_relaxed);
Node* oldHead = head_.load(std::memory_order_relaxed);
do
{
first = (oldHead == &m_end_);
node->m_next_ = oldHead;
} while (!m_head_.compare_exchange_strong(
first = (oldHead == &end_);
node->next_ = oldHead;
} while (!head_.compare_exchange_strong(
oldHead, node, std::memory_order_release, std::memory_order_relaxed));
return first;
}
@@ -206,14 +206,14 @@ public:
Element*
popFront()
{
Node* node = m_head_.load();
Node* node = head_.load();
Node* newHead = nullptr;
do
{
if (node == &m_end_)
if (node == &end_)
return nullptr;
newHead = node->m_next_.load();
} while (!m_head_.compare_exchange_strong(
newHead = node->next_.load();
} while (!head_.compare_exchange_strong(
node, newHead, std::memory_order_release, std::memory_order_relaxed));
return static_cast<Element*>(node);
}
@@ -228,43 +228,43 @@ public:
iterator
begin()
{
return iterator(m_head_.load());
return iterator(head_.load());
}
iterator
end()
{
return iterator(&m_end_);
return iterator(&end_);
}
[[nodiscard]] const_iterator
begin() const
{
return const_iterator(m_head_.load());
return const_iterator(head_.load());
}
[[nodiscard]] const_iterator
end() const
{
return const_iterator(&m_end_);
return const_iterator(&end_);
}
[[nodiscard]] const_iterator
cbegin() const
{
return const_iterator(m_head_.load());
return const_iterator(head_.load());
}
[[nodiscard]] const_iterator
cend() const
{
return const_iterator(&m_end_);
return const_iterator(&end_);
}
/** @} */
private:
Node m_end_;
std::atomic<Node*> m_head_;
Node end_;
std::atomic<Node*> head_;
};
} // namespace beast

View File

@@ -24,7 +24,7 @@ namespace detail {
template <class T>
/*constexpr*/
inline void
reverse_bytes(T& t)
reverseBytes(T& t)
{
unsigned char* bytes =
static_cast<unsigned char*>(std::memmove(std::addressof(t), std::addressof(t), sizeof(T)));
@@ -35,14 +35,14 @@ reverse_bytes(T& t)
template <class T>
/*constexpr*/
inline void
maybe_reverse_bytes(T& t, std::false_type)
maybeReverseBytes(T& t, std::false_type)
{
}
template <class T>
/*constexpr*/
inline void
maybe_reverse_bytes(T& t, std::true_type)
maybeReverseBytes(T& t, std::true_type)
{
reverse_bytes(t);
}
@@ -50,15 +50,15 @@ maybe_reverse_bytes(T& t, std::true_type)
template <class T, class Hasher>
/*constexpr*/
inline void
maybe_reverse_bytes(T& t, Hasher&)
maybeReverseBytes(T& t, Hasher&)
{
maybe_reverse_bytes(
t, std::integral_constant<bool, Hasher::endian != boost::endian::order::native>{});
maybeReverseBytes(
t, std::integral_constant<bool, Hasher::kENDIAN != boost::endian::order::native>{});
}
} // namespace detail
// is_uniquely_represented<T>
// IsUniquelyRepresented<T>
// A type T is contiguously hashable if for all combinations of two values of
// a type, say x and y, if x == y, then it must also be true that
@@ -75,69 +75,69 @@ struct IsUniquelyRepresented
};
template <class T>
struct is_uniquely_represented<T const> : public IsUniquelyRepresented<T>
struct IsUniquelyRepresented<T const> : public IsUniquelyRepresented<T>
{
explicit is_uniquely_represented() = default;
explicit IsUniquelyRepresented() = default;
};
template <class T>
struct is_uniquely_represented<T volatile> : public IsUniquelyRepresented<T>
struct IsUniquelyRepresented<T volatile> : public IsUniquelyRepresented<T>
{
explicit is_uniquely_represented() = default;
explicit IsUniquelyRepresented() = default;
};
template <class T>
struct is_uniquely_represented<T const volatile> : public IsUniquelyRepresented<T>
struct IsUniquelyRepresented<T const volatile> : public IsUniquelyRepresented<T>
{
explicit is_uniquely_represented() = default;
explicit IsUniquelyRepresented() = default;
};
// is_uniquely_represented<std::pair<T, U>>
// IsUniquelyRepresented<std::pair<T, U>>
template <class T, class U>
struct is_uniquely_represented<std::pair<T, U>>
struct IsUniquelyRepresented<std::pair<T, U>>
: public std::integral_constant<
bool,
IsUniquelyRepresented<T>::value && IsUniquelyRepresented<U>::value &&
sizeof(T) + sizeof(U) == sizeof(std::pair<T, U>)>
{
explicit is_uniquely_represented() = default;
explicit IsUniquelyRepresented() = default;
};
// is_uniquely_represented<std::tuple<T...>>
// IsUniquelyRepresented<std::tuple<T...>>
template <class... T>
struct is_uniquely_represented<std::tuple<T...>>
struct IsUniquelyRepresented<std::tuple<T...>>
: public std::integral_constant<
bool,
std::conjunction_v<IsUniquelyRepresented<T>...> &&
sizeof(std::tuple<T...>) == (sizeof(T) + ...)>
{
explicit is_uniquely_represented() = default;
explicit IsUniquelyRepresented() = default;
};
// is_uniquely_represented<T[N]>
// IsUniquelyRepresented<T[N]>
template <class T, std::size_t N>
struct is_uniquely_represented<T[N]> : public IsUniquelyRepresented<T>
struct IsUniquelyRepresented<T[N]> : public IsUniquelyRepresented<T>
{
explicit is_uniquely_represented() = default;
explicit IsUniquelyRepresented() = default;
};
// is_uniquely_represented<std::array<T, N>>
// IsUniquelyRepresented<std::array<T, N>>
template <class T, std::size_t N>
struct is_uniquely_represented<std::array<T, N>>
struct IsUniquelyRepresented<std::array<T, N>>
: public std::integral_constant<
bool,
IsUniquelyRepresented<T>::value && sizeof(T) * N == sizeof(std::array<T, N>)>
{
explicit is_uniquely_represented() = default;
explicit IsUniquelyRepresented() = default;
};
/** Metafunction returning `true` if the type can be hashed in one call.
For `is_contiguously_hashable<T>::value` to be true, then for every
For `IsContiguouslyHashable<T>::value` to be true, then for every
combination of possible values of `T` held in `x` and `y`,
if `x == y`, then it must be true that `memcmp(&x, &y, sizeof(T))`
return 0; i.e. that `x` and `y` are represented by the same bit pattern.
@@ -160,13 +160,13 @@ struct IsContiguouslyHashable
};
template <class T, std::size_t N, class HashAlgorithm>
struct is_contiguously_hashable<T[N], HashAlgorithm>
struct IsContiguouslyHashable<T[N], HashAlgorithm>
: public std::integral_constant<
bool,
IsUniquelyRepresented<T[N]>::value &&
(sizeof(T) == 1 || HashAlgorithm::endian == boost::endian::order::native)>
{
explicit is_contiguously_hashable() = default;
explicit IsContiguouslyHashable() = default;
};
/** @} */
@@ -213,7 +213,7 @@ inline std::enable_if_t<
(std::is_integral_v<T> || std::is_pointer_v<T> || std::is_enum_v<T>)>
hash_append(Hasher& h, T t) noexcept
{
detail::reverse_bytes(t);
detail::reverseBytes(t);
h(std::addressof(t), sizeof(t));
}
@@ -223,7 +223,7 @@ hash_append(Hasher& h, T t) noexcept
{
if (t == 0)
t = 0;
detail::maybe_reverse_bytes(t, h);
detail::maybeReverseBytes(t, h);
h(&t, sizeof(t));
}
@@ -232,7 +232,7 @@ inline void
hash_append(Hasher& h, std::nullptr_t) noexcept
{
void const* p = nullptr;
detail::maybe_reverse_bytes(p, h);
detail::maybeReverseBytes(p, h);
h(&p, sizeof(p));
}
@@ -373,13 +373,13 @@ hash_append(Hasher& h, boost::container::flat_set<Key, Compare, Alloc> const& v)
namespace detail {
inline void
for_each_item(...) noexcept
forEachItem(...) noexcept
{
}
template <class Hasher, class T>
inline int
hash_one(Hasher& h, T const& t) noexcept
hashOne(Hasher& h, T const& t) noexcept
{
hash_append(h, t);
return 0;

View File

@@ -29,7 +29,7 @@ public:
factory function in the Collector interface.
@see Collector.
*/
explicit Counter(std::shared_ptr<CounterImpl> const& impl) : m_impl_(impl)
explicit Counter(std::shared_ptr<CounterImpl> const& impl) : impl_(impl)
{
}
@@ -38,8 +38,8 @@ public:
void
increment(value_type amount) const
{
if (m_impl_)
m_impl_->increment(amount);
if (impl_)
impl_->increment(amount);
}
Counter const&
@@ -85,7 +85,7 @@ public:
}
private:
std::shared_ptr<CounterImpl> m_impl_;
std::shared_ptr<CounterImpl> impl_;
};
} // namespace beast::insight

View File

@@ -31,7 +31,7 @@ public:
factory function in the Collector interface.
@see Collector.
*/
explicit Event(std::shared_ptr<EventImpl> const& impl) : m_impl_(impl)
explicit Event(std::shared_ptr<EventImpl> const& impl) : impl_(impl)
{
}
@@ -41,18 +41,18 @@ public:
notify(std::chrono::duration<Rep, Period> const& value) const
{
using namespace std::chrono;
if (m_impl_)
m_impl_->notify(ceil<value_type>(value));
if (impl_)
impl_->notify(ceil<value_type>(value));
}
[[nodiscard]] std::shared_ptr<EventImpl> const&
impl() const
{
return m_impl_;
return impl_;
}
private:
std::shared_ptr<EventImpl> m_impl_;
std::shared_ptr<EventImpl> impl_;
};
} // namespace beast::insight

View File

@@ -31,7 +31,7 @@ public:
factory function in the Collector interface.
@see Collector.
*/
explicit Gauge(std::shared_ptr<GaugeImpl> const& impl) : m_impl_(impl)
explicit Gauge(std::shared_ptr<GaugeImpl> const& impl) : impl_(impl)
{
}
@@ -44,8 +44,8 @@ public:
void
set(value_type value) const
{
if (m_impl_)
m_impl_->set(value);
if (impl_)
impl_->set(value);
}
Gauge const&
@@ -61,8 +61,8 @@ public:
void
increment(difference_type amount) const
{
if (m_impl_)
m_impl_->increment(amount);
if (impl_)
impl_->increment(amount);
}
Gauge const&
@@ -111,11 +111,11 @@ public:
[[nodiscard]] std::shared_ptr<GaugeImpl> const&
impl() const
{
return m_impl_;
return impl_;
}
private:
std::shared_ptr<GaugeImpl> m_impl_;
std::shared_ptr<GaugeImpl> impl_;
};
} // namespace beast::insight

View File

@@ -29,6 +29,6 @@ public:
/** Create a group container that uses the specified collector. */
std::unique_ptr<Groups>
make_Groups(Collector::ptr const& collector);
makeGroups(Collector::ptr const& collector);
} // namespace beast::insight

View File

@@ -20,18 +20,18 @@ public:
factory function in the Collector interface.
@see Collector.
*/
explicit Hook(std::shared_ptr<HookImpl> const& impl) : m_impl_(impl)
explicit Hook(std::shared_ptr<HookImpl> const& impl) : impl_(impl)
{
}
[[nodiscard]] std::shared_ptr<HookImpl> const&
impl() const
{
return m_impl_;
return impl_;
}
private:
std::shared_ptr<HookImpl> m_impl_;
std::shared_ptr<HookImpl> impl_;
};
} // namespace beast::insight

View File

@@ -28,7 +28,7 @@ public:
factory function in the Collector interface.
@see Collector.
*/
explicit Meter(std::shared_ptr<MeterImpl> const& impl) : m_impl_(impl)
explicit Meter(std::shared_ptr<MeterImpl> const& impl) : impl_(impl)
{
}
@@ -37,8 +37,8 @@ public:
void
increment(value_type amount) const
{
if (m_impl_)
m_impl_->increment(amount);
if (impl_)
impl_->increment(amount);
}
Meter const&
@@ -66,11 +66,11 @@ public:
[[nodiscard]] std::shared_ptr<MeterImpl> const&
impl() const
{
return m_impl_;
return impl_;
}
private:
std::shared_ptr<MeterImpl> m_impl_;
std::shared_ptr<MeterImpl> impl_;
};
} // namespace beast::insight

View File

@@ -11,7 +11,7 @@ public:
explicit NullCollector() = default;
static std::shared_ptr<Collector>
New();
make();
};
} // namespace beast::insight

View File

@@ -21,7 +21,7 @@ public:
@param journal Destination for logging output.
*/
static std::shared_ptr<StatsDCollector>
New(IP::Endpoint const& address, std::string const& prefix, Journal journal);
make(IP::Endpoint const& address, std::string const& prefix, Journal journal);
};
} // namespace beast::insight

View File

@@ -27,37 +27,37 @@ to_string(Address const& addr)
/** Returns `true` if this is a loopback address. */
inline bool
is_loopback(Address const& addr)
isLoopback(Address const& addr)
{
return addr.is_loopback();
}
/** Returns `true` if the address is unspecified. */
inline bool
is_unspecified(Address const& addr)
isUnspecified(Address const& addr)
{
return addr.is_unspecified();
}
/** Returns `true` if the address is a multicast address. */
inline bool
is_multicast(Address const& addr)
isMulticast(Address const& addr)
{
return addr.is_multicast();
}
/** Returns `true` if the address is a private unroutable address. */
inline bool
is_private(Address const& addr)
isPrivate(Address const& addr)
{
return (addr.is_v4()) ? is_private(addr.to_v4()) : is_private(addr.to_v6());
return (addr.is_v4()) ? isPrivate(addr.to_v4()) : isPrivate(addr.to_v6());
}
/** Returns `true` if the address is a public routable address. */
inline bool
is_public(Address const& addr)
isPublic(Address const& addr)
{
return (addr.is_v4()) ? is_public(addr.to_v4()) : is_public(addr.to_v6());
return (addr.is_v4()) ? isPublic(addr.to_v4()) : isPublic(addr.to_v6());
}
} // namespace IP

View File

@@ -10,21 +10,21 @@ namespace beast::IP {
The port is set to zero.
*/
Endpoint
from_asio(boost::asio::ip::address const& address);
fromAsio(boost::asio::ip::address const& address);
/** Convert to Endpoint. */
Endpoint
from_asio(boost::asio::ip::tcp::endpoint const& endpoint);
fromAsio(boost::asio::ip::tcp::endpoint const& endpoint);
/** Convert to asio::ip::address.
The port is ignored.
*/
boost::asio::ip::address
to_asio_address(Endpoint const& endpoint);
toAsioAddress(Endpoint const& endpoint);
/** Convert to asio::ip::tcp::endpoint. */
boost::asio::ip::tcp::endpoint
to_asio_endpoint(Endpoint const& endpoint);
toAsioEndpoint(Endpoint const& endpoint);
} // namespace beast::IP
@@ -36,24 +36,24 @@ struct IPAddressConversion
explicit IPAddressConversion() = default;
static IP::Endpoint
from_asio(boost::asio::ip::address const& address)
fromAsio(boost::asio::ip::address const& address)
{
return IP::from_asio(address);
return IP::fromAsio(address);
}
static IP::Endpoint
from_asio(boost::asio::ip::tcp::endpoint const& endpoint)
fromAsio(boost::asio::ip::tcp::endpoint const& endpoint)
{
return IP::from_asio(endpoint);
return IP::fromAsio(endpoint);
}
static boost::asio::ip::address
to_asio_address(IP::Endpoint const& address)
toAsioAddress(IP::Endpoint const& address)
{
return IP::to_asio_address(address);
return IP::toAsioAddress(address);
}
static boost::asio::ip::tcp::endpoint
to_asio_endpoint(IP::Endpoint const& address)
toAsioEndpoint(IP::Endpoint const& address)
{
return IP::to_asio_endpoint(address);
return IP::toAsioEndpoint(address);
}
};

View File

@@ -10,16 +10,16 @@ using AddressV4 = boost::asio::ip::address_v4;
/** Returns `true` if the address is a private unroutable address. */
bool
is_private(AddressV4 const& addr);
isPrivate(AddressV4 const& addr);
/** Returns `true` if the address is a public routable address. */
bool
is_public(AddressV4 const& addr);
isPublic(AddressV4 const& addr);
/** Returns the address class for the given address.
@note Class 'D' represents multicast addresses (224.*.*.*).
*/
char
get_class(AddressV4 const& address);
getClass(AddressV4 const& address);
} // namespace beast::IP

View File

@@ -10,10 +10,10 @@ using AddressV6 = boost::asio::ip::address_v6;
/** Returns `true` if the address is a private unroutable address. */
bool
is_private(AddressV6 const& addr);
isPrivate(AddressV6 const& addr);
/** Returns `true` if the address is a public routable address. */
bool
is_public(AddressV6 const& addr);
isPublic(AddressV6 const& addr);
} // namespace beast::IP

View File

@@ -39,21 +39,21 @@ public:
[[nodiscard]] Port
port() const
{
return m_port_;
return port_;
}
/** Returns a new Endpoint with a different port. */
[[nodiscard]] Endpoint
atPort(Port port) const
{
return Endpoint(m_addr_, port);
return Endpoint(addr_, port);
}
/** Returns the address portion of this endpoint. */
[[nodiscard]] Address const&
address() const
{
return m_addr_;
return addr_;
}
/** Convenience accessors for the address part. */
@@ -61,22 +61,22 @@ public:
[[nodiscard]] bool
isV4() const
{
return m_addr_.is_v4();
return addr_.is_v4();
}
[[nodiscard]] bool
isV6() const
{
return m_addr_.is_v6();
return addr_.is_v6();
}
[[nodiscard]] AddressV4
toV4() const
{
return m_addr_.to_v4();
return addr_.to_v4();
}
[[nodiscard]] AddressV6
toV6() const
{
return m_addr_.to_v6();
return addr_.to_v6();
}
/** @} */
@@ -114,12 +114,12 @@ public:
hash_append(Hasher& h, Endpoint const& endpoint)
{
using ::beast::hash_append;
hash_append(h, endpoint.m_addr_, endpoint.m_port_);
hash_append(h, endpoint.addr_, endpoint.port_);
}
private:
Address m_addr_;
Port m_port_;
Address addr_;
Port port_;
};
//------------------------------------------------------------------------------
@@ -128,37 +128,37 @@ private:
/** Returns `true` if the endpoint is a loopback address. */
inline bool
is_loopback(Endpoint const& endpoint)
isLoopback(Endpoint const& endpoint)
{
return is_loopback(endpoint.address());
return isLoopback(endpoint.address());
}
/** Returns `true` if the endpoint is unspecified. */
inline bool
is_unspecified(Endpoint const& endpoint)
isUnspecified(Endpoint const& endpoint)
{
return is_unspecified(endpoint.address());
return isUnspecified(endpoint.address());
}
/** Returns `true` if the endpoint is a multicast address. */
inline bool
is_multicast(Endpoint const& endpoint)
isMulticast(Endpoint const& endpoint)
{
return is_multicast(endpoint.address());
return isMulticast(endpoint.address());
}
/** Returns `true` if the endpoint is a private unroutable address. */
inline bool
is_private(Endpoint const& endpoint)
isPrivate(Endpoint const& endpoint)
{
return is_private(endpoint.address());
return isPrivate(endpoint.address());
}
/** Returns `true` if the endpoint is a public routable address. */
inline bool
is_public(Endpoint const& endpoint)
isPublic(Endpoint const& endpoint)
{
return is_public(endpoint.address());
return isPublic(endpoint.address());
}
//------------------------------------------------------------------------------

View File

@@ -16,9 +16,9 @@ namespace beast::rfc2616 {
namespace detail {
struct ci_equal_pred
struct CiEqualPred
{
explicit ci_equal_pred() = default;
explicit CiEqualPred() = default;
bool
operator()(char c1, char c2)
@@ -34,14 +34,14 @@ struct ci_equal_pred
This excludes the CRLF sequence allowed for line continuations.
*/
inline bool
is_lws(char c)
isLws(char c)
{
return c == ' ' || c == '\t';
}
/** Returns `true` if `c` is any whitespace character. */
inline bool
is_white(char c)
isWhite(char c)
{
switch (c)
{
@@ -59,14 +59,14 @@ is_white(char c)
template <class FwdIter>
FwdIter
trim_right(FwdIter first, FwdIter last)
trimRight(FwdIter first, FwdIter last)
{
if (first == last)
return last;
do
{
--last;
if (!is_white(*last))
if (!isWhite(*last))
return ++last;
} while (last != first);
return first;
@@ -74,13 +74,13 @@ trim_right(FwdIter first, FwdIter last)
template <class String>
String
trim_right(String const& s)
trimRight(String const& s)
{
using std::begin;
using std::end;
auto first(begin(s));
auto last(end(s));
last = trim_right(first, last);
last = trimRight(first, last);
return {first, last};
}
@@ -143,7 +143,7 @@ split(FwdIt first, FwdIt last, Char delim)
}
else if (*iter == delim)
{
e = trim_right(e);
e = trimRight(e);
if (!e.empty())
{
result.emplace_back(std::move(e));
@@ -151,7 +151,7 @@ split(FwdIt first, FwdIt last, Char delim)
}
++iter;
}
else if (is_lws(*iter))
else if (isLws(*iter))
{
++iter;
}
@@ -163,7 +163,7 @@ split(FwdIt first, FwdIt last, Char delim)
if (!e.empty())
{
e = trim_right(e);
e = trimRight(e);
if (!e.empty())
result.emplace_back(std::move(e));
}
@@ -174,16 +174,16 @@ template <
class FwdIt,
class Result = std::vector<std::basic_string<typename std::iterator_traits<FwdIt>::value_type>>>
Result
split_commas(FwdIt first, FwdIt last)
splitCommas(FwdIt first, FwdIt last)
{
return split(first, last, ',');
}
template <class Result = std::vector<std::string>>
Result
split_commas(boost::beast::string_view const& s)
splitCommas(boost::beast::string_view const& s)
{
return split_commas(s.begin(), s.end());
return splitCommas(s.begin(), s.end());
}
//------------------------------------------------------------------------------
@@ -196,7 +196,7 @@ split_commas(boost::beast::string_view const& s)
@note Values returned may contain backslash escapes.
*/
class list_iterator
class ListIterator
{
using iter_type = boost::string_ref::const_iterator;
@@ -211,20 +211,20 @@ public:
using difference_type = std::ptrdiff_t;
using iterator_category = std::forward_iterator_tag;
list_iterator(iter_type begin, iter_type end) : it_(begin), end_(end)
ListIterator(iter_type begin, iter_type end) : it_(begin), end_(end)
{
if (it_ != end_)
increment();
}
bool
operator==(list_iterator const& other) const
operator==(ListIterator const& other) const
{
return other.it_ == it_ && other.end_ == end_ && other.value_.size() == value_.size();
}
bool
operator!=(list_iterator const& other) const
operator!=(ListIterator const& other) const
{
return !(*this == other);
}
@@ -241,14 +241,14 @@ public:
return &*(*this);
}
list_iterator&
ListIterator&
operator++()
{
increment();
return *this;
}
list_iterator
ListIterator
operator++(int)
{
auto temp = *this;
@@ -264,7 +264,7 @@ private:
template <class>
void
list_iterator::increment()
ListIterator::increment()
{
using namespace detail;
value_.clear();
@@ -302,7 +302,7 @@ list_iterator::increment()
it_++;
continue;
}
else if (is_lws(*it_))
else if (isLws(*it_))
{
++it_;
continue;
@@ -313,7 +313,7 @@ list_iterator::increment()
for (;;)
{
++it_;
if (it_ == end_ || *it_ == ',' || is_lws(*it_))
if (it_ == end_ || *it_ == ',' || isLws(*it_))
{
value_ = boost::string_ref(&*start, std::distance(start, it_));
return;
@@ -327,17 +327,17 @@ list_iterator::increment()
A case-insensitive comparison is used.
*/
inline bool
ci_equal(boost::string_ref s1, boost::string_ref s2)
ciEqual(boost::string_ref s1, boost::string_ref s2)
{
return boost::range::equal(s1, s2, detail::ci_equal_pred{});
return boost::range::equal(s1, s2, detail::CiEqualPred{});
}
/** Returns a range representing the list. */
inline boost::iterator_range<list_iterator>
make_list(boost::string_ref const& field)
inline boost::iterator_range<ListIterator>
makeList(boost::string_ref const& field)
{
return boost::iterator_range<list_iterator>{
list_iterator{field.begin(), field.end()}, list_iterator{field.end(), field.end()}};
return boost::iterator_range<ListIterator>{
ListIterator{field.begin(), field.end()}, ListIterator{field.end(), field.end()}};
}
/** Returns true if the specified token exists in the list.
@@ -346,19 +346,19 @@ make_list(boost::string_ref const& field)
*/
template <class = void>
bool
token_in_list(boost::string_ref const& value, boost::string_ref const& token)
tokenInList(boost::string_ref const& value, boost::string_ref const& token)
{
for (auto const& item : make_list(value))
for (auto const& item : makeList(value))
{
if (ci_equal(item, token))
if (ciEqual(item, token))
return true;
}
return false;
}
template <bool isRequest, class Body, class Fields>
template <bool IsRequest, class Body, class Fields>
bool
is_keep_alive(boost::beast::http::message<isRequest, Body, Fields> const& m)
isKeepAlive(boost::beast::http::message<IsRequest, Body, Fields> const& m)
{
if (m.version() <= 10)
{

View File

@@ -23,7 +23,7 @@ namespace beast::test {
functions inside coroutines. This is handy for testing
asynchronous asio code.
*/
class enable_yield_to
class EnableYieldTo
{
protected:
boost::asio::io_context ios_;
@@ -39,8 +39,7 @@ public:
/// The type of yield context passed to functions.
using yield_context = boost::asio::yield_context;
explicit enable_yield_to(std::size_t concurrency = 1)
: work_(boost::asio::make_work_guard(ios_))
explicit EnableYieldTo(std::size_t concurrency = 1) : work_(boost::asio::make_work_guard(ios_))
{
threads_.reserve(concurrency);
for (std::size_t i = 0; i < concurrency; ++i)
@@ -49,7 +48,7 @@ public:
}
}
~enable_yield_to()
~EnableYieldTo()
{
work_ = boost::none;
for (auto& t : threads_)
@@ -58,7 +57,7 @@ public:
/// Return the `io_context` associated with the object
boost::asio::io_context&
get_io_context()
getIoContext()
{
return ios_;
}
@@ -81,7 +80,7 @@ public:
#else
template <class F0, class... FN>
void
yield_to(F0&& f0, FN&&... fn);
yieldTo(F0&& f0, FN&&... fn);
#endif
private:
@@ -97,7 +96,7 @@ private:
template <class F0, class... FN>
void
enable_yield_to::yield_to(F0&& f0, FN&&... fn)
EnableYieldTo::yieldTo(F0&& f0, FN&&... fn)
{
running_ = 1 + sizeof...(FN);
spawn(f0, fn...);
@@ -107,7 +106,7 @@ enable_yield_to::yield_to(F0&& f0, FN&&... fn)
template <class F0, class... FN>
inline void
enable_yield_to::spawn(F0&& f, FN&&... fn)
EnableYieldTo::spawn(F0&& f, FN&&... fn)
{
boost::asio::spawn(
ios_,

View File

@@ -13,7 +13,7 @@ namespace beast {
template <typename T>
std::string
type_name()
typeName()
{
using TR = std::remove_reference_t<T>;

View File

@@ -16,19 +16,19 @@ class ConstContainer
private:
using cont_type = Container;
cont_type m_cont_;
cont_type cont_;
protected:
cont_type&
cont()
{
return m_cont_;
return cont_;
}
[[nodiscard]] cont_type const&
cont() const
{
return m_cont_;
return cont_;
}
public:
@@ -42,14 +42,14 @@ public:
[[nodiscard]] bool
empty() const
{
return m_cont_.empty();
return cont_.empty();
}
/** Returns the number of items in the container. */
[[nodiscard]] size_type
size() const
{
return m_cont_.size();
return cont_.size();
}
/** Returns forward iterators for traversal. */
@@ -57,25 +57,25 @@ public:
[[nodiscard]] const_iterator
begin() const
{
return m_cont_.cbegin();
return cont_.cbegin();
}
[[nodiscard]] const_iterator
cbegin() const
{
return m_cont_.cbegin();
return cont_.cbegin();
}
[[nodiscard]] const_iterator
end() const
{
return m_cont_.cend();
return cont_.cend();
}
[[nodiscard]] const_iterator
cend() const
{
return m_cont_.cend();
return cont_.cend();
}
/** @} */
};

View File

@@ -12,23 +12,23 @@ namespace detail {
/// Holds test suites registered during static initialization.
inline SuiteList&
global_suites()
globalSuites()
{
static SuiteList kS;
return kS;
}
template <class Suite>
struct insert_suite
struct InsertSuite
{
insert_suite(
InsertSuite(
char const* name,
char const* module,
char const* library,
bool manual,
int priority)
{
global_suites().insert<Suite>(name, module, library, manual, priority);
globalSuites().insert<Suite>(name, module, library, manual, priority);
}
};
@@ -36,9 +36,9 @@ struct insert_suite
/// Holds test suites registered during static initialization.
inline SuiteList const&
global_suites()
globalSuites()
{
return detail::global_suites();
return detail::globalSuites();
}
} // namespace beast::unit_test

View File

@@ -122,7 +122,7 @@ Selector::operator()(SuiteInfo const& s)
/** Returns a predicate that implements a smart matching rule.
The predicate checks the suite, module, and library fields of the
suite_info in that order. When it finds a match, it changes modes
SuiteInfo in that order. When it finds a match, it changes modes
depending on what was found:
If a suite is matched first, then only the suite is selected. The
@@ -136,28 +136,28 @@ Selector::operator()(SuiteInfo const& s)
*/
inline Selector
match_auto(std::string const& name)
matchAuto(std::string const& name)
{
return Selector(Selector::ModeT::Automatch, name);
}
/** Return a predicate that matches all suites not marked manual. */
inline Selector
match_all()
matchAll()
{
return Selector(Selector::ModeT::All);
}
/** Returns a predicate that matches a specific suite. */
inline Selector
match_suite(std::string const& name)
matchSuite(std::string const& name)
{
return Selector(Selector::ModeT::Suite, name);
}
/** Returns a predicate that matches all suites in a library. */
inline Selector
match_library(std::string const& name)
matchLibrary(std::string const& name)
{
return Selector(Selector::ModeT::Library, name);
}

View File

@@ -13,9 +13,9 @@ namespace beast::unit_test {
class Recorder : public Runner
{
private:
Results m_results_;
SuiteResults m_suite_;
CaseResults m_case_;
Results results_;
SuiteResults suite_;
CaseResults case_;
public:
Recorder() = default;
@@ -24,51 +24,51 @@ public:
[[nodiscard]] Results const&
report() const
{
return m_results_;
return results_;
}
private:
void
onSuiteBegin(SuiteInfo const& info) override
{
m_suite_ = SuiteResults(info.fullName());
suite_ = SuiteResults(info.fullName());
}
void
onSuiteEnd() override
{
m_results_.insert(std::move(m_suite_));
results_.insert(std::move(suite_));
}
void
onCaseBegin(std::string const& name) override
{
m_case_ = CaseResults(name);
case_ = CaseResults(name);
}
void
onCaseEnd() override
{
if (!m_case_.tests.empty())
m_suite_.insert(std::move(m_case_));
if (!case_.tests.empty())
suite_.insert(std::move(case_));
}
void
onPass() override
{
m_case_.tests.pass();
case_.tests.pass();
}
void
onFail(std::string const& reason) override
{
m_case_.tests.fail(reason);
case_.tests.fail(reason);
}
void
onLog(std::string const& s) override
{
m_case_.log.insert(s);
case_.log.insert(s);
}
};

View File

@@ -196,21 +196,21 @@ Reporter<Unused>::fmtdur(typename clock_type::duration const& d)
template <class Unused>
void
Reporter<Unused>::on_suite_begin(SuiteInfo const& info)
Reporter<Unused>::onSuiteBegin(SuiteInfo const& info)
{
suite_results_ = SuiteResults{info.fullName()};
}
template <class Unused>
void
Reporter<Unused>::on_suite_end()
Reporter<Unused>::onSuiteEnd()
{
results_.add(suite_results_);
}
template <class Unused>
void
Reporter<Unused>::on_case_begin(std::string const& name)
Reporter<Unused>::onCaseBegin(std::string const& name)
{
case_results_ = CaseResults(name);
os_ << suite_results_.name << (case_results_.name.empty() ? "" : (" " + case_results_.name))
@@ -219,21 +219,21 @@ Reporter<Unused>::on_case_begin(std::string const& name)
template <class Unused>
void
Reporter<Unused>::on_case_end()
Reporter<Unused>::onCaseEnd()
{
suite_results_.add(case_results_);
}
template <class Unused>
void
Reporter<Unused>::on_pass()
Reporter<Unused>::onPass()
{
++case_results_.total;
}
template <class Unused>
void
Reporter<Unused>::on_fail(std::string const& reason)
Reporter<Unused>::onFail(std::string const& reason)
{
++case_results_.failed;
++case_results_.total;
@@ -243,7 +243,7 @@ Reporter<Unused>::on_fail(std::string const& reason)
template <class Unused>
void
Reporter<Unused>::on_log(std::string const& s)
Reporter<Unused>::onLog(std::string const& s)
{
os_ << s;
}

View File

@@ -165,7 +165,7 @@ public:
class Results : public detail::ConstContainer<std::vector<SuiteResults>>
{
private:
std::size_t m_cases_{0};
std::size_t cases_{0};
std::size_t total_{0};
std::size_t failed_{0};
@@ -176,7 +176,7 @@ public:
[[nodiscard]] std::size_t
cases() const
{
return m_cases_;
return cases_;
}
/** Returns the total number of test conditions. */
@@ -198,7 +198,7 @@ public:
void
insert(SuiteResults&& r)
{
m_cases_ += r.size();
cases_ += r.size();
total_ += r.total();
failed_ += r.failed();
cont().emplace_back(std::move(r));
@@ -207,7 +207,7 @@ public:
void
insert(SuiteResults const& r)
{
m_cases_ += r.size();
cases_ += r.size();
total_ += r.total();
failed_ += r.failed();
cont().push_back(r);

View File

@@ -63,7 +63,7 @@ public:
/** Run a sequence of suites.
The expression
`FwdIter::value_type`
must be convertible to `suite_info`.
must be convertible to `SuiteInfo`.
@return `true` if any conditions failed.
*/
template <class FwdIter>
@@ -73,7 +73,7 @@ public:
/** Conditionally run a sequence of suites.
pred will be called as:
@code
bool pred(suite_info const&);
bool pred(SuiteInfo const&);
@endcode
@return `true` if any conditions failed.
*/
@@ -91,7 +91,7 @@ public:
/** Conditionally run suites in a container.
pred will be called as:
@code
bool pred(suite_info const&);
bool pred(SuiteInfo const&);
@endcode
@return `true` if any conditions failed.
*/

View File

@@ -299,8 +299,8 @@ private:
static Suite**
pThisSuite()
{
static Suite* kPTS = nullptr; // NOLINT(misc-const-correctness)
return &kPTS;
static Suite* kP_TS = nullptr; // NOLINT TODO
return &kP_TS;
}
/** Runs the suite. */
@@ -579,7 +579,7 @@ Suite::run(Runner& r)
// detail:
// This inserts the suite with the given manual flag
#define BEAST_DEFINE_TESTSUITE_INSERT(Class, Module, Library, manual, priority) \
static beast::unit_test::detail::insert_suite<Class##_test> \
static beast::unit_test::detail::InsertSuite<Class##_test> \
Library##Module##Class##_test_instance(#Class, #Module, #Library, manual, priority)
//------------------------------------------------------------------------------

View File

@@ -93,15 +93,10 @@ public:
//------------------------------------------------------------------------------
/// Convenience for producing suite_info for a given test type.
/// Convenience for producing SuiteInfo for a given test type.
template <class Suite>
SuiteInfo
make_suite_info(
std::string name,
std::string module,
std::string library,
bool manual,
int priority)
makeSuiteInfo(std::string name, std::string module, std::string library, bool manual, int priority)
{
return SuiteInfo(
std::move(name), std::move(module), std::move(library), manual, priority, [](Runner& r) {

View File

@@ -58,7 +58,7 @@ SuiteList::insert(
BOOST_ASSERT(result.second); // Duplicate type
}
#endif
cont().emplace(make_suite_info<Suite>(name, module, library, manual, priority));
cont().emplace(makeSuiteInfo<Suite>(name, module, library, manual, priority));
}
} // namespace beast::unit_test

View File

@@ -16,7 +16,7 @@ namespace beast::unit_test {
class Thread
{
private:
suite* s_ = nullptr;
Suite* s_ = nullptr;
std::thread t_;
public:
@@ -41,7 +41,7 @@ public:
}
template <class F, class... Args>
explicit Thread(suite& s, F&& f, Args&&... args) : s_(&s)
explicit Thread(Suite& s, F&& f, Args&&... args) : s_(&s)
{
std::function<void(void)> b = std::bind(std::forward<F>(f), std::forward<Args>(args)...);
t_ = std::thread(&Thread::run, this, std::move(b));
@@ -54,13 +54,13 @@ public:
}
[[nodiscard]] std::thread::id
get_id() const
getId() const
{
return t_.get_id();
}
static unsigned
hardware_concurrency() noexcept
hardwareConcurrency() noexcept
{
return std::thread::hardware_concurrency();
}
@@ -69,7 +69,7 @@ public:
join()
{
t_.join();
s_->propagate_abort();
s_->propagateAbort();
}
void
@@ -93,7 +93,7 @@ private:
{
f();
}
catch (suite::abort_exception const&) // NOLINT(bugprone-empty-catch)
catch (Suite::AbortException const&) // NOLINT(bugprone-empty-catch)
{
}
catch (std::exception const& e)

View File

@@ -47,8 +47,8 @@ private:
// Severity level / threshold of a Journal message.
using Severity = severities::Severity;
// Invariant: m_sink always points to a valid Sink
Sink* m_sink_;
// Invariant: sink_ always points to a valid Sink
Sink* sink_;
public:
//--------------------------------------------------------------------------
@@ -108,7 +108,7 @@ public:
private:
Severity thresh_;
bool m_console_;
bool console_;
};
#ifndef __INTELLISENSE__
@@ -132,7 +132,7 @@ public:
class ScopedStream
{
public:
ScopedStream(ScopedStream const& other) : ScopedStream(other.m_sink_, other.m_level_)
ScopedStream(ScopedStream const& other) : ScopedStream(other.sink_, other.level_)
{
}
@@ -151,7 +151,7 @@ public:
std::ostringstream&
ostream() const
{
return m_ostream_;
return ostream_;
}
std::ostream&
@@ -162,9 +162,9 @@ public:
operator<<(T const& t) const;
private:
Sink& m_sink_;
Severity const m_level_;
std::ostringstream mutable m_ostream_;
Sink& sink_;
Severity const level_;
std::ostringstream mutable ostream_;
};
#ifndef __INTELLISENSE__
@@ -183,7 +183,7 @@ public:
{
public:
/** Create a stream which produces no output. */
explicit Stream() : m_sink_(getNullSink()), m_level_(severities::KDisabled)
explicit Stream() : sink_(getNullSink()), level_(severities::KDisabled)
{
}
@@ -191,14 +191,14 @@ public:
Constructor is inlined so checking active() very inexpensive.
*/
Stream(Sink& sink, Severity level) : m_sink_(sink), m_level_(level)
Stream(Sink& sink, Severity level) : sink_(sink), level_(level)
{
XRPL_ASSERT(
m_level_ < severities::KDisabled, "beast::Journal::Stream::Stream : maximum level");
level_ < severities::KDisabled, "beast::Journal::Stream::Stream : maximum level");
}
/** Construct or copy another Stream. */
Stream(Stream const& other) : Stream(other.m_sink_, other.m_level_)
Stream(Stream const& other) : Stream(other.sink_, other.level_)
{
}
@@ -209,14 +209,14 @@ public:
[[nodiscard]] Sink&
sink() const
{
return m_sink_;
return sink_;
}
/** Returns the Severity level of messages this Stream reports. */
[[nodiscard]] Severity
level() const
{
return m_level_;
return level_;
}
/** Returns `true` if sink logs anything at this stream's level. */
@@ -224,7 +224,7 @@ public:
[[nodiscard]] bool
active() const
{
return m_sink_.active(m_level_);
return sink_.active(level_);
}
explicit
@@ -245,8 +245,8 @@ public:
/** @} */
private:
Sink& m_sink_;
Severity m_level_;
Sink& sink_;
Severity level_;
};
#ifndef __INTELLISENSE__
@@ -264,7 +264,7 @@ public:
Journal() = delete;
/** Create a journal that writes to the specified sink. */
explicit Journal(Sink& sink) : m_sink_(&sink)
explicit Journal(Sink& sink) : sink_(&sink)
{
}
@@ -272,14 +272,14 @@ public:
[[nodiscard]] Sink&
sink() const
{
return *m_sink_;
return *sink_;
}
/** Returns a stream for this sink, with the specified severity level. */
[[nodiscard]] Stream
stream(Severity level) const
{
return Stream(*m_sink_, level);
return Stream(*sink_, level);
}
/** Returns `true` if any message would be logged at this severity level.
@@ -289,7 +289,7 @@ public:
[[nodiscard]] bool
active(Severity level) const
{
return m_sink_->active(level);
return sink_->active(level);
}
/** Severity stream access functions. */
@@ -297,37 +297,37 @@ public:
[[nodiscard]] Stream
trace() const
{
return {*m_sink_, severities::KTrace};
return {*sink_, severities::KTrace};
}
[[nodiscard]] Stream
debug() const
{
return {*m_sink_, severities::KDebug};
return {*sink_, severities::KDebug};
}
[[nodiscard]] Stream
info() const
{
return {*m_sink_, severities::KInfo};
return {*sink_, severities::KInfo};
}
[[nodiscard]] Stream
warn() const
{
return {*m_sink_, severities::KWarning};
return {*sink_, severities::KWarning};
}
[[nodiscard]] Stream
error() const
{
return {*m_sink_, severities::KError};
return {*sink_, severities::KError};
}
[[nodiscard]] Stream
fatal() const
{
return {*m_sink_, severities::KFatal};
return {*sink_, severities::KFatal};
}
/** @} */
};
@@ -347,15 +347,15 @@ template <typename T>
Journal::ScopedStream::ScopedStream(Journal::Stream const& stream, T const& t)
: ScopedStream(stream.sink(), stream.level())
{
m_ostream_ << t;
ostream_ << t;
}
template <typename T>
std::ostream&
Journal::ScopedStream::operator<<(T const& t) const
{
m_ostream_ << t;
return m_ostream_;
ostream_ << t;
return ostream_;
}
//------------------------------------------------------------------------------
@@ -370,7 +370,7 @@ Journal::Stream::operator<<(T const& t) const
namespace detail {
template <class CharT, class Traits = std::char_traits<CharT>>
class LogstreamBuf : public std::basic_stringbuf<CharT, Traits>
class LogStreamBuf : public std::basic_stringbuf<CharT, Traits>
{
beast::Journal::Stream strm_;
@@ -389,11 +389,11 @@ class LogstreamBuf : public std::basic_stringbuf<CharT, Traits>
}
public:
explicit LogstreamBuf(beast::Journal::Stream const& strm) : strm_(strm)
explicit LogStreamBuf(beast::Journal::Stream const& strm) : strm_(strm)
{
}
~LogstreamBuf() override
~LogStreamBuf() override
{
sync();
}
@@ -422,7 +422,7 @@ class BasicLogstream : public std::basic_ostream<CharT, Traits>
using pos_type = typename traits_type::pos_type;
using off_type = typename traits_type::off_type;
detail::LogstreamBuf<CharT, Traits> buf_;
detail::LogStreamBuf<CharT, Traits> buf_;
public:
explicit BasicLogstream(beast::Journal::Stream const& strm)

View File

@@ -157,7 +157,7 @@ public:
operator*() const;
private:
Source* m_source_;
Source* source_;
};
//------------------------------------------------------------------------------
@@ -169,9 +169,9 @@ private:
class PropertyStream::Proxy
{
private:
Map const* m_map_;
std::string m_key_;
std::ostringstream mutable m_ostream_;
Map const* map_;
std::string key_;
std::ostringstream mutable ostream_;
public:
Proxy(Map const& map, std::string key);
@@ -189,7 +189,7 @@ public:
std::ostream&
operator<<(T const& t) const
{
return m_ostream_ << t;
return ostream_ << t;
}
};
@@ -202,7 +202,7 @@ public:
class PropertyStream::Map
{
private:
PropertyStream& m_stream_;
PropertyStream& stream_;
public:
explicit Map(PropertyStream& stream);
@@ -224,7 +224,7 @@ public:
void
add(std::string const& key, Value value) const
{
m_stream_.add(key, value);
stream_.add(key, value);
}
template <typename Key, typename Value>
@@ -261,7 +261,7 @@ template <typename Value>
PropertyStream::Proxy&
PropertyStream::Proxy::operator=(Value value)
{
m_map_->add(m_key_, value);
map_->add(key_, value);
return *this;
}
@@ -274,7 +274,7 @@ PropertyStream::Proxy::operator=(Value value)
class PropertyStream::Set
{
private:
PropertyStream& m_stream_;
PropertyStream& stream_;
public:
Set(std::string const& key, Map& map);
@@ -294,7 +294,7 @@ public:
void
add(Value value) const
{
m_stream_.add(value);
stream_.add(value);
}
};
@@ -308,7 +308,7 @@ public:
class PropertyStream::Source
{
private:
std::string const m_name_;
std::string const name_;
std::recursive_mutex lock_;
Item item_;
Source* parent_{nullptr};

View File

@@ -44,7 +44,7 @@ namespace detail::zero_helper {
// be made from a namespace that does not include overloads of the function..
template <class T>
auto
call_signum(T const& t)
callSignum(T const& t)
{
return signum(t);
}
@@ -57,42 +57,42 @@ template <typename T>
bool
operator==(T const& t, Zero)
{
return detail::zero_helper::call_signum(t) == 0;
return detail::zero_helper::callSignum(t) == 0;
}
template <typename T>
bool
operator!=(T const& t, Zero)
{
return detail::zero_helper::call_signum(t) != 0;
return detail::zero_helper::callSignum(t) != 0;
}
template <typename T>
bool
operator<(T const& t, Zero)
{
return detail::zero_helper::call_signum(t) < 0;
return detail::zero_helper::callSignum(t) < 0;
}
template <typename T>
bool
operator>(T const& t, Zero)
{
return detail::zero_helper::call_signum(t) > 0;
return detail::zero_helper::callSignum(t) > 0;
}
template <typename T>
bool
operator>=(T const& t, Zero)
{
return detail::zero_helper::call_signum(t) >= 0;
return detail::zero_helper::callSignum(t) >= 0;
}
template <typename T>
bool
operator<=(T const& t, Zero)
{
return detail::zero_helper::call_signum(t) <= 0;
return detail::zero_helper::callSignum(t) <= 0;
}
// Handle operators where T is on the right side by

View File

@@ -6,15 +6,15 @@ namespace beast {
/** Makes T const or non const depending on a bool. */
template <bool IsConst, class T>
struct maybe_const
struct MaybeConst
{
explicit maybe_const() = default;
explicit MaybeConst() = default;
using type = std::
conditional_t<IsConst, typename std::remove_const<T>::type const, std::remove_const_t<T>>;
};
/** Alias for omitting `typename`. */
template <bool IsConst, class T>
using maybe_const_t = typename maybe_const<IsConst, T>::type;
using maybe_const_t = typename MaybeConst<IsConst, T>::type;
} // namespace beast

Some files were not shown because too many files have changed in this diff Show More