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/CompressionType.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 CompressionTypeMapper |
31 | { |
32 | |
33 | static const int NONE_HASH = HashingUtils::HashString("NONE"); |
34 | static const int GZIP_HASH = HashingUtils::HashString("GZIP"); |
35 | static const int BZIP2_HASH = HashingUtils::HashString("BZIP2"); |
36 | |
37 | |
38 | CompressionType GetCompressionTypeForName(const Aws::String& name) |
39 | { |
40 | int hashCode = HashingUtils::HashString(name.c_str()); |
41 | if (hashCode == NONE_HASH) |
42 | { |
43 | return CompressionType::NONE; |
44 | } |
45 | else if (hashCode == GZIP_HASH) |
46 | { |
47 | return CompressionType::GZIP; |
48 | } |
49 | else if (hashCode == BZIP2_HASH) |
50 | { |
51 | return CompressionType::BZIP2; |
52 | } |
53 | EnumParseOverflowContainer* overflowContainer = Aws::GetEnumOverflowContainer(); |
54 | if(overflowContainer) |
55 | { |
56 | overflowContainer->StoreOverflow(hashCode, name); |
57 | return static_cast<CompressionType>(hashCode); |
58 | } |
59 | |
60 | return CompressionType::NOT_SET; |
61 | } |
62 | |
63 | Aws::String GetNameForCompressionType(CompressionType enumValue) |
64 | { |
65 | switch(enumValue) |
66 | { |
67 | case CompressionType::NONE: |
68 | return "NONE"; |
69 | case CompressionType::GZIP: |
70 | return "GZIP"; |
71 | case CompressionType::BZIP2: |
72 | return "BZIP2"; |
73 | default: |
74 | EnumParseOverflowContainer* overflowContainer = Aws::GetEnumOverflowContainer(); |
75 | if(overflowContainer) |
76 | { |
77 | return overflowContainer->RetrieveOverflow(static_cast<int>(enumValue)); |
78 | } |
79 | |
80 | return {}; |
81 | } |
82 | } |
83 | |
84 | } // namespace CompressionTypeMapper |
85 | } // namespace Model |
86 | } // namespace S3 |
87 | } // namespace Aws |
88 |