71 lines
1.9 KiB
C++
71 lines
1.9 KiB
C++
/**
|
|
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
* SPDX-License-Identifier: Apache-2.0.
|
|
*/
|
|
|
|
#include <aws/wafv2/model/IPAddressVersion.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 WAFV2
|
|
{
|
|
namespace Model
|
|
{
|
|
namespace IPAddressVersionMapper
|
|
{
|
|
|
|
static const int IPV4_HASH = HashingUtils::HashString("IPV4");
|
|
static const int IPV6_HASH = HashingUtils::HashString("IPV6");
|
|
|
|
|
|
IPAddressVersion GetIPAddressVersionForName(const Aws::String& name)
|
|
{
|
|
int hashCode = HashingUtils::HashString(name.c_str());
|
|
if (hashCode == IPV4_HASH)
|
|
{
|
|
return IPAddressVersion::IPV4;
|
|
}
|
|
else if (hashCode == IPV6_HASH)
|
|
{
|
|
return IPAddressVersion::IPV6;
|
|
}
|
|
EnumParseOverflowContainer* overflowContainer = Aws::GetEnumOverflowContainer();
|
|
if(overflowContainer)
|
|
{
|
|
overflowContainer->StoreOverflow(hashCode, name);
|
|
return static_cast<IPAddressVersion>(hashCode);
|
|
}
|
|
|
|
return IPAddressVersion::NOT_SET;
|
|
}
|
|
|
|
Aws::String GetNameForIPAddressVersion(IPAddressVersion enumValue)
|
|
{
|
|
switch(enumValue)
|
|
{
|
|
case IPAddressVersion::IPV4:
|
|
return "IPV4";
|
|
case IPAddressVersion::IPV6:
|
|
return "IPV6";
|
|
default:
|
|
EnumParseOverflowContainer* overflowContainer = Aws::GetEnumOverflowContainer();
|
|
if(overflowContainer)
|
|
{
|
|
return overflowContainer->RetrieveOverflow(static_cast<int>(enumValue));
|
|
}
|
|
|
|
return {};
|
|
}
|
|
}
|
|
|
|
} // namespace IPAddressVersionMapper
|
|
} // namespace Model
|
|
} // namespace WAFV2
|
|
} // namespace Aws
|