AWS SDK for C++  1.9.15
AWS SDK for C++
EventMessage.h
Go to the documentation of this file.
1 
6 #pragma once
7 
10 
11 namespace 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 
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;
113  size_t m_headersLength;
114  size_t m_payloadLength;
115 
117  Aws::Vector<unsigned char> m_eventPayload;
118  };
119 
120  }
121  }
122 }
EventHeader.h
Aws::Utils::Event::Message::GetHeadersLength
size_t GetHeadersLength() const
Definition: EventMessage.h:76
Aws::Utils::Event::EventHeaderValueCollection
Aws::Map< Aws::String, EventHeaderValue > EventHeaderValueCollection
Definition: EventHeader.h:308
Aws::Utils::Event::Message::GetTotalLength
size_t GetTotalLength() const
Definition: EventMessage.h:69
AWS_CORE_API
#define AWS_CORE_API
Definition: Core_EXPORTS.h:25
Aws::Utils::Event::Message::GetEventPayload
const Aws::Vector< unsigned char > & GetEventPayload() const
Definition: EventMessage.h:104
Aws::Utils::Event::ERROR_MESSAGE_HEADER
AWS_CORE_API const char ERROR_MESSAGE_HEADER[]
Aws::Utils::Event::Message::SetTotalLength
void SetTotalLength(size_t length)
Definition: EventMessage.h:63
Aws::Utils::Event::Message::SetHeadersLength
void SetHeadersLength(size_t length)
Definition: EventMessage.h:75
Aws::IoTWireless::Model::Event
Event
Definition: Event.h:17
Aws::Utils::Event::Message::GetEventPayloadWithOwnership
Aws::Vector< unsigned char > && GetEventPayloadWithOwnership()
Definition: EventMessage.h:103
Aws::Utils::Event::EVENT_TYPE_HEADER
AWS_CORE_API const char EVENT_TYPE_HEADER[]
Aws::Utils::Event::Message::GetPayloadLength
size_t GetPayloadLength() const
Definition: EventMessage.h:82
Aws::Utils::Event::Message::GetNameForContentType
static Aws::String GetNameForContentType(ContentType value)
Aws::Vector
std::vector< T, Aws::Allocator< T > > Vector
Definition: AWSVector.h:17
Aws::Utils::Event::EventHeaderValuePair
std::pair< Aws::String, EventHeaderValue > EventHeaderValuePair
Definition: EventHeader.h:307
Aws::Utils::Event::EventHeaderValue
Definition: EventHeader.h:29
Aws::Utils::Event::Message::WriteEventPayload
void WriteEventPayload(const unsigned char *data, size_t length)
Aws::Utils::Event::Message::GetEventHeaders
const Aws::Utils::Event::EventHeaderValueCollection & GetEventHeaders() const
Definition: EventMessage.h:92
Aws::Utils::Event::Message::MessageType
MessageType
Definition: EventMessage.h:33
Aws::Utils::Event::Message::WriteEventPayload
void WriteEventPayload(const Aws::String &bits)
Aws::Utils::Event::Message::WriteEventPayload
void WriteEventPayload(const Aws::Vector< unsigned char > &bits)
Aws::Utils::Event::Message::SetPayloadLength
void SetPayloadLength(size_t length)
Definition: EventMessage.h:81
Aws::Utils::Event::Message::GetEventPayload
Aws::Vector< unsigned char > & GetEventPayload()
Definition: EventMessage.h:105
Aws::Utils::Event::Message::GetNameForMessageType
static Aws::String GetNameForMessageType(MessageType value)
Aws::Utils::Event::Message::ContentType
ContentType
Definition: EventMessage.h:41
Aws::Utils::Event::ERROR_CODE_HEADER
AWS_CORE_API const char ERROR_CODE_HEADER[]
Aws::Utils::Event::MESSAGE_TYPE_HEADER
AWS_CORE_API const char MESSAGE_TYPE_HEADER[]
Aws::Utils::Event::CONTENT_TYPE_HEADER
AWS_CORE_API const char CONTENT_TYPE_HEADER[]
Aws::Utils::Event::Message::GetMessageTypeForName
static MessageType GetMessageTypeForName(const Aws::String &name)
Aws::Utils::Event::Message::GetContentTypeForName
static ContentType GetContentTypeForName(const Aws::String &name)
Aws::Utils::Event::Message
Definition: EventMessage.h:30
Core_EXPORTS.h
Aws
Definition: AccessManagementClient.h:15
length
char const int length
Definition: cJSON.h:164
Aws::Utils::Event::Message::InsertEventHeader
void InsertEventHeader(const Aws::String &headerName, const EventHeaderValue &eventHeaderValue)
Definition: EventMessage.h:87
Aws::Utils::Event::Message::GetEventPayloadAsString
Aws::String GetEventPayloadAsString()
Definition: EventMessage.h:109
Aws::String
std::basic_string< char, std::char_traits< char >, Aws::Allocator< char > > String
Definition: AWSString.h:97
Aws::Utils::Event::EXCEPTION_TYPE_HEADER
AWS_CORE_API const char EXCEPTION_TYPE_HEADER[]
Aws::Utils::Event::Message::Reset
void Reset()