azure-sdk-for-cpp/sdk/storage/sample/main.cpp
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

65 lines
1.3 KiB
C++

// Copyright(c) Microsoft Corporation.All rights reserved.
// SPDX - License - Identifier : MIT
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif
#include "samples_common.hpp"
#include <cstdio>
#include <stdexcept>
const std::string& GetConnectionString()
{
const static std::string c_ConnectionString = "";
if (!c_ConnectionString.empty())
{
return c_ConnectionString;
}
const static std::string envConnectionString = std::getenv("AZURE_STORAGE_CONNECTION_STRING");
if (!envConnectionString.empty())
{
return envConnectionString;
}
throw std::runtime_error("Cannot find connection string");
}
int main(int argc, char** argv)
{
if (argc != 2)
{
printf("Usage: %s <sample name>\n", argv[0]);
}
else if (std::string(argv[1]) == "All")
{
for (auto sample : Sample::samples())
{
auto func = sample.second;
func();
}
}
else
{
auto ite = Sample::samples().find(argv[1]);
if (ite == Sample::samples().end())
{
printf("Cannot find sample %s\n", argv[1]);
}
else
{
auto func = ite->second;
func();
return 0;
}
}
printf("\nAvailable sample names:\n All\n");
for (const auto& i : Sample::samples())
{
printf(" %s\n", i.first.data());
}
return 1;
}