diff --git a/sdk/core/azure-core/CHANGELOG.md b/sdk/core/azure-core/CHANGELOG.md index 21b434168..074ee032e 100644 --- a/sdk/core/azure-core/CHANGELOG.md +++ b/sdk/core/azure-core/CHANGELOG.md @@ -2,6 +2,9 @@ ## 1.0.0-beta.5 (Unreleased) +### Breaking Changes + +- Make `ToLower` and `LocaleInvariantCaseInsensitiveEqual` internal by moving them from `Azure::Core::Strings` to `Azure::Core::Internal::Strings`. ## 1.0.0-beta.4 (2021-01-13) diff --git a/sdk/core/azure-core/CMakeLists.txt b/sdk/core/azure-core/CMakeLists.txt index 53d83716d..fdad1a44a 100644 --- a/sdk/core/azure-core/CMakeLists.txt +++ b/sdk/core/azure-core/CMakeLists.txt @@ -63,6 +63,7 @@ set( inc/azure/core/http/transport.hpp inc/azure/core/internal/contract.hpp inc/azure/core/internal/log.hpp + inc/azure/core/internal/strings.hpp inc/azure/core/logging/logging.hpp inc/azure/core/base64.hpp inc/azure/core/context.hpp @@ -74,7 +75,6 @@ set( inc/azure/core/operation_status.hpp inc/azure/core/platform.hpp inc/azure/core/response.hpp - inc/azure/core/strings.hpp inc/azure/core/uuid.hpp inc/azure/core/version.hpp inc/azure/core.hpp diff --git a/sdk/core/azure-core/inc/azure/core.hpp b/sdk/core/azure-core/inc/azure/core.hpp index 0b1930c78..748440b05 100644 --- a/sdk/core/azure-core/inc/azure/core.hpp +++ b/sdk/core/azure-core/inc/azure/core.hpp @@ -16,7 +16,6 @@ #include "azure/core/datetime.hpp" #include "azure/core/nullable.hpp" #include "azure/core/response.hpp" -#include "azure/core/strings.hpp" #include "azure/core/uuid.hpp" #include "azure/core/version.hpp" diff --git a/sdk/core/azure-core/inc/azure/core/strings.hpp b/sdk/core/azure-core/inc/azure/core/internal/strings.hpp similarity index 67% rename from sdk/core/azure-core/inc/azure/core/strings.hpp rename to sdk/core/azure-core/inc/azure/core/internal/strings.hpp index a4df0e195..0e121adcb 100644 --- a/sdk/core/azure-core/inc/azure/core/strings.hpp +++ b/sdk/core/azure-core/inc/azure/core/internal/strings.hpp @@ -2,17 +2,17 @@ // SPDX-License-Identifier: MIT /** - * @brief Public utility functions for strings. + * @brief Internal utility functions for strings. * */ #pragma once #include -namespace Azure { namespace Core { namespace Strings { +namespace Azure { namespace Core { namespace Internal { namespace Strings { bool LocaleInvariantCaseInsensitiveEqual(const std::string& lhs, const std::string& rhs) noexcept; std::string const ToLower(const std::string& src) noexcept; unsigned char ToLower(const unsigned char src) noexcept; -}}} // namespace Azure::Core::Strings +}}}} // namespace Azure::Core::Internal::Strings diff --git a/sdk/core/azure-core/inc/azure/core/operation_status.hpp b/sdk/core/azure-core/inc/azure/core/operation_status.hpp index 342836d69..f30ca3842 100644 --- a/sdk/core/azure-core/inc/azure/core/operation_status.hpp +++ b/sdk/core/azure-core/inc/azure/core/operation_status.hpp @@ -12,7 +12,7 @@ #include #include // for std::move -#include "azure/core/strings.hpp" +#include "azure/core/internal/strings.hpp" namespace Azure { namespace Core { @@ -51,7 +51,7 @@ namespace Azure { namespace Core { */ bool operator==(const OperationStatus& other) const noexcept { - return Strings::LocaleInvariantCaseInsensitiveEqual(m_value, other.m_value); + return Internal::Strings::LocaleInvariantCaseInsensitiveEqual(m_value, other.m_value); } /** diff --git a/sdk/core/azure-core/src/http/raw_response.cpp b/sdk/core/azure-core/src/http/raw_response.cpp index add21062b..6ab0e6d09 100644 --- a/sdk/core/azure-core/src/http/raw_response.cpp +++ b/sdk/core/azure-core/src/http/raw_response.cpp @@ -2,7 +2,7 @@ // SPDX-License-Identifier: MIT #include "azure/core/http/http.hpp" -#include "azure/core/strings.hpp" +#include "azure/core/internal/strings.hpp" #include #include @@ -32,7 +32,7 @@ void RawResponse::AddHeader(uint8_t const* const first, uint8_t const* const las } // Always toLower() headers - auto headerName = Azure::Core::Strings::ToLower(std::string(start, end)); + auto headerName = Azure::Core::Internal::Strings::ToLower(std::string(start, end)); start = end + 1; // start value while (start < last && (*start == ' ' || *start == '\t')) { diff --git a/sdk/core/azure-core/src/http/request.cpp b/sdk/core/azure-core/src/http/request.cpp index f317c8535..0e17bbccb 100644 --- a/sdk/core/azure-core/src/http/request.cpp +++ b/sdk/core/azure-core/src/http/request.cpp @@ -2,7 +2,7 @@ // SPDX-License-Identifier: MIT #include "azure/core/http/http.hpp" -#include "azure/core/strings.hpp" +#include "azure/core/internal/strings.hpp" #include #include @@ -24,7 +24,7 @@ static std::map MergeMaps( void Request::AddHeader(std::string const& name, std::string const& value) { - auto headerNameLowerCase = Azure::Core::Strings::ToLower(name); + auto headerNameLowerCase = Azure::Core::Internal::Strings::ToLower(name); return this->m_retryModeEnabled ? Details::InsertHeaderWithValidation(this->m_retryHeaders, headerNameLowerCase, value) : Details::InsertHeaderWithValidation(this->m_headers, headerNameLowerCase, value); diff --git a/sdk/core/azure-core/src/http/url.cpp b/sdk/core/azure-core/src/http/url.cpp index 967ff50af..8672f2f80 100644 --- a/sdk/core/azure-core/src/http/url.cpp +++ b/sdk/core/azure-core/src/http/url.cpp @@ -2,7 +2,7 @@ // SPDX-License-Identifier: MIT #include "azure/core/http/http.hpp" -#include "azure/core/strings.hpp" +#include "azure/core/internal/strings.hpp" #include #include @@ -21,7 +21,8 @@ Url::Url(const std::string& url) if (schemeIter != std::string::npos) { std::transform(url.begin(), url.begin() + schemeIter, std::back_inserter(m_scheme), [](char c) { - return static_cast(Azure::Core::Strings::ToLower(static_cast(c))); + return static_cast( + Azure::Core::Internal::Strings::ToLower(static_cast(c))); }); pos = url.begin() + schemeIter + schemeEnd.length(); diff --git a/sdk/core/azure-core/src/strings.cpp b/sdk/core/azure-core/src/strings.cpp index cac9021ad..6e0e01c81 100644 --- a/sdk/core/azure-core/src/strings.cpp +++ b/sdk/core/azure-core/src/strings.cpp @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT -#include "azure/core/strings.hpp" +#include "azure/core/internal/strings.hpp" #include @@ -67,7 +67,7 @@ const unsigned char c_LocaleInvariantLowercaseTable[256] = { }; } // unnamed namespace -namespace Azure { namespace Core { namespace Strings { +namespace Azure { namespace Core { namespace Internal { namespace Strings { unsigned char ToLower(const unsigned char symbol) noexcept { @@ -97,4 +97,4 @@ namespace Azure { namespace Core { namespace Strings { }); } -}}} // namespace Azure::Core::Strings +}}}} // namespace Azure::Core::Internal::Strings diff --git a/sdk/core/azure-core/test/ut/simplified_header.cpp b/sdk/core/azure-core/test/ut/simplified_header.cpp index 4900aa567..f3e70f921 100644 --- a/sdk/core/azure-core/test/ut/simplified_header.cpp +++ b/sdk/core/azure-core/test/ut/simplified_header.cpp @@ -20,7 +20,6 @@ TEST(Logging, simplifiedHeader) EXPECT_NO_THROW(Azure::Core::Nullable n); EXPECT_NO_THROW(Azure::Core::Http::RawResponse r( 1, 1, Azure::Core::Http::HttpStatusCode::Accepted, "phrase")); - EXPECT_NO_THROW(Azure::Core::Strings::ToLower("A")); EXPECT_NO_THROW(Azure::Core::Uuid::CreateUuid()); EXPECT_NO_THROW(Azure::Core::Details::Version::VersionString()); diff --git a/sdk/core/azure-core/test/ut/string.cpp b/sdk/core/azure-core/test/ut/string.cpp index d15f44fe2..2744adf1d 100644 --- a/sdk/core/azure-core/test/ut/string.cpp +++ b/sdk/core/azure-core/test/ut/string.cpp @@ -1,13 +1,13 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT -#include +#include #include #include TEST(String, invariantCompare) { - using Azure::Core::Strings::LocaleInvariantCaseInsensitiveEqual; + using Azure::Core::Internal::Strings::LocaleInvariantCaseInsensitiveEqual; EXPECT_TRUE(LocaleInvariantCaseInsensitiveEqual("", "")); EXPECT_TRUE(LocaleInvariantCaseInsensitiveEqual("a", "a")); EXPECT_TRUE(LocaleInvariantCaseInsensitiveEqual("A", "a")); @@ -22,7 +22,7 @@ TEST(String, invariantCompare) TEST(String, toLower) { - using Azure::Core::Strings::ToLower; + using Azure::Core::Internal::Strings::ToLower; EXPECT_TRUE(ToLower("") == ""); EXPECT_TRUE(ToLower("a") == "a"); EXPECT_TRUE(ToLower("A") == "a"); diff --git a/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/protocol/blob_rest_client.hpp b/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/protocol/blob_rest_client.hpp index f2d061ea1..7b464912b 100644 --- a/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/protocol/blob_rest_client.hpp +++ b/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/protocol/blob_rest_client.hpp @@ -18,7 +18,6 @@ #include #include #include -#include #include #include #include diff --git a/sdk/storage/azure-storage-common/inc/azure/storage/common/storage_common.hpp b/sdk/storage/azure-storage-common/inc/azure/storage/common/storage_common.hpp index 45a6b94ce..5fef87a7c 100644 --- a/sdk/storage/azure-storage-common/inc/azure/storage/common/storage_common.hpp +++ b/sdk/storage/azure-storage-common/inc/azure/storage/common/storage_common.hpp @@ -9,7 +9,7 @@ #include #include -#include +#include namespace Azure { namespace Storage { @@ -57,7 +57,7 @@ namespace Azure { namespace Storage { { return std::lexicographical_compare( lhs.begin(), lhs.end(), rhs.begin(), rhs.end(), [](char c1, char c2) { - return Core::Strings::ToLower(c1) < Core::Strings::ToLower(c2); + return Core::Internal::Strings::ToLower(c1) < Core::Internal::Strings::ToLower(c2); }); } }; diff --git a/sdk/storage/azure-storage-common/src/shared_key_policy.cpp b/sdk/storage/azure-storage-common/src/shared_key_policy.cpp index 018607fd2..defc8f4ad 100644 --- a/sdk/storage/azure-storage-common/src/shared_key_policy.cpp +++ b/sdk/storage/azure-storage-common/src/shared_key_policy.cpp @@ -7,7 +7,7 @@ #include #include -#include +#include #include "azure/storage/common/crypt.hpp" @@ -32,7 +32,7 @@ namespace Azure { namespace Storage { namespace Details { "If-Unmodified-Since", "Range"}) { - auto ite = headers.find(Azure::Core::Strings::ToLower(headerName)); + auto ite = headers.find(Azure::Core::Internal::Strings::ToLower(headerName)); if (ite != headers.end()) { if (headerName == "Content-Length" && ite->second == "0") @@ -54,7 +54,7 @@ namespace Azure { namespace Storage { namespace Details { ite != headers.end() && ite->first.substr(0, prefix.length()) == prefix; ++ite) { - std::string key = Azure::Core::Strings::ToLower(ite->first); + std::string key = Azure::Core::Internal::Strings::ToLower(ite->first); ordered_kv.emplace_back(std::make_pair(std::move(key), ite->second)); } std::sort(ordered_kv.begin(), ordered_kv.end()); @@ -68,7 +68,7 @@ namespace Azure { namespace Storage { namespace Details { string_to_sign += "/" + m_credential->AccountName + "/" + request.GetUrl().GetPath() + "\n"; for (const auto& query : request.GetUrl().GetQueryParameters()) { - std::string key = Azure::Core::Strings::ToLower(query.first); + std::string key = Azure::Core::Internal::Strings::ToLower(query.first); ordered_kv.emplace_back(std::make_pair( Azure::Core::Http::Url::Decode(key), Azure::Core::Http::Url::Decode(query.second))); } diff --git a/sdk/storage/azure-storage-common/test/test_base.cpp b/sdk/storage/azure-storage-common/test/test_base.cpp index 6e8ab9858..7555be901 100644 --- a/sdk/storage/azure-storage-common/test/test_base.cpp +++ b/sdk/storage/azure-storage-common/test/test_base.cpp @@ -20,8 +20,8 @@ #include #include +#include #include -#include namespace Azure { namespace Storage { namespace Test { @@ -166,7 +166,7 @@ namespace Azure { namespace Storage { namespace Test { std::string LowercaseRandomString(size_t size) { - return Azure::Core::Strings::ToLower(RandomString(size)); + return Azure::Core::Internal::Strings::ToLower(RandomString(size)); } Storage::Metadata RandomMetadata(size_t size)