| 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/ObjectStorageClass.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 ObjectStorageClassMapper |
| 31 | { |
| 32 | |
| 33 | static const int STANDARD_HASH = HashingUtils::HashString("STANDARD"); |
| 34 | static const int REDUCED_REDUNDANCY_HASH = HashingUtils::HashString("REDUCED_REDUNDANCY"); |
| 35 | static const int GLACIER_HASH = HashingUtils::HashString("GLACIER"); |
| 36 | static const int STANDARD_IA_HASH = HashingUtils::HashString("STANDARD_IA"); |
| 37 | static const int ONEZONE_IA_HASH = HashingUtils::HashString("ONEZONE_IA"); |
| 38 | static const int INTELLIGENT_TIERING_HASH = HashingUtils::HashString("INTELLIGENT_TIERING"); |
| 39 | static const int DEEP_ARCHIVE_HASH = HashingUtils::HashString("DEEP_ARCHIVE"); |
| 40 | |
| 41 | |
| 42 | ObjectStorageClass GetObjectStorageClassForName(const Aws::String& name) |
| 43 | { |
| 44 | int hashCode = HashingUtils::HashString(name.c_str()); |
| 45 | if (hashCode == STANDARD_HASH) |
| 46 | { |
| 47 | return ObjectStorageClass::STANDARD; |
| 48 | } |
| 49 | else if (hashCode == REDUCED_REDUNDANCY_HASH) |
| 50 | { |
| 51 | return ObjectStorageClass::REDUCED_REDUNDANCY; |
| 52 | } |
| 53 | else if (hashCode == GLACIER_HASH) |
| 54 | { |
| 55 | return ObjectStorageClass::GLACIER; |
| 56 | } |
| 57 | else if (hashCode == STANDARD_IA_HASH) |
| 58 | { |
| 59 | return ObjectStorageClass::STANDARD_IA; |
| 60 | } |
| 61 | else if (hashCode == ONEZONE_IA_HASH) |
| 62 | { |
| 63 | return ObjectStorageClass::ONEZONE_IA; |
| 64 | } |
| 65 | else if (hashCode == INTELLIGENT_TIERING_HASH) |
| 66 | { |
| 67 | return ObjectStorageClass::INTELLIGENT_TIERING; |
| 68 | } |
| 69 | else if (hashCode == DEEP_ARCHIVE_HASH) |
| 70 | { |
| 71 | return ObjectStorageClass::DEEP_ARCHIVE; |
| 72 | } |
| 73 | EnumParseOverflowContainer* overflowContainer = Aws::GetEnumOverflowContainer(); |
| 74 | if(overflowContainer) |
| 75 | { |
| 76 | overflowContainer->StoreOverflow(hashCode, name); |
| 77 | return static_cast<ObjectStorageClass>(hashCode); |
| 78 | } |
| 79 | |
| 80 | return ObjectStorageClass::NOT_SET; |
| 81 | } |
| 82 | |
| 83 | Aws::String GetNameForObjectStorageClass(ObjectStorageClass enumValue) |
| 84 | { |
| 85 | switch(enumValue) |
| 86 | { |
| 87 | case ObjectStorageClass::STANDARD: |
| 88 | return "STANDARD"; |
| 89 | case ObjectStorageClass::REDUCED_REDUNDANCY: |
| 90 | return "REDUCED_REDUNDANCY"; |
| 91 | case ObjectStorageClass::GLACIER: |
| 92 | return "GLACIER"; |
| 93 | case ObjectStorageClass::STANDARD_IA: |
| 94 | return "STANDARD_IA"; |
| 95 | case ObjectStorageClass::ONEZONE_IA: |
| 96 | return "ONEZONE_IA"; |
| 97 | case ObjectStorageClass::INTELLIGENT_TIERING: |
| 98 | return "INTELLIGENT_TIERING"; |
| 99 | case ObjectStorageClass::DEEP_ARCHIVE: |
| 100 | return "DEEP_ARCHIVE"; |
| 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 ObjectStorageClassMapper |
| 113 | } // namespace Model |
| 114 | } // namespace S3 |
| 115 | } // namespace Aws |
| 116 |