Apache Qpid - AMQP Messaging for Java JMS, C++, Python, Ruby, and .NET Apache Qpid Documentation
MessageProperties.h
Go to the documentation of this file.
1 #ifndef QPID_FRAMING_MESSAGEPROPERTIES_H
2 #define QPID_FRAMING_MESSAGEPROPERTIES_H
3 /*
4  *
5  * Licensed to the Apache Software Foundation (ASF) under one
6  * or more contributor license agreements. See the NOTICE file
7  * distributed with this work for additional information
8  * regarding copyright ownership. The ASF licenses this file
9  * to you under the Apache License, Version 2.0 (the
10  * "License"); you may not use this file except in compliance
11  * with the License. You may obtain a copy of the License at
12  *
13  * http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing,
16  * software distributed under the License is distributed on an
17  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18  * KIND, either express or implied. See the License for the
19  * specific language governing permissions and limitations
20  * under the License.
21  *
22  */
23 
28 
29 
30 #include "qpid/framing/ReplyTo.h"
31 
32 #include <ostream>
33 #include "qpid/framing/amqp_types_full.h"
35 #include "qpid/CommonImportExport.h"
36 
37 namespace qpid {
38 namespace framing {
39 
40 class QPID_COMMON_CLASS_EXTERN MessageProperties {
41  uint64_t contentLength;
42  Uuid messageId;
43  std::string correlationId;
44  ReplyTo replyTo;
45  std::string contentType;
46  std::string contentEncoding;
47  std::string userId;
48  std::string appId;
49  FieldTable applicationHeaders;
50  uint16_t flags;
51 public:
52  static const uint16_t TYPE = 1027;
54  uint64_t _contentLength,
55  const Uuid& _messageId,
56  const std::string& _correlationId,
57  const ReplyTo& _replyTo,
58  const std::string& _contentType,
59  const std::string& _contentEncoding,
60  const std::string& _userId,
61  const std::string& _appId,
62  const FieldTable& _applicationHeaders) :
63  contentLength(_contentLength),
64  messageId(_messageId),
65  correlationId(_correlationId),
66  replyTo(_replyTo),
67  contentType(_contentType),
68  contentEncoding(_contentEncoding),
69  userId(_userId),
70  appId(_appId),
71  applicationHeaders(_applicationHeaders),
72  flags(0){
73  flags |= (1 << 8);
74  flags |= (1 << 9);
75  flags |= (1 << 10);
76  flags |= (1 << 11);
77  flags |= (1 << 12);
78  flags |= (1 << 13);
79  flags |= (1 << 14);
80  flags |= (1 << 15);
81  flags |= (1 << 0);
82  if (correlationId.size() >= 65536) throw IllegalArgumentException("Value for correlationId is too large");
83  if (contentType.size() >= 256) throw IllegalArgumentException("Value for contentType is too large");
84  if (contentEncoding.size() >= 256) throw IllegalArgumentException("Value for contentEncoding is too large");
85  if (userId.size() >= 65536) throw IllegalArgumentException("Value for userId is too large");
86  if (appId.size() >= 65536) throw IllegalArgumentException("Value for appId is too large");
87  }
88  MessageProperties() : contentLength(0), flags(0) {}
89 
90  QPID_COMMON_EXTERN void setContentLength(uint64_t _contentLength);
91  QPID_COMMON_EXTERN uint64_t getContentLength() const;
92  QPID_COMMON_EXTERN bool hasContentLength() const;
93  QPID_COMMON_EXTERN void clearContentLengthFlag();
94  QPID_COMMON_EXTERN void setMessageId(const Uuid& _messageId);
95  QPID_COMMON_EXTERN const Uuid& getMessageId() const;
96  QPID_COMMON_EXTERN bool hasMessageId() const;
97  QPID_COMMON_EXTERN void clearMessageIdFlag();
98  QPID_COMMON_EXTERN void setCorrelationId(const std::string& _correlationId);
99  QPID_COMMON_EXTERN const std::string& getCorrelationId() const;
100  QPID_COMMON_EXTERN bool hasCorrelationId() const;
101  QPID_COMMON_EXTERN void clearCorrelationIdFlag();
102  QPID_COMMON_EXTERN void setReplyTo(const ReplyTo& _replyTo);
103  QPID_COMMON_EXTERN const ReplyTo& getReplyTo() const;
104  QPID_COMMON_EXTERN bool hasReplyTo() const;
105  QPID_COMMON_EXTERN void clearReplyToFlag();
106  QPID_COMMON_EXTERN void setContentType(const std::string& _contentType);
107  QPID_COMMON_EXTERN const std::string& getContentType() const;
108  QPID_COMMON_EXTERN bool hasContentType() const;
109  QPID_COMMON_EXTERN void clearContentTypeFlag();
110  QPID_COMMON_EXTERN void setContentEncoding(const std::string& _contentEncoding);
111  QPID_COMMON_EXTERN const std::string& getContentEncoding() const;
112  QPID_COMMON_EXTERN bool hasContentEncoding() const;
113  QPID_COMMON_EXTERN void clearContentEncodingFlag();
114  QPID_COMMON_EXTERN void setUserId(const std::string& _userId);
115  QPID_COMMON_EXTERN const std::string& getUserId() const;
116  QPID_COMMON_EXTERN bool hasUserId() const;
117  QPID_COMMON_EXTERN void clearUserIdFlag();
118  QPID_COMMON_EXTERN void setAppId(const std::string& _appId);
119  QPID_COMMON_EXTERN const std::string& getAppId() const;
120  QPID_COMMON_EXTERN bool hasAppId() const;
121  QPID_COMMON_EXTERN void clearAppIdFlag();
122  QPID_COMMON_EXTERN void setApplicationHeaders(const FieldTable& _applicationHeaders);
123  QPID_COMMON_EXTERN const FieldTable& getApplicationHeaders() const;
124  QPID_COMMON_EXTERN FieldTable& getApplicationHeaders();
125  QPID_COMMON_EXTERN bool hasApplicationHeaders() const;
126  QPID_COMMON_EXTERN void clearApplicationHeadersFlag();
127  QPID_COMMON_EXTERN friend std::ostream& operator<<(std::ostream&, const MessageProperties&);
128  QPID_COMMON_EXTERN void encode(Buffer&) const;
129  QPID_COMMON_EXTERN void decode(Buffer&, uint32_t=0);
130  QPID_COMMON_EXTERN void encodeStructBody(Buffer&) const;
131  QPID_COMMON_EXTERN void decodeStructBody(Buffer&, uint32_t=0);
132  QPID_COMMON_EXTERN uint32_t encodedSize() const;
133  QPID_COMMON_EXTERN uint32_t bodySize() const;
134  QPID_COMMON_EXTERN void print(std::ostream& out) const;
135 }; /* class MessageProperties */
136 
137 }}
138 #endif
MessageProperties(uint64_t _contentLength, const Uuid &_messageId, const std::string &_correlationId, const ReplyTo &_replyTo, const std::string &_contentType, const std::string &_contentEncoding, const std::string &_userId, const std::string &_appId, const FieldTable &_applicationHeaders)
std::ostream & operator<<(std::ostream &, TypeCode)
void decode(const Message &message, qpid::types::Variant::Map &map, const std::string &encoding=std::string())
Decodes message content into a Variant::Map.
unsigned int uint32_t
Definition: IntegerTypes.h:27
unsigned short uint16_t
Definition: IntegerTypes.h:25
void encode(const qpid::types::Variant::Map &map, Message &message, const std::string &encoding=std::string())
Encodes a Variant::Map into a message.

Qpid C++ API Reference
Generated on Tue Oct 28 2014 for Qpid C++ Client API by doxygen 1.8.5