| 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/MetadataDirective.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 MetadataDirectiveMapper | 
| 31 | { | 
| 32 | |
| 33 | static const int COPY_HASH = HashingUtils::HashString( "COPY"); | 
| 34 | static const int REPLACE_HASH = HashingUtils::HashString( "REPLACE"); | 
| 35 | |
| 36 | |
| 37 | MetadataDirective GetMetadataDirectiveForName(const Aws::String& name) | 
| 38 | { | 
| 39 | int hashCode = HashingUtils::HashString(name.c_str()); | 
| 40 | if (hashCode == COPY_HASH) | 
| 41 | { | 
| 42 | return MetadataDirective::COPY; | 
| 43 | } | 
| 44 | else if (hashCode == REPLACE_HASH) | 
| 45 | { | 
| 46 | return MetadataDirective::REPLACE; | 
| 47 | } | 
| 48 | EnumParseOverflowContainer* overflowContainer = Aws::GetEnumOverflowContainer(); | 
| 49 | if(overflowContainer) | 
| 50 | { | 
| 51 | overflowContainer->StoreOverflow(hashCode, name); | 
| 52 | return static_cast<MetadataDirective>(hashCode); | 
| 53 | } | 
| 54 | |
| 55 | return MetadataDirective::NOT_SET; | 
| 56 | } | 
| 57 | |
| 58 | Aws::String GetNameForMetadataDirective(MetadataDirective enumValue) | 
| 59 | { | 
| 60 | switch(enumValue) | 
| 61 | { | 
| 62 | case MetadataDirective::COPY: | 
| 63 | return "COPY"; | 
| 64 | case MetadataDirective::REPLACE: | 
| 65 | return "REPLACE"; | 
| 66 | default: | 
| 67 | EnumParseOverflowContainer* overflowContainer = Aws::GetEnumOverflowContainer(); | 
| 68 | if(overflowContainer) | 
| 69 | { | 
| 70 | return overflowContainer->RetrieveOverflow(static_cast<int>(enumValue)); | 
| 71 | } | 
| 72 | |
| 73 | return {}; | 
| 74 | } | 
| 75 | } | 
| 76 | |
| 77 | } // namespace MetadataDirectiveMapper | 
| 78 | } // namespace Model | 
| 79 | } // namespace S3 | 
| 80 | } // namespace Aws | 
| 81 | 
