| 1 | /* |
|---|---|
| 2 | * Copyright 2010-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"). |
| 5 | * You may not use this file except in compliance with the License. |
| 6 | * A copy of the License is located at |
| 7 | * |
| 8 | * http://aws.amazon.com/apache2.0 |
| 9 | * |
| 10 | * or in the "license" file accompanying this file. This file is distributed |
| 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either |
| 12 | * express or implied. See the License for the specific language governing |
| 13 | * permissions and limitations under the License. |
| 14 | */ |
| 15 | |
| 16 | #include <aws/s3/model/BucketCannedACL.h> |
| 17 | #include <aws/core/utils/HashingUtils.h> |
| 18 | #include <aws/core/Globals.h> |
| 19 | #include <aws/core/utils/EnumParseOverflowContainer.h> |
| 20 | |
| 21 | using namespace Aws::Utils; |
| 22 | |
| 23 | |
| 24 | namespace Aws |
| 25 | { |
| 26 | namespace S3 |
| 27 | { |
| 28 | namespace Model |
| 29 | { |
| 30 | namespace BucketCannedACLMapper |
| 31 | { |
| 32 | |
| 33 | static const int private__HASH = HashingUtils::HashString("private"); |
| 34 | static const int public_read_HASH = HashingUtils::HashString("public-read"); |
| 35 | static const int public_read_write_HASH = HashingUtils::HashString("public-read-write"); |
| 36 | static const int authenticated_read_HASH = HashingUtils::HashString("authenticated-read"); |
| 37 | |
| 38 | |
| 39 | BucketCannedACL GetBucketCannedACLForName(const Aws::String& name) |
| 40 | { |
| 41 | int hashCode = HashingUtils::HashString(name.c_str()); |
| 42 | if (hashCode == private__HASH) |
| 43 | { |
| 44 | return BucketCannedACL::private_; |
| 45 | } |
| 46 | else if (hashCode == public_read_HASH) |
| 47 | { |
| 48 | return BucketCannedACL::public_read; |
| 49 | } |
| 50 | else if (hashCode == public_read_write_HASH) |
| 51 | { |
| 52 | return BucketCannedACL::public_read_write; |
| 53 | } |
| 54 | else if (hashCode == authenticated_read_HASH) |
| 55 | { |
| 56 | return BucketCannedACL::authenticated_read; |
| 57 | } |
| 58 | EnumParseOverflowContainer* overflowContainer = Aws::GetEnumOverflowContainer(); |
| 59 | if(overflowContainer) |
| 60 | { |
| 61 | overflowContainer->StoreOverflow(hashCode, name); |
| 62 | return static_cast<BucketCannedACL>(hashCode); |
| 63 | } |
| 64 | |
| 65 | return BucketCannedACL::NOT_SET; |
| 66 | } |
| 67 | |
| 68 | Aws::String GetNameForBucketCannedACL(BucketCannedACL enumValue) |
| 69 | { |
| 70 | switch(enumValue) |
| 71 | { |
| 72 | case BucketCannedACL::private_: |
| 73 | return "private"; |
| 74 | case BucketCannedACL::public_read: |
| 75 | return "public-read"; |
| 76 | case BucketCannedACL::public_read_write: |
| 77 | return "public-read-write"; |
| 78 | case BucketCannedACL::authenticated_read: |
| 79 | return "authenticated-read"; |
| 80 | default: |
| 81 | EnumParseOverflowContainer* overflowContainer = Aws::GetEnumOverflowContainer(); |
| 82 | if(overflowContainer) |
| 83 | { |
| 84 | return overflowContainer->RetrieveOverflow(static_cast<int>(enumValue)); |
| 85 | } |
| 86 | |
| 87 | return {}; |
| 88 | } |
| 89 | } |
| 90 | |
| 91 | } // namespace BucketCannedACLMapper |
| 92 | } // namespace Model |
| 93 | } // namespace S3 |
| 94 | } // namespace Aws |
| 95 |