Move APIs from Azure::Core::Strings to Azure::Core::Internal since they aren't meant for end users to call. (#1337)

Fixes https://github.com/Azure/azure-sdk-for-cpp/issues/1319

See https://github.com/Azure/azure-sdk-for-cpp/pull/1297#discussion_r554458422 for context.

~There is an open question whether this should be in the Jan or Feb milestone.~ Moved to Feb
This commit is contained in:
Ahson Khan 2021-01-15 14:02:40 -08:00 committed by GitHub
parent 9492bef54b
commit c564c02544
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 30 additions and 29 deletions

View File

@ -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)

View File

@ -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

View File

@ -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"

View File

@ -2,17 +2,17 @@
// SPDX-License-Identifier: MIT
/**
* @brief Public utility functions for strings.
* @brief Internal utility functions for strings.
*
*/
#pragma once
#include <string>
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

View File

@ -12,7 +12,7 @@
#include <string>
#include <utility> // 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);
}
/**

View File

@ -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 <cctype>
#include <map>
@ -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'))
{

View File

@ -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 <map>
#include <string>
@ -24,7 +24,7 @@ static std::map<std::string, std::string> 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);

View File

@ -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 <algorithm>
#include <cctype>
@ -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<char>(Azure::Core::Strings::ToLower(static_cast<unsigned char>(c)));
return static_cast<char>(
Azure::Core::Internal::Strings::ToLower(static_cast<unsigned char>(c)));
});
pos = url.begin() + schemeIter + schemeEnd.length();

View File

@ -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 <algorithm>
@ -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

View File

@ -20,7 +20,6 @@ TEST(Logging, simplifiedHeader)
EXPECT_NO_THROW(Azure::Core::Nullable<int> 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());

View File

@ -1,13 +1,13 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT
#include <azure/core/strings.hpp>
#include <azure/core/internal/strings.hpp>
#include <gtest/gtest.h>
#include <string>
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");

View File

@ -18,7 +18,6 @@
#include <azure/core/http/pipeline.hpp>
#include <azure/core/nullable.hpp>
#include <azure/core/response.hpp>
#include <azure/core/strings.hpp>
#include <azure/storage/common/crypt.hpp>
#include <azure/storage/common/storage_common.hpp>
#include <azure/storage/common/storage_exception.hpp>

View File

@ -9,7 +9,7 @@
#include <string>
#include <vector>
#include <azure/core/strings.hpp>
#include <azure/core/internal/strings.hpp>
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);
});
}
};

View File

@ -7,7 +7,7 @@
#include <cctype>
#include <azure/core/http/http.hpp>
#include <azure/core/strings.hpp>
#include <azure/core/internal/strings.hpp>
#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)));
}

View File

@ -20,8 +20,8 @@
#include <string>
#include <azure/core/http/http.hpp>
#include <azure/core/internal/strings.hpp>
#include <azure/core/platform.hpp>
#include <azure/core/strings.hpp>
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)