From ecbead7761aeeab15e32d3550b914899e59f4bf0 Mon Sep 17 00:00:00 2001 From: Kan Tang Date: Wed, 27 Jan 2021 07:03:29 -0800 Subject: [PATCH] Remove c_ for constants. (#1491) * Remove c_ for constants. * Update CHANGELOG.md --- .../src/datalake_utilities.cpp | 12 ++--- .../test/datalake_file_system_client_test.cpp | 4 +- .../test/datalake_service_client_test.cpp | 4 +- .../azure-storage-files-shares/CHANGELOG.md | 5 ++ .../storage/files/shares/share_constants.hpp | 16 +++--- .../src/share_client.cpp | 4 +- .../src/share_directory_client.cpp | 18 +++---- .../src/share_file_client.cpp | 54 +++++++++---------- .../test/share_service_client_test.cpp | 4 +- 9 files changed, 63 insertions(+), 58 deletions(-) diff --git a/sdk/storage/azure-storage-files-datalake/src/datalake_utilities.cpp b/sdk/storage/azure-storage-files-datalake/src/datalake_utilities.cpp index d61eae8c0..e823ab96b 100644 --- a/sdk/storage/azure-storage-files-datalake/src/datalake_utilities.cpp +++ b/sdk/storage/azure-storage-files-datalake/src/datalake_utilities.cpp @@ -9,16 +9,16 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake { namespace Details { - const static std::string c_DfsEndPointIdentifier = ".dfs."; - const static std::string c_BlobEndPointIdentifier = ".blob."; + const static std::string DfsEndPointIdentifier = ".dfs."; + const static std::string BlobEndPointIdentifier = ".blob."; std::string GetBlobUrlFromUrl(const std::string& url) { std::string result = url; - auto pos = result.find(c_DfsEndPointIdentifier); + auto pos = result.find(DfsEndPointIdentifier); if (pos != std::string::npos) { - result.replace(pos, c_DfsEndPointIdentifier.size(), c_BlobEndPointIdentifier); + result.replace(pos, DfsEndPointIdentifier.size(), BlobEndPointIdentifier); } return result; } @@ -26,10 +26,10 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake { nam std::string GetDfsUrlFromUrl(const std::string& url) { std::string result = url; - auto pos = result.find(c_BlobEndPointIdentifier); + auto pos = result.find(BlobEndPointIdentifier); if (pos != std::string::npos) { - result.replace(pos, c_BlobEndPointIdentifier.size(), c_DfsEndPointIdentifier); + result.replace(pos, BlobEndPointIdentifier.size(), DfsEndPointIdentifier); } return result; } diff --git a/sdk/storage/azure-storage-files-datalake/test/datalake_file_system_client_test.cpp b/sdk/storage/azure-storage-files-datalake/test/datalake_file_system_client_test.cpp index 7d4626442..520fc1ab5 100644 --- a/sdk/storage/azure-storage-files-datalake/test/datalake_file_system_client_test.cpp +++ b/sdk/storage/azure-storage-files-datalake/test/datalake_file_system_client_test.cpp @@ -10,7 +10,7 @@ namespace Azure { namespace Storage { namespace Test { - const size_t c_PATH_TEST_SIZE = 5; + const size_t PathTestSize = 5; std::shared_ptr DataLakeFileSystemClientTest::m_fileSystemClient; @@ -33,7 +33,7 @@ namespace Azure { namespace Storage { namespace Test { m_directoryB = LowercaseRandomString(); m_pathNameSetA.clear(); m_pathNameSetB.clear(); - for (size_t i = 0; i < c_PATH_TEST_SIZE; ++i) + for (size_t i = 0; i < PathTestSize; ++i) { { auto name = m_directoryA + "/" + LowercaseRandomString(); diff --git a/sdk/storage/azure-storage-files-datalake/test/datalake_service_client_test.cpp b/sdk/storage/azure-storage-files-datalake/test/datalake_service_client_test.cpp index 5a24fa868..11f7dd13e 100644 --- a/sdk/storage/azure-storage-files-datalake/test/datalake_service_client_test.cpp +++ b/sdk/storage/azure-storage-files-datalake/test/datalake_service_client_test.cpp @@ -8,7 +8,7 @@ namespace Azure { namespace Storage { namespace Test { - const size_t c_FILE_SYSTEM_TEST_SIZE = 5; + const size_t FileSystemTestSize = 5; std::shared_ptr DataLakeServiceClientTest::m_dataLakeServiceClient; @@ -26,7 +26,7 @@ namespace Azure { namespace Storage { namespace Test { m_fileSystemPrefixB = LowercaseRandomString(10); m_fileSystemNameSetA.clear(); m_fileSystemNameSetB.clear(); - for (size_t i = 0; i < c_FILE_SYSTEM_TEST_SIZE; ++i) + for (size_t i = 0; i < FileSystemTestSize; ++i) { { auto name = m_fileSystemPrefixA + LowercaseRandomString(10); diff --git a/sdk/storage/azure-storage-files-shares/CHANGELOG.md b/sdk/storage/azure-storage-files-shares/CHANGELOG.md index 1eff9036e..ba656c0af 100644 --- a/sdk/storage/azure-storage-files-shares/CHANGELOG.md +++ b/sdk/storage/azure-storage-files-shares/CHANGELOG.md @@ -14,6 +14,11 @@ - Added `ShareLeaseClient`, all lease related APIs are moved to `ShareLeaseClient`. - Changed lease duration to be `std::chrono::seconds`. - Added `RequestId` in each return types for REST API calls, except for concurrent APIs. +- Removed `c_` for constants: `c_FileDefaultTimeValue`, `c_FileCopySourceTime`, `c_FileInheritPermission`, `FilePreserveSmbProperties` and `FileAllHandles`. + +### Other Changes and Improvements + +- Removed `c_` for constants and renamed to pascal format. ## 12.0.0-beta.6 (2020-01-14) diff --git a/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_constants.hpp b/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_constants.hpp index 04ab64e7d..ab96d0c1e 100644 --- a/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_constants.hpp +++ b/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_constants.hpp @@ -6,16 +6,16 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { - constexpr static const char* c_FileDefaultTimeValue = "now"; - constexpr static const char* c_FileCopySourceTime = "source"; - constexpr static const char* c_FileInheritPermission = "inherit"; - constexpr static const char* c_FilePreserveSmbProperties = "preserve"; - constexpr static const char* c_FileAllHandles = "*"; + constexpr static const char* FileDefaultTimeValue = "now"; + constexpr static const char* FileCopySourceTime = "source"; + constexpr static const char* FileInheritPermission = "inherit"; + constexpr static const char* FilePreserveSmbProperties = "preserve"; + constexpr static const char* FileAllHandles = "*"; namespace Details { - constexpr int64_t c_FileUploadDefaultChunkSize = 4 * 1024 * 1024; - constexpr int64_t c_FileDownloadDefaultChunkSize = 4 * 1024 * 1024; - constexpr static const char* c_ShareSnapshotQueryParameter = "sharesnapshot"; + constexpr int64_t FileUploadDefaultChunkSize = 4 * 1024 * 1024; + constexpr int64_t FileDownloadDefaultChunkSize = 4 * 1024 * 1024; + constexpr static const char* ShareSnapshotQueryParameter = "sharesnapshot"; // Error codes: constexpr static const char* ParentNotFound = "ParentNotFound"; diff --git a/sdk/storage/azure-storage-files-shares/src/share_client.cpp b/sdk/storage/azure-storage-files-shares/src/share_client.cpp index f5f801c01..2d2d15139 100644 --- a/sdk/storage/azure-storage-files-shares/src/share_client.cpp +++ b/sdk/storage/azure-storage-files-shares/src/share_client.cpp @@ -98,12 +98,12 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { ShareClient newClient(*this); if (snapshot.empty()) { - newClient.m_shareUrl.RemoveQueryParameter(Details::c_ShareSnapshotQueryParameter); + newClient.m_shareUrl.RemoveQueryParameter(Details::ShareSnapshotQueryParameter); } else { newClient.m_shareUrl.AppendQueryParameter( - Details::c_ShareSnapshotQueryParameter, + Details::ShareSnapshotQueryParameter, Storage::Details::UrlEncodeQueryParameter(snapshot)); } return newClient; diff --git a/sdk/storage/azure-storage-files-shares/src/share_directory_client.cpp b/sdk/storage/azure-storage-files-shares/src/share_directory_client.cpp index 653b9273a..67692576b 100644 --- a/sdk/storage/azure-storage-files-shares/src/share_directory_client.cpp +++ b/sdk/storage/azure-storage-files-shares/src/share_directory_client.cpp @@ -112,12 +112,12 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { ShareDirectoryClient newClient(*this); if (shareSnapshot.empty()) { - newClient.m_shareDirectoryUrl.RemoveQueryParameter(Details::c_ShareSnapshotQueryParameter); + newClient.m_shareDirectoryUrl.RemoveQueryParameter(Details::ShareSnapshotQueryParameter); } else { newClient.m_shareDirectoryUrl.AppendQueryParameter( - Details::c_ShareSnapshotQueryParameter, + Details::ShareSnapshotQueryParameter, Storage::Details::UrlEncodeQueryParameter(shareSnapshot)); } return newClient; @@ -143,7 +143,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { } else { - protocolLayerOptions.FileCreationTime = std::string(c_FileDefaultTimeValue); + protocolLayerOptions.FileCreationTime = std::string(FileDefaultTimeValue); } if (options.SmbProperties.LastWrittenOn.HasValue()) { @@ -153,7 +153,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { } else { - protocolLayerOptions.FileLastWriteTime = std::string(c_FileDefaultTimeValue); + protocolLayerOptions.FileLastWriteTime = std::string(FileDefaultTimeValue); } if (options.DirectoryPermission.HasValue()) { @@ -165,7 +165,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { } else { - protocolLayerOptions.FilePermission = std::string(c_FileInheritPermission); + protocolLayerOptions.FilePermission = std::string(FileInheritPermission); } auto result = Details::ShareRestClient::Directory::Create( m_shareDirectoryUrl, *m_pipeline, options.Context, protocolLayerOptions); @@ -265,7 +265,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { } else { - protocolLayerOptions.FileCreationTime = std::string(c_FileDefaultTimeValue); + protocolLayerOptions.FileCreationTime = std::string(FileDefaultTimeValue); } if (smbProperties.LastWrittenOn.HasValue()) { @@ -275,7 +275,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { } else { - protocolLayerOptions.FileLastWriteTime = std::string(c_FileDefaultTimeValue); + protocolLayerOptions.FileLastWriteTime = std::string(FileDefaultTimeValue); } if (options.FilePermission.HasValue()) { @@ -287,7 +287,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { } else { - protocolLayerOptions.FilePermission = std::string(c_FileInheritPermission); + protocolLayerOptions.FilePermission = std::string(FileInheritPermission); } return Details::ShareRestClient::Directory::SetProperties( m_shareDirectoryUrl, *m_pipeline, options.Context, protocolLayerOptions); @@ -366,7 +366,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { const ForceCloseAllShareDirectoryHandlesOptions& options) const { auto protocolLayerOptions = Details::ShareRestClient::Directory::ForceCloseHandlesOptions(); - protocolLayerOptions.HandleId = c_FileAllHandles; + protocolLayerOptions.HandleId = FileAllHandles; protocolLayerOptions.ContinuationToken = options.ContinuationToken; protocolLayerOptions.Recursive = options.Recursive; return Details::ShareRestClient::Directory::ForceCloseHandles( diff --git a/sdk/storage/azure-storage-files-shares/src/share_file_client.cpp b/sdk/storage/azure-storage-files-shares/src/share_file_client.cpp index b3d43cf74..2fb4ce1a2 100644 --- a/sdk/storage/azure-storage-files-shares/src/share_file_client.cpp +++ b/sdk/storage/azure-storage-files-shares/src/share_file_client.cpp @@ -99,12 +99,12 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { ShareFileClient newClient(*this); if (shareSnapshot.empty()) { - newClient.m_shareFileUrl.RemoveQueryParameter(Details::c_ShareSnapshotQueryParameter); + newClient.m_shareFileUrl.RemoveQueryParameter(Details::ShareSnapshotQueryParameter); } else { newClient.m_shareFileUrl.AppendQueryParameter( - Details::c_ShareSnapshotQueryParameter, + Details::ShareSnapshotQueryParameter, Storage::Details::UrlEncodeQueryParameter(shareSnapshot)); } return newClient; @@ -131,7 +131,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { } else { - protocolLayerOptions.FileCreationTime = std::string(c_FileDefaultTimeValue); + protocolLayerOptions.FileCreationTime = std::string(FileDefaultTimeValue); } if (options.SmbProperties.LastWrittenOn.HasValue()) { @@ -141,7 +141,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { } else { - protocolLayerOptions.FileLastWriteTime = std::string(c_FileDefaultTimeValue); + protocolLayerOptions.FileLastWriteTime = std::string(FileDefaultTimeValue); } if (options.Permission.HasValue()) { @@ -153,7 +153,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { } else { - protocolLayerOptions.FilePermission = std::string(c_FileInheritPermission); + protocolLayerOptions.FilePermission = std::string(FileInheritPermission); } protocolLayerOptions.XMsContentLength = fileSize; if (!options.HttpHeaders.ContentType.empty()) @@ -320,7 +320,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { } else { - protocolLayerOptions.FileCopyFileCreationTime = std::string(c_FileCopySourceTime); + protocolLayerOptions.FileCopyFileCreationTime = std::string(FileCopySourceTime); } if (options.SmbProperties.LastWrittenOn.HasValue()) { @@ -330,7 +330,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { } else { - protocolLayerOptions.FileCopyFileLastWriteTime = std::string(c_FileCopySourceTime); + protocolLayerOptions.FileCopyFileLastWriteTime = std::string(FileCopySourceTime); } if (options.PermissionCopyMode.HasValue()) { @@ -403,7 +403,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { } else { - protocolLayerOptions.FileCreationTime = std::string(c_FileDefaultTimeValue); + protocolLayerOptions.FileCreationTime = std::string(FileDefaultTimeValue); } if (smbProperties.LastWrittenOn.HasValue()) { @@ -413,7 +413,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { } else { - protocolLayerOptions.FileLastWriteTime = std::string(c_FileDefaultTimeValue); + protocolLayerOptions.FileLastWriteTime = std::string(FileDefaultTimeValue); } protocolLayerOptions.XMsContentLength = options.Size; protocolLayerOptions.LeaseIdOptional = options.AccessConditions.LeaseId; @@ -427,7 +427,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { } else { - protocolLayerOptions.FilePermission = std::string(c_FileInheritPermission); + protocolLayerOptions.FilePermission = std::string(FileInheritPermission); } if (!httpHeaders.ContentType.empty()) @@ -565,7 +565,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { ShareFileClient::ForceCloseAllHandles(const ForceCloseAllShareFileHandlesOptions& options) const { auto protocolLayerOptions = Details::ShareRestClient::File::ForceCloseHandlesOptions(); - protocolLayerOptions.HandleId = c_FileAllHandles; + protocolLayerOptions.HandleId = FileAllHandles; protocolLayerOptions.ContinuationToken = options.ContinuationToken; return Details::ShareRestClient::File::ForceCloseHandles( m_shareFileUrl, *m_pipeline, options.Context, protocolLayerOptions); @@ -580,7 +580,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { // thing in one shot. If it's a large file, we'll get its full size in Content-Range and can // keep downloading it in chunks. int64_t firstChunkOffset = options.Range.HasValue() ? options.Range.GetValue().Offset : 0; - int64_t firstChunkLength = Details::c_FileDownloadDefaultChunkSize; + int64_t firstChunkLength = Details::FileDownloadDefaultChunkSize; if (options.InitialChunkSize.HasValue()) { firstChunkLength = options.InitialChunkSize.GetValue(); @@ -679,10 +679,10 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { } else { - int64_t c_grainSize = 4 * 1024; + int64_t GrainSize = 4 * 1024; chunkSize = remainingSize / options.Concurrency; - chunkSize = (std::max(chunkSize, int64_t(1)) + c_grainSize - 1) / c_grainSize * c_grainSize; - chunkSize = std::min(chunkSize, Details::c_FileDownloadDefaultChunkSize); + chunkSize = (std::max(chunkSize, int64_t(1)) + GrainSize - 1) / GrainSize * GrainSize; + chunkSize = std::min(chunkSize, Details::FileDownloadDefaultChunkSize); } Storage::Details::ConcurrentTransfer( @@ -699,7 +699,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { // thing in one shot. If it's a large file, we'll get its full size in Content-Range and can // keep downloading it in chunks. int64_t firstChunkOffset = options.Range.HasValue() ? options.Range.GetValue().Offset : 0; - int64_t firstChunkLength = Details::c_FileDownloadDefaultChunkSize; + int64_t firstChunkLength = Details::FileDownloadDefaultChunkSize; if (options.InitialChunkSize.HasValue()) { firstChunkLength = options.InitialChunkSize.GetValue(); @@ -809,10 +809,10 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { } else { - int64_t c_grainSize = 4 * 1024; + int64_t GrainSize = 4 * 1024; chunkSize = remainingSize / options.Concurrency; - chunkSize = (std::max(chunkSize, int64_t(1)) + c_grainSize - 1) / c_grainSize * c_grainSize; - chunkSize = std::min(chunkSize, Details::c_FileDownloadDefaultChunkSize); + chunkSize = (std::max(chunkSize, int64_t(1)) + GrainSize - 1) / GrainSize * GrainSize; + chunkSize = std::min(chunkSize, Details::FileDownloadDefaultChunkSize); } Storage::Details::ConcurrentTransfer( @@ -843,7 +843,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { } else { - protocolLayerOptions.FileCreationTime = std::string(c_FileDefaultTimeValue); + protocolLayerOptions.FileCreationTime = std::string(FileDefaultTimeValue); } if (options.SmbProperties.LastWrittenOn.HasValue()) { @@ -853,7 +853,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { } else { - protocolLayerOptions.FileLastWriteTime = std::string(c_FileDefaultTimeValue); + protocolLayerOptions.FileLastWriteTime = std::string(FileDefaultTimeValue); } if (options.FilePermission.HasValue()) { @@ -865,7 +865,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { } else { - protocolLayerOptions.FilePermission = std::string(c_FileInheritPermission); + protocolLayerOptions.FilePermission = std::string(FileInheritPermission); } if (!options.HttpHeaders.ContentType.empty()) @@ -901,7 +901,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { m_shareFileUrl, *m_pipeline, options.Context, protocolLayerOptions); int64_t chunkSize = options.ChunkSize.HasValue() ? options.ChunkSize.GetValue() - : Details::c_FileUploadDefaultChunkSize; + : Details::FileUploadDefaultChunkSize; auto uploadPageFunc = [&](int64_t offset, int64_t length, int64_t chunkId, int64_t numChunks) { unused(chunkId, numChunks); @@ -943,7 +943,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { } else { - protocolLayerOptions.FileCreationTime = std::string(c_FileDefaultTimeValue); + protocolLayerOptions.FileCreationTime = std::string(FileDefaultTimeValue); } if (options.SmbProperties.LastWrittenOn.HasValue()) { @@ -953,7 +953,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { } else { - protocolLayerOptions.FileLastWriteTime = std::string(c_FileDefaultTimeValue); + protocolLayerOptions.FileLastWriteTime = std::string(FileDefaultTimeValue); } if (options.FilePermission.HasValue()) { @@ -965,7 +965,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { } else { - protocolLayerOptions.FilePermission = std::string(c_FileInheritPermission); + protocolLayerOptions.FilePermission = std::string(FileInheritPermission); } if (!options.HttpHeaders.ContentType.empty()) @@ -1001,7 +1001,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { m_shareFileUrl, *m_pipeline, options.Context, protocolLayerOptions); int64_t chunkSize = options.ChunkSize.HasValue() ? options.ChunkSize.GetValue() - : Details::c_FileUploadDefaultChunkSize; + : Details::FileUploadDefaultChunkSize; auto uploadPageFunc = [&](int64_t offset, int64_t length, int64_t chunkId, int64_t numChunks) { unused(chunkId, numChunks); diff --git a/sdk/storage/azure-storage-files-shares/test/share_service_client_test.cpp b/sdk/storage/azure-storage-files-shares/test/share_service_client_test.cpp index 7af57ff71..c43ee47bc 100644 --- a/sdk/storage/azure-storage-files-shares/test/share_service_client_test.cpp +++ b/sdk/storage/azure-storage-files-shares/test/share_service_client_test.cpp @@ -18,7 +18,7 @@ namespace Azure { namespace Storage { namespace Test { } } // namespace - const size_t c_SHARE_TEST_SIZE = 5; + const size_t ShareTestSize = 5; std::shared_ptr FileShareServiceClientTest::m_fileShareServiceClient; @@ -36,7 +36,7 @@ namespace Azure { namespace Storage { namespace Test { m_sharePrefixB = LowercaseRandomString(10); m_shareNameSetA.clear(); m_shareNameSetB.clear(); - for (size_t i = 0; i < c_SHARE_TEST_SIZE; ++i) + for (size_t i = 0; i < ShareTestSize; ++i) { { auto name = m_sharePrefixA + LowercaseRandomString(10);