Loading...
Searching...
No Matches
message.hpp
Go to the documentation of this file.
#ifndef PROTON_MESSAGE_HPP
#define PROTON_MESSAGE_HPP
/*
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
#include "./fwd.hpp"
#include "./internal/export.hpp"
#include "./duration.hpp"
#include "./timestamp.hpp"
#include "./value.hpp"
#include "./map.hpp"
#include <proton/type_compat.h>
#include <string>
#include <vector>
struct pn_message_t;
namespace proton {
class message {
public:
typedef map<std::string, scalar> property_map;
typedef map<annotation_key, value> annotation_map;
PN_CPP_EXTERN message();
PN_CPP_EXTERN message(const message&);
PN_CPP_EXTERN message& operator=(const message&);
PN_CPP_EXTERN message(message&&);
PN_CPP_EXTERN message& operator=(message&&);
PN_CPP_EXTERN message(const value& x);
PN_CPP_EXTERN ~message();
PN_CPP_EXTERN void clear();
PN_CPP_EXTERN void id(const message_id&);
PN_CPP_EXTERN message_id id() const;
PN_CPP_EXTERN void user(const std::string&);
PN_CPP_EXTERN std::string user() const;
PN_CPP_EXTERN void encode(std::vector<char>&) const;
PN_CPP_EXTERN std::vector<char> encode() const;
PN_CPP_EXTERN void decode(const std::vector<char>&);
PN_CPP_EXTERN void to(const std::string&);
PN_CPP_EXTERN std::string to() const;
PN_CPP_EXTERN void address(const std::string&);
PN_CPP_EXTERN std::string address() const;
PN_CPP_EXTERN void reply_to(const std::string&);
PN_CPP_EXTERN std::string reply_to() const;
PN_CPP_EXTERN void correlation_id(const message_id&);
PN_CPP_EXTERN message_id correlation_id() const;
PN_CPP_EXTERN void body(const value& x);
PN_CPP_EXTERN const value& body() const;
PN_CPP_EXTERN value& body();
PN_CPP_EXTERN void subject(const std::string&);
PN_CPP_EXTERN std::string subject() const;
PN_CPP_EXTERN void content_type(const std::string&);
PN_CPP_EXTERN std::string content_type() const;
PN_CPP_EXTERN void content_encoding(const std::string&);
PN_CPP_EXTERN std::string content_encoding() const;
PN_CPP_EXTERN void expiry_time(timestamp);
PN_CPP_EXTERN timestamp expiry_time() const;
PN_CPP_EXTERN void creation_time(timestamp);
PN_CPP_EXTERN timestamp creation_time() const;
PN_CPP_EXTERN bool inferred() const;
PN_CPP_EXTERN void inferred(bool);
PN_CPP_EXTERN bool durable() const;
PN_CPP_EXTERN void durable(bool);
PN_CPP_EXTERN duration ttl() const;
PN_CPP_EXTERN void ttl(duration);
PN_CPP_EXTERN uint8_t priority() const;
PN_CPP_EXTERN void priority(uint8_t);
// XXX The triple-not in the last sentence above is confusing.
PN_CPP_EXTERN bool first_acquirer() const;
PN_CPP_EXTERN void first_acquirer(bool);
PN_CPP_EXTERN uint32_t delivery_count() const;
PN_CPP_EXTERN void delivery_count(uint32_t);
PN_CPP_EXTERN void group_id(const std::string&);
PN_CPP_EXTERN std::string group_id() const;
PN_CPP_EXTERN void reply_to_group_id(const std::string&);
PN_CPP_EXTERN std::string reply_to_group_id() const;
PN_CPP_EXTERN int32_t group_sequence() const;
PN_CPP_EXTERN void group_sequence(int32_t);
PN_CPP_EXTERN property_map& properties();
PN_CPP_EXTERN const property_map& properties() const;
PN_CPP_EXTERN annotation_map& message_annotations();
PN_CPP_EXTERN const annotation_map& message_annotations() const;
PN_CPP_EXTERN annotation_map& delivery_annotations();
PN_CPP_EXTERN const annotation_map& delivery_annotations() const;
PN_CPP_EXTERN static const uint8_t default_priority;
friend PN_CPP_EXTERN std::ostream& operator<<(std::ostream&, const message&);
private:
struct impl;
pn_message_t* pn_msg() const;
struct impl& impl() const;
mutable pn_message_t* pn_msg_;
PN_CPP_EXTERN friend void swap(message&, message&);
};
PN_CPP_EXTERN std::string to_string(const message&);
} // proton
#endif // PROTON_MESSAGE_HPP
proton::duration
A span of time in milliseconds.
Definition duration.hpp:39
proton::map
A collection of key-value pairs.
Definition map.hpp:69
proton::message_id
An AMQP message ID.
Definition message_id.hpp:47
proton::message
An AMQP message.
Definition message.hpp:48
proton::message::encode
void encode(std::vector< char > &) const
Encode entire message into a byte vector, growing it if necessary.
proton::message::operator=
message & operator=(message &&)
Move a message.
proton::message::property_map
map< std::string, scalar > property_map
A map of string keys and AMQP scalar values.
Definition message.hpp:51
proton::message::inferred
bool inferred() const
Get the inferred flag.
proton::message::user
void user(const std::string &)
Set the user name or ID.
proton::message::inferred
void inferred(bool)
Set the inferred flag.
proton::message::creation_time
timestamp creation_time() const
Get the creation time.
proton::message::default_priority
static const uint8_t default_priority
Default priority assigned to new messages.
Definition message.hpp:314
proton::message::encode
std::vector< char > encode() const
Return encoded message as a byte vector.
proton::message::group_sequence
void group_sequence(int32_t)
Set the group sequence for a message.
proton::message::to
void to(const std::string &)
Set the destination address.
proton::message::subject
void subject(const std::string &)
Set the subject.
proton::message::annotation_map
map< annotation_key, value > annotation_map
A map of AMQP annotation keys and AMQP values.
Definition message.hpp:54
proton::message::reply_to
void reply_to(const std::string &)
Set the address for replies.
proton::message::expiry_time
void expiry_time(timestamp)
Set the expiration time.
proton::message::delivery_annotations
const annotation_map & delivery_annotations() const
Examine the delivery annotations map.
proton::message::content_encoding
void content_encoding(const std::string &)
Set the content encoding of the body.
proton::message::creation_time
void creation_time(timestamp)
Set the creation time.
proton::message::decode
void decode(const std::vector< char > &)
Decode from string data into the message.
proton::message::durable
bool durable() const
Get the durable flag.
proton::message::message
message(const message &)
Copy a message.
proton::message::ttl
void ttl(duration)
Set the TTL.
proton::message::group_id
std::string group_id() const
Get the message group ID.
proton::message::first_acquirer
bool first_acquirer() const
Get the first acquirer flag.
proton::message::first_acquirer
void first_acquirer(bool)
Set the first acquirer flag.
proton::message::priority
void priority(uint8_t)
Set the priority.
proton::message::message_annotations
const annotation_map & message_annotations() const
Examine the message annotations map.
proton::message::expiry_time
timestamp expiry_time() const
Get the expiration time.
proton::message::ttl
duration ttl() const
Get the TTL.
proton::message::to
std::string to() const
Get the destination address.
proton::message::reply_to_group_id
void reply_to_group_id(const std::string &)
Set the reply-to group ID.
proton::message::subject
std::string subject() const
Get the subject.
proton::message::id
void id(const message_id &)
Set the message ID.
proton::message::delivery_annotations
annotation_map & delivery_annotations()
Get the delivery annotations map.
proton::message::durable
void durable(bool)
Set the durable flag.
proton::message::user
std::string user() const
Get the user name or ID.
proton::message::content_type
std::string content_type() const
Get the content type of the body.
proton::message::reply_to_group_id
std::string reply_to_group_id() const
Get the reply-to group ID.
proton::message::operator=
message & operator=(const message &)
Copy a message.
proton::message::properties
property_map & properties()
Get the application properties map.
proton::message::message
message(const value &x)
Create a message with its body set from any value that can be converted to a proton::value.
proton::message::delivery_count
void delivery_count(uint32_t)
Get the delivery count.
proton::message::content_encoding
std::string content_encoding() const
Get the content encoding of the body.
proton::message::priority
uint8_t priority() const
Get the priority.
proton::message::delivery_count
uint32_t delivery_count() const
Get the delivery count.
proton::message::message
message()
Create an empty message.
proton::message::properties
const property_map & properties() const
Examine the application properties map.
proton::message::group_id
void group_id(const std::string &)
Set the message group ID.
proton::message::message
message(message &&)
Move a message.
proton::message::clear
void clear()
Clear the message content and properties.
proton::message::message_annotations
annotation_map & message_annotations()
Get the message annotations map.
proton::message::correlation_id
void correlation_id(const message_id &)
Set the ID for matching related messages.
proton::message::body
const value & body() const
Get the body.
proton::message::body
value & body()
Get a reference to the body that can be modified in place.
proton::message::id
message_id id() const
Get the message ID.
proton::message::operator<<
friend std::ostream & operator<<(std::ostream &, const message &)
Human readable string representation.
proton::message::body
void body(const value &x)
Set the body. Equivalent to body() = x.
proton::message::content_type
void content_type(const std::string &)
Set the content type of the body.
proton::message::correlation_id
message_id correlation_id() const
Get the ID for matching related messages.
proton::message::group_sequence
int32_t group_sequence() const
Get the group sequence.
proton::message::reply_to
std::string reply_to() const
Get the address for replies.
proton::timestamp
A 64-bit timestamp in milliseconds since the Unix epoch.
Definition timestamp.hpp:35
proton::value
A holder for any AMQP value, simple or complex.
Definition value.hpp:57
duration.hpp
A span of time in milliseconds.
fwd.hpp
Forward declarations.
map.hpp
A collection of key-value pairs.
proton
The main Proton namespace.
Definition annotation_key.hpp:33
proton::to_string
std::string to_string(const message &)
Human readable string representation.
proton::swap
void swap(map< K, T > &, map< K, T > &)
Swap proton::map instances.
timestamp.hpp
A 64-bit timestamp in milliseconds since the Unix epoch.
value.hpp
A holder for any AMQP value, simple or complex.