Qpid Proton C++  0.13.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
message.hpp
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 "./annotation_key.hpp"
26 #include "./codec/map.hpp"
27 #include "./duration.hpp"
28 #include "./internal/export.hpp"
29 #include "./message_id.hpp"
30 #include "./internal/pn_unique_ptr.hpp"
31 #include "./value.hpp"
32 
33 #include <string>
34 #include <vector>
35 #include <utility>
36 
37 struct pn_message_t;
38 
39 namespace proton {
40 
41 class delivery;
42 class message_id;
43 class annotation_key;
44 
49 class message {
50  public:
53  typedef std::map<std::string, scalar> property_map;
54 
57  typedef std::map<annotation_key, value> annotation_map;
58 
60  PN_CPP_EXTERN message();
61 
63  PN_CPP_EXTERN message(const message&);
64 
66  PN_CPP_EXTERN message& operator=(const message&);
67 
68 #if PN_CPP_HAS_RVALUE_REFERENCES
69  PN_CPP_EXTERN message(message&&);
71 
73  PN_CPP_EXTERN message& operator=(message&&);
74 #endif
75 
78  PN_CPP_EXTERN message(const value& x);
79 
80  PN_CPP_EXTERN ~message();
81 
84 
86  PN_CPP_EXTERN void clear();
87 
92  PN_CPP_EXTERN void id(const message_id& id);
93 
95  PN_CPP_EXTERN message_id id() const;
96 
98  PN_CPP_EXTERN void user(const std::string &user);
99 
101  PN_CPP_EXTERN std::string user() const;
102 
105  PN_CPP_EXTERN void encode(std::vector<char> &bytes) const;
106 
108  PN_CPP_EXTERN std::vector<char> encode() const;
109 
111  PN_CPP_EXTERN void decode(const std::vector<char> &bytes);
112 
114 
117 
119  PN_CPP_EXTERN void to(const std::string &addr);
120 
122  PN_CPP_EXTERN std::string to() const;
123 
126  PN_CPP_EXTERN void address(const std::string &addr);
127  PN_CPP_EXTERN std::string address() const;
129 
131  PN_CPP_EXTERN void reply_to(const std::string &addr);
132 
134  PN_CPP_EXTERN std::string reply_to() const;
135 
137  PN_CPP_EXTERN void correlation_id(const message_id&);
138 
140  PN_CPP_EXTERN message_id correlation_id() const;
141 
143 
146 
148  PN_CPP_EXTERN void body(const value& x);
149 
151  PN_CPP_EXTERN const value& body() const;
152 
154  PN_CPP_EXTERN value& body();
155 
157  PN_CPP_EXTERN void subject(const std::string &s);
158 
160  PN_CPP_EXTERN std::string subject() const;
161 
163  PN_CPP_EXTERN void content_type(const std::string &s);
164 
166  PN_CPP_EXTERN std::string content_type() const;
167 
169  PN_CPP_EXTERN void content_encoding(const std::string &s);
170 
172  PN_CPP_EXTERN std::string content_encoding() const;
173 
175  PN_CPP_EXTERN void expiry_time(timestamp t);
176 
178  PN_CPP_EXTERN timestamp expiry_time() const;
179 
181  PN_CPP_EXTERN void creation_time(timestamp t);
182 
184  PN_CPP_EXTERN timestamp creation_time() const;
185 
195  PN_CPP_EXTERN bool inferred() const;
196 
198  PN_CPP_EXTERN void inferred(bool);
199 
201 
204 
209  PN_CPP_EXTERN bool durable() const;
210 
212  PN_CPP_EXTERN void durable(bool);
213 
221  PN_CPP_EXTERN duration ttl() const;
222 
224  PN_CPP_EXTERN void ttl(duration);
225 
231  PN_CPP_EXTERN uint8_t priority() const;
232 
234  PN_CPP_EXTERN void priority(uint8_t);
235 
244 
245  // XXX The triple-not in the last sentence above is confusing.
246 
247  PN_CPP_EXTERN bool first_acquirer() const;
248 
250  PN_CPP_EXTERN void first_acquirer(bool);
251 
256  PN_CPP_EXTERN uint32_t delivery_count() const;
257 
259  PN_CPP_EXTERN void delivery_count(uint32_t);
260 
262 
265 
267  PN_CPP_EXTERN void group_id(const std::string &s);
268 
270  PN_CPP_EXTERN std::string group_id() const;
271 
273  PN_CPP_EXTERN void reply_to_group_id(const std::string &s);
274 
276  PN_CPP_EXTERN std::string reply_to_group_id() const;
277 
283  PN_CPP_EXTERN int32_t group_sequence() const;
284 
286  PN_CPP_EXTERN void group_sequence(int32_t);
287 
289 
292 
295  PN_CPP_EXTERN property_map& properties();
296 
299  PN_CPP_EXTERN const property_map& properties() const;
300 
303  PN_CPP_EXTERN annotation_map& message_annotations();
304 
307  PN_CPP_EXTERN const annotation_map& message_annotations() const;
308 
311  PN_CPP_EXTERN annotation_map& delivery_annotations();
312 
315  PN_CPP_EXTERN const annotation_map& delivery_annotations() const;
316 
318 
320  private:
321  pn_message_t *pn_msg() const;
322 
323  mutable pn_message_t *pn_msg_;
324  mutable value body_;
325  mutable property_map application_properties_;
326  mutable annotation_map message_annotations_;
327  mutable annotation_map delivery_annotations_;
328 
330  void decode(proton::delivery);
331 
332  PN_CPP_EXTERN friend void swap(message&, message&);
333  friend class messaging_adapter;
335 };
336 
337 } // proton
338 
339 #endif // PROTON_MESSAGE_HPP
duration ttl() const
Get the TTL.
An AMQP message.
Definition: message.hpp:49
message_id id() const
Get the message ID.
std::string to() const
Get the destination address.
std::map< std::string, scalar > property_map
Experimental - A map of string keys and AMQP scalar values.
Definition: message.hpp:53
std::string subject() const
Get the subject.
std::string user() const
Get the user name or ID.
A span of time in milliseconds.
Definition: duration.hpp:34
message_id correlation_id() const
Get the ID for matching related messages.
void decode(const std::vector< char > &bytes)
Decode from string data into the message.
timestamp expiry_time() const
Get the expiration time.
annotation_map & message_annotations()
Experimental - Get the message annotations map.
annotation_map & delivery_annotations()
Experimental - Get the delivery annotations map.
A received message.
Definition: delivery.hpp:40
uint32_t delivery_count() const
Get the delivery count.
std::string reply_to_group_id() const
Get the reply-to group ID.
timestamp creation_time() const
Get the creation time.
std::string reply_to() const
Get the address for replies.
A 64-bit timestamp in milliseconds since the Unix epoch.
Definition: timestamp.hpp:30
bool durable() const
Get the durable flag.
A holder for any AMQP value, simple or complex.
Definition: value.hpp:69
message & operator=(const message &)
Copy a message.
void clear()
Clear the message content and properties.
uint8_t priority() const
Get the priority.
bool inferred() const
Get the inferred flag.
std::string content_encoding() const
Get the content encoding of the body.
int32_t group_sequence() const
Get the group sequence.
std::string group_id() const
Get the message group ID.
property_map & properties()
Experimental - Get the application properties map.
std::vector< char > encode() const
Return encoded message as a byte vector.
std::map< annotation_key, value > annotation_map
Experimental - A map of AMQP annotation keys and AMQP values.
Definition: message.hpp:57
bool first_acquirer() const
Get the first acquirer flag.
const value & body() const
Get the body.
An AMQP message ID.
Definition: message_id.hpp:42
std::string content_type() const
Get the content type of the body.
message()
Create an empty message.