Qpid Proton C++ API  0.18.1
message.hpp
Go to the documentation of this file.
1 #ifndef PROTON_MESSAGE_HPP
2 #define PROTON_MESSAGE_HPP
3 
4 /*
5  *
6  * Licensed to the Apache Software Foundation (ASF) under one
7  * or more contributor license agreements. See the NOTICE file
8  * distributed with this work for additional information
9  * regarding copyright ownership. The ASF licenses this file
10  * to you under the Apache License, Version 2.0 (the
11  * "License"); you may not use this file except in compliance
12  * with the License. You may obtain a copy of the License at
13  *
14  * http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing,
17  * software distributed under the License is distributed on an
18  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19  * KIND, either express or implied. See the License for the
20  * specific language governing permissions and limitations
21  * under the License.
22  *
23  */
24 
25 #include "./fwd.hpp"
26 #include "./internal/export.hpp"
27 #include "./duration.hpp"
28 #include "./timestamp.hpp"
29 #include "./value.hpp"
30 #include "./map.hpp"
31 
32 #include "./internal/pn_unique_ptr.hpp"
33 
34 #include <proton/type_compat.h>
35 
36 #include <string>
37 #include <vector>
38 
41 
42 struct pn_message_t;
43 
44 namespace proton {
45 
50 class message {
51  public:
54 
57 
59  PN_CPP_EXTERN message();
60 
62  PN_CPP_EXTERN message(const message&);
63 
65  PN_CPP_EXTERN message& operator=(const message&);
66 
67 #if PN_CPP_HAS_RVALUE_REFERENCES
68  PN_CPP_EXTERN message(message&&);
70 
72  PN_CPP_EXTERN message& operator=(message&&);
73 #endif
74 
77  PN_CPP_EXTERN message(const value& x);
78 
79  PN_CPP_EXTERN ~message();
80 
83 
85  PN_CPP_EXTERN void clear();
86 
91  PN_CPP_EXTERN void id(const message_id&);
92 
94  PN_CPP_EXTERN message_id id() const;
95 
97  PN_CPP_EXTERN void user(const std::string&);
98 
100  PN_CPP_EXTERN std::string user() const;
101 
104  PN_CPP_EXTERN void encode(std::vector<char>&) const;
105 
107  PN_CPP_EXTERN std::vector<char> encode() const;
108 
110  PN_CPP_EXTERN void decode(const std::vector<char>&);
111 
113 
116 
118  PN_CPP_EXTERN void to(const std::string&);
119 
121  PN_CPP_EXTERN std::string to() const;
122 
125  PN_CPP_EXTERN void address(const std::string&);
126  PN_CPP_EXTERN std::string address() const;
128 
130  PN_CPP_EXTERN void reply_to(const std::string&);
131 
133  PN_CPP_EXTERN std::string reply_to() const;
134 
136  PN_CPP_EXTERN void correlation_id(const message_id&);
137 
139  PN_CPP_EXTERN message_id correlation_id() const;
140 
142 
145 
147  PN_CPP_EXTERN void body(const value& x);
148 
150  PN_CPP_EXTERN const value& body() const;
151 
153  PN_CPP_EXTERN value& body();
154 
156  PN_CPP_EXTERN void subject(const std::string&);
157 
159  PN_CPP_EXTERN std::string subject() const;
160 
162  PN_CPP_EXTERN void content_type(const std::string&);
163 
165  PN_CPP_EXTERN std::string content_type() const;
166 
168  PN_CPP_EXTERN void content_encoding(const std::string&);
169 
171  PN_CPP_EXTERN std::string content_encoding() const;
172 
174  PN_CPP_EXTERN void expiry_time(timestamp);
175 
177  PN_CPP_EXTERN timestamp expiry_time() const;
178 
180  PN_CPP_EXTERN void creation_time(timestamp);
181 
183  PN_CPP_EXTERN timestamp creation_time() const;
184 
194  PN_CPP_EXTERN bool inferred() const;
195 
197  PN_CPP_EXTERN void inferred(bool);
198 
200 
203 
208  PN_CPP_EXTERN bool durable() const;
209 
211  PN_CPP_EXTERN void durable(bool);
212 
220  PN_CPP_EXTERN duration ttl() const;
221 
223  PN_CPP_EXTERN void ttl(duration);
224 
232  PN_CPP_EXTERN uint8_t priority() const;
233 
235  PN_CPP_EXTERN void priority(uint8_t);
236 
245 
246  // XXX The triple-not in the last sentence above is confusing.
247 
248  PN_CPP_EXTERN bool first_acquirer() const;
249 
251  PN_CPP_EXTERN void first_acquirer(bool);
252 
257  PN_CPP_EXTERN uint32_t delivery_count() const;
258 
260  PN_CPP_EXTERN void delivery_count(uint32_t);
261 
263 
266 
268  PN_CPP_EXTERN void group_id(const std::string&);
269 
271  PN_CPP_EXTERN std::string group_id() const;
272 
274  PN_CPP_EXTERN void reply_to_group_id(const std::string&);
275 
277  PN_CPP_EXTERN std::string reply_to_group_id() const;
278 
284  PN_CPP_EXTERN int32_t group_sequence() const;
285 
287  PN_CPP_EXTERN void group_sequence(int32_t);
288 
290 
293 
296  PN_CPP_EXTERN property_map& properties();
297 
299  PN_CPP_EXTERN const property_map& properties() const;
300 
303  PN_CPP_EXTERN annotation_map& message_annotations();
304 
306  PN_CPP_EXTERN const annotation_map& message_annotations() const;
307 
310  PN_CPP_EXTERN annotation_map& delivery_annotations();
311 
313  PN_CPP_EXTERN const annotation_map& delivery_annotations() const;
314 
316 
318  PN_CPP_EXTERN static const uint8_t default_priority;
319 
321  private:
322  struct impl;
323  pn_message_t* pn_msg() const;
324  struct impl& impl() const;
325 
326  mutable pn_message_t* pn_msg_;
327 
328  PN_CPP_EXTERN friend void swap(message&, message&);
330 };
331 
332 } // proton
333 
334 #endif // PROTON_MESSAGE_HPP
An AMQP message.
Definition: message.hpp:50
std::string group_id() const
Get the message group ID.
const value & body() const
Get the body.
bool inferred() const
Get the inferred flag.
uint8_t priority() const
Get the priority.
message_id correlation_id() const
Get the ID for matching related messages.
void swap(map< K, T > &, map< K, T > &)
Swap proton::map instances.
message_id id() const
Get the message ID.
timestamp creation_time() const
Get the creation time.
bool first_acquirer() const
Get the first acquirer flag.
A span of time in milliseconds.
Definition: duration.hpp:39
std::vector< char > encode() const
Return encoded message as a byte vector.
Forward declarations.
uint32_t delivery_count() const
Get the delivery count.
A collection of key-value pairs.
map< std::string, scalar > property_map
A map of string keys and AMQP scalar values.
Definition: message.hpp:53
A collection of key-value pairs.
Definition: map.hpp:44
std::string content_type() const
Get the content type of the body.
annotation_map & message_annotations()
Get the message annotations map.
annotation_map & delivery_annotations()
Get the delivery annotations map.
std::string user() const
Get the user name or ID.
int32_t group_sequence() const
Get the group sequence.
A span of time in milliseconds.
map< annotation_key, value > annotation_map
A map of AMQP annotation keys and AMQP values.
Definition: message.hpp:56
std::string subject() const
Get the subject.
bool durable() const
Get the durable flag.
A 64-bit timestamp in milliseconds since the Unix epoch.
Definition: timestamp.hpp:35
A holder for any AMQP value, simple or complex.
Definition: value.hpp:57
std::string to() const
Get the destination address.
message & operator=(const message &)
Copy a message.
void clear()
Clear the message content and properties.
static const uint8_t default_priority
Default priority assigned to new messages.
Definition: message.hpp:318
timestamp expiry_time() const
Get the expiration time.
std::string content_encoding() const
Get the content encoding of the body.
property_map & properties()
Get the application properties map.
std::string reply_to_group_id() const
Get the reply-to group ID.
std::string reply_to() const
Get the address for replies.
The main Proton namespace.
Definition: annotation_key.hpp:33
void decode(const std::vector< char > &)
Decode from string data into the message.
A 64-bit timestamp in milliseconds since the Unix epoch.
A holder for any AMQP value, simple or complex.
An AMQP message ID.
Definition: message_id.hpp:47
message()
Create an empty message.
duration ttl() const
Get the TTL.