1/*
2 * Copyright 2010-2018 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/core/utils/event/EventHeader.h>
17#include <aws/core/utils/HashingUtils.h>
18
19namespace Aws
20{
21 namespace Utils
22 {
23 namespace Event
24 {
25 static const int HASH_BOOL_TRUE = HashingUtils::HashString("BOOL_TRUE");
26 static const int HASH_BOOL_FALSE = HashingUtils::HashString("BOOL_FALSE");
27 static const int HASH_BYTE = HashingUtils::HashString("BYTE");
28 static const int HASH_INT16 = HashingUtils::HashString("INT16");
29 static const int HASH_INT32 = HashingUtils::HashString("INT32");
30 static const int HASH_INT64 = HashingUtils::HashString("INT64");
31 static const int HASH_BYTE_BUF = HashingUtils::HashString("BYTE_BUFFER");
32 static const int HASH_STRING = HashingUtils::HashString("STRING");
33 static const int HASH_TIMESTAMP = HashingUtils::HashString("TIMESTAMP");
34 static const int HASH_UUID = HashingUtils::HashString("UUID");
35
36 EventHeaderValue::EventHeaderType EventHeaderValue::GetEventHeaderTypeForName(const Aws::String& name)
37 {
38 int hashCode = Aws::Utils::HashingUtils::HashString(name.c_str());
39 if (hashCode == HASH_BOOL_TRUE)
40 {
41 return EventHeaderType::BOOL_TRUE;
42 }
43 else if (hashCode == HASH_BOOL_FALSE)
44 {
45 return EventHeaderType::BOOL_FALSE;
46 }
47 else if (hashCode == HASH_BYTE)
48 {
49 return EventHeaderType::BYTE;
50 }
51 else if (hashCode == HASH_INT16)
52 {
53 return EventHeaderType::INT16;
54 }
55 else if (hashCode == HASH_INT32)
56 {
57 return EventHeaderType::INT32;
58 }
59 else if (hashCode == HASH_INT64)
60 {
61 return EventHeaderType::INT64;
62 }
63 else if (hashCode == HASH_BYTE_BUF)
64 {
65 return EventHeaderType::BYTE_BUF;
66 }
67 else if (hashCode == HASH_STRING)
68 {
69 return EventHeaderType::STRING;
70 }
71 else if (hashCode == HASH_TIMESTAMP)
72 {
73 return EventHeaderType::TIMESTAMP;
74 }
75 else if (hashCode == HASH_UUID)
76 {
77 return EventHeaderType::UUID;
78 }
79 else
80 {
81 return EventHeaderType::UNKNOWN;
82 }
83 }
84
85 Aws::String EventHeaderValue::GetNameForEventHeaderType(EventHeaderType value)
86 {
87 switch (value)
88 {
89 case EventHeaderType::BOOL_TRUE:
90 return "BOOL_TRUE";
91 case EventHeaderType::BOOL_FALSE:
92 return "BOOL_FALSE";
93 case EventHeaderType::BYTE:
94 return "BYTE";
95 case EventHeaderType::INT16:
96 return "INT16";
97 case EventHeaderType::INT32:
98 return "INT32";
99 case EventHeaderType::INT64:
100 return "INT64";
101 case EventHeaderType::BYTE_BUF:
102 return "BYTE_BUF";
103 case EventHeaderType::STRING:
104 return "STRING";
105 case EventHeaderType::TIMESTAMP:
106 return "TIMESTAMP";
107 case EventHeaderType::UUID:
108 return "UUID";
109 default:
110 return "UNKNOWN";
111 }
112 }
113
114 }
115 }
116}
117
118