Mention min clang format version and format all cpp and hpp files with clang-format version 9.0 (#1208)

* Add info about clang-format version

* updates for cpp and hpp format

* special cases
This commit is contained in:
Victor Vazquez 2020-12-18 02:34:23 +00:00 committed by GitHub
parent 6a317e8b87
commit 8aac9091c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
42 changed files with 192 additions and 210 deletions

View File

@ -57,6 +57,7 @@ CMake version 3.13 or higher is required to build these libraries. Download and
#### Third Party Dependencies
- curl
- libxml2
- clang-format (min version 9)
Vcpkg can be used to install the Azure SDK for CPP dependencies into a specific folder on the system instead of globally installing them.
Follow [vcpkg install guide](https://github.com/microsoft/vcpkg#getting-started) to get vcpkg and install the following dependencies:

View File

@ -508,10 +508,10 @@ namespace Azure { namespace Core { namespace Http {
*/
explicit Request(HttpMethod httpMethod, Url url, bool downloadViaStream)
: Request(
httpMethod,
std::move(url),
NullBodyStream::GetNullBodyStream(),
downloadViaStream)
httpMethod,
std::move(url),
NullBodyStream::GetNullBodyStream(),
downloadViaStream)
{
}

View File

@ -48,7 +48,9 @@ namespace Azure { namespace Core {
* @param initialValue A non-absent value to initialize with.
*/
constexpr Nullable(T initialValue) noexcept(std::is_nothrow_move_constructible<T>::value)
: m_value(std::move(initialValue)), m_hasValue(true) {}
: m_value(std::move(initialValue)), m_hasValue(true)
{
}
/// Copy constructor.
Nullable(const Nullable& other) noexcept(std::is_nothrow_copy_constructible<T>::value)

View File

@ -57,44 +57,35 @@ namespace Azure { namespace Core {
*
* @return `true` If a value is contained, `false` if value is absent.
*/
bool HasValue() const noexcept {
return this->m_value.HasValue();
}
bool HasValue() const noexcept { return this->m_value.HasValue(); }
/**
* @brief Get a pointer to a value of a specific type.
*/
const T* operator->() const {
const T* operator->() const
{
return &this->m_value.GetValue(); // GetValue ensures there is a contained value
}
/**
* @brief Get a pointer to a value of a specific type.
*/
T* operator->() {
return &this->m_value.GetValue();
}
T* operator->() { return &this->m_value.GetValue(); }
/**
* @brief Get value of a specific type.
*/
T& operator*() {
return this->m_value.GetValue();
}
T& operator*() { return this->m_value.GetValue(); }
/**
* @brief Get value of a specific type.
*/
const T& operator*() const {
return this->m_value.GetValue();
}
const T& operator*() const { return this->m_value.GetValue(); }
/**
* @brief Get an rvalue reference to the value of a specific type.
*/
T&& ExtractValue() {
return std::move(this->m_value).GetValue();
}
T&& ExtractValue() { return std::move(this->m_value).GetValue(); }
/**
* @brief Get a smart pointer rvalue reference to the value of a specific type.

View File

@ -52,4 +52,3 @@ namespace Azure { namespace Core {
#undef AZURE_CORE_VERSION_MINOR
#undef AZURE_CORE_VERSION_PATCH
#undef AZURE_CORE_VERSION_PRERELEASE

View File

@ -341,13 +341,11 @@ CURLcode CurlConnection::SendBuffer(
switch (sendResult)
{
case CURLE_OK:
{
case CURLE_OK: {
sentBytesTotal += sentBytesPerRequest;
break;
}
case CURLE_AGAIN:
{
case CURLE_AGAIN: {
// start polling operation with 1 min timeout
auto pollUntilSocketIsReady = pollSocketUntilEventOrTimeout(
context, m_curlSocket, PollSocketDirection::Write, 60000L);
@ -364,8 +362,7 @@ CURLcode CurlConnection::SendBuffer(
// Ready to continue download.
break;
}
default:
{
default: {
return sendResult;
}
}
@ -721,8 +718,7 @@ int64_t CurlConnection::ReadFromSocket(Context const& context, uint8_t* buffer,
switch (readResult)
{
case CURLE_AGAIN:
{
case CURLE_AGAIN: {
// start polling operation
auto pollUntilSocketIsReady = pollSocketUntilEventOrTimeout(
context, m_curlSocket, PollSocketDirection::Read, 60000L);
@ -739,12 +735,10 @@ int64_t CurlConnection::ReadFromSocket(Context const& context, uint8_t* buffer,
// Ready to continue download.
break;
}
case CURLE_OK:
{
case CURLE_OK: {
break;
}
default:
{
default: {
// Error reading from socket
throw TransportException(
"Error while reading from network socket. CURLE code: " + std::to_string(readResult)

View File

@ -165,7 +165,7 @@ void printStream(Context const& context, std::unique_ptr<Http::RawResponse> resp
}
cout << static_cast<typename std::underlying_type<Http::HttpStatusCode>::type>(
response->GetStatusCode())
response->GetStatusCode())
<< endl;
cout << response->GetReasonPhrase() << endl;
cout << "headers:" << endl;

View File

@ -1,10 +1,10 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT
#include <gtest/gtest.h>
#include <azure/core/http/pipeline.hpp>
#include <azure/core/internal/log.hpp>
#include <azure/core/logging/logging.hpp>
#include <gtest/gtest.h>
#include <utility>
#include <vector>

View File

@ -1,8 +1,8 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT
#include <gtest/gtest.h>
#include <azure/core/nullable.hpp>
#include <gtest/gtest.h>
#include <string>
#include <vector>
@ -123,13 +123,13 @@ TEST(Nullable, Swap)
TEST(Nullable, CopyConstruction)
{
//Empty
// Empty
Nullable<int> val1;
Nullable<int> val2(val1);
EXPECT_FALSE(val1);
EXPECT_FALSE(val2);
//Non-Empty
// Non-Empty
Nullable<int> val3(12345);
Nullable<int> val4(val3);
EXPECT_TRUE(val3);
@ -137,22 +137,21 @@ TEST(Nullable, CopyConstruction)
EXPECT_TRUE(val3.GetValue() == 12345);
EXPECT_TRUE(val4.GetValue() == 12345);
//Literal
// Literal
Nullable<int> val5 = 54321;
EXPECT_TRUE(val5);
EXPECT_TRUE(val5.GetValue() == 54321);
//Value
// Value
const int i = 1;
Nullable<int> val6(i);
EXPECT_TRUE(val6);
EXPECT_TRUE(val6.GetValue() == 1);
}
TEST(Nullable, Disengage)
{
Nullable<int> val1(12345);
Nullable<int> val1(12345);
val1.Reset();
EXPECT_FALSE(val1);
}
@ -170,7 +169,5 @@ TEST(Nullable, ValueOr)
EXPECT_FALSE(val2);
EXPECT_TRUE(val2.ValueOr(678910) == 678910);
// Ensure val2 is still disengaged after call to ValueOr
EXPECT_FALSE(val2);
EXPECT_FALSE(val2);
}

View File

@ -23,7 +23,7 @@ TEST(Operation, Poll)
EXPECT_FALSE(operation.IsDone());
EXPECT_FALSE(operation.HasValue());
while(!operation.IsDone())
while (!operation.IsDone())
{
EXPECT_FALSE(operation.HasValue());
EXPECT_THROW(operation.Value(), std::runtime_error);
@ -45,12 +45,12 @@ TEST(Operation, PollUntilDone)
EXPECT_FALSE(operation.IsDone());
EXPECT_FALSE(operation.HasValue());
EXPECT_THROW(operation.Value(), std::runtime_error);
auto start = std::chrono::high_resolution_clock::now();
auto response = operation.PollUntilDone(500ms);
auto end = std::chrono::high_resolution_clock::now();
std::chrono::duration<double, std::milli> elapsed = end - start;
//StringOperation test code is implemented to poll 2 times
// StringOperation test code is implemented to poll 2 times
EXPECT_TRUE(elapsed >= 1s);
EXPECT_TRUE(operation.IsDone());

View File

@ -1,9 +1,9 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT
#include <gtest/gtest.h>
#include <azure/core/http/pipeline.hpp>
#include <azure/core/http/policy.hpp>
#include <gtest/gtest.h>
#include <vector>

View File

@ -1,9 +1,9 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT
#include <gtest/gtest.h>
#include <azure/core/http/pipeline.hpp>
#include <azure/core/http/policy.hpp>
#include <gtest/gtest.h>
#include <vector>

View File

@ -8,8 +8,8 @@
*
*/
#include <gtest/gtest.h>
#include <azure/core.hpp>
#include <gtest/gtest.h>
#include <vector>

View File

@ -1,9 +1,9 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT
#include <gtest/gtest.h>
#include <azure/core/http/pipeline.hpp>
#include <azure/core/http/policy.hpp>
#include <gtest/gtest.h>
using namespace Azure::Core;
using namespace Azure::Core::Http;

View File

@ -9,10 +9,10 @@
*
*/
#include <gtest/gtest.h>
#include <azure/core/http/body_stream.hpp>
#include <azure/core/http/http.hpp>
#include <azure/core/http/pipeline.hpp>
#include <gtest/gtest.h>
#include <memory>
#include <vector>

View File

@ -1,10 +1,10 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT
#include <gtest/gtest.h>
#include <azure/core/uuid.hpp>
#include <string>
#include <gtest/gtest.h>
#include <set>
#include <string>
using namespace Azure::Core;
@ -14,14 +14,14 @@ TEST(Uuid, Basic)
EXPECT_TRUE(uuid.GetUuidString().length() == 36);
}
TEST(Uuid, Randomness)
{
TEST(Uuid, Randomness)
{
const int size = 100000;
std::set<std::string> uuids;
for (int i = 0; i < size; i++)
{
auto ret = uuids.insert(Uuid::CreateUuid().GetUuidString());
//If the value already exists in the set then the insert will fail
// If the value already exists in the set then the insert will fail
// ret.second == false means the insert failed.
EXPECT_TRUE(ret.second);
}

View File

@ -52,4 +52,3 @@ namespace Azure { namespace Identity {
#undef AZURE_IDENTITY_VERSION_MINOR
#undef AZURE_IDENTITY_VERSION_PATCH
#undef AZURE_IDENTITY_VERSION_PRERELEASE

View File

@ -3332,8 +3332,8 @@ namespace Azure { namespace Storage { namespace Blobs {
Storage::Details::XmlWriter& writer,
const SetServicePropertiesOptions& options)
{
writer.Write(Storage::Details::XmlNode{
Storage::Details::XmlNodeType::StartTag, "StorageServiceProperties"});
writer.Write(Storage::Details::XmlNode{Storage::Details::XmlNodeType::StartTag,
"StorageServiceProperties"});
BlobServicePropertiesToXml(writer, options.Properties);
writer.Write(Storage::Details::XmlNode{Storage::Details::XmlNodeType::EndTag});
}
@ -3362,16 +3362,16 @@ namespace Azure { namespace Storage { namespace Blobs {
writer.Write(Storage::Details::XmlNode{Storage::Details::XmlNodeType::EndTag});
if (options.DefaultServiceVersion.HasValue())
{
writer.Write(Storage::Details::XmlNode{
Storage::Details::XmlNodeType::StartTag, "DefaultServiceVersion"});
writer.Write(Storage::Details::XmlNode{
Storage::Details::XmlNodeType::Text,
nullptr,
options.DefaultServiceVersion.GetValue().data()});
writer.Write(Storage::Details::XmlNode{Storage::Details::XmlNodeType::StartTag,
"DefaultServiceVersion"});
writer.Write(
Storage::Details::XmlNode{Storage::Details::XmlNodeType::Text,
nullptr,
options.DefaultServiceVersion.GetValue().data()});
writer.Write(Storage::Details::XmlNode{Storage::Details::XmlNodeType::EndTag});
}
writer.Write(Storage::Details::XmlNode{
Storage::Details::XmlNodeType::StartTag, "DeleteRetentionPolicy"});
writer.Write(Storage::Details::XmlNode{Storage::Details::XmlNodeType::StartTag,
"DeleteRetentionPolicy"});
BlobRetentionPolicyToXml(writer, options.DeleteRetentionPolicy);
writer.Write(Storage::Details::XmlNode{Storage::Details::XmlNodeType::EndTag});
writer.Write(
@ -3402,8 +3402,8 @@ namespace Azure { namespace Storage { namespace Blobs {
writer.Write(Storage::Details::XmlNode{
Storage::Details::XmlNodeType::Text, nullptr, options.Write ? "true" : "false"});
writer.Write(Storage::Details::XmlNode{Storage::Details::XmlNodeType::EndTag});
writer.Write(Storage::Details::XmlNode{
Storage::Details::XmlNodeType::StartTag, "RetentionPolicy"});
writer.Write(Storage::Details::XmlNode{Storage::Details::XmlNodeType::StartTag,
"RetentionPolicy"});
BlobRetentionPolicyToXml(writer, options.RetentionPolicy);
writer.Write(Storage::Details::XmlNode{Storage::Details::XmlNodeType::EndTag});
}
@ -3434,12 +3434,11 @@ namespace Azure { namespace Storage { namespace Blobs {
writer.Write(Storage::Details::XmlNode{
Storage::Details::XmlNodeType::Text, nullptr, options.ExposedHeaders.data()});
writer.Write(Storage::Details::XmlNode{Storage::Details::XmlNodeType::EndTag});
writer.Write(Storage::Details::XmlNode{
Storage::Details::XmlNodeType::StartTag, "MaxAgeInSeconds"});
writer.Write(Storage::Details::XmlNode{
Storage::Details::XmlNodeType::Text,
nullptr,
std::to_string(options.MaxAgeInSeconds).data()});
writer.Write(Storage::Details::XmlNode{Storage::Details::XmlNodeType::StartTag,
"MaxAgeInSeconds"});
writer.Write(Storage::Details::XmlNode{Storage::Details::XmlNodeType::Text,
nullptr,
std::to_string(options.MaxAgeInSeconds).data()});
writer.Write(Storage::Details::XmlNode{Storage::Details::XmlNodeType::EndTag});
writer.Write(Storage::Details::XmlNode{Storage::Details::XmlNodeType::EndTag});
}
@ -3462,14 +3461,14 @@ namespace Azure { namespace Storage { namespace Blobs {
{
writer.Write(
Storage::Details::XmlNode{Storage::Details::XmlNodeType::StartTag, "IncludeAPIs"});
writer.Write(Storage::Details::XmlNode{
Storage::Details::XmlNodeType::Text,
nullptr,
options.IncludeApis.GetValue() ? "true" : "false"});
writer.Write(
Storage::Details::XmlNode{Storage::Details::XmlNodeType::Text,
nullptr,
options.IncludeApis.GetValue() ? "true" : "false"});
writer.Write(Storage::Details::XmlNode{Storage::Details::XmlNodeType::EndTag});
}
writer.Write(Storage::Details::XmlNode{
Storage::Details::XmlNodeType::StartTag, "RetentionPolicy"});
writer.Write(Storage::Details::XmlNode{Storage::Details::XmlNodeType::StartTag,
"RetentionPolicy"});
BlobRetentionPolicyToXml(writer, options.RetentionPolicy);
writer.Write(Storage::Details::XmlNode{Storage::Details::XmlNodeType::EndTag});
}
@ -3487,10 +3486,9 @@ namespace Azure { namespace Storage { namespace Blobs {
{
writer.Write(
Storage::Details::XmlNode{Storage::Details::XmlNodeType::StartTag, "Days"});
writer.Write(Storage::Details::XmlNode{
Storage::Details::XmlNodeType::Text,
nullptr,
std::to_string(options.Days.GetValue()).data()});
writer.Write(Storage::Details::XmlNode{Storage::Details::XmlNodeType::Text,
nullptr,
std::to_string(options.Days.GetValue()).data()});
writer.Write(Storage::Details::XmlNode{Storage::Details::XmlNodeType::EndTag});
}
}
@ -3506,32 +3504,30 @@ namespace Azure { namespace Storage { namespace Blobs {
writer.Write(Storage::Details::XmlNode{Storage::Details::XmlNodeType::EndTag});
if (options.IndexDocument.HasValue())
{
writer.Write(Storage::Details::XmlNode{
Storage::Details::XmlNodeType::StartTag, "IndexDocument"});
writer.Write(Storage::Details::XmlNode{
Storage::Details::XmlNodeType::Text,
nullptr,
options.IndexDocument.GetValue().data()});
writer.Write(Storage::Details::XmlNode{Storage::Details::XmlNodeType::StartTag,
"IndexDocument"});
writer.Write(Storage::Details::XmlNode{Storage::Details::XmlNodeType::Text,
nullptr,
options.IndexDocument.GetValue().data()});
writer.Write(Storage::Details::XmlNode{Storage::Details::XmlNodeType::EndTag});
}
if (options.DefaultIndexDocumentPath.HasValue())
{
writer.Write(Storage::Details::XmlNode{
Storage::Details::XmlNodeType::StartTag, "DefaultIndexDocumentPath"});
writer.Write(Storage::Details::XmlNode{
Storage::Details::XmlNodeType::Text,
nullptr,
options.DefaultIndexDocumentPath.GetValue().data()});
writer.Write(Storage::Details::XmlNode{Storage::Details::XmlNodeType::StartTag,
"DefaultIndexDocumentPath"});
writer.Write(
Storage::Details::XmlNode{Storage::Details::XmlNodeType::Text,
nullptr,
options.DefaultIndexDocumentPath.GetValue().data()});
writer.Write(Storage::Details::XmlNode{Storage::Details::XmlNodeType::EndTag});
}
if (options.ErrorDocument404Path.HasValue())
{
writer.Write(Storage::Details::XmlNode{
Storage::Details::XmlNodeType::StartTag, "ErrorDocument404Path"});
writer.Write(Storage::Details::XmlNode{
Storage::Details::XmlNodeType::Text,
nullptr,
options.ErrorDocument404Path.GetValue().data()});
writer.Write(Storage::Details::XmlNode{Storage::Details::XmlNodeType::StartTag,
"ErrorDocument404Path"});
writer.Write(Storage::Details::XmlNode{Storage::Details::XmlNodeType::Text,
nullptr,
options.ErrorDocument404Path.GetValue().data()});
writer.Write(Storage::Details::XmlNode{Storage::Details::XmlNodeType::EndTag});
}
}
@ -5216,8 +5212,8 @@ namespace Azure { namespace Storage { namespace Blobs {
Storage::Details::XmlWriter& writer,
const SetBlobContainerAccessPolicyOptions& options)
{
writer.Write(Storage::Details::XmlNode{
Storage::Details::XmlNodeType::StartTag, "SignedIdentifiers"});
writer.Write(Storage::Details::XmlNode{Storage::Details::XmlNodeType::StartTag,
"SignedIdentifiers"});
for (const auto& i : options.SignedIdentifiers)
{
BlobSignedIdentifierToXml(writer, i);
@ -5229,8 +5225,8 @@ namespace Azure { namespace Storage { namespace Blobs {
Storage::Details::XmlWriter& writer,
const BlobSignedIdentifier& options)
{
writer.Write(Storage::Details::XmlNode{
Storage::Details::XmlNodeType::StartTag, "SignedIdentifier"});
writer.Write(Storage::Details::XmlNode{Storage::Details::XmlNodeType::StartTag,
"SignedIdentifier"});
writer.Write(Storage::Details::XmlNode{Storage::Details::XmlNodeType::StartTag, "Id"});
writer.Write(Storage::Details::XmlNode{
Storage::Details::XmlNodeType::Text, nullptr, options.Id.data()});
@ -7915,10 +7911,9 @@ namespace Azure { namespace Storage { namespace Blobs {
Storage::Details::XmlNode{Storage::Details::XmlNodeType::StartTag, "BlockList"});
for (const auto& i : options.BlockList)
{
writer.Write(Storage::Details::XmlNode{
Storage::Details::XmlNodeType::StartTag,
BlockTypeToString(i.first).data(),
i.second.data()});
writer.Write(Storage::Details::XmlNode{Storage::Details::XmlNodeType::StartTag,
BlockTypeToString(i.first).data(),
i.second.data()});
}
writer.Write(Storage::Details::XmlNode{Storage::Details::XmlNodeType::EndTag});
}

View File

@ -59,4 +59,3 @@ namespace Azure { namespace Storage { namespace Blobs {
#undef AZURE_STORAGE_BLOBS_VERSION_MINOR
#undef AZURE_STORAGE_BLOBS_VERSION_PATCH
#undef AZURE_STORAGE_BLOBS_VERSION_PRERELEASE

View File

@ -44,7 +44,8 @@ namespace Azure { namespace Storage { namespace Blobs {
{
policies.emplace_back(p->Clone());
}
policies.emplace_back(std::make_unique<Storage::Details::StorageRetryPolicy>(options.RetryOptions));
policies.emplace_back(
std::make_unique<Storage::Details::StorageRetryPolicy>(options.RetryOptions));
for (const auto& p : options.PerRetryPolicies)
{
policies.emplace_back(p->Clone());

View File

@ -167,15 +167,14 @@ namespace Azure { namespace Storage { namespace Test {
}
}
for (auto permissions :
{Sas::BlobSasPermissions::All,
Sas::BlobSasPermissions::Read,
Sas::BlobSasPermissions::Write,
Sas::BlobSasPermissions::Delete,
Sas::BlobSasPermissions::Add,
Sas::BlobSasPermissions::Create,
Sas::BlobSasPermissions::Tags,
Sas::BlobSasPermissions::DeleteVersion})
for (auto permissions : {Sas::BlobSasPermissions::All,
Sas::BlobSasPermissions::Read,
Sas::BlobSasPermissions::Write,
Sas::BlobSasPermissions::Delete,
Sas::BlobSasPermissions::Add,
Sas::BlobSasPermissions::Create,
Sas::BlobSasPermissions::Tags,
Sas::BlobSasPermissions::DeleteVersion})
{
blobSasBuilder.SetPermissions(permissions);
auto sasToken = blobSasBuilder.GenerateSasToken(*keyCredential);
@ -267,15 +266,14 @@ namespace Azure { namespace Storage { namespace Test {
EXPECT_NO_THROW(serviceClient.ListBlobContainersSegment());
}
for (auto permissions :
{Sas::BlobContainerSasPermissions::All,
Sas::BlobContainerSasPermissions::Read,
Sas::BlobContainerSasPermissions::Write,
Sas::BlobContainerSasPermissions::Delete,
Sas::BlobContainerSasPermissions::List,
Sas::BlobContainerSasPermissions::Add,
Sas::BlobContainerSasPermissions::Create,
Sas::BlobContainerSasPermissions::Tags})
for (auto permissions : {Sas::BlobContainerSasPermissions::All,
Sas::BlobContainerSasPermissions::Read,
Sas::BlobContainerSasPermissions::Write,
Sas::BlobContainerSasPermissions::Delete,
Sas::BlobContainerSasPermissions::List,
Sas::BlobContainerSasPermissions::Add,
Sas::BlobContainerSasPermissions::Create,
Sas::BlobContainerSasPermissions::Tags})
{
containerSasBuilder.SetPermissions(permissions);
auto sasToken = containerSasBuilder.GenerateSasToken(*keyCredential);

View File

@ -59,4 +59,3 @@ namespace Azure { namespace Storage { namespace Common {
#undef AZURE_STORAGE_COMMON_VERSION_MINOR
#undef AZURE_STORAGE_COMMON_VERSION_PATCH
#undef AZURE_STORAGE_COMMON_VERSION_PRERELEASE

View File

@ -94,8 +94,8 @@ namespace Azure { namespace Storage { namespace Sas {
+ "\n" + (IPRange.HasValue() ? IPRange.GetValue() : "") + "\n" + protocol + "\n"
+ Storage::Details::DefaultSasVersion + "\n";
std::string signature
= Base64Encode(Storage::Details::HmacSha256(stringToSign, Base64Decode(credential.GetAccountKey())));
std::string signature = Base64Encode(
Storage::Details::HmacSha256(stringToSign, Base64Decode(credential.GetAccountKey())));
Azure::Core::Http::Url builder;
builder.AppendQueryParameter(

View File

@ -2,13 +2,16 @@
// SPDX-License-Identifier: MIT
#include <azure/core/platform.hpp>
#include "azure/storage/common/crypt.hpp"
#if defined(AZ_PLATFORM_WINDOWS)
#if !defined(NOMINMAX)
#define NOMINMAX
#endif
// Windows needs to go before bcrypt
#include <windows.h>
#include <bcrypt.h>
#elif defined(AZ_PLATFORM_POSIX)
#include <openssl/bio.h>

View File

@ -2,6 +2,7 @@
// SPDX-License-Identifier: MIT
#include <azure/core/platform.hpp>
#include "azure/storage/common/file_io.hpp"
#if defined(AZ_PLATFORM_POSIX)

View File

@ -18,18 +18,17 @@ namespace Azure { namespace Storage { namespace Details {
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::Strings::ToLower(headerName));
if (ite != headers.end())

View File

@ -2,6 +2,7 @@
// SPDX-License-Identifier: MIT
#include <azure/core/platform.hpp>
#include "azure/storage/common/storage_per_retry_policy.hpp"
#include <ctime>

View File

@ -8,7 +8,7 @@
#include <map>
#include <string>
namespace Azure { namespace Storage{ namespace Files { namespace DataLake { namespace Details {
namespace Azure { namespace Storage { namespace Files { namespace DataLake { namespace Details {
std::string GetBlobUriFromUri(const std::string& uri);
std::string GetDfsUriFromUri(const std::string& uri);

View File

@ -59,4 +59,3 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
#undef AZURE_STORAGE_FILES_DATALAKE_VERSION_MINOR
#undef AZURE_STORAGE_FILES_DATALAKE_VERSION_PATCH
#undef AZURE_STORAGE_FILES_DATALAKE_VERSION_PRERELEASE

View File

@ -1,8 +1,8 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT
#include "azure/identity/client_secret_credential.hpp"
#include "datalake_file_system_client_test.hpp"
#include "azure/identity/client_secret_credential.hpp"
#include "azure/storage/common/crypt.hpp"
#include "azure/storage/files/datalake/datalake_options.hpp"

View File

@ -1371,10 +1371,9 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
{
writer.Write(
Storage::Details::XmlNode{Storage::Details::XmlNodeType::StartTag, "Days"});
writer.Write(Storage::Details::XmlNode{
Storage::Details::XmlNodeType::Text,
nullptr,
std::to_string(object.Days.GetValue()).data()});
writer.Write(Storage::Details::XmlNode{Storage::Details::XmlNodeType::Text,
nullptr,
std::to_string(object.Days.GetValue()).data()});
writer.Write(Storage::Details::XmlNode{Storage::Details::XmlNodeType::EndTag});
}
}
@ -1395,14 +1394,14 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
{
writer.Write(
Storage::Details::XmlNode{Storage::Details::XmlNodeType::StartTag, "IncludeAPIs"});
writer.Write(Storage::Details::XmlNode{
Storage::Details::XmlNodeType::Text,
nullptr,
object.IncludeApis.GetValue() ? "true" : "false"});
writer.Write(
Storage::Details::XmlNode{Storage::Details::XmlNodeType::Text,
nullptr,
object.IncludeApis.GetValue() ? "true" : "false"});
writer.Write(Storage::Details::XmlNode{Storage::Details::XmlNodeType::EndTag});
}
writer.Write(Storage::Details::XmlNode{
Storage::Details::XmlNodeType::StartTag, "RetentionPolicy"});
writer.Write(Storage::Details::XmlNode{Storage::Details::XmlNodeType::StartTag,
"RetentionPolicy"});
ShareRetentionPolicyToXml(writer, object.RetentionPolicy);
writer.Write(Storage::Details::XmlNode{Storage::Details::XmlNodeType::EndTag});
}
@ -1433,12 +1432,11 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
writer.Write(Storage::Details::XmlNode{
Storage::Details::XmlNodeType::Text, nullptr, object.ExposedHeaders.data()});
writer.Write(Storage::Details::XmlNode{Storage::Details::XmlNodeType::EndTag});
writer.Write(Storage::Details::XmlNode{
Storage::Details::XmlNodeType::StartTag, "MaxAgeInSeconds"});
writer.Write(Storage::Details::XmlNode{
Storage::Details::XmlNodeType::Text,
nullptr,
std::to_string(object.MaxAgeInSeconds).data()});
writer.Write(Storage::Details::XmlNode{Storage::Details::XmlNodeType::StartTag,
"MaxAgeInSeconds"});
writer.Write(Storage::Details::XmlNode{Storage::Details::XmlNodeType::Text,
nullptr,
std::to_string(object.MaxAgeInSeconds).data()});
writer.Write(Storage::Details::XmlNode{Storage::Details::XmlNodeType::EndTag});
writer.Write(Storage::Details::XmlNode{Storage::Details::XmlNodeType::EndTag});
}
@ -1470,8 +1468,8 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
Storage::Details::XmlWriter& writer,
const Models::ShareProtocolSettings& object)
{
writer.Write(Storage::Details::XmlNode{
Storage::Details::XmlNodeType::StartTag, "ProtocolSettings"});
writer.Write(Storage::Details::XmlNode{Storage::Details::XmlNodeType::StartTag,
"ProtocolSettings"});
SmbSettingsToXml(writer, object.Settings);
writer.Write(Storage::Details::XmlNode{Storage::Details::XmlNodeType::EndTag});
}
@ -1480,8 +1478,8 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
Storage::Details::XmlWriter& writer,
const Models::StorageServiceProperties& object)
{
writer.Write(Storage::Details::XmlNode{
Storage::Details::XmlNodeType::StartTag, "StorageServiceProperties"});
writer.Write(Storage::Details::XmlNode{Storage::Details::XmlNodeType::StartTag,
"StorageServiceProperties"});
writer.Write(
Storage::Details::XmlNode{Storage::Details::XmlNodeType::StartTag, "HourMetrics"});
MetricsToXml(writer, object.HourMetrics);
@ -4149,8 +4147,8 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
Storage::Details::XmlWriter& writer,
const Models::SignedIdentifier& object)
{
writer.Write(Storage::Details::XmlNode{
Storage::Details::XmlNodeType::StartTag, "SignedIdentifier"});
writer.Write(Storage::Details::XmlNode{Storage::Details::XmlNodeType::StartTag,
"SignedIdentifier"});
writer.Write(Storage::Details::XmlNode{Storage::Details::XmlNodeType::StartTag, "Id"});
writer.Write(Storage::Details::XmlNode{
Storage::Details::XmlNodeType::Text, nullptr, object.Id.data()});
@ -4163,8 +4161,8 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
Storage::Details::XmlWriter& writer,
const std::vector<Models::SignedIdentifier>& object)
{
writer.Write(Storage::Details::XmlNode{
Storage::Details::XmlNodeType::StartTag, "SignedIdentifiers"});
writer.Write(Storage::Details::XmlNode{Storage::Details::XmlNodeType::StartTag,
"SignedIdentifiers"});
for (const auto& item : object)
{
SignedIdentifierToXml(writer, item);

View File

@ -72,7 +72,8 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
ShareClient WithSnapshot(const std::string& snapshot) const;
/**
* @brief Gets the ShareDirectoryClient that's pointing to the root directory of current ShareClient
* @brief Gets the ShareDirectoryClient that's pointing to the root directory of current
* ShareClient
* @return ShareDirectoryClient The root directory of the share.
*/
ShareDirectoryClient GetRootShareDirectoryClient() const;

View File

@ -47,8 +47,8 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
const ShareClientOptions& options = ShareClientOptions());
/**
* @brief Initialize a new instance of ShareDirectoryClient using anonymous access or shared access
* signature.
* @brief Initialize a new instance of ShareDirectoryClient using anonymous access or shared
* access signature.
* @param shareDirectoryUri The URI of the directory this client's request targets.
* @param options Optional parameters used to initialize the client.
*/
@ -64,7 +64,8 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
std::string GetUri() const { return m_shareDirectoryUri.GetAbsoluteUrl(); }
/**
* @brief Create a ShareDirectoryClient that's a sub directory of the current ShareDirectoryClient
* @brief Create a ShareDirectoryClient that's a sub directory of the current
* ShareDirectoryClient
* @param subDirectoryName The name of the subdirectory.
* @return ShareDirectoryClient A directory client that can be used to manage a share directory
* resource.

View File

@ -232,4 +232,4 @@ namespace Azure { namespace Storage { namespace Sas {
std::string Permissions;
};
}}} // namespace Azure::Storage::Files::Shares
}}} // namespace Azure::Storage::Sas

View File

@ -59,4 +59,3 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
#undef AZURE_STORAGE_FILES_SHARES_VERSION_MINOR
#undef AZURE_STORAGE_FILES_SHARES_VERSION_PATCH
#undef AZURE_STORAGE_FILES_SHARES_VERSION_PRERELEASE

View File

@ -51,7 +51,8 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
{
policies.emplace_back(p->Clone());
}
policies.emplace_back(std::make_unique<Storage::Details::StorageRetryPolicy>(options.RetryOptions));
policies.emplace_back(
std::make_unique<Storage::Details::StorageRetryPolicy>(options.RetryOptions));
for (const auto& p : options.PerRetryPolicies)
{
policies.emplace_back(p->Clone());

View File

@ -90,7 +90,8 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
m_pipeline = std::make_shared<Azure::Core::Http::HttpPipeline>(policies);
}
ShareDirectoryClient ShareDirectoryClient::GetSubShareDirectoryClient(const std::string& subDirectoryName) const
ShareDirectoryClient ShareDirectoryClient::GetSubShareDirectoryClient(
const std::string& subDirectoryName) const
{
auto builder = m_shareDirectoryUri;
builder.AppendPath(Storage::Details::UrlEncodePath(subDirectoryName));
@ -104,7 +105,8 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
return ShareFileClient(builder, m_pipeline);
}
ShareDirectoryClient ShareDirectoryClient::WithShareSnapshot(const std::string& shareSnapshot) const
ShareDirectoryClient ShareDirectoryClient::WithShareSnapshot(
const std::string& shareSnapshot) const
{
ShareDirectoryClient newClient(*this);
if (shareSnapshot.empty())
@ -272,7 +274,8 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
std::move(ret), result.ExtractRawResponse());
}
Azure::Core::Response<Models::ForceCloseDirectoryHandleResult> ShareDirectoryClient::ForceCloseHandle(
Azure::Core::Response<Models::ForceCloseDirectoryHandleResult>
ShareDirectoryClient::ForceCloseHandle(
const std::string& handleId,
const ForceCloseDirectoryHandleOptions& options) const
{
@ -285,7 +288,8 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
}
Azure::Core::Response<Models::ForceCloseAllDirectoryHandlesResult>
ShareDirectoryClient::ForceCloseAllHandles(const ForceCloseAllDirectoryHandlesOptions& options) const
ShareDirectoryClient::ForceCloseAllHandles(
const ForceCloseAllDirectoryHandlesOptions& options) const
{
auto protocolLayerOptions = Details::ShareRestClient::Directory::ForceCloseHandlesOptions();
protocolLayerOptions.HandleId = c_FileAllHandles;

View File

@ -32,7 +32,8 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
if (parsedConnectionString.KeyCredential)
{
return ShareFileClient(fileUri.GetAbsoluteUrl(), parsedConnectionString.KeyCredential, options);
return ShareFileClient(
fileUri.GetAbsoluteUrl(), parsedConnectionString.KeyCredential, options);
}
else
{
@ -68,7 +69,9 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
m_pipeline = std::make_shared<Azure::Core::Http::HttpPipeline>(policies);
}
ShareFileClient::ShareFileClient(const std::string& shareFileUri, const ShareClientOptions& options)
ShareFileClient::ShareFileClient(
const std::string& shareFileUri,
const ShareClientOptions& options)
: m_shareFileUri(shareFileUri)
{
std::vector<std::unique_ptr<Azure::Core::Http::HttpPolicy>> policies;
@ -486,8 +489,8 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
Models::ForceCloseFileHandleResult(), result.ExtractRawResponse());
}
Azure::Core::Response<Models::ForceCloseAllFileHandlesResult> ShareFileClient::ForceCloseAllHandles(
const ForceCloseAllFileHandlesOptions& options) const
Azure::Core::Response<Models::ForceCloseAllFileHandlesResult>
ShareFileClient::ForceCloseAllHandles(const ForceCloseAllFileHandlesOptions& options) const
{
auto protocolLayerOptions = Details::ShareRestClient::File::ForceCloseHandlesOptions();
protocolLayerOptions.HandleId = c_FileAllHandles;

View File

@ -48,7 +48,8 @@ namespace Azure { namespace Storage { namespace Test {
for (int32_t i = 0; i < 5; ++i)
{
auto fileName = RandomString(10);
Files::Shares::ShareFileClient client = m_fileShareDirectoryClient->GetShareFileClient(fileName);
Files::Shares::ShareFileClient client
= m_fileShareDirectoryClient->GetShareFileClient(fileName);
EXPECT_NO_THROW(client.Create(1024));
fileClients.emplace_back(std::move(client));
}
@ -62,7 +63,8 @@ namespace Azure { namespace Storage { namespace Test {
for (int32_t i = 0; i < 5; ++i)
{
auto fileName = RandomString(10);
Files::Shares::ShareFileClient client = m_fileShareDirectoryClient->GetShareFileClient(fileName);
Files::Shares::ShareFileClient client
= m_fileShareDirectoryClient->GetShareFileClient(fileName);
EXPECT_NO_THROW(client.Create(1024));
EXPECT_NO_THROW(client.Create(1024));
}

View File

@ -70,13 +70,12 @@ namespace Azure { namespace Storage { namespace Test {
EXPECT_NO_THROW(shareClient.ListFilesAndDirectoriesSegment());
};
for (auto permissions :
{Sas::ShareSasPermissions::Read,
Sas::ShareSasPermissions::Write,
Sas::ShareSasPermissions::Delete,
Sas::ShareSasPermissions::List,
Sas::ShareSasPermissions::Create,
Sas::ShareSasPermissions::All})
for (auto permissions : {Sas::ShareSasPermissions::Read,
Sas::ShareSasPermissions::Write,
Sas::ShareSasPermissions::Delete,
Sas::ShareSasPermissions::List,
Sas::ShareSasPermissions::Create,
Sas::ShareSasPermissions::All})
{
shareSasBuilder.SetPermissions(permissions);
auto sasToken = shareSasBuilder.GenerateSasToken(*keyCredential);
@ -103,11 +102,10 @@ namespace Azure { namespace Storage { namespace Test {
}
}
for (auto permissions :
{Sas::ShareFileSasPermissions::Read,
Sas::ShareFileSasPermissions::Write,
Sas::ShareFileSasPermissions::Delete,
Sas::ShareFileSasPermissions::Create})
for (auto permissions : {Sas::ShareFileSasPermissions::Read,
Sas::ShareFileSasPermissions::Write,
Sas::ShareFileSasPermissions::Delete,
Sas::ShareFileSasPermissions::Create})
{
fileSasBuilder.SetPermissions(permissions);
auto sasToken = fileSasBuilder.GenerateSasToken(*keyCredential);

View File

@ -8,7 +8,4 @@
using namespace Azure::Template;
std::string const TemplateClient::ClientVersion()
{
return Version::VersionString();
}
std::string const TemplateClient::ClientVersion() { return Version::VersionString(); }

View File

@ -10,6 +10,6 @@ using namespace Azure::Template;
TEST(Template, Basic)
{
TemplateClient templateClient;
EXPECT_FALSE(templateClient.ClientVersion().empty());
}