AWS SDK for C++

AWS SDK for C++ Version 1.11.440

Loading...
Searching...
No Matches
EventMessage.h
1
6#pragma once
7
8#include <aws/core/Core_EXPORTS.h>
9#include <aws/core/utils/event/EventHeader.h>
10
11namespace Aws
12{
13 namespace Utils
14 {
15 namespace Event
16 {
17 extern AWS_CORE_API const char EVENT_TYPE_HEADER[];
18 extern AWS_CORE_API const char CONTENT_TYPE_HEADER[];
19 extern AWS_CORE_API const char MESSAGE_TYPE_HEADER[];
20 extern AWS_CORE_API const char ERROR_CODE_HEADER[];
21 extern AWS_CORE_API const char ERROR_MESSAGE_HEADER[];
22 extern AWS_CORE_API const char EXCEPTION_TYPE_HEADER[];
23
29 class AWS_CORE_API Message
30 {
31 public:
32 enum class MessageType
33 {
34 UNKNOWN,
35 EVENT,
36 REQUEST_LEVEL_ERROR,
37 REQUEST_LEVEL_EXCEPTION
38 };
39
40 enum class ContentType
41 {
42 UNKNOWN,
43 APPLICATION_OCTET_STREAM,
44 APPLICATION_JSON,
45 TEXT_PLAIN
46 };
47
50
53
54
58 void Reset();
59
63 inline void SetTotalLength(size_t length)
64 {
65 m_totalLength = length;
66 m_eventPayload.reserve(length);
67 }
68
69 inline size_t GetTotalLength() const { return m_totalLength; }
70
75 inline void SetHeadersLength(size_t length) { m_headersLength = length; }
76 inline size_t GetHeadersLength() const { return m_headersLength; }
77
81 inline void SetPayloadLength(size_t length) { m_payloadLength = length; }
82 inline size_t GetPayloadLength() const { return m_payloadLength; }
83
87 inline void InsertEventHeader(const Aws::String& headerName, const EventHeaderValue& eventHeaderValue)
88 {
89 m_eventHeaders.emplace(Aws::Utils::Event::EventHeaderValuePair(headerName, eventHeaderValue));
90 }
91
92 inline const Aws::Utils::Event::EventHeaderValueCollection& GetEventHeaders() const { return m_eventHeaders; }
93
97 void WriteEventPayload(const unsigned char* data, size_t length);
99 void WriteEventPayload(const Aws::String& bits);
103 Aws::Vector<unsigned char>&& GetEventPayloadWithOwnership() { return std::move(m_eventPayload); }
104 const Aws::Vector<unsigned char>& GetEventPayload() const { return m_eventPayload; }
105 Aws::Vector<unsigned char>& GetEventPayload() { return m_eventPayload; }
109 inline Aws::String GetEventPayloadAsString() { return Aws::String(m_eventPayload.begin(), m_eventPayload.end()); }
110
111 private:
112 size_t m_totalLength = 0;
113 size_t m_headersLength = 0;
114 size_t m_payloadLength = 0;
115
117 Aws::Vector<unsigned char> m_eventPayload;
118 };
119
120 }
121 }
122}
const Aws::Vector< unsigned char > & GetEventPayload() const
void SetHeadersLength(size_t length)
void SetTotalLength(size_t length)
void WriteEventPayload(const unsigned char *data, size_t length)
size_t GetTotalLength() const
Aws::Vector< unsigned char > && GetEventPayloadWithOwnership()
void InsertEventHeader(const Aws::String &headerName, const EventHeaderValue &eventHeaderValue)
size_t GetPayloadLength() const
static MessageType GetMessageTypeForName(const Aws::String &name)
static ContentType GetContentTypeForName(const Aws::String &name)
size_t GetHeadersLength() const
void SetPayloadLength(size_t length)
const Aws::Utils::Event::EventHeaderValueCollection & GetEventHeaders() const
static Aws::String GetNameForContentType(ContentType value)
static Aws::String GetNameForMessageType(MessageType value)
Aws::Vector< unsigned char > & GetEventPayload()
Aws::String GetEventPayloadAsString()
void WriteEventPayload(const Aws::String &bits)
void WriteEventPayload(const Aws::Vector< unsigned char > &bits)
AWS_CORE_API const char EXCEPTION_TYPE_HEADER[]
AWS_CORE_API const char MESSAGE_TYPE_HEADER[]
AWS_CORE_API const char CONTENT_TYPE_HEADER[]
Aws::Map< Aws::String, EventHeaderValue > EventHeaderValueCollection
std::pair< Aws::String, EventHeaderValue > EventHeaderValuePair
AWS_CORE_API const char ERROR_CODE_HEADER[]
AWS_CORE_API const char EVENT_TYPE_HEADER[]
AWS_CORE_API const char ERROR_MESSAGE_HEADER[]
std::basic_string< char, std::char_traits< char >, Aws::Allocator< char > > String
Definition AWSString.h:97
std::vector< T, Aws::Allocator< T > > Vector
Definition AWSVector.h:17