Qpid C++ Messaging API  1.39.0
Message.h
1 #ifndef QPID_MESSAGING_MESSAGE_H
2 #define QPID_MESSAGING_MESSAGE_H
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 #include "qpid/messaging/ImportExport.h"
25 
26 #include "qpid/messaging/Duration.h"
27 #include "qpid/types/Exception.h"
28 #include "qpid/types/Variant.h"
29 
30 #include <string>
31 
32 namespace qpid {
33 namespace messaging {
34 
35 class Address;
36 class Codec;
37 class MessageImpl;
38 
42 class QPID_MESSAGING_CLASS_EXTERN Message
43 {
44  public:
45  QPID_MESSAGING_EXTERN Message(qpid::types::Variant&);
46  QPID_MESSAGING_EXTERN Message(const std::string& bytes = std::string());
47  QPID_MESSAGING_EXTERN Message(const char*, size_t);
48  QPID_MESSAGING_EXTERN Message(const Message&);
49  QPID_MESSAGING_EXTERN ~Message();
50 
51  QPID_MESSAGING_EXTERN Message& operator=(const Message&);
52 
53  QPID_MESSAGING_EXTERN void setReplyTo(const Address&);
54  QPID_MESSAGING_EXTERN const Address& getReplyTo() const;
55 
56  QPID_MESSAGING_EXTERN void setSubject(const std::string&);
57  QPID_MESSAGING_EXTERN const std::string& getSubject() const;
58 
64  QPID_MESSAGING_EXTERN void setContentType(const std::string&);
70  QPID_MESSAGING_EXTERN const std::string& getContentType() const;
71 
77  QPID_MESSAGING_EXTERN void setMessageId(const std::string&);
78  QPID_MESSAGING_EXTERN const std::string& getMessageId() const;
79 
86  QPID_MESSAGING_EXTERN void setUserId(const std::string&);
87  QPID_MESSAGING_EXTERN const std::string& getUserId() const;
88 
96  QPID_MESSAGING_EXTERN void setCorrelationId(const std::string&);
97  QPID_MESSAGING_EXTERN const std::string& getCorrelationId() const;
98 
104  QPID_MESSAGING_EXTERN void setPriority(uint8_t);
105  QPID_MESSAGING_EXTERN uint8_t getPriority() const;
106 
112  QPID_MESSAGING_EXTERN void setTtl(Duration ttl);
116  QPID_MESSAGING_EXTERN Duration getTtl() const;
117 
124  QPID_MESSAGING_EXTERN void setDurable(bool durable);
125  QPID_MESSAGING_EXTERN bool getDurable() const;
126 
134  QPID_MESSAGING_EXTERN bool getRedelivered() const;
140  QPID_MESSAGING_EXTERN void setRedelivered(bool);
141 
150  QPID_MESSAGING_EXTERN const qpid::types::Variant::Map& getProperties() const;
151  QPID_MESSAGING_EXTERN qpid::types::Variant::Map& getProperties();
152  QPID_MESSAGING_EXTERN void setProperties(const qpid::types::Variant::Map&);
153 
160  QPID_MESSAGING_EXTERN void setContent(const std::string&);
165  QPID_MESSAGING_EXTERN void setContent(const char* chars, size_t count);
166 
168  QPID_MESSAGING_EXTERN std::string getContent() const;
170  QPID_MESSAGING_EXTERN std::string getContentBytes() const;
172  QPID_MESSAGING_EXTERN void setContentBytes(const std::string&);
178  QPID_MESSAGING_EXTERN qpid::types::Variant& getContentObject();
184  QPID_MESSAGING_EXTERN const qpid::types::Variant& getContentObject() const;
189  QPID_MESSAGING_EXTERN void setContentObject(const qpid::types::Variant&);
196  QPID_MESSAGING_EXTERN const char* getContentPtr() const;
198  QPID_MESSAGING_EXTERN size_t getContentSize() const;
199 
200  QPID_MESSAGING_EXTERN void setProperty(const std::string&, const qpid::types::Variant&);
201  private:
202  MessageImpl* impl;
203  friend struct MessageImplAccess;
204 };
205 
206 struct QPID_MESSAGING_CLASS_EXTERN EncodingException : qpid::types::Exception
207 {
208  QPID_MESSAGING_EXTERN EncodingException(const std::string& msg);
209 };
210 
220 QPID_MESSAGING_EXTERN void decode(const Message& message,
221  qpid::types::Variant::Map& map,
222  const std::string& encoding = std::string());
232 QPID_MESSAGING_EXTERN void decode(const Message& message,
233  qpid::types::Variant::List& list,
234  const std::string& encoding = std::string());
244 QPID_MESSAGING_EXTERN void encode(const qpid::types::Variant::Map& map,
245  Message& message,
246  const std::string& encoding = std::string());
256 QPID_MESSAGING_EXTERN void encode(const qpid::types::Variant::List& list,
257  Message& message,
258  const std::string& encoding = std::string());
259 
260 }} // namespace qpid::messaging
261 
262 #endif
Definition: Address.h:122
Definition: Exception.h:31
Definition: Variant.h:73
Definition: Duration.h:35
Definition: Message.h:206
Definition: Message.h:42
Definition: Address.h:32