From bd5d7aa094ddae4aded3177a246ce19243e8ce01 Mon Sep 17 00:00:00 2001 From: Bernard Normier Date: Sun, 26 Jan 2025 15:00:15 -0500 Subject: [PATCH] namespace cleanup (#3427) --- cpp/include/Ice/Comparable.h | 182 +++++++++--------- cpp/src/Glacier2/InstrumentationI.cpp | 38 ++-- .../CryptPermissionsVerifierI.cpp | 37 ++-- 3 files changed, 125 insertions(+), 132 deletions(-) diff --git a/cpp/include/Ice/Comparable.h b/cpp/include/Ice/Comparable.h index 73dd66cdd06..9c0e6c04d8f 100644 --- a/cpp/include/Ice/Comparable.h +++ b/cpp/include/Ice/Comparable.h @@ -111,104 +111,104 @@ namespace Ice } } }; +} - namespace Tuple +namespace Ice::Tuple +{ + /** + * Relational operator for generated structs. + * @param lhs The left-hand side. + * @param rhs The right-hand side. + * @return True if the left-hand side compares less than the right-hand side, false otherwise. + */ + template< + class T, + std::enable_if_t< + std::is_member_function_pointer_v && !std::is_polymorphic_v, + bool> = true> + bool operator<(const T& lhs, const T& rhs) { - /** - * Relational operator for generated structs. - * @param lhs The left-hand side. - * @param rhs The right-hand side. - * @return True if the left-hand side compares less than the right-hand side, false otherwise. - */ - template< - class C, - std::enable_if_t< - std::is_member_function_pointer_v && !std::is_polymorphic_v, - bool> = true> - bool operator<(const C& lhs, const C& rhs) - { - return lhs.ice_tuple() < rhs.ice_tuple(); - } + return lhs.ice_tuple() < rhs.ice_tuple(); + } - /** - * Relational operator for generated structs. - * @param lhs The left-hand side. - * @param rhs The right-hand side. - * @return True if the left-hand side compares less than or equal to the right-hand side, false otherwise. - */ - template< - class C, - std::enable_if_t< - std::is_member_function_pointer_v && !std::is_polymorphic_v, - bool> = true> - bool operator<=(const C& lhs, const C& rhs) - { - return lhs.ice_tuple() <= rhs.ice_tuple(); - } + /** + * Relational operator for generated structs. + * @param lhs The left-hand side. + * @param rhs The right-hand side. + * @return True if the left-hand side compares less than or equal to the right-hand side, false otherwise. + */ + template< + class T, + std::enable_if_t< + std::is_member_function_pointer_v && !std::is_polymorphic_v, + bool> = true> + bool operator<=(const T& lhs, const T& rhs) + { + return lhs.ice_tuple() <= rhs.ice_tuple(); + } - /** - * Relational operator for generated structs. - * @param lhs The left-hand side. - * @param rhs The right-hand side. - * @return True if the left-hand side compares greater than the right-hand side, false otherwise. - */ - template< - class C, - std::enable_if_t< - std::is_member_function_pointer_v && !std::is_polymorphic_v, - bool> = true> - bool operator>(const C& lhs, const C& rhs) - { - return lhs.ice_tuple() > rhs.ice_tuple(); - } + /** + * Relational operator for generated structs. + * @param lhs The left-hand side. + * @param rhs The right-hand side. + * @return True if the left-hand side compares greater than the right-hand side, false otherwise. + */ + template< + class T, + std::enable_if_t< + std::is_member_function_pointer_v && !std::is_polymorphic_v, + bool> = true> + bool operator>(const T& lhs, const T& rhs) + { + return lhs.ice_tuple() > rhs.ice_tuple(); + } - /** - * Relational operator for generated structs. - * @param lhs The left-hand side. - * @param rhs The right-hand side. - * @return True if the left-hand side compares greater than or equal to the right-hand side, false otherwise. - */ - template< - class C, - std::enable_if_t< - std::is_member_function_pointer_v && !std::is_polymorphic_v, - bool> = true> - bool operator>=(const C& lhs, const C& rhs) - { - return lhs.ice_tuple() >= rhs.ice_tuple(); - } + /** + * Relational operator for generated structs. + * @param lhs The left-hand side. + * @param rhs The right-hand side. + * @return True if the left-hand side compares greater than or equal to the right-hand side, false otherwise. + */ + template< + class T, + std::enable_if_t< + std::is_member_function_pointer_v && !std::is_polymorphic_v, + bool> = true> + bool operator>=(const T& lhs, const T& rhs) + { + return lhs.ice_tuple() >= rhs.ice_tuple(); + } - /** - * Relational operator for generated structs. - * @param lhs The left-hand side. - * @param rhs The right-hand side. - * @return True if the left-hand side compares equal to the right-hand side, false otherwise. - */ - template< - class C, - std::enable_if_t< - std::is_member_function_pointer_v && !std::is_polymorphic_v, - bool> = true> - bool operator==(const C& lhs, const C& rhs) - { - return lhs.ice_tuple() == rhs.ice_tuple(); - } + /** + * Relational operator for generated structs. + * @param lhs The left-hand side. + * @param rhs The right-hand side. + * @return True if the left-hand side compares equal to the right-hand side, false otherwise. + */ + template< + class T, + std::enable_if_t< + std::is_member_function_pointer_v && !std::is_polymorphic_v, + bool> = true> + bool operator==(const T& lhs, const T& rhs) + { + return lhs.ice_tuple() == rhs.ice_tuple(); + } - /** - * Relational operator for generated structs. - * @param lhs The left-hand side. - * @param rhs The right-hand side. - * @return True if the left-hand side is not equal to the right-hand side, false otherwise. - */ - template< - class C, - std::enable_if_t< - std::is_member_function_pointer_v && !std::is_polymorphic_v, - bool> = true> - bool operator!=(const C& lhs, const C& rhs) - { - return lhs.ice_tuple() != rhs.ice_tuple(); - } + /** + * Relational operator for generated structs. + * @param lhs The left-hand side. + * @param rhs The right-hand side. + * @return True if the left-hand side is not equal to the right-hand side, false otherwise. + */ + template< + class T, + std::enable_if_t< + std::is_member_function_pointer_v && !std::is_polymorphic_v, + bool> = true> + bool operator!=(const T& lhs, const T& rhs) + { + return lhs.ice_tuple() != rhs.ice_tuple(); } } diff --git a/cpp/src/Glacier2/InstrumentationI.cpp b/cpp/src/Glacier2/InstrumentationI.cpp index 805cf28770a..2a00c9e6bf1 100644 --- a/cpp/src/Glacier2/InstrumentationI.cpp +++ b/cpp/src/Glacier2/InstrumentationI.cpp @@ -73,36 +73,32 @@ namespace SessionHelper::Attributes SessionHelper::attributes; - namespace + struct ForwardedUpdate { - struct ForwardedUpdate - { - ForwardedUpdate(bool clientP) : client(clientP) {} + ForwardedUpdate(bool clientP) : client(clientP) {} - void operator()(const shared_ptr& v) + void operator()(const shared_ptr& v) + { + if (client) { - if (client) + ++v->forwardedClient; + if (v->queuedClient > 0) { - ++v->forwardedClient; - if (v->queuedClient > 0) - { - --v->queuedClient; - } + --v->queuedClient; } - else + } + else + { + ++v->forwardedServer; + if (v->queuedServer > 0) { - ++v->forwardedServer; - if (v->queuedServer > 0) - { - --v->queuedServer; - } + --v->queuedServer; } } + } - int client; - }; - - } + int client; + }; } void diff --git a/cpp/src/Glacier2CryptPermissionsVerifier/CryptPermissionsVerifierI.cpp b/cpp/src/Glacier2CryptPermissionsVerifier/CryptPermissionsVerifierI.cpp index 50a1b8dee24..5b3c845affe 100644 --- a/cpp/src/Glacier2CryptPermissionsVerifier/CryptPermissionsVerifierI.cpp +++ b/cpp/src/Glacier2CryptPermissionsVerifier/CryptPermissionsVerifierI.cpp @@ -100,35 +100,32 @@ namespace { } - namespace - { #if defined(__APPLE__) || defined(_WIN32) - const char* const padBytes0 = ""; - const char* const padBytes1 = "="; - const char* const padBytes2 = "=="; + const char* const padBytes0 = ""; + const char* const padBytes1 = "="; + const char* const padBytes2 = "=="; - inline string paddingBytes(size_t length) + inline string paddingBytes(size_t length) + { + switch (length % 4) { - switch (length % 4) + case 2: + { + return padBytes2; + } + case 3: { - case 2: - { - return padBytes2; - } - case 3: - { - return padBytes1; - } - default: - { - return padBytes0; - } + return padBytes1; + } + default: + { + return padBytes0; } } + } #endif - } bool CryptPermissionsVerifierI::checkPermissions(string userId, string password, string&, const Current&) const { auto p = _passwords.find(userId);