Skip to content

Commit 48b9f05

Browse files
AMQP::Reliable::publish() now takes std::string_view + added extra constructor to AMQP::Envelope
1 parent 7d3e790 commit 48b9f05

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

include/amqpcpp/envelope.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* When you send or receive a message to the rabbitMQ server, it is encapsulated
55
* in an envelope that contains additional meta information as well.
66
*
7-
* @copyright 2014 - 2020 Copernica BV
7+
* @copyright 2014 - 2023 Copernica BV
88
*/
99

1010
/**
@@ -53,6 +53,7 @@ class Envelope : public MetaData
5353
* @param size
5454
*/
5555
Envelope(const char *body, uint64_t size) : MetaData(), _body(body), _bodySize(size) {}
56+
Envelope(const char *body) : Envelope(body, strlen(body)) {}
5657

5758
/**
5859
* Read envelope frmo an input-buffer

include/amqpcpp/reliable.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* throttling at the same time.
1010
*
1111
* @author Michael van der Werve <[email protected]>
12-
* @copyright 2020 - 2022 Copernica BV
12+
* @copyright 2020 - 2023 Copernica BV
1313
*/
1414

1515
/**
@@ -239,9 +239,9 @@ class Reliable : public BASE
239239
* @param flags optional flags
240240
* @return bool
241241
*/
242-
DeferredPublish &publish(const std::string &exchange, const std::string &routingKey, const std::string &message, int flags = 0) { return publish(exchange, routingKey, Envelope(message.data(), message.size()), flags); }
243-
DeferredPublish &publish(const std::string &exchange, const std::string &routingKey, const char *message, size_t size, int flags = 0) { return publish(exchange, routingKey, Envelope(message, size), flags); }
244-
DeferredPublish &publish(const std::string &exchange, const std::string &routingKey, const char *message, int flags = 0) { return publish(exchange, routingKey, Envelope(message, strlen(message)), flags); }
242+
DeferredPublish &publish(const std::string_view &exchange, const std::string_view &routingKey, const std::string_view &message, int flags = 0) { return publish(exchange, routingKey, Envelope(message.data(), message.size()), flags); }
243+
DeferredPublish &publish(const std::string_view &exchange, const std::string_view &routingKey, const char *message, size_t size, int flags = 0) { return publish(exchange, routingKey, Envelope(message, size), flags); }
244+
DeferredPublish &publish(const std::string_view &exchange, const std::string_view &routingKey, const char *message, int flags = 0) { return publish(exchange, routingKey, Envelope(message, strlen(message)), flags); }
245245

246246
/**
247247
* Publish a message to an exchange. See amqpcpp/channel.h for more details on the flags.
@@ -254,7 +254,7 @@ class Reliable : public BASE
254254
* @param size size of the message
255255
* @param flags optional flags
256256
*/
257-
DeferredPublish &publish(const std::string &exchange, const std::string &routingKey, const Envelope &envelope, int flags = 0)
257+
DeferredPublish &publish(const std::string_view &exchange, const std::string_view &routingKey, const Envelope &envelope, int flags = 0)
258258
{
259259
// publish the entire thing, and remember if it failed at any point
260260
uint64_t tag = BASE::publish(exchange, routingKey, envelope, flags);

0 commit comments

Comments
 (0)