azure-sdk-for-cpp/sdk/storage/sample/samples_common.hpp
JinmingHu f74011a2e0
Add Unittest for Blob Service, other fixes and enhancements found during validation (#181)
* Give AccessTier a default value to eliminate warning

* Add blob clients conversion functions

* Fix bug in shared key authentication

* Add GetUri().

* make lease-status and lease-state optional

* Check duplicates in metadata

* add tests for blob service

* AppendBlocb doesn't support AccessTier

* fix bug in "RangeFromXml"

* redefine PageRange in convenience layer

* suppress warnings from gtest

* add API AppendBlockFromUri

* connection string parsing

* Add memorystream

* Rename connection string constants

* Adapt to new bodystream, this will be rewritten when bosystream is changed to unique_ptr

* fix compiler errors

* Change MemoryStream interface

* samples framework

* Add newline at the end of file

* fix compiler error
2020-06-24 01:17:09 -07:00

40 lines
908 B
C++

// Copyright(c) Microsoft Corporation.All rights reserved.
// SPDX - License - Identifier : MIT
#pragma once
#include <functional>
#include <map>
#include <string>
const std::string& GetConnectionString();
class Sample {
public:
static const std::map<std::string, std::function<void()>>& samples() { return m_samples(); }
protected:
static void add_sample(std::string sample_name, std::function<void()> func)
{
m_samples().emplace(std::move(sample_name), std::move(func));
}
private:
static std::map<std::string, std::function<void()>>& m_samples()
{
static std::map<std::string, std::function<void()>> samples_instance;
return samples_instance;
}
};
#define SAMPLE(NAME, FUNCTION) \
void FUNCTION(); \
\
class Sample##NAME : public Sample { \
public: \
Sample##NAME() { add_sample(#NAME, FUNCTION); } \
}; \
namespace { \
Sample##NAME Sample##NAME_; \
}