71 lines
1.8 KiB
C++
71 lines
1.8 KiB
C++
/**
|
|
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
* SPDX-License-Identifier: Apache-2.0.
|
|
*/
|
|
|
|
#include <aws/greengrass/model/Permission.h>
|
|
#include <aws/core/utils/HashingUtils.h>
|
|
#include <aws/core/Globals.h>
|
|
#include <aws/core/utils/EnumParseOverflowContainer.h>
|
|
|
|
using namespace Aws::Utils;
|
|
|
|
|
|
namespace Aws
|
|
{
|
|
namespace Greengrass
|
|
{
|
|
namespace Model
|
|
{
|
|
namespace PermissionMapper
|
|
{
|
|
|
|
static const int ro_HASH = HashingUtils::HashString("ro");
|
|
static const int rw_HASH = HashingUtils::HashString("rw");
|
|
|
|
|
|
Permission GetPermissionForName(const Aws::String& name)
|
|
{
|
|
int hashCode = HashingUtils::HashString(name.c_str());
|
|
if (hashCode == ro_HASH)
|
|
{
|
|
return Permission::ro;
|
|
}
|
|
else if (hashCode == rw_HASH)
|
|
{
|
|
return Permission::rw;
|
|
}
|
|
EnumParseOverflowContainer* overflowContainer = Aws::GetEnumOverflowContainer();
|
|
if(overflowContainer)
|
|
{
|
|
overflowContainer->StoreOverflow(hashCode, name);
|
|
return static_cast<Permission>(hashCode);
|
|
}
|
|
|
|
return Permission::NOT_SET;
|
|
}
|
|
|
|
Aws::String GetNameForPermission(Permission enumValue)
|
|
{
|
|
switch(enumValue)
|
|
{
|
|
case Permission::ro:
|
|
return "ro";
|
|
case Permission::rw:
|
|
return "rw";
|
|
default:
|
|
EnumParseOverflowContainer* overflowContainer = Aws::GetEnumOverflowContainer();
|
|
if(overflowContainer)
|
|
{
|
|
return overflowContainer->RetrieveOverflow(static_cast<int>(enumValue));
|
|
}
|
|
|
|
return {};
|
|
}
|
|
}
|
|
|
|
} // namespace PermissionMapper
|
|
} // namespace Model
|
|
} // namespace Greengrass
|
|
} // namespace Aws
|