| 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/ObjectCannedACL.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 ObjectCannedACLMapper |
| 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 | static const int aws_exec_read_HASH = HashingUtils::HashString("aws-exec-read"); |
| 38 | static const int bucket_owner_read_HASH = HashingUtils::HashString("bucket-owner-read"); |
| 39 | static const int bucket_owner_full_control_HASH = HashingUtils::HashString("bucket-owner-full-control"); |
| 40 | |
| 41 | |
| 42 | ObjectCannedACL GetObjectCannedACLForName(const Aws::String& name) |
| 43 | { |
| 44 | int hashCode = HashingUtils::HashString(name.c_str()); |
| 45 | if (hashCode == private__HASH) |
| 46 | { |
| 47 | return ObjectCannedACL::private_; |
| 48 | } |
| 49 | else if (hashCode == public_read_HASH) |
| 50 | { |
| 51 | return ObjectCannedACL::public_read; |
| 52 | } |
| 53 | else if (hashCode == public_read_write_HASH) |
| 54 | { |
| 55 | return ObjectCannedACL::public_read_write; |
| 56 | } |
| 57 | else if (hashCode == authenticated_read_HASH) |
| 58 | { |
| 59 | return ObjectCannedACL::authenticated_read; |
| 60 | } |
| 61 | else if (hashCode == aws_exec_read_HASH) |
| 62 | { |
| 63 | return ObjectCannedACL::aws_exec_read; |
| 64 | } |
| 65 | else if (hashCode == bucket_owner_read_HASH) |
| 66 | { |
| 67 | return ObjectCannedACL::bucket_owner_read; |
| 68 | } |
| 69 | else if (hashCode == bucket_owner_full_control_HASH) |
| 70 | { |
| 71 | return ObjectCannedACL::bucket_owner_full_control; |
| 72 | } |
| 73 | EnumParseOverflowContainer* overflowContainer = Aws::GetEnumOverflowContainer(); |
| 74 | if(overflowContainer) |
| 75 | { |
| 76 | overflowContainer->StoreOverflow(hashCode, name); |
| 77 | return static_cast<ObjectCannedACL>(hashCode); |
| 78 | } |
| 79 | |
| 80 | return ObjectCannedACL::NOT_SET; |
| 81 | } |
| 82 | |
| 83 | Aws::String GetNameForObjectCannedACL(ObjectCannedACL enumValue) |
| 84 | { |
| 85 | switch(enumValue) |
| 86 | { |
| 87 | case ObjectCannedACL::private_: |
| 88 | return "private"; |
| 89 | case ObjectCannedACL::public_read: |
| 90 | return "public-read"; |
| 91 | case ObjectCannedACL::public_read_write: |
| 92 | return "public-read-write"; |
| 93 | case ObjectCannedACL::authenticated_read: |
| 94 | return "authenticated-read"; |
| 95 | case ObjectCannedACL::aws_exec_read: |
| 96 | return "aws-exec-read"; |
| 97 | case ObjectCannedACL::bucket_owner_read: |
| 98 | return "bucket-owner-read"; |
| 99 | case ObjectCannedACL::bucket_owner_full_control: |
| 100 | return "bucket-owner-full-control"; |
| 101 | default: |
| 102 | EnumParseOverflowContainer* overflowContainer = Aws::GetEnumOverflowContainer(); |
| 103 | if(overflowContainer) |
| 104 | { |
| 105 | return overflowContainer->RetrieveOverflow(static_cast<int>(enumValue)); |
| 106 | } |
| 107 | |
| 108 | return {}; |
| 109 | } |
| 110 | } |
| 111 | |
| 112 | } // namespace ObjectCannedACLMapper |
| 113 | } // namespace Model |
| 114 | } // namespace S3 |
| 115 | } // namespace Aws |
| 116 |