remove azure hpp (#809)

Remove Azure.hpp

Make Azure/Core/Strings.hpp public

Move ToLower and InvariantIsEqual to Strings.hpp

Also removing `AZURE_UNREFERENCED_PARAMETER`  

fixes: https://github.com/Azure/azure-sdk-for-cpp/issues/811
This commit is contained in:
Victor Vazquez 2020-10-20 11:08:58 -07:00 committed by GitHub
parent 90387b3c5d
commit e1dddce239
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 38 additions and 49 deletions

View File

@ -5,6 +5,10 @@
### Breaking Changes
- `Azure::Core::Http::Url::AppendPath` now does not encode the input by default.
- Removed `azure.hpp`.
### New Features
- Added `strings.hpp` with `Azure::Core::Strings::LocaleInvariantCaseInsensitiveEqual` and `Azure::Core::Strings::ToLower`.
### Other changes and Improvements

View File

@ -8,7 +8,6 @@
#pragma once
#include "azure/core/azure.hpp"
#include "azure/core/context.hpp"
#include "azure/core/http/http.hpp"
#include "azure/core/http/transport.hpp"

View File

@ -9,8 +9,6 @@
#pragma once
#include "azure/core/azure.hpp"
#include <functional>
#include <initializer_list>
#include <set>

View File

@ -2,25 +2,17 @@
// SPDX-License-Identifier: MIT
/**
* @file
* @brief Common definitions.
* @brief Public utility functions for strings.
*
*/
#pragma once
#include "azure/core/internal/contract.hpp"
#include <string>
/**
* @brief Used in implementations to mark an unreferenced function parameter.
*/
#define AZURE_UNREFERENCED_PARAMETER(x) ((void)(x));
namespace Azure { namespace Core { namespace Details {
namespace Azure { namespace Core { 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::Details
}}} // namespace Azure::Core::Strings

View File

@ -2,7 +2,6 @@
// SPDX-License-Identifier: MIT
#include "azure/core/http/curl/curl.hpp"
#include "azure/core/azure.hpp"
#include "azure/core/http/http.hpp"
#include "azure/core/internal/log.hpp"

View File

@ -1,8 +1,8 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT
#include "azure/core/azure.hpp"
#include "azure/core/http/http.hpp"
#include "azure/core/strings.hpp"
#include <cctype>
#include <map>
@ -32,7 +32,7 @@ void RawResponse::AddHeader(uint8_t const* const begin, uint8_t const* const las
}
// Always toLower() headers
auto headerName = Azure::Core::Details::ToLower(std::string(start, end));
auto headerName = Azure::Core::Strings::ToLower(std::string(start, end));
start = end + 1; // start value
while (start < last && (*start == ' ' || *start == '\t'))
{

View File

@ -1,8 +1,8 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT
#include "azure/core/azure.hpp"
#include "azure/core/http/http.hpp"
#include "azure/core/strings.hpp"
#include <map>
#include <string>
@ -24,12 +24,10 @@ static std::map<std::string, std::string> MergeMaps(
void Request::AddHeader(std::string const& name, std::string const& value)
{
auto headerNameLowerCase = Azure::Core::Details::ToLower(name);
auto headerNameLowerCase = Azure::Core::Strings::ToLower(name);
return this->m_retryModeEnabled
? Details::InsertHeaderWithValidation(
this->m_retryHeaders, headerNameLowerCase, value)
: Details::InsertHeaderWithValidation(
this->m_headers, headerNameLowerCase, value);
? Details::InsertHeaderWithValidation(this->m_retryHeaders, headerNameLowerCase, value)
: Details::InsertHeaderWithValidation(this->m_headers, headerNameLowerCase, value);
}
void Request::RemoveHeader(std::string const& name)

View File

@ -10,7 +10,7 @@ std::unique_ptr<RawResponse> TransportPolicy::Send(
Request& request,
NextHttpPolicy nextHttpPolicy) const
{
AZURE_UNREFERENCED_PARAMETER(nextHttpPolicy);
(void)nextHttpPolicy;
/**
* The transport policy is always the last policy.
* Call the transport and return

View File

@ -1,8 +1,8 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT
#include "azure/core/azure.hpp"
#include "azure/core/http/http.hpp"
#include "azure/core/strings.hpp"
#include <algorithm>
#include <cctype>
@ -20,7 +20,7 @@ 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::Details::ToLower(static_cast<unsigned char>(c)));
return static_cast<char>(Azure::Core::Strings::ToLower(static_cast<unsigned char>(c)));
});
pos = url.begin() + schemeIter + schemeEnd.length();

View File

@ -1,7 +1,6 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT
#include "azure/core/azure.hpp"
#include "azure/core/http/http.hpp"
#include "azure/core/http/winhttp/win_http_client.hpp"
@ -15,8 +14,8 @@ WinHttpTansport::~WinHttpTansport() {}
std::unique_ptr<RawResponse> WinHttpTansport::Send(Context const& context, Request& request)
{
AZURE_UNREFERENCED_PARAMETER(context);
AZURE_UNREFERENCED_PARAMETER(request);
void(context);
void(request);
throw;
}

View File

@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT
#include "azure/core/azure.hpp"
#include "azure/core/strings.hpp"
#include <algorithm>
@ -67,7 +67,7 @@ const unsigned char c_LocaleInvariantLowercaseTable[256] = {
};
} // unnamed namespace
namespace Azure { namespace Core { namespace Details {
namespace Azure { namespace Core { namespace Strings {
unsigned char ToLower(const unsigned char symbol) noexcept
{
@ -97,4 +97,4 @@ namespace Azure { namespace Core { namespace Details {
});
}
}}} // namespace Azure::Core::Details
}}} // namespace Azure::Core::Strings

View File

@ -1,13 +1,13 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT
#include "azure/core/strings.hpp"
#include "gtest/gtest.h"
#include <azure/core/azure.hpp>
#include <string>
TEST(String, invariantCompare)
{
using Azure::Core::Details::LocaleInvariantCaseInsensitiveEqual;
using Azure::Core::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::Details::ToLower;
using Azure::Core::Strings::ToLower;
EXPECT_TRUE(ToLower("") == "");
EXPECT_TRUE(ToLower("a") == "a");
EXPECT_TRUE(ToLower("A") == "a");

View File

@ -4,6 +4,7 @@
#include "azure/storage/common/shared_key_policy.hpp"
#include "azure/core/http/http.hpp"
#include "azure/core/strings.hpp"
#include "azure/storage/common/crypt.hpp"
#include <algorithm>
@ -16,20 +17,19 @@ namespace Azure { namespace Storage {
string_to_sign += Azure::Core::Http::HttpMethodToString(request.GetMethod()) + "\n";
const auto& headers = request.GetHeaders();
for (std::string headerName :
{"Content-Encoding",
"Content-Language",
"Content-Length",
"Content-MD5",
"Content-Type",
"Date",
"If-Modified-Since",
"If-Match",
"If-None-Match",
"If-Unmodified-Since",
"Range"})
for (std::string headerName : {"Content-Encoding",
"Content-Language",
"Content-Length",
"Content-MD5",
"Content-Type",
"Date",
"If-Modified-Since",
"If-Match",
"If-None-Match",
"If-Unmodified-Since",
"Range"})
{
auto ite = headers.find(Azure::Core::Details::ToLower(headerName));
auto ite = headers.find(Azure::Core::Strings::ToLower(headerName));
if (ite != headers.end())
{
if (headerName == "Content-Length" && ite->second == "0")