aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/event/EventHeader.cpp
blob: c3c989bedbb43d632ee0e035ce9826363f441564 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/**
 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
 * SPDX-License-Identifier: Apache-2.0.
 */

#include <aws/core/utils/event/EventHeader.h>
#include <aws/core/utils/HashingUtils.h>

namespace Aws
{
    namespace Utils
    {
        namespace Event
        {
            static const int HASH_BOOL_TRUE = HashingUtils::HashString("BOOL_TRUE");
            static const int HASH_BOOL_FALSE = HashingUtils::HashString("BOOL_FALSE");
            static const int HASH_BYTE = HashingUtils::HashString("BYTE");
            static const int HASH_INT16 = HashingUtils::HashString("INT16");
            static const int HASH_INT32 = HashingUtils::HashString("INT32");
            static const int HASH_INT64 = HashingUtils::HashString("INT64");
            static const int HASH_BYTE_BUF = HashingUtils::HashString("BYTE_BUFFER");
            static const int HASH_STRING = HashingUtils::HashString("STRING");
            static const int HASH_TIMESTAMP = HashingUtils::HashString("TIMESTAMP");
            static const int HASH_UUID = HashingUtils::HashString("UUID");

            EventHeaderValue::EventHeaderType EventHeaderValue::GetEventHeaderTypeForName(const Aws::String& name)
            {
                int hashCode = Aws::Utils::HashingUtils::HashString(name.c_str());
                if (hashCode == HASH_BOOL_TRUE)
                {
                    return EventHeaderType::BOOL_TRUE;
                }
                else if (hashCode == HASH_BOOL_FALSE)
                {
                    return EventHeaderType::BOOL_FALSE;
                }
                else if (hashCode == HASH_BYTE)
                {
                    return EventHeaderType::BYTE;
                }
                else if (hashCode == HASH_INT16)
                {
                    return EventHeaderType::INT16;
                }
                else if (hashCode == HASH_INT32)
                {
                    return EventHeaderType::INT32;
                }
                else if (hashCode == HASH_INT64)
                {
                    return EventHeaderType::INT64;
                }
                else if (hashCode == HASH_BYTE_BUF)
                {
                    return EventHeaderType::BYTE_BUF;
                }
                else if (hashCode == HASH_STRING)
                {
                    return EventHeaderType::STRING;
                }
                else if (hashCode == HASH_TIMESTAMP)
                {
                    return EventHeaderType::TIMESTAMP;
                }
                else if (hashCode == HASH_UUID)
                {
                    return EventHeaderType::UUID;
                }
                else
                {
                    return EventHeaderType::UNKNOWN;
                }
            }

            Aws::String EventHeaderValue::GetNameForEventHeaderType(EventHeaderType value)
            {
                switch (value)
                {
                case EventHeaderType::BOOL_TRUE:
                    return "BOOL_TRUE";
                case EventHeaderType::BOOL_FALSE:
                    return "BOOL_FALSE";
                case EventHeaderType::BYTE:
                    return "BYTE";
                case EventHeaderType::INT16:
                    return "INT16";
                case EventHeaderType::INT32:
                    return "INT32";
                case EventHeaderType::INT64:
                    return "INT64";
                case EventHeaderType::BYTE_BUF:
                    return "BYTE_BUF";
                case EventHeaderType::STRING:
                    return "STRING";
                case EventHeaderType::TIMESTAMP:
                    return "TIMESTAMP";
                case EventHeaderType::UUID:
                    return "UUID";
                default:
                    return "UNKNOWN";
                }
            }

        }
    }
}