PackageVersion made constexpr and moved to src/package_version.hpp (#2166)

This commit is contained in:
Anton Kolesnyk 2021-04-29 00:34:24 +00:00 committed by GitHub
parent 248dc0b96a
commit cd36753d76
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
58 changed files with 1227 additions and 514 deletions

View File

@ -124,7 +124,7 @@ macro(az_vcpkg_export targetName macroNamePart dllImportExportHeaderPath)
# Produce version file.
write_basic_package_version_file(
"${targetName}-cppConfigVersion.cmake"
VERSION ${AZ_LIBRARY_VERSION} # the version that we extracted from version.hpp
VERSION ${AZ_LIBRARY_VERSION} # the version that we extracted from package_version.hpp
COMPATIBILITY SameMajorVersion
)

View File

@ -2,8 +2,8 @@
# SPDX-License-Identifier: MIT
#
# Sets ${AZ_LIBRARY_VERSION} in the parent context with the version value
# constructed from version.hpp. The version.hpp must follow the example in
# templates for version information to parse correctly.
# constructed from package_version.hpp. The package_version.hpp must follow
# the example in templates for version information to parse correctly.
function(get_az_version VERSION_HPP_FILE)
if(NOT EXISTS ${VERSION_HPP_FILE})

View File

@ -4,11 +4,11 @@ $RepoRoot = "${PSScriptRoot}/../.."
$VersionRegex = '(#define AZURE_\w+_VERSION_MAJOR )(?<major>[0-9]+)(\s+#define AZURE_\w+_VERSION_MINOR )(?<minor>[0-9]+)(\s+#define AZURE_\w+_VERSION_PATCH )(?<patch>[0-9]+)(\s+#define AZURE_\w+_VERSION_PRERELEASE )"(?<prerelease>[a-zA-Z0-9.]*)"';
function Get-VersionHppLocaiton ($ServiceDirectory, $PackageName) {
$versionHppLocation = Get-ChildItem version.hpp -Path "$RepoRoot/sdk/$ServiceDirectory/$PackageName" -Recurse
Write-Verbose "version.hpp location: $versionHppLocation"
$versionHppLocation = Get-ChildItem package_version.hpp -Path "$RepoRoot/sdk/$ServiceDirectory/$PackageName" -Recurse
Write-Verbose "package_version.hpp location: $versionHppLocation"
if (!$versionHppLocation) {
Write-Warning "Could not locate version.hpp file in sdk/$ServiceDirectory/$PackageName"
Write-Warning "Could not locate package_version.hpp file in sdk/$ServiceDirectory/$PackageName"
}
return $versionHppLocation

View File

@ -6,11 +6,11 @@ Bumps up package versions after release
The root of the repo (defaults to ${PSScriptRoot}/..)
.PARAMETER ServiceDirectory
The service directory under <repo-root>/sdk/ used to find version.hpp
The service directory under <repo-root>/sdk/ used to find package_version.hpp
.PARAMETER PackageName
The package name under <repo-root>/sdk/<service-directory> used to find
version.hpp
package_version.hpp
.PARAMETER NewVersionString
New version string to use. Must follow SemVer conventions.
@ -48,7 +48,7 @@ function Update-Version(
exit 1
}
Write-Verbose "Saving version.hpp file..."
Write-Verbose "Saving package_version.hpp file..."
$versionHppContent = Get-Content $VersionHppLocation -Raw
if ($SemVer.IsPrerelease) {

View File

@ -81,7 +81,6 @@ set(
inc/azure/core/response.hpp
inc/azure/core/url.hpp
inc/azure/core/uuid.hpp
inc/azure/core/version.hpp
inc/azure/core.hpp
)
@ -102,16 +101,19 @@ set(
src/http/url.cpp
src/io/body_stream.cpp
src/io/random_access_file_body_stream.cpp
src/private/curl_connection.hpp
src/private/curl_connection_pool.hpp
src/private/curl_session.hpp
src/private/environment_log_level_listener.hpp
src/private/package_version.hpp
src/base64.cpp
src/context.cpp
src/datetime.cpp
src/environment_log_level_listener.cpp
src/environment_log_level_listener_private.hpp
src/exception.cpp
src/logger.cpp
src/operation_status.cpp
src/strings.cpp
src/version.cpp
)
add_library(azure-core ${AZURE_CORE_HEADER} ${AZURE_CORE_SOURCE})
@ -145,7 +147,7 @@ if(BUILD_TRANSPORT_WINHTTP)
target_link_libraries(azure-core PRIVATE winhttp)
endif()
get_az_version("${CMAKE_CURRENT_SOURCE_DIR}/inc/azure/core/version.hpp")
get_az_version("${CMAKE_CURRENT_SOURCE_DIR}/src/private/package_version.hpp")
generate_documentation(azure-core ${AZ_LIBRARY_VERSION})
az_vcpkg_export(

View File

@ -17,7 +17,7 @@
#if (!defined(WINAPI_PARTITION_DESKTOP) || WINAPI_PARTITION_DESKTOP) // See azure/core/platform.hpp
// for explanation.
#include "environment_log_level_listener_private.hpp"
#include "private/environment_log_level_listener.hpp"
#include "azure/core/datetime.hpp"
#include "azure/core/internal/strings.hpp"

View File

@ -7,7 +7,7 @@
#include <mutex>
#include <shared_mutex>
#include "environment_log_level_listener_private.hpp"
#include "private/environment_log_level_listener.hpp"
using namespace Azure::Core::Diagnostics;
using namespace Azure::Core::Diagnostics::_internal;

View File

@ -0,0 +1,200 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT
/**
* @file
* @brief The libcurl connection keeps the curl handle and performs the data transfer to the
* network.
*/
#pragma once
#include "azure/core/http/http.hpp"
#include <chrono>
#include <curl/curl.h>
#include <string>
namespace Azure { namespace Core { namespace Http {
namespace _detail {
// libcurl CURL_MAX_WRITE_SIZE is 64k. Using same value for default uploading chunk size.
// This can be customizable in the HttpRequest
constexpr static int64_t DefaultUploadChunkSize = 1024 * 64;
constexpr static auto DefaultLibcurlReaderSize = 1024;
// Run time error template
constexpr static const char* DefaultFailedToGetNewConnectionTemplate
= "Fail to get a new connection for: ";
constexpr static int DefaultMaxOpenNewConnectionIntentsAllowed = 10;
// After 3 connections are received from the pool and failed to send a request, the next
// connections would ask the pool to be clean and spawn new connection.
constexpr static int RequestPoolResetAfterConnectionFailed = 3;
// 90 sec -> cleaner wait time before next clean routine
constexpr static int DefaultCleanerIntervalMilliseconds = 1000 * 90;
// 60 sec -> expired connection is when it waits for 60 sec or more and it's not re-used
constexpr static int DefaultConnectionExpiredMilliseconds = 1000 * 60;
// Define the maximun allowed connections per host-index in the pool. If this number is reached
// for the host-index, next connections trying to be added to the pool will be ignored.
constexpr static size_t MaxConnectionsPerIndex = 1024;
} // namespace _detail
/**
* @brief Interface for the connection to the network with Curl.
*
* @remark This interface enables to mock the communication to the network with any behavior for
* testing.
*
*/
class CurlNetworkConnection {
protected:
bool m_isShutDown = false;
public:
/**
* @brief Allow derived classes calling a destructor.
*
*/
virtual ~CurlNetworkConnection() = default;
/**
* @brief Get the Connection Properties Key object
*
*/
virtual std::string const& GetConnectionKey() const = 0;
/**
* @brief Update last usage time for the connection.
*/
virtual void UpdateLastUsageTime() = 0;
/**
* @brief Checks whether this CURL connection is expired.
*/
virtual bool IsExpired() = 0;
/**
* @brief This function is used when working with streams to pull more data from the wire.
* Function will try to keep pulling data from socket until the buffer is all written or until
* there is no more data to get from the socket.
*
*/
virtual int64_t ReadFromSocket(uint8_t* buffer, int64_t bufferSize, Context const& context) = 0;
/**
* @brief This method will use libcurl socket to write all the bytes from buffer.
*
*/
virtual CURLcode SendBuffer(uint8_t const* buffer, size_t bufferSize, Context const& context)
= 0;
/**
* @brief Set the connection into an invalid and unusable state.
*
* @remark A connection won't be returned to the connection pool if it was shut it down.
*
*/
virtual void Shutdown() { m_isShutDown = true; };
/**
* @brief Check if the the connection was shut it down.
*
* @return `true` is the connection was shut it down.
*/
bool IsShutdown() const { return m_isShutDown; };
};
/**
* @brief CURL HTTP connection.
*/
class CurlConnection : public CurlNetworkConnection {
private:
CURL* m_handle;
curl_socket_t m_curlSocket;
std::chrono::steady_clock::time_point m_lastUseTime;
std::string m_connectionKey;
public:
/**
* @Brief Construct CURL HTTP connection.
*
* @param host HTTP connection host name.
*/
CurlConnection(CURL* handle, std::string connectionPropertiesKey)
: m_handle(handle), m_connectionKey(std::move(connectionPropertiesKey))
{
// Get the socket that libcurl is using from handle. Will use this to wait while
// reading/writing
// into wire
#if defined(_MSC_VER)
#pragma warning(push)
// C26812: The enum type 'CURLcode' is un-scoped. Prefer 'enum class' over 'enum' (Enum.3)
#pragma warning(disable : 26812)
#endif
auto result = curl_easy_getinfo(m_handle, CURLINFO_ACTIVESOCKET, &m_curlSocket);
#if defined(_MSC_VER)
#pragma warning(pop)
#endif
if (result != CURLE_OK)
{
throw Http::TransportException(
"Broken connection. Couldn't get the active sockect for it."
+ std::string(curl_easy_strerror(result)));
}
}
/**
* @brief Destructor.
* @details Cleans up CURL (invokes `curl_easy_cleanup()`).
*/
~CurlConnection() override { curl_easy_cleanup(this->m_handle); }
std::string const& GetConnectionKey() const override { return this->m_connectionKey; }
/**
* @brief Update last usage time for the connection.
*/
void UpdateLastUsageTime() override
{
this->m_lastUseTime = std::chrono::steady_clock::now();
}
/**
* @brief Checks whether this CURL connection is expired.
* @return `true` if this connection is considered expired, `false` otherwise.
*/
bool IsExpired() override
{
auto connectionOnWaitingTimeMs = std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::steady_clock::now() - this->m_lastUseTime);
return connectionOnWaitingTimeMs.count() >= _detail::DefaultConnectionExpiredMilliseconds;
}
/**
* @brief This function is used when working with streams to pull more data from the wire.
* Function will try to keep pulling data from socket until the buffer is all written or until
* there is no more data to get from the socket.
*
* @param context #Azure::Core::Context so that operation can be cancelled.
* @param buffer ptr to buffer where to copy bytes from socket.
* @param bufferSize size of the buffer and the requested bytes to be pulled from wire.
* @return return the numbers of bytes pulled from socket. It can be less than what it was
* requested.
*/
int64_t ReadFromSocket(uint8_t* buffer, int64_t bufferSize, Context const& context) override;
/**
* @brief This method will use libcurl socket to write all the bytes from buffer.
*
* @remarks Hardcoded timeout is used in case a socket stop responding.
*
* @param context #Azure::Core::Context so that operation can be cancelled.
* @param buffer ptr to the data to be sent to wire.
* @param bufferSize size of the buffer to send.
* @return CURL_OK when response is sent successfully.
*/
CURLcode SendBuffer(uint8_t const* buffer, size_t bufferSize, Context const& context)
override;
void Shutdown() override;
};
}}} // namespace Azure::Core::Http

View File

@ -0,0 +1,127 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT
/**
* @file
* @brief The curl connection pool provides the utilities for creating a new curl connection and to
* keep a pool of connections to be re-used.
*/
#pragma once
#include "azure/core/dll_import_export.hpp"
#include "azure/core/http/http.hpp"
#include "private/curl_connection.hpp"
#include <atomic>
#include <condition_variable>
#include <curl/curl.h>
#include <list>
#include <map>
#include <memory>
#include <mutex>
#include <thread>
#if defined(TESTING_BUILD)
// Define the class name that reads from ConnectionPool private members
namespace Azure { namespace Core { namespace Test {
class CurlConnectionPool_connectionPoolTest_Test;
class CurlConnectionPool_uniquePort_Test;
}}} // namespace Azure::Core::Test
#endif
namespace Azure { namespace Core { namespace Http { namespace _detail {
/**
* @brief CURL HTTP connection pool makes it possible to re-use one curl connection to perform
* more than one request. Use this component when connections are not re-used by default.
*
* This pool offers static methods and it is allocated statically. There can be only one
* connection pool per application.
*/
class CurlConnectionPool {
#if defined(TESTING_BUILD)
// Give access to private to this tests class
friend class Azure::Core::Test::CurlConnectionPool_connectionPoolTest_Test;
friend class Azure::Core::Test::CurlConnectionPool_uniquePort_Test;
#endif
public:
~CurlConnectionPool()
{
using namespace Azure::Core::Http::_detail;
if (m_cleanThread.joinable())
{
{
std::unique_lock<std::mutex> lock(ConnectionPoolMutex);
// Remove all connections
g_curlConnectionPool.ConnectionPoolIndex.clear();
}
// Signal clean thread to wake up
ConditionalVariableForCleanThread.notify_one();
// join thread
m_cleanThread.join();
}
curl_global_cleanup();
}
/**
* @brief Finds a connection to be re-used from the connection pool.
* @remark If there is not any available connection, a new connection is created.
*
* @param request HTTP request to get #Azure::Core::Http::CurlNetworkConnection for.
* @param options The connection settings which includes host name and libcurl handle specific
* configuration.
* @param resetPool Request the pool to remove all current connections for the provided
* options to force the creation of a new connection.
*
* @return #Azure::Core::Http::CurlNetworkConnection to use.
*/
std::unique_ptr<CurlNetworkConnection> ExtractOrCreateCurlConnection(
Request& request,
CurlTransportOptions const& options,
bool resetPool = false);
/**
* @brief Moves a connection back to the pool to be re-used.
*
* @param connection CURL HTTP connection to add to the pool.
* @param lastStatusCode The most recent HTTP status code received from the \p connection.
*/
void MoveConnectionBackToPool(
std::unique_ptr<CurlNetworkConnection> connection,
HttpStatusCode lastStatusCode);
/**
* @brief Keeps a unique key for each host and creates a connection pool for each key.
*
* @details This way getting a connection for a specific host can be done in O(1) instead of
* looping a single connection list to find the first connection for the required host.
*
* @remark There might be multiple connections for each host.
*/
std::map<std::string, std::list<std::unique_ptr<CurlNetworkConnection>>> ConnectionPoolIndex;
std::mutex ConnectionPoolMutex;
// This is used to put the cleaning pool thread to sleep and yet to be able to wake it if the
// application finishes.
std::condition_variable ConditionalVariableForCleanThread;
AZ_CORE_DLLEXPORT static Azure::Core::Http::_detail::CurlConnectionPool g_curlConnectionPool;
bool IsCleanThreadRunning = false;
private:
// private constructor to keep this as singleton.
CurlConnectionPool() { curl_global_init(CURL_GLOBAL_ALL); }
// Makes possible to know the number of current connections in the connection pool for an
// index
int64_t ConnectionsOnPool(std::string const& host) { return ConnectionPoolIndex[host].size(); };
std::thread m_cleanThread;
};
}}}} // namespace Azure::Core::Http::_detail

View File

@ -0,0 +1,418 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT
/**
* @file
* @brief The curl session consumes a curl connection to perform a request with it and start
* streaming the response.
*
* @remark The curl session is a body stream derived class.
*/
#pragma once
#include "azure/core/http/http.hpp"
#include "private/curl_connection.hpp"
#include "private/curl_connection_pool.hpp"
#include <memory>
#include <string>
#ifdef TESTING_BUILD
// Define the class name that reads from ConnectionPool private members
namespace Azure { namespace Core { namespace Test {
class CurlConnectionPool_connectionPoolTest_Test;
}}} // namespace Azure::Core::Test
#endif
namespace Azure { namespace Core { namespace Http {
/**
* @brief Stateful component that controls sending an HTTP Request with libcurl over the wire.
*
* @remark This component does not use the classic libcurl easy interface to send and receive
* bytes from the network using callbacks. Instead, `CurlSession` supports working with the custom
* HTTP protocol option from libcurl to manually upload and download bytes from the network socket
* using curl_easy_send() and curl_easy_recv().
*
* @remarks This component is expected to be used by an HTTP Transporter to ensure that
* transporter to be reusable in multiple pipelines while every call to network is unique.
*/
class CurlSession : public Azure::Core::IO::BodyStream {
#ifdef TESTING_BUILD
// Give access to private to this tests class
friend class Azure::Core::Test::CurlConnectionPool_connectionPoolTest_Test;
#endif
private:
/**
* @brief Read one expected byte and throw if it is different than the \p expected
*
*/
void ReadExpected(uint8_t expected, Context const& context);
/**
* @brief Read `\\r\\n` from internal buffer or from the wire.
*
* @remark throw if `\\r\\n` are not the next data read.
*/
void ReadCRLF(Context const& context);
/**
* @brief This is used to set the current state of a session.
*
* @remark The session needs to know what's the state on it when an exception occurs so the
* connection is not moved back to the connection pool. When a new request is going to be sent,
* the session will be in `PERFORM` until the request has been uploaded and a response code is
* received from the server. At that point the state will change to `STREAMING`.
* If there is any error before changing the state, the connection need to be cleaned up.
*
*/
enum class SessionState
{
PERFORM,
STREAMING
};
/*
* Enum used by ResponseBufferParser to control the parsing internal state while building
* the HTTP RawResponse
*
*/
enum class ResponseParserState
{
StatusLine,
Headers,
EndOfHeaders,
};
/**
* @brief stateful component used to read and parse a buffer to construct a valid HTTP
* RawResponse.
*
* @remark It uses an internal string as a buffer to accumulate a response token (version, code,
* header, etc.) until the next delimiter is found. Then it uses this string to keep building
* the HTTP RawResponse.
*
* @remark Only status line and headers are parsed and built. Body is ignored by this
* component. A libcurl session will use this component to build and return the HTTP
* RawResponse with a body stream to the pipeline.
*/
class ResponseBufferParser {
private:
/**
* @brief Controls what the parser is expecting during the reading process
*
*/
ResponseParserState state = ResponseParserState::StatusLine;
/**
* @brief Unique ptr to a response. Parser will create an Initial-valid HTTP RawResponse and
* then it will append headers to it. This response is moved to a different owner once
* parsing is completed.
*
*/
std::unique_ptr<RawResponse> m_response;
/**
* @brief Indicates if parser has found the end of the headers and there is nothing left for
* the HTTP RawResponse.
*
*/
bool m_parseCompleted = false;
bool m_delimiterStartInPrevPosition = false;
/**
* @brief This buffer is used when the parsed buffer doesn't contain a completed token. The
* content from the buffer will be appended to this buffer. Once that a delimiter is found,
* the token for the HTTP RawResponse is taken from this internal sting if it contains data.
*
* @remark This buffer allows a libcurl session to use any size of buffer to read from a
* socket while constructing an initial valid HTTP RawResponse. No matter if the response
* from wire contains hundreds of headers, we can use only one fixed size buffer to parse it
* all.
*
*/
std::string m_internalBuffer;
/**
* @brief This method is invoked by the Parsing process if the internal state is set to
* status code. Function will get the status-line expected tokens until finding the end of
* status line delimiter.
*
* @remark When the end of status line delimiter is found, this method will create the HTTP
* RawResponse. The HTTP RawResponse is constructed by default with body type as Stream.
*
* @param buffer Points to a memory address with all or some part of a HTTP status line.
* @param bufferSize Indicates the size of the buffer.
* @return Returns the index of the last parsed position from buffer.
*/
int64_t BuildStatusCode(uint8_t const* const buffer, int64_t const bufferSize);
/**
* @brief This method is invoked by the Parsing process if the internal state is set to
* headers. Function will keep adding headers to the HTTP RawResponse created before while
* parsing an status line.
*
* @param buffer Points to a memory address with all or some part of a HTTP header.
* @param bufferSize Indicates the size of the buffer.
* @return Returns the index of the last parsed position from buffer. When the returned
* value is smaller than the body size, means there is part of the body response in the
* buffer.
*/
int64_t BuildHeader(uint8_t const* const buffer, int64_t const bufferSize);
public:
/**
* @brief Construct a new RawResponse Buffer Parser object.
*
*/
ResponseBufferParser() {}
/**
* @brief Parses the content of a buffer to construct a valid HTTP RawResponse. This method
* is expected to be called over and over until it returns 0, indicating there is nothing
* more to parse to build the HTTP RawResponse.
*
* @param buffer points to a memory area that contains, all or some part of an HTTP
* response.
* @param bufferSize Indicates the size of the buffer.
* @return Returns the index of the last parsed position. Returning a 0 means nothing was
* parsed and it is likely that the HTTP RawResponse is completed. Returning the same value
* as the buffer size means all buffer was parsed and the HTTP might be completed or not.
* Returning a value smaller than the buffer size will likely indicate that the HTTP
* RawResponse is completed and that the rest of the buffer contains part of the response
* body.
*/
int64_t Parse(uint8_t const* const buffer, int64_t const bufferSize);
/**
* @brief Indicates when the parser has completed parsing and building the HTTP RawResponse.
*
* @return `true` if parsing is completed. Otherwise `false`.
*/
bool IsParseCompleted() const { return m_parseCompleted; }
/**
* @brief Moves the internal response to a different owner.
*
* @return Will move the response only if parsing is completed and if the HTTP RawResponse
* was not moved before.
*/
std::unique_ptr<RawResponse> ExtractResponse()
{
if (m_parseCompleted && m_response != nullptr)
{
return std::move(m_response);
}
return nullptr; // parse is not completed or response has been moved already.
}
};
/**
* @brief The current state of the session.
*
* @remark The state of the session is used to determine if a connection can be moved back to
* the connection pool or not. A connection can be re-used only when the session state is
* `STREAMING` and the response has been read completely.
*
*/
SessionState m_sessionState = SessionState::PERFORM;
std::unique_ptr<CurlNetworkConnection> m_connection;
/**
* @brief unique ptr for the HTTP RawResponse. The session is responsable for creating the
* response once that an HTTP status line is received.
*
*/
std::unique_ptr<RawResponse> m_response;
/**
* @brief The HTTP Request for to be used by the session.
*
*/
Request& m_request;
/**
* @brief Control field to handle the case when part of HTTP response body was copied to the
* inner buffer. When a libcurl stream tries to read part of the body, this field will help to
* decide how much data to take from the inner buffer before pulling more data from network.
*
*/
int64_t m_bodyStartInBuffer = -1;
/**
* @brief Control field to handle the number of bytes containing relevant data within the
* internal buffer. This is because internal buffer can be set to be size N but after writing
* from wire into it, it can be holding less then N bytes.
*
*/
int64_t m_innerBufferSize = _detail::DefaultLibcurlReaderSize;
bool m_isChunkedResponseType = false;
/**
* @brief This is a copy of the value of an HTTP response header `content-length`. The value
* is received as string and parsed to size_t. This field avoid parsing the string header
* every time from HTTP RawResponse.
*
* @remark This value is also used to avoid trying to read more data from network than what we
* are expecting to.
*
*/
int64_t m_contentLength = 0;
/**
* @brief For chunked responses, this field knows the size of the current chuck size server
* will de sending
*
*/
int64_t m_chunkSize = 0;
int64_t m_sessionTotalRead = 0;
/**
* @brief Internal buffer from a session used to read bytes from a socket. This buffer is only
* used while constructing an HTTP RawResponse without adding a body to it. Customers would
* provide their own buffer to copy from socket when reading the HTTP body using streams.
*
*/
uint8_t m_readBuffer[_detail::DefaultLibcurlReaderSize]
= {0}; // to work with libcurl custom read.
/**
* @brief Function used when working with Streams to manually write from the HTTP Request to
* the wire.
*
* @param context #Azure::Core::Context so that operation can be cancelled.
*
* @return CURL_OK when response is sent successfully.
*/
CURLcode SendRawHttp(Context const& context);
/**
* @brief Upload body.
*
* @param context #Azure::Core::Context so that operation can be cancelled.
*
* @return Curl code.
*/
CURLcode UploadBody(Context const& context);
/**
* @brief This function is used after sending an HTTP request to the server to read the HTTP
* RawResponse from wire until the end of headers only.
*
* @param context #Azure::Core::Context so that operation can be cancelled.
* @param reuseInternalBuffer Indicates whether the internal buffer should be reused.
*/
void ReadStatusLineAndHeadersFromRawResponse(
Context const& context,
bool reuseInternalBuffer = false);
/**
* @brief Reads from inner buffer or from Wire until chunkSize is parsed and converted to
* unsigned long long
*
* @param context #Azure::Core::Context so that operation can be cancelled.
*/
void ParseChunkSize(Context const& context);
/**
* @brief Last HTTP status code read.
*
* @remark The last status is initialized as a bad request just as a way to know that there's
* not a good request performed by the session. The status will be updated as soon as the
* session sent a request and it is used to decide if a connection can be re-used or not.
*/
Http::HttpStatusCode m_lastStatusCode = Http::HttpStatusCode::BadRequest;
/**
* @brief check whether an end of file has been reached.
* @return `true` if end of file has been reached, `false` otherwise.
*/
bool IsEOF()
{
auto eof = m_isChunkedResponseType ? m_chunkSize == 0 : m_contentLength == m_sessionTotalRead;
// `IsEOF` is called before trying to move a connection back to the connection pool.
// If the session state is `PERFORM` it means the request could not complete an upload
// operation (might have throw while uploading).
// Connection should not be moved back to the connection pool on this scenario.
return eof && m_sessionState != SessionState::PERFORM;
}
/**
* @brief All connections will request to keep the channel open to re-use the
* connection.
*
* @remark This option can be disabled from the transport adapter options. When disabled, the
* session won't return connections to the connection pool. Connection will be closed as soon as
* the request is completed.
*
*/
bool m_keepAlive = true;
/**
* @brief Implement #Azure::Core::IO::BodyStream::OnRead(). Calling this function pulls data
* from the wire.
*
* @param context #Azure::Core::Context so that operation can be cancelled.
* @param buffer Buffer where data from wire is written to.
* @param count The number of bytes to read from the network.
* @return The actual number of bytes read from the network.
*/
int64_t OnRead(uint8_t* buffer, int64_t count, Azure::Core::Context const& context) override;
public:
/**
* @brief Construct a new Curl Session object. Init internal libcurl handler.
*
* @param request reference to an HTTP Request.
*/
CurlSession(Request& request, std::unique_ptr<CurlNetworkConnection> connection, bool keepAlive)
: m_connection(std::move(connection)), m_request(request), m_keepAlive(keepAlive)
{
}
~CurlSession() override
{
// mark connection as reusable only if entire response was read
// If not, connection can't be reused because next Read will start from what it is currently
// in the wire.
// By not moving the connection back to the pool, it gets destroyed calling the connection
// destructor to clean libcurl handle and close the connection.
// IsEOF will also handle a connection that fail to complete an upload request.
if (IsEOF() && m_keepAlive)
{
_detail::CurlConnectionPool::g_curlConnectionPool.MoveConnectionBackToPool(
std::move(m_connection), m_lastStatusCode);
}
}
/**
* @brief Function will use the HTTP request received in constructor to perform a network call
* based on the HTTP request configuration.
*
* @param context #Azure::Core::Context so that operation can be cancelled.
* @return CURLE_OK when the network call is completed successfully.
*/
CURLcode Perform(Context const& context);
/**
* @brief Moved the ownership of the HTTP RawResponse out of the session.
*
* @return the unique ptr to the HTTP RawResponse or null if the HTTP RawResponse is not yet
* created or was moved before.
*/
std::unique_ptr<Azure::Core::Http::RawResponse> ExtractResponse();
/**
* @brief Implement #Azure::Core::IO::BodyStream length.
*
* @return The size of the payload.
*/
int64_t Length() const override { return m_contentLength; }
};
}}} // namespace Azure::Core::Http

View File

@ -8,17 +8,15 @@
#pragma once
#include "azure/core/dll_import_export.hpp"
#include <string>
#define AZURE_CORE_VERSION_MAJOR 1
#define AZURE_CORE_VERSION_MINOR 0
#define AZURE_CORE_VERSION_PATCH 0
#define AZURE_CORE_VERSION_PRERELEASE "beta.9"
namespace Azure { namespace Core { namespace _detail {
#define AZURE_CORE_VERSION_ITOA_HELPER(i) #i
#define AZURE_CORE_VERSION_ITOA(i) AZURE_CORE_VERSION_ITOA_HELPER(i)
namespace Azure { namespace Core { namespace _detail {
/**
* @brief Provides version information.
*/
@ -33,23 +31,27 @@ namespace Azure { namespace Core { namespace _detail {
/// Patch numeric identifier.
static constexpr int Patch = AZURE_CORE_VERSION_PATCH;
/// Optional pre-release identifier. SDK is in a pre-release state when not empty.
AZ_CORE_DLLEXPORT static std::string const PreRelease;
/// Indicates whether the SDK is in a pre-release state.
static constexpr bool IsPreRelease = sizeof(AZURE_CORE_VERSION_PRERELEASE) != sizeof("");
/**
* @brief The version in string format used for telemetry following the `semver.org` standard
* (https://semver.org).
*/
static std::string ToString();
private:
// To avoid leaking out the #define values we smuggle out the value
// which will later be used to initialize the PreRelease std::string
static constexpr const char* secret = AZURE_CORE_VERSION_PRERELEASE;
static constexpr const char* ToString()
{
return IsPreRelease
? AZURE_CORE_VERSION_ITOA(AZURE_CORE_VERSION_MAJOR) "." AZURE_CORE_VERSION_ITOA(
AZURE_CORE_VERSION_MINOR) "." AZURE_CORE_VERSION_ITOA(AZURE_CORE_VERSION_PATCH) "-" AZURE_CORE_VERSION_PRERELEASE
: AZURE_CORE_VERSION_ITOA(AZURE_CORE_VERSION_MAJOR) "." AZURE_CORE_VERSION_ITOA(
AZURE_CORE_VERSION_MINOR) "." AZURE_CORE_VERSION_ITOA(AZURE_CORE_VERSION_PATCH);
}
};
}}} // namespace Azure::Core::_detail
#undef AZURE_CORE_VERSION_ITOA_HELPER
#undef AZURE_CORE_VERSION_ITOA
#undef AZURE_CORE_VERSION_MAJOR
#undef AZURE_CORE_VERSION_MINOR
#undef AZURE_CORE_VERSION_PATCH

View File

@ -1,29 +0,0 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT
#include "azure/core/version.hpp"
#include <sstream>
#include <string>
using namespace Azure::Core::_detail;
const std::string PackageVersion::PreRelease = secret;
std::string PackageVersion::ToString()
{
static const std::string versionString = [] {
std::string version;
std::stringstream ss;
std::string dot = ".";
ss << PackageVersion::Major << dot << PackageVersion::Minor << dot << PackageVersion::Patch;
if (!PackageVersion::PreRelease.empty())
ss << "-" << PackageVersion::PreRelease;
return ss.str();
}();
return versionString;
}

View File

@ -25,9 +25,9 @@
#include <azure/core/io/body_stream.hpp>
#include <azure/core/response.hpp>
#include <http/curl/curl_connection_pool_private.hpp>
#include <http/curl/curl_connection_private.hpp>
#include <http/curl/curl_session_private.hpp>
#include <private/curl_connection.hpp>
#include <private/curl_connection_pool.hpp>
#include <private/curl_session.hpp>
#include <cstdlib>

View File

@ -15,11 +15,11 @@
#include <thread>
// The next includes are from Azure Core private headers.
// That's why the path starts from `sdk/core/azure-core/src/`
// That's why the path starts from `private/`
// They are included to test the connection pool from the curl transport adapter implementation.
#include <http/curl/curl_connection_pool_private.hpp>
#include <http/curl/curl_connection_private.hpp>
#include <http/curl/curl_session_private.hpp>
#include <private/curl_connection.hpp>
#include <private/curl_connection_pool.hpp>
#include <private/curl_session.hpp>
#include "curl_session.hpp"

View File

@ -14,8 +14,8 @@
#include "azure/core/http/curl_transport.hpp"
#endif
#include <http/curl/curl_connection_private.hpp>
#include <http/curl/curl_session_private.hpp>
#include <private/curl_connection.hpp>
#include <private/curl_session.hpp>
#include "transport_adapter_base.hpp"

View File

@ -24,7 +24,7 @@
#include <gtest/gtest.h>
#include <string>
#include <http/curl/curl_connection_pool_private.hpp>
#include <private/curl_connection_pool.hpp>
namespace Azure { namespace Core { namespace Test {

View File

@ -6,8 +6,8 @@
#include <azure/core/http/curl_transport.hpp>
#include <azure/core/http/http.hpp>
#include <http/curl/curl_connection_private.hpp>
#include <http/curl/curl_session_private.hpp>
#include <private/curl_connection.hpp>
#include <private/curl_session.hpp>
using ::testing::_;
using ::testing::DoAll;

View File

@ -36,15 +36,14 @@ set(
inc/azure/identity/client_secret_credential.hpp
inc/azure/identity/environment_credential.hpp
inc/azure/identity/dll_import_export.hpp
inc/azure/identity/version.hpp
inc/azure/identity.hpp
)
set(
AZURE_IDENTITY_SOURCE
src/private/package_version.hpp
src/client_secret_credential.cpp
src/environment_credential.cpp
src/version.cpp
)
add_library(azure-identity ${AZURE_IDENTITY_HEADER} ${AZURE_IDENTITY_SOURCE})
@ -65,7 +64,7 @@ target_include_directories(
target_link_libraries(azure-identity PUBLIC Azure::azure-core)
get_az_version("${CMAKE_CURRENT_SOURCE_DIR}/inc/azure/identity/version.hpp")
get_az_version("${CMAKE_CURRENT_SOURCE_DIR}/src/private/package_version.hpp")
generate_documentation(azure-identity ${AZ_LIBRARY_VERSION})
az_vcpkg_export(

View File

@ -8,17 +8,15 @@
#pragma once
#include "azure/identity/dll_import_export.hpp"
#include <string>
#define AZURE_IDENTITY_VERSION_MAJOR 1
#define AZURE_IDENTITY_VERSION_MINOR 0
#define AZURE_IDENTITY_VERSION_PATCH 0
#define AZURE_IDENTITY_VERSION_PRERELEASE "beta.6"
namespace Azure { namespace Identity { namespace _detail {
#define AZURE_IDENTITY_VERSION_ITOA_HELPER(i) #i
#define AZURE_IDENTITY_VERSION_ITOA(i) AZURE_IDENTITY_VERSION_ITOA_HELPER(i)
namespace Azure { namespace Identity { namespace _detail {
/**
* @brief Provides version information.
*/
@ -33,23 +31,27 @@ namespace Azure { namespace Identity { namespace _detail {
/// Patch numeric identifier.
static constexpr int Patch = AZURE_IDENTITY_VERSION_PATCH;
/// Optional pre-release identifier. SDK is in a pre-release state when not empty.
AZ_IDENTITY_DLLEXPORT static std::string const PreRelease;
/// Indicates whether the SDK is in a pre-release state.
static constexpr bool IsPreRelease = sizeof(AZURE_IDENTITY_VERSION_PRERELEASE) != sizeof("");
/**
* @brief The version in string format used for telemetry following the `semver.org` standard
* (https://semver.org).
*/
static std::string ToString();
private:
// To avoid leaking out the #define values we smuggle out the value
// which will later be used to initialize the PreRelease std::string
static constexpr char const* secret = AZURE_IDENTITY_VERSION_PRERELEASE;
static constexpr const char* ToString()
{
return IsPreRelease
? AZURE_IDENTITY_VERSION_ITOA(AZURE_IDENTITY_VERSION_MAJOR) "." AZURE_IDENTITY_VERSION_ITOA(
AZURE_IDENTITY_VERSION_MINOR) "." AZURE_IDENTITY_VERSION_ITOA(AZURE_IDENTITY_VERSION_PATCH) "-" AZURE_IDENTITY_VERSION_PRERELEASE
: AZURE_IDENTITY_VERSION_ITOA(AZURE_IDENTITY_VERSION_MAJOR) "." AZURE_IDENTITY_VERSION_ITOA(
AZURE_IDENTITY_VERSION_MINOR) "." AZURE_IDENTITY_VERSION_ITOA(AZURE_IDENTITY_VERSION_PATCH);
}
};
}}} // namespace Azure::Identity::_detail
#undef AZURE_IDENTITY_VERSION_ITOA_HELPER
#undef AZURE_IDENTITY_VERSION_ITOA
#undef AZURE_IDENTITY_VERSION_MAJOR
#undef AZURE_IDENTITY_VERSION_MINOR
#undef AZURE_IDENTITY_VERSION_PATCH

View File

@ -1,29 +0,0 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT
#include "azure/identity/version.hpp"
#include <sstream>
#include <string>
using namespace Azure::Identity::_detail;
std::string const PackageVersion::PreRelease = secret;
std::string PackageVersion::ToString()
{
static const std::string versionString = [] {
std::string version;
std::stringstream ss;
std::string dot = ".";
ss << PackageVersion::Major << dot << PackageVersion::Minor << dot << PackageVersion::Patch;
if (!PackageVersion::PreRelease.empty())
ss << "-" << PackageVersion::PreRelease;
return ss.str();
}();
return versionString;
}

View File

@ -34,11 +34,11 @@ set(
inc/azure/keyvault/common/internal/unix_time_helper.hpp
inc/azure/keyvault/common/keyvault_constants.hpp
inc/azure/keyvault/common/keyvault_exception.hpp
inc/azure/keyvault/common/version.hpp
)
set(
AZURE_KEYVAULT_COMMON_SOURCE
src/private/package_version.hpp
src/keyvault_exception.cpp
src/keyvault_pipeline.cpp
)
@ -66,7 +66,7 @@ endif()
# coverage. Has no effect if BUILD_CODE_COVERAGE is OFF
create_code_coverage(keyvault azure-security-keyvault-common azure-security-keyvault-common-test)
get_az_version("${CMAKE_CURRENT_SOURCE_DIR}/inc/azure/keyvault/common/version.hpp")
get_az_version("${CMAKE_CURRENT_SOURCE_DIR}/src/private/package_version.hpp")
generate_documentation(azure-security-keyvault-common ${AZ_LIBRARY_VERSION})
if(BUILD_TESTING)

View File

@ -1,40 +0,0 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT
/**
* @brief This file is used for automatic release operations.
*
*/
#pragma once
#include <string>
#include "azure/keyvault/common/dll_import_export.hpp"
#define AZURE_SECURITY_KEYVAULT_COMMON_VERSION_MAJOR 4
#define AZURE_SECURITY_KEYVAULT_COMMON_VERSION_MINOR 0
#define AZURE_SECURITY_KEYVAULT_COMMON_VERSION_PATCH 0
#define AZURE_SECURITY_KEYVAULT_COMMON_VERSION_PRERELEASE "beta.2"
namespace Azure { namespace Security { namespace KeyVault { namespace Common { namespace _detail {
class PackageVersion {
public:
static constexpr int Major = AZURE_SECURITY_KEYVAULT_COMMON_VERSION_MAJOR;
static constexpr int Minor = AZURE_SECURITY_KEYVAULT_COMMON_VERSION_MINOR;
static constexpr int Patch = AZURE_SECURITY_KEYVAULT_COMMON_VERSION_PATCH;
AZ_SECURITY_KEYVAULT_COMMON_DLLEXPORT static std::string const PreRelease;
static std::string ToString();
private:
// To avoid leaking out the #define values we smuggle out the value
// which will later be used to initialize the PreRelease std::string
static constexpr const char* secret = AZURE_SECURITY_KEYVAULT_COMMON_VERSION_PRERELEASE;
};
}}}}} // namespace Azure::Security::KeyVault::Common::_detail
#undef AZURE_SECURITY_KEYVAULT_COMMON_VERSION_MAJOR
#undef AZURE_SECURITY_KEYVAULT_COMMON_VERSION_MINOR
#undef AZURE_SECURITY_KEYVAULT_COMMON_VERSION_PATCH
#undef AZURE_SECURITY_KEYVAULT_COMMON_VERSION_PRERELEASE

View File

@ -0,0 +1,60 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT
/**
* @file
* @brief Provides version information.
*/
#pragma once
#define AZURE_SECURITY_KEYVAULT_COMMON_VERSION_MAJOR 4
#define AZURE_SECURITY_KEYVAULT_COMMON_VERSION_MINOR 0
#define AZURE_SECURITY_KEYVAULT_COMMON_VERSION_PATCH 0
#define AZURE_SECURITY_KEYVAULT_COMMON_VERSION_PRERELEASE "beta.2"
#define AZURE_SECURITY_KEYVAULT_COMMON_VERSION_ITOA_HELPER(i) #i
#define AZURE_SECURITY_KEYVAULT_COMMON_VERSION_ITOA(i) \
AZURE_SECURITY_KEYVAULT_COMMON_VERSION_ITOA_HELPER(i)
namespace Azure { namespace Security { namespace KeyVault { namespace Common { namespace _detail {
/**
* @brief Provides version information.
*/
class PackageVersion {
public:
/// Major numeric identifier.
static constexpr int Major = AZURE_SECURITY_KEYVAULT_COMMON_VERSION_MAJOR;
/// Minor numeric identifier.
static constexpr int Minor = AZURE_SECURITY_KEYVAULT_COMMON_VERSION_MINOR;
/// Patch numeric identifier.
static constexpr int Patch = AZURE_SECURITY_KEYVAULT_COMMON_VERSION_PATCH;
/// Indicates whether the SDK is in a pre-release state.
static constexpr bool IsPreRelease
= sizeof(AZURE_SECURITY_KEYVAULT_COMMON_VERSION_PRERELEASE) != sizeof("");
/**
* @brief The version in string format used for telemetry following the `semver.org` standard
* (https://semver.org).
*/
static constexpr const char* ToString()
{
return IsPreRelease
? AZURE_SECURITY_KEYVAULT_COMMON_VERSION_ITOA(AZURE_SECURITY_KEYVAULT_COMMON_VERSION_MAJOR) "." AZURE_SECURITY_KEYVAULT_COMMON_VERSION_ITOA(
AZURE_SECURITY_KEYVAULT_COMMON_VERSION_MINOR) "." AZURE_SECURITY_KEYVAULT_COMMON_VERSION_ITOA(AZURE_SECURITY_KEYVAULT_COMMON_VERSION_PATCH) "-" AZURE_SECURITY_KEYVAULT_COMMON_VERSION_PRERELEASE
: AZURE_SECURITY_KEYVAULT_COMMON_VERSION_ITOA(AZURE_SECURITY_KEYVAULT_COMMON_VERSION_MAJOR) "." AZURE_SECURITY_KEYVAULT_COMMON_VERSION_ITOA(
AZURE_SECURITY_KEYVAULT_COMMON_VERSION_MINOR) "." AZURE_SECURITY_KEYVAULT_COMMON_VERSION_ITOA(AZURE_SECURITY_KEYVAULT_COMMON_VERSION_PATCH);
}
};
}}}}} // namespace Azure::Security::KeyVault::Common::_detail
#undef AZURE_SECURITY_KEYVAULT_COMMON_VERSION_ITOA_HELPER
#undef AZURE_SECURITY_KEYVAULT_COMMON_VERSION_ITOA
#undef AZURE_SECURITY_KEYVAULT_COMMON_VERSION_MAJOR
#undef AZURE_SECURITY_KEYVAULT_COMMON_VERSION_MINOR
#undef AZURE_SECURITY_KEYVAULT_COMMON_VERSION_PATCH
#undef AZURE_SECURITY_KEYVAULT_COMMON_VERSION_PRERELEASE

View File

@ -45,11 +45,11 @@ set(
inc/azure/keyvault/keys/key_vault_key.hpp
inc/azure/keyvault/keys/list_keys_single_page_result.hpp
inc/azure/keyvault/keys/recover_deleted_key_operation.hpp
inc/azure/keyvault/keys/version.hpp
)
set(
AZURE_KEYVAULT_KEYS_SOURCE
src/private/package_version.hpp
src/delete_key_operation.cpp
src/deleted_key.cpp
src/import_key_options.cpp
@ -83,7 +83,7 @@ target_link_libraries(azure-security-keyvault-keys PUBLIC Azure::azure-security-
# coverage. Has no effect if BUILD_CODE_COVERAGE is OFF
create_code_coverage(keyvault azure-security-keyvault-keys azure-security-keyvault-keys-test)
get_az_version("${CMAKE_CURRENT_SOURCE_DIR}/inc/azure/keyvault/keys/version.hpp")
get_az_version("${CMAKE_CURRENT_SOURCE_DIR}/src/private/package_version.hpp")
generate_documentation(azure-security-keyvault-keys ${AZ_LIBRARY_VERSION})
if(BUILD_TESTING)

View File

@ -23,4 +23,3 @@
#include "azure/keyvault/keys/key_vault_key.hpp"
#include "azure/keyvault/keys/list_keys_single_page_result.hpp"
#include "azure/keyvault/keys/recover_deleted_key_operation.hpp"
#include "azure/keyvault/keys/version.hpp"

View File

@ -1,40 +0,0 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT
/**
* @brief This file is used for automatic release operations.
*
*/
#pragma once
#include <string>
#include "azure/keyvault/keys/dll_import_export.hpp"
#define AZURE_SECURITY_KEYVAULT_KEYS_VERSION_MAJOR 4
#define AZURE_SECURITY_KEYVAULT_KEYS_VERSION_MINOR 0
#define AZURE_SECURITY_KEYVAULT_KEYS_VERSION_PATCH 0
#define AZURE_SECURITY_KEYVAULT_KEYS_VERSION_PRERELEASE "beta.2"
namespace Azure { namespace Security { namespace KeyVault { namespace Keys { namespace _detail {
class PackageVersion {
public:
static constexpr int Major = AZURE_SECURITY_KEYVAULT_KEYS_VERSION_MAJOR;
static constexpr int Minor = AZURE_SECURITY_KEYVAULT_KEYS_VERSION_MINOR;
static constexpr int Patch = AZURE_SECURITY_KEYVAULT_KEYS_VERSION_PATCH;
AZ_SECURITY_KEYVAULT_KEYS_DLLEXPORT static std::string const PreRelease;
static std::string ToString();
private:
// To avoid leaking out the #define values we smuggle out the value
// which will later be used to initialize the PreRelease std::string
static constexpr const char* secret = AZURE_SECURITY_KEYVAULT_KEYS_VERSION_PRERELEASE;
};
}}}}} // namespace Azure::Security::KeyVault::Keys::_detail
#undef AZURE_SECURITY_KEYVAULT_KEYS_VERSION_MAJOR
#undef AZURE_SECURITY_KEYVAULT_KEYS_VERSION_MINOR
#undef AZURE_SECURITY_KEYVAULT_KEYS_VERSION_PATCH
#undef AZURE_SECURITY_KEYVAULT_KEYS_VERSION_PRERELEASE

View File

@ -0,0 +1,60 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT
/**
* @file
* @brief Provides version information.
*/
#pragma once
#define AZURE_SECURITY_KEYVAULT_KEYS_VERSION_MAJOR 4
#define AZURE_SECURITY_KEYVAULT_KEYS_VERSION_MINOR 0
#define AZURE_SECURITY_KEYVAULT_KEYS_VERSION_PATCH 0
#define AZURE_SECURITY_KEYVAULT_KEYS_VERSION_PRERELEASE "beta.2"
#define AZURE_SECURITY_KEYVAULT_KEYS_VERSION_ITOA_HELPER(i) #i
#define AZURE_SECURITY_KEYVAULT_KEYS_VERSION_ITOA(i) \
AZURE_SECURITY_KEYVAULT_KEYS_VERSION_ITOA_HELPER(i)
namespace Azure { namespace Security { namespace KeyVault { namespace Keys { namespace _detail {
/**
* @brief Provides version information.
*/
class PackageVersion {
public:
/// Major numeric identifier.
static constexpr int Major = AZURE_SECURITY_KEYVAULT_KEYS_VERSION_MAJOR;
/// Minor numeric identifier.
static constexpr int Minor = AZURE_SECURITY_KEYVAULT_KEYS_VERSION_MINOR;
/// Patch numeric identifier.
static constexpr int Patch = AZURE_SECURITY_KEYVAULT_KEYS_VERSION_PATCH;
/// Indicates whether the SDK is in a pre-release state.
static constexpr bool IsPreRelease
= sizeof(AZURE_SECURITY_KEYVAULT_KEYS_VERSION_PRERELEASE) != sizeof("");
/**
* @brief The version in string format used for telemetry following the `semver.org` standard
* (https://semver.org).
*/
static constexpr const char* ToString()
{
return IsPreRelease
? AZURE_SECURITY_KEYVAULT_KEYS_VERSION_ITOA(AZURE_SECURITY_KEYVAULT_KEYS_VERSION_MAJOR) "." AZURE_SECURITY_KEYVAULT_KEYS_VERSION_ITOA(
AZURE_SECURITY_KEYVAULT_KEYS_VERSION_MINOR) "." AZURE_SECURITY_KEYVAULT_KEYS_VERSION_ITOA(AZURE_SECURITY_KEYVAULT_KEYS_VERSION_PATCH) "-" AZURE_SECURITY_KEYVAULT_KEYS_VERSION_PRERELEASE
: AZURE_SECURITY_KEYVAULT_KEYS_VERSION_ITOA(AZURE_SECURITY_KEYVAULT_KEYS_VERSION_MAJOR) "." AZURE_SECURITY_KEYVAULT_KEYS_VERSION_ITOA(
AZURE_SECURITY_KEYVAULT_KEYS_VERSION_MINOR) "." AZURE_SECURITY_KEYVAULT_KEYS_VERSION_ITOA(AZURE_SECURITY_KEYVAULT_KEYS_VERSION_PATCH);
}
};
}}}}} // namespace Azure::Security::KeyVault::Keys::_detail
#undef AZURE_SECURITY_KEYVAULT_KEYS_VERSION_ITOA_HELPER
#undef AZURE_SECURITY_KEYVAULT_KEYS_VERSION_ITOA
#undef AZURE_SECURITY_KEYVAULT_KEYS_VERSION_MAJOR
#undef AZURE_SECURITY_KEYVAULT_KEYS_VERSION_MINOR
#undef AZURE_SECURITY_KEYVAULT_KEYS_VERSION_PATCH
#undef AZURE_SECURITY_KEYVAULT_KEYS_VERSION_PRERELEASE

View File

@ -40,12 +40,12 @@ set(
inc/azure/storage/blobs/block_blob_client.hpp
inc/azure/storage/blobs/dll_import_export.hpp
inc/azure/storage/blobs/page_blob_client.hpp
inc/azure/storage/blobs/version.hpp
inc/azure/storage/blobs.hpp
)
set(
AZURE_STORAGE_BLOB_SOURCE
src/private/package_version.hpp
src/append_blob_client.cpp
src/blob_client.cpp
src/blob_container_client.cpp
@ -72,7 +72,7 @@ target_include_directories(
target_link_libraries(azure-storage-blobs PUBLIC Azure::azure-storage-common)
get_az_version("${CMAKE_CURRENT_SOURCE_DIR}/inc/azure/storage/blobs/version.hpp")
get_az_version("${CMAKE_CURRENT_SOURCE_DIR}/src/private/package_version.hpp")
generate_documentation(azure-storage-blobs ${AZ_LIBRARY_VERSION})
az_vcpkg_export(

View File

@ -1,61 +0,0 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT
/**
* @file
* @brief Provides version information.
*/
#pragma once
#include <cstring>
#include <string>
#define AZURE_STORAGE_BLOBS_VERSION_MAJOR 12
#define AZURE_STORAGE_BLOBS_VERSION_MINOR 0
#define AZURE_STORAGE_BLOBS_VERSION_PATCH 0
#define AZURE_STORAGE_BLOBS_VERSION_PRERELEASE "beta.11"
namespace Azure { namespace Storage { namespace Blobs { namespace _detail {
/**
* @brief Provides version information.
*/
struct PackageVersion
{
public:
/// Major numeric identifier.
constexpr static int Major = AZURE_STORAGE_BLOBS_VERSION_MAJOR;
/// Minor numeric identifier.
constexpr static int Minor = AZURE_STORAGE_BLOBS_VERSION_MINOR;
/// Patch numeric identifier.
constexpr static int Patch = AZURE_STORAGE_BLOBS_VERSION_PATCH;
/// Optional pre-release identifier. SDK is in a pre-release state when not empty.
constexpr static const char* PreRelease = AZURE_STORAGE_BLOBS_VERSION_PRERELEASE;
/**
* @brief The version in string format used for telemetry following the `semver.org` standard
* (https://semver.org).
*/
static std::string ToString()
{
std::string versionString
= std::to_string(Major) + "." + std::to_string(Minor) + "." + std::to_string(Patch);
if (std::strlen(PreRelease) != 0)
{
versionString += "-";
versionString += PreRelease;
}
return versionString;
}
};
}}}} // namespace Azure::Storage::Blobs::_detail
#undef AZURE_STORAGE_BLOBS_VERSION_MAJOR
#undef AZURE_STORAGE_BLOBS_VERSION_MINOR
#undef AZURE_STORAGE_BLOBS_VERSION_PATCH
#undef AZURE_STORAGE_BLOBS_VERSION_PRERELEASE

View File

@ -17,7 +17,10 @@
#include "azure/storage/blobs/append_blob_client.hpp"
#include "azure/storage/blobs/block_blob_client.hpp"
#include "azure/storage/blobs/page_blob_client.hpp"
#include "azure/storage/blobs/version.hpp"
#include "private/package_version.hpp"
#include <algorithm>
namespace Azure { namespace Storage { namespace Blobs {

View File

@ -14,7 +14,8 @@
#include "azure/storage/blobs/append_blob_client.hpp"
#include "azure/storage/blobs/block_blob_client.hpp"
#include "azure/storage/blobs/page_blob_client.hpp"
#include "azure/storage/blobs/version.hpp"
#include "private/package_version.hpp"
namespace Azure { namespace Storage { namespace Blobs {

View File

@ -11,7 +11,7 @@
#include <azure/storage/common/storage_service_version_policy.hpp>
#include <azure/storage/common/storage_switch_to_secondary_policy.hpp>
#include "azure/storage/blobs/version.hpp"
#include "private/package_version.hpp"
namespace Azure { namespace Storage { namespace Blobs {

View File

@ -0,0 +1,59 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT
/**
* @file
* @brief Provides version information.
*/
#pragma once
#define AZURE_STORAGE_BLOBS_VERSION_MAJOR 12
#define AZURE_STORAGE_BLOBS_VERSION_MINOR 0
#define AZURE_STORAGE_BLOBS_VERSION_PATCH 0
#define AZURE_STORAGE_BLOBS_VERSION_PRERELEASE "beta.11"
#define AZURE_STORAGE_BLOBS_VERSION_ITOA_HELPER(i) #i
#define AZURE_STORAGE_BLOBS_VERSION_ITOA(i) AZURE_STORAGE_BLOBS_VERSION_ITOA_HELPER(i)
namespace Azure { namespace Storage { namespace Blobs { namespace _detail {
/**
* @brief Provides version information.
*/
class PackageVersion {
public:
/// Major numeric identifier.
static constexpr int Major = AZURE_STORAGE_BLOBS_VERSION_MAJOR;
/// Minor numeric identifier.
static constexpr int Minor = AZURE_STORAGE_BLOBS_VERSION_MINOR;
/// Patch numeric identifier.
static constexpr int Patch = AZURE_STORAGE_BLOBS_VERSION_PATCH;
/// Indicates whether the SDK is in a pre-release state.
static constexpr bool IsPreRelease
= sizeof(AZURE_STORAGE_BLOBS_VERSION_PRERELEASE) != sizeof("");
/**
* @brief The version in string format used for telemetry following the `semver.org` standard
* (https://semver.org).
*/
static constexpr const char* ToString()
{
return IsPreRelease
? AZURE_STORAGE_BLOBS_VERSION_ITOA(AZURE_STORAGE_BLOBS_VERSION_MAJOR) "." AZURE_STORAGE_BLOBS_VERSION_ITOA(
AZURE_STORAGE_BLOBS_VERSION_MINOR) "." AZURE_STORAGE_BLOBS_VERSION_ITOA(AZURE_STORAGE_BLOBS_VERSION_PATCH) "-" AZURE_STORAGE_BLOBS_VERSION_PRERELEASE
: AZURE_STORAGE_BLOBS_VERSION_ITOA(AZURE_STORAGE_BLOBS_VERSION_MAJOR) "." AZURE_STORAGE_BLOBS_VERSION_ITOA(
AZURE_STORAGE_BLOBS_VERSION_MINOR) "." AZURE_STORAGE_BLOBS_VERSION_ITOA(AZURE_STORAGE_BLOBS_VERSION_PATCH);
}
};
}}}} // namespace Azure::Storage::Blobs::_detail
#undef AZURE_STORAGE_BLOBS_VERSION_ITOA_HELPER
#undef AZURE_STORAGE_BLOBS_VERSION_ITOA
#undef AZURE_STORAGE_BLOBS_VERSION_MAJOR
#undef AZURE_STORAGE_BLOBS_VERSION_MINOR
#undef AZURE_STORAGE_BLOBS_VERSION_PATCH
#undef AZURE_STORAGE_BLOBS_VERSION_PRERELEASE

View File

@ -46,12 +46,12 @@ set(
inc/azure/storage/common/storage_per_retry_policy.hpp
inc/azure/storage/common/storage_service_version_policy.hpp
inc/azure/storage/common/storage_switch_to_secondary_policy.hpp
inc/azure/storage/common/version.hpp
inc/azure/storage/common/xml_wrapper.hpp
)
set(
AZURE_STORAGE_COMMON_SOURCE
src/private/package_version.hpp
src/account_sas_builder.cpp
src/crypt.cpp
src/file_io.cpp
@ -90,7 +90,7 @@ else()
target_link_libraries(azure-storage-common PRIVATE OpenSSL::SSL OpenSSL::Crypto)
endif()
get_az_version("${CMAKE_CURRENT_SOURCE_DIR}/inc/azure/storage/common/version.hpp")
get_az_version("${CMAKE_CURRENT_SOURCE_DIR}/src/private/package_version.hpp")
generate_documentation(azure-storage-common ${AZ_LIBRARY_VERSION})
az_vcpkg_export(

View File

@ -1,61 +0,0 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT
/**
* @file
* @brief Provides version information.
*/
#pragma once
#include <cstring>
#include <string>
#define AZURE_STORAGE_COMMON_VERSION_MAJOR 12
#define AZURE_STORAGE_COMMON_VERSION_MINOR 0
#define AZURE_STORAGE_COMMON_VERSION_PATCH 0
#define AZURE_STORAGE_COMMON_VERSION_PRERELEASE "beta.11"
namespace Azure { namespace Storage { namespace Common { namespace _detail {
/**
* @brief Provides version information.
*/
struct PackageVersion
{
public:
/// Major numeric identifier.
constexpr static int Major = AZURE_STORAGE_COMMON_VERSION_MAJOR;
/// Minor numeric identifier.
constexpr static int Minor = AZURE_STORAGE_COMMON_VERSION_MINOR;
/// Patch numeric identifier.
constexpr static int Patch = AZURE_STORAGE_COMMON_VERSION_PATCH;
/// Optional pre-release identifier. SDK is in a pre-release state when not empty.
constexpr static const char* PreRelease = AZURE_STORAGE_COMMON_VERSION_PRERELEASE;
/**
* @brief The version in string format used for telemetry following the `semver.org` standard
* (https://semver.org).
*/
static std::string ToString()
{
std::string versionString
= std::to_string(Major) + "." + std::to_string(Minor) + "." + std::to_string(Patch);
if (std::strlen(PreRelease) != 0)
{
versionString += "-";
versionString += PreRelease;
}
return versionString;
}
};
}}}} // namespace Azure::Storage::Common::_detail
#undef AZURE_STORAGE_COMMON_VERSION_MAJOR
#undef AZURE_STORAGE_COMMON_VERSION_MINOR
#undef AZURE_STORAGE_COMMON_VERSION_PATCH
#undef AZURE_STORAGE_COMMON_VERSION_PRERELEASE

View File

@ -0,0 +1,61 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT
/**
* @file
* @brief Provides version information.
*/
#pragma once
#include <array>
#define AZURE_STORAGE_COMMON_VERSION_MAJOR 12
#define AZURE_STORAGE_COMMON_VERSION_MINOR 0
#define AZURE_STORAGE_COMMON_VERSION_PATCH 0
#define AZURE_STORAGE_COMMON_VERSION_PRERELEASE "beta.11"
#define AZURE_STORAGE_COMMON_VERSION_ITOA_HELPER(i) #i
#define AZURE_STORAGE_COMMON_VERSION_ITOA(i) AZURE_STORAGE_COMMON_VERSION_ITOA_HELPER(i)
namespace Azure { namespace Storage { namespace Common { namespace _detail {
/**
* @brief Provides version information.
*/
class PackageVersion {
public:
/// Major numeric identifier.
static constexpr int Major = AZURE_STORAGE_COMMON_VERSION_MAJOR;
/// Minor numeric identifier.
static constexpr int Minor = AZURE_STORAGE_COMMON_VERSION_MINOR;
/// Patch numeric identifier.
static constexpr int Patch = AZURE_STORAGE_COMMON_VERSION_PATCH;
/// Indicates whether the SDK is in a pre-release state.
static constexpr bool IsPreRelease
= sizeof(AZURE_STORAGE_COMMON_VERSION_PRERELEASE) != sizeof("");
/**
* @brief The version in string format used for telemetry following the `semver.org` standard
* (https://semver.org).
*/
static constexpr const char* ToString()
{
return IsPreRelease
? AZURE_STORAGE_COMMON_VERSION_ITOA(AZURE_STORAGE_COMMON_VERSION_MAJOR) "." AZURE_STORAGE_COMMON_VERSION_ITOA(
AZURE_STORAGE_COMMON_VERSION_MINOR) "." AZURE_STORAGE_COMMON_VERSION_ITOA(AZURE_STORAGE_COMMON_VERSION_PATCH) "-" AZURE_STORAGE_COMMON_VERSION_PRERELEASE
: AZURE_STORAGE_COMMON_VERSION_ITOA(AZURE_STORAGE_COMMON_VERSION_MAJOR) "." AZURE_STORAGE_COMMON_VERSION_ITOA(
AZURE_STORAGE_COMMON_VERSION_MINOR) "." AZURE_STORAGE_COMMON_VERSION_ITOA(AZURE_STORAGE_COMMON_VERSION_PATCH);
}
};
}}}} // namespace Azure::Storage::Common::_detail
#undef AZURE_STORAGE_COMMON_VERSION_ITOA_HELPER
#undef AZURE_STORAGE_COMMON_VERSION_ITOA
#undef AZURE_STORAGE_COMMON_VERSION_MAJOR
#undef AZURE_STORAGE_COMMON_VERSION_MINOR
#undef AZURE_STORAGE_COMMON_VERSION_PATCH
#undef AZURE_STORAGE_COMMON_VERSION_PRERELEASE

View File

@ -41,12 +41,12 @@ set(
inc/azure/storage/files/datalake/datalake_service_client.hpp
inc/azure/storage/files/datalake/datalake_utilities.hpp
inc/azure/storage/files/datalake/dll_import_export.hpp
inc/azure/storage/files/datalake/version.hpp
inc/azure/storage/files/datalake.hpp
)
set(
AZURE_STORAGE_FILES_DATALAKE_SOURCE
src/private/package_version.hpp
src/datalake_directory_client.cpp
src/datalake_file_client.cpp
src/datalake_file_system_client.cpp
@ -73,7 +73,7 @@ target_include_directories(
target_link_libraries(azure-storage-files-datalake PUBLIC Azure::azure-storage-blobs)
get_az_version("${CMAKE_CURRENT_SOURCE_DIR}/inc/azure/storage/files/datalake/version.hpp")
get_az_version("${CMAKE_CURRENT_SOURCE_DIR}/src/private/package_version.hpp")
generate_documentation(azure-storage-files-datalake ${AZ_LIBRARY_VERSION})
az_vcpkg_export(

View File

@ -1,61 +0,0 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT
/**
* @file
* @brief Provides version information.
*/
#pragma once
#include <cstring>
#include <string>
#define AZURE_STORAGE_FILES_DATALAKE_VERSION_MAJOR 12
#define AZURE_STORAGE_FILES_DATALAKE_VERSION_MINOR 0
#define AZURE_STORAGE_FILES_DATALAKE_VERSION_PATCH 0
#define AZURE_STORAGE_FILES_DATALAKE_VERSION_PRERELEASE "beta.11"
namespace Azure { namespace Storage { namespace Files { namespace DataLake { namespace _detail {
/**
* @brief Provides version information.
*/
struct PackageVersion
{
public:
/// Major numeric identifier.
constexpr static int Major = AZURE_STORAGE_FILES_DATALAKE_VERSION_MAJOR;
/// Minor numeric identifier.
constexpr static int Minor = AZURE_STORAGE_FILES_DATALAKE_VERSION_MINOR;
/// Patch numeric identifier.
constexpr static int Patch = AZURE_STORAGE_FILES_DATALAKE_VERSION_PATCH;
/// Optional pre-release identifier. SDK is in a pre-release state when not empty.
constexpr static const char* PreRelease = AZURE_STORAGE_FILES_DATALAKE_VERSION_PRERELEASE;
/**
* @brief The version in string format used for telemetry following the `semver.org` standard
* (https://semver.org).
*/
static std::string ToString()
{
std::string versionString
= std::to_string(Major) + "." + std::to_string(Minor) + "." + std::to_string(Patch);
if (std::strlen(PreRelease) != 0)
{
versionString += "-";
versionString += PreRelease;
}
return versionString;
}
};
}}}}} // namespace Azure::Storage::Files::DataLake::_detail
#undef AZURE_STORAGE_FILES_DATALAKE_VERSION_MAJOR
#undef AZURE_STORAGE_FILES_DATALAKE_VERSION_MINOR
#undef AZURE_STORAGE_FILES_DATALAKE_VERSION_PATCH
#undef AZURE_STORAGE_FILES_DATALAKE_VERSION_PRERELEASE

View File

@ -12,7 +12,6 @@
#include "azure/storage/files/datalake/datalake_file_client.hpp"
#include "azure/storage/files/datalake/datalake_utilities.hpp"
#include "azure/storage/files/datalake/version.hpp"
namespace Azure { namespace Storage { namespace Files { namespace DataLake {

View File

@ -11,7 +11,6 @@
#include "azure/storage/files/datalake/datalake_constants.hpp"
#include "azure/storage/files/datalake/datalake_utilities.hpp"
#include "azure/storage/files/datalake/version.hpp"
namespace Azure { namespace Storage { namespace Files { namespace DataLake {

View File

@ -18,7 +18,8 @@
#include "azure/storage/files/datalake/datalake_file_client.hpp"
#include "azure/storage/files/datalake/datalake_path_client.hpp"
#include "azure/storage/files/datalake/datalake_utilities.hpp"
#include "azure/storage/files/datalake/version.hpp"
#include "private/package_version.hpp"
namespace Azure { namespace Storage { namespace Files { namespace DataLake {

View File

@ -14,7 +14,8 @@
#include "azure/storage/files/datalake/datalake_constants.hpp"
#include "azure/storage/files/datalake/datalake_utilities.hpp"
#include "azure/storage/files/datalake/version.hpp"
#include "private/package_version.hpp"
namespace Azure { namespace Storage { namespace Files { namespace DataLake {

View File

@ -15,7 +15,8 @@
#include "azure/storage/files/datalake/datalake_file_system_client.hpp"
#include "azure/storage/files/datalake/datalake_utilities.hpp"
#include "azure/storage/files/datalake/version.hpp"
#include "private/package_version.hpp"
namespace Azure { namespace Storage { namespace Files { namespace DataLake {

View File

@ -0,0 +1,60 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT
/**
* @file
* @brief Provides version information.
*/
#pragma once
#define AZURE_STORAGE_FILES_DATALAKE_VERSION_MAJOR 12
#define AZURE_STORAGE_FILES_DATALAKE_VERSION_MINOR 0
#define AZURE_STORAGE_FILES_DATALAKE_VERSION_PATCH 0
#define AZURE_STORAGE_FILES_DATALAKE_VERSION_PRERELEASE "beta.11"
#define AZURE_STORAGE_FILES_DATALAKE_VERSION_ITOA_HELPER(i) #i
#define AZURE_STORAGE_FILES_DATALAKE_VERSION_ITOA(i) \
AZURE_STORAGE_FILES_DATALAKE_VERSION_ITOA_HELPER(i)
namespace Azure { namespace Storage { namespace Files { namespace DataLake { namespace _detail {
/**
* @brief Provides version information.
*/
class PackageVersion {
public:
/// Major numeric identifier.
static constexpr int Major = AZURE_STORAGE_FILES_DATALAKE_VERSION_MAJOR;
/// Minor numeric identifier.
static constexpr int Minor = AZURE_STORAGE_FILES_DATALAKE_VERSION_MINOR;
/// Patch numeric identifier.
static constexpr int Patch = AZURE_STORAGE_FILES_DATALAKE_VERSION_PATCH;
/// Indicates whether the SDK is in a pre-release state.
static constexpr bool IsPreRelease
= sizeof(AZURE_STORAGE_FILES_DATALAKE_VERSION_PRERELEASE) != sizeof("");
/**
* @brief The version in string format used for telemetry following the `semver.org` standard
* (https://semver.org).
*/
static constexpr const char* ToString()
{
return IsPreRelease
? AZURE_STORAGE_FILES_DATALAKE_VERSION_ITOA(AZURE_STORAGE_FILES_DATALAKE_VERSION_MAJOR) "." AZURE_STORAGE_FILES_DATALAKE_VERSION_ITOA(
AZURE_STORAGE_FILES_DATALAKE_VERSION_MINOR) "." AZURE_STORAGE_FILES_DATALAKE_VERSION_ITOA(AZURE_STORAGE_FILES_DATALAKE_VERSION_PATCH) "-" AZURE_STORAGE_FILES_DATALAKE_VERSION_PRERELEASE
: AZURE_STORAGE_FILES_DATALAKE_VERSION_ITOA(AZURE_STORAGE_FILES_DATALAKE_VERSION_MAJOR) "." AZURE_STORAGE_FILES_DATALAKE_VERSION_ITOA(
AZURE_STORAGE_FILES_DATALAKE_VERSION_MINOR) "." AZURE_STORAGE_FILES_DATALAKE_VERSION_ITOA(AZURE_STORAGE_FILES_DATALAKE_VERSION_PATCH);
}
};
}}}}} // namespace Azure::Storage::Files::DataLake::_detail
#undef AZURE_STORAGE_FILES_DATALAKE_VERSION_ITOA_HELPER
#undef AZURE_STORAGE_FILES_DATALAKE_VERSION_ITOA
#undef AZURE_STORAGE_FILES_DATALAKE_VERSION_MAJOR
#undef AZURE_STORAGE_FILES_DATALAKE_VERSION_MINOR
#undef AZURE_STORAGE_FILES_DATALAKE_VERSION_PATCH
#undef AZURE_STORAGE_FILES_DATALAKE_VERSION_PRERELEASE

View File

@ -40,12 +40,12 @@ set(
inc/azure/storage/files/shares/share_responses.hpp
inc/azure/storage/files/shares/share_sas_builder.hpp
inc/azure/storage/files/shares/share_service_client.hpp
inc/azure/storage/files/shares/version.hpp
inc/azure/storage/files/shares.hpp
)
set(
AZURE_STORAGE_FILES_SHARES_SOURCE
src/private/package_version.hpp
src/share_client.cpp
src/share_directory_client.cpp
src/share_file_attributes.cpp
@ -71,7 +71,7 @@ target_include_directories(
target_link_libraries(azure-storage-files-shares PUBLIC Azure::azure-storage-common)
get_az_version("${CMAKE_CURRENT_SOURCE_DIR}/inc/azure/storage/files/shares/version.hpp")
get_az_version("${CMAKE_CURRENT_SOURCE_DIR}/src/private/package_version.hpp")
generate_documentation(azure-storage-files-shares ${AZ_LIBRARY_VERSION})
az_vcpkg_export(

View File

@ -1,61 +0,0 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT
/**
* @file
* @brief Provides version information.
*/
#pragma once
#include <cstring>
#include <string>
#define AZURE_STORAGE_FILES_SHARES_VERSION_MAJOR 12
#define AZURE_STORAGE_FILES_SHARES_VERSION_MINOR 0
#define AZURE_STORAGE_FILES_SHARES_VERSION_PATCH 0
#define AZURE_STORAGE_FILES_SHARES_VERSION_PRERELEASE "beta.11"
namespace Azure { namespace Storage { namespace Files { namespace Shares { namespace _detail {
/**
* @brief Provides version information.
*/
struct PackageVersion
{
public:
/// Major numeric identifier.
constexpr static int Major = AZURE_STORAGE_FILES_SHARES_VERSION_MAJOR;
/// Minor numeric identifier.
constexpr static int Minor = AZURE_STORAGE_FILES_SHARES_VERSION_MINOR;
/// Patch numeric identifier.
constexpr static int Patch = AZURE_STORAGE_FILES_SHARES_VERSION_PATCH;
/// Optional pre-release identifier. SDK is in a pre-release state when not empty.
constexpr static const char* PreRelease = AZURE_STORAGE_FILES_SHARES_VERSION_PRERELEASE;
/**
* @brief The version in string format used for telemetry following the `semver.org` standard
* (https://semver.org).
*/
static std::string ToString()
{
std::string versionString
= std::to_string(Major) + "." + std::to_string(Minor) + "." + std::to_string(Patch);
if (std::strlen(PreRelease) != 0)
{
versionString += "-";
versionString += PreRelease;
}
return versionString;
}
};
}}}}} // namespace Azure::Storage::Files::Shares::_detail
#undef AZURE_STORAGE_FILES_SHARES_VERSION_MAJOR
#undef AZURE_STORAGE_FILES_SHARES_VERSION_MINOR
#undef AZURE_STORAGE_FILES_SHARES_VERSION_PATCH
#undef AZURE_STORAGE_FILES_SHARES_VERSION_PRERELEASE

View File

@ -0,0 +1,59 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT
/**
* @file
* @brief Provides version information.
*/
#pragma once
#define AZURE_STORAGE_FILES_SHARES_VERSION_MAJOR 12
#define AZURE_STORAGE_FILES_SHARES_VERSION_MINOR 0
#define AZURE_STORAGE_FILES_SHARES_VERSION_PATCH 0
#define AZURE_STORAGE_FILES_SHARES_VERSION_PRERELEASE "beta.11"
#define AZURE_STORAGE_FILES_SHARES_VERSION_ITOA_HELPER(i) #i
#define AZURE_STORAGE_FILES_SHARES_VERSION_ITOA(i) AZURE_STORAGE_FILES_SHARES_VERSION_ITOA_HELPER(i)
namespace Azure { namespace Storage { namespace Files { namespace Shares { namespace _detail {
/**
* @brief Provides version information.
*/
class PackageVersion {
public:
/// Major numeric identifier.
static constexpr int Major = AZURE_STORAGE_FILES_SHARES_VERSION_MAJOR;
/// Minor numeric identifier.
static constexpr int Minor = AZURE_STORAGE_FILES_SHARES_VERSION_MINOR;
/// Patch numeric identifier.
static constexpr int Patch = AZURE_STORAGE_FILES_SHARES_VERSION_PATCH;
/// Indicates whether the SDK is in a pre-release state.
static constexpr bool IsPreRelease
= sizeof(AZURE_STORAGE_FILES_SHARES_VERSION_PRERELEASE) != sizeof("");
/**
* @brief The version in string format used for telemetry following the `semver.org` standard
* (https://semver.org).
*/
static constexpr const char* ToString()
{
return IsPreRelease
? AZURE_STORAGE_FILES_SHARES_VERSION_ITOA(AZURE_STORAGE_FILES_SHARES_VERSION_MAJOR) "." AZURE_STORAGE_FILES_SHARES_VERSION_ITOA(
AZURE_STORAGE_FILES_SHARES_VERSION_MINOR) "." AZURE_STORAGE_FILES_SHARES_VERSION_ITOA(AZURE_STORAGE_FILES_SHARES_VERSION_PATCH) "-" AZURE_STORAGE_FILES_SHARES_VERSION_PRERELEASE
: AZURE_STORAGE_FILES_SHARES_VERSION_ITOA(AZURE_STORAGE_FILES_SHARES_VERSION_MAJOR) "." AZURE_STORAGE_FILES_SHARES_VERSION_ITOA(
AZURE_STORAGE_FILES_SHARES_VERSION_MINOR) "." AZURE_STORAGE_FILES_SHARES_VERSION_ITOA(AZURE_STORAGE_FILES_SHARES_VERSION_PATCH);
}
};
}}}}} // namespace Azure::Storage::Files::Shares::_detail
#undef AZURE_STORAGE_FILES_SHARES_VERSION_ITOA_HELPER
#undef AZURE_STORAGE_FILES_SHARES_VERSION_ITOA
#undef AZURE_STORAGE_FILES_SHARES_VERSION_MAJOR
#undef AZURE_STORAGE_FILES_SHARES_VERSION_MINOR
#undef AZURE_STORAGE_FILES_SHARES_VERSION_PATCH
#undef AZURE_STORAGE_FILES_SHARES_VERSION_PRERELEASE

View File

@ -14,7 +14,8 @@
#include "azure/storage/files/shares/share_directory_client.hpp"
#include "azure/storage/files/shares/share_file_client.hpp"
#include "azure/storage/files/shares/version.hpp"
#include "private/package_version.hpp"
namespace Azure { namespace Storage { namespace Files { namespace Shares {

View File

@ -13,7 +13,8 @@
#include <azure/storage/common/storage_service_version_policy.hpp>
#include "azure/storage/files/shares/share_file_client.hpp"
#include "azure/storage/files/shares/version.hpp"
#include "private/package_version.hpp"
namespace Azure { namespace Storage { namespace Files { namespace Shares {

View File

@ -18,7 +18,8 @@
#include <azure/storage/common/storage_service_version_policy.hpp>
#include "azure/storage/files/shares/share_constants.hpp"
#include "azure/storage/files/shares/version.hpp"
#include "private/package_version.hpp"
namespace Azure { namespace Storage { namespace Files { namespace Shares {

View File

@ -13,7 +13,8 @@
#include <azure/storage/common/storage_service_version_policy.hpp>
#include "azure/storage/files/shares/share_client.hpp"
#include "azure/storage/files/shares/version.hpp"
#include "private/package_version.hpp"
namespace Azure { namespace Storage { namespace Files { namespace Shares {
ShareServiceClient ShareServiceClient::CreateFromConnectionString(

View File

@ -30,14 +30,13 @@ set(
AZURE_TEMPLATE_HEADER
inc/azure/template/dll_import_export.hpp
inc/azure/template/template_client.hpp
inc/azure/template/version.hpp
inc/azure/template.hpp
)
set(
AZURE_TEMPLATE_SOURCE
src/private/package_version.hpp
src/template_client.cpp
src/version.cpp
)
add_library(azure-template ${AZURE_TEMPLATE_HEADER} ${AZURE_TEMPLATE_SOURCE})
@ -60,7 +59,7 @@ add_library(Azure::azure-template ALIAS azure-template)
# coverage. Has no effect if BUILD_CODE_COVERAGE is OFF
create_code_coverage(template azure-template azure-template-test)
get_az_version("${CMAKE_CURRENT_SOURCE_DIR}/inc/azure/template/version.hpp")
get_az_version("${CMAKE_CURRENT_SOURCE_DIR}/src/private//package_version.hpp")
generate_documentation(azure-template ${AZ_LIBRARY_VERSION})
az_vcpkg_export(

View File

@ -5,4 +5,3 @@
#include "azure/template/dll_import_export.hpp"
#include "azure/template/template_client.hpp"
#include "azure/template/version.hpp"

View File

@ -9,7 +9,7 @@ namespace Azure { namespace Template {
class TemplateClient {
public:
std::string const ClientVersion();
std::string ClientVersion() const;
};
}} // namespace Azure::Template

View File

@ -1,19 +1,22 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT
/**
* @file
* @brief Provides version information.
*/
#pragma once
#include "azure/template/dll_import_export.hpp"
#include <string>
#define AZURE_TEMPLATE_VERSION_MAJOR 1
#define AZURE_TEMPLATE_VERSION_MINOR 0
#define AZURE_TEMPLATE_VERSION_PATCH 0
#define AZURE_TEMPLATE_VERSION_PRERELEASE "beta.25"
namespace Azure { namespace Template { namespace _detail {
#define AZURE_TEMPLATE_VERSION_ITOA_HELPER(i) #i
#define AZURE_TEMPLATE_VERSION_ITOA(i) AZURE_TEMPLATE_VERSION_ITOA_HELPER(i)
namespace Azure { namespace Template { namespace _detail {
/**
* @brief Provides version information.
*/
@ -28,23 +31,27 @@ namespace Azure { namespace Template { namespace _detail {
/// Patch numeric identifier.
static constexpr int Patch = AZURE_TEMPLATE_VERSION_PATCH;
/// Optional pre-release identifier. SDK is in a pre-release state when not empty.
AZ_TEMPLATE_DLLEXPORT static std::string const PreRelease;
/// Indicates whether the SDK is in a pre-release state.
static constexpr bool IsPreRelease = sizeof(AZURE_TEMPLATE_VERSION_PRERELEASE) != sizeof("");
/**
* @brief The version in string format used for telemetry following the `semver.org` standard
* (https://semver.org).
*/
static std::string ToString();
private:
// To avoid leaking out the #define values we smuggle out the value
// which will later be used to initialize the PreRelease std::string
static constexpr const char* secret = AZURE_TEMPLATE_VERSION_PRERELEASE;
static constexpr const char* ToString()
{
return IsPreRelease
? AZURE_TEMPLATE_VERSION_ITOA(AZURE_TEMPLATE_VERSION_MAJOR) "." AZURE_TEMPLATE_VERSION_ITOA(
AZURE_TEMPLATE_VERSION_MINOR) "." AZURE_TEMPLATE_VERSION_ITOA(AZURE_TEMPLATE_VERSION_PATCH) "-" AZURE_TEMPLATE_VERSION_PRERELEASE
: AZURE_TEMPLATE_VERSION_ITOA(AZURE_TEMPLATE_VERSION_MAJOR) "." AZURE_TEMPLATE_VERSION_ITOA(
AZURE_TEMPLATE_VERSION_MINOR) "." AZURE_TEMPLATE_VERSION_ITOA(AZURE_TEMPLATE_VERSION_PATCH);
}
};
}}} // namespace Azure::Template::_detail
#undef AZURE_TEMPLATE_VERSION_ITOA_HELPER
#undef AZURE_TEMPLATE_VERSION_ITOA
#undef AZURE_TEMPLATE_VERSION_MAJOR
#undef AZURE_TEMPLATE_VERSION_MINOR
#undef AZURE_TEMPLATE_VERSION_PATCH

View File

@ -2,11 +2,12 @@
// SPDX-License-Identifier: MIT
#include "azure/template/template_client.hpp"
#include "azure/template/version.hpp"
#include "private/package_version.hpp"
#include <string>
using namespace Azure::Template;
using namespace Azure::Template::_detail;
std::string const TemplateClient::ClientVersion() { return PackageVersion::ToString(); }
std::string TemplateClient::ClientVersion() const { return PackageVersion::ToString(); }

View File

@ -1,28 +0,0 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT
#include <azure/template/version.hpp>
#include <sstream>
#include <string>
using namespace Azure::Template::_detail;
const std::string PackageVersion::PreRelease = secret;
std::string PackageVersion::ToString()
{
static const std::string versionString = [] {
std::string version;
std::stringstream ss;
std::string dot = ".";
ss << PackageVersion::Major << dot << PackageVersion::Minor << dot << PackageVersion::Patch;
if (!PackageVersion::PreRelease.empty())
ss << "-" << PackageVersion::PreRelease;
return ss.str();
}();
return versionString;
}