diff --git a/include/amqpcpp/envelope.h b/include/amqpcpp/envelope.h index 02726b3..deaf197 100644 --- a/include/amqpcpp/envelope.h +++ b/include/amqpcpp/envelope.h @@ -4,7 +4,7 @@ * When you send or receive a message to the rabbitMQ server, it is encapsulated * in an envelope that contains additional meta information as well. * - * @copyright 2014 - 2020 Copernica BV + * @copyright 2014 - 2023 Copernica BV */ /** @@ -53,6 +53,7 @@ public: * @param size */ Envelope(const char *body, uint64_t size) : MetaData(), _body(body), _bodySize(size) {} + Envelope(const char *body) : Envelope(body, strlen(body)) {} /** * Read envelope frmo an input-buffer diff --git a/include/amqpcpp/reliable.h b/include/amqpcpp/reliable.h index a084299..4c07001 100644 --- a/include/amqpcpp/reliable.h +++ b/include/amqpcpp/reliable.h @@ -9,7 +9,7 @@ * throttling at the same time. * * @author Michael van der Werve - * @copyright 2020 - 2022 Copernica BV + * @copyright 2020 - 2023 Copernica BV */ /** @@ -239,9 +239,9 @@ public: * @param flags optional flags * @return bool */ - 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); } - 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); } - 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); } + 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); } + 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); } + 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); } /** * Publish a message to an exchange. See amqpcpp/channel.h for more details on the flags. @@ -254,7 +254,7 @@ public: * @param size size of the message * @param flags optional flags */ - DeferredPublish &publish(const std::string &exchange, const std::string &routingKey, const Envelope &envelope, int flags = 0) + DeferredPublish &publish(const std::string_view &exchange, const std::string_view &routingKey, const Envelope &envelope, int flags = 0) { // publish the entire thing, and remember if it failed at any point uint64_t tag = BASE::publish(exchange, routingKey, envelope, flags);