many methods in the Channel class now take a std::string_view instead of a std::string parameter, and are thus a bit more efficient
This commit is contained in:
parent
1adbd25164
commit
84a87d8f93
|
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
* Class describing a (mid-level) AMQP channel implementation
|
||||
*
|
||||
* @copyright 2014 - 2018 Copernica BV
|
||||
* @copyright 2014 - 2023 Copernica BV
|
||||
*/
|
||||
|
||||
/**
|
||||
|
|
@ -219,12 +219,12 @@ public:
|
|||
* This function returns a deferred handler. Callbacks can be installed
|
||||
* using onSuccess(), onError() and onFinalize() methods.
|
||||
*/
|
||||
Deferred &declareExchange(const std::string &name, ExchangeType type, int flags, const Table &arguments) { return _implementation->declareExchange(name, type, flags, arguments); }
|
||||
Deferred &declareExchange(const std::string &name, ExchangeType type, const Table &arguments) { return _implementation->declareExchange(name, type, 0, arguments); }
|
||||
Deferred &declareExchange(const std::string &name, ExchangeType type = fanout, int flags = 0) { return _implementation->declareExchange(name, type, flags, Table()); }
|
||||
Deferred &declareExchange(ExchangeType type, int flags, const Table &arguments) { return _implementation->declareExchange(std::string(), type, flags, arguments); }
|
||||
Deferred &declareExchange(ExchangeType type, const Table &arguments) { return _implementation->declareExchange(std::string(), type, 0, arguments); }
|
||||
Deferred &declareExchange(ExchangeType type = fanout, int flags = 0) { return _implementation->declareExchange(std::string(), type, flags, Table()); }
|
||||
Deferred &declareExchange(const std::string_view &name, ExchangeType type, int flags, const Table &arguments) { return _implementation->declareExchange(name, type, flags, arguments); }
|
||||
Deferred &declareExchange(const std::string_view &name, ExchangeType type, const Table &arguments) { return _implementation->declareExchange(name, type, 0, arguments); }
|
||||
Deferred &declareExchange(const std::string_view &name, ExchangeType type = fanout, int flags = 0) { return _implementation->declareExchange(name, type, flags, Table()); }
|
||||
Deferred &declareExchange(ExchangeType type, int flags, const Table &arguments) { return _implementation->declareExchange(std::string_view(), type, flags, arguments); }
|
||||
Deferred &declareExchange(ExchangeType type, const Table &arguments) { return _implementation->declareExchange(std::string_view(), type, 0, arguments); }
|
||||
Deferred &declareExchange(ExchangeType type = fanout, int flags = 0) { return _implementation->declareExchange(std::string_view(), type, flags, Table()); }
|
||||
|
||||
/**
|
||||
* Remove an exchange
|
||||
|
|
@ -239,7 +239,7 @@ public:
|
|||
* This function returns a deferred handler. Callbacks can be installed
|
||||
* using onSuccess(), onError() and onFinalize() methods.
|
||||
*/
|
||||
Deferred &removeExchange(const std::string &name, int flags = 0) { return _implementation->removeExchange(name, flags); }
|
||||
Deferred &removeExchange(const std::string_view &name, int flags = 0) { return _implementation->removeExchange(name, flags); }
|
||||
|
||||
/**
|
||||
* Bind two exchanges to each other
|
||||
|
|
@ -252,8 +252,8 @@ public:
|
|||
* This function returns a deferred handler. Callbacks can be installed
|
||||
* using onSuccess(), onError() and onFinalize() methods.
|
||||
*/
|
||||
Deferred &bindExchange(const std::string &source, const std::string &target, const std::string &routingkey, const Table &arguments) { return _implementation->bindExchange(source, target, routingkey, arguments); }
|
||||
Deferred &bindExchange(const std::string &source, const std::string &target, const std::string &routingkey) { return _implementation->bindExchange(source, target, routingkey, Table()); }
|
||||
Deferred &bindExchange(const std::string_view &source, const std::string_view &target, const std::string_view &routingkey, const Table &arguments) { return _implementation->bindExchange(source, target, routingkey, arguments); }
|
||||
Deferred &bindExchange(const std::string_view &source, const std::string_view &target, const std::string_view &routingkey) { return _implementation->bindExchange(source, target, routingkey, Table()); }
|
||||
|
||||
/**
|
||||
* Unbind two exchanges from one another
|
||||
|
|
@ -266,8 +266,8 @@ public:
|
|||
* This function returns a deferred handler. Callbacks can be installed
|
||||
* using onSuccess(), onError() and onFinalize() methods.
|
||||
*/
|
||||
Deferred &unbindExchange(const std::string &target, const std::string &source, const std::string &routingkey, const Table &arguments) { return _implementation->unbindExchange(target, source, routingkey, arguments); }
|
||||
Deferred &unbindExchange(const std::string &target, const std::string &source, const std::string &routingkey) { return _implementation->unbindExchange(target, source, routingkey, Table()); }
|
||||
Deferred &unbindExchange(const std::string_view &target, const std::string_view &source, const std::string_view &routingkey, const Table &arguments) { return _implementation->unbindExchange(target, source, routingkey, arguments); }
|
||||
Deferred &unbindExchange(const std::string_view &target, const std::string_view &source, const std::string_view &routingkey) { return _implementation->unbindExchange(target, source, routingkey, Table()); }
|
||||
|
||||
/**
|
||||
* Declare a queue
|
||||
|
|
@ -298,12 +298,12 @@ public:
|
|||
*
|
||||
* });
|
||||
*/
|
||||
DeferredQueue &declareQueue(const std::string &name, int flags, const Table &arguments) { return _implementation->declareQueue(name, flags, arguments); }
|
||||
DeferredQueue &declareQueue(const std::string &name, const Table &arguments) { return _implementation->declareQueue(name, 0, arguments); }
|
||||
DeferredQueue &declareQueue(const std::string &name, int flags = 0) { return _implementation->declareQueue(name, flags, Table()); }
|
||||
DeferredQueue &declareQueue(int flags, const Table &arguments) { return _implementation->declareQueue(std::string(), flags, arguments); }
|
||||
DeferredQueue &declareQueue(const Table &arguments) { return _implementation->declareQueue(std::string(), 0, arguments); }
|
||||
DeferredQueue &declareQueue(int flags = 0) { return _implementation->declareQueue(std::string(), flags, Table()); }
|
||||
DeferredQueue &declareQueue(const std::string_view &name, int flags, const Table &arguments) { return _implementation->declareQueue(name, flags, arguments); }
|
||||
DeferredQueue &declareQueue(const std::string_view &name, const Table &arguments) { return _implementation->declareQueue(name, 0, arguments); }
|
||||
DeferredQueue &declareQueue(const std::string_view &name, int flags = 0) { return _implementation->declareQueue(name, flags, Table()); }
|
||||
DeferredQueue &declareQueue(int flags, const Table &arguments) { return _implementation->declareQueue(std::string_view(), flags, arguments); }
|
||||
DeferredQueue &declareQueue(const Table &arguments) { return _implementation->declareQueue(std::string_view(), 0, arguments); }
|
||||
DeferredQueue &declareQueue(int flags = 0) { return _implementation->declareQueue(std::string_view(), flags, Table()); }
|
||||
|
||||
/**
|
||||
* Bind a queue to an exchange
|
||||
|
|
@ -316,8 +316,8 @@ public:
|
|||
* This function returns a deferred handler. Callbacks can be installed
|
||||
* using onSuccess(), onError() and onFinalize() methods.
|
||||
*/
|
||||
Deferred &bindQueue(const std::string &exchange, const std::string &queue, const std::string &routingkey, const Table &arguments) { return _implementation->bindQueue(exchange, queue, routingkey, arguments); }
|
||||
Deferred &bindQueue(const std::string &exchange, const std::string &queue, const std::string &routingkey) { return _implementation->bindQueue(exchange, queue, routingkey, Table()); }
|
||||
Deferred &bindQueue(const std::string_view &exchange, const std::string_view &queue, const std::string_view &routingkey, const Table &arguments) { return _implementation->bindQueue(exchange, queue, routingkey, arguments); }
|
||||
Deferred &bindQueue(const std::string_view &exchange, const std::string_view &queue, const std::string_view &routingkey) { return _implementation->bindQueue(exchange, queue, routingkey, Table()); }
|
||||
|
||||
/**
|
||||
* Unbind a queue from an exchange
|
||||
|
|
@ -329,8 +329,8 @@ public:
|
|||
* This function returns a deferred handler. Callbacks can be installed
|
||||
* using onSuccess(), onError() and onFinalize() methods.
|
||||
*/
|
||||
Deferred &unbindQueue(const std::string &exchange, const std::string &queue, const std::string &routingkey, const Table &arguments) { return _implementation->unbindQueue(exchange, queue, routingkey, arguments); }
|
||||
Deferred &unbindQueue(const std::string &exchange, const std::string &queue, const std::string &routingkey) { return _implementation->unbindQueue(exchange, queue, routingkey, Table()); }
|
||||
Deferred &unbindQueue(const std::string_view &exchange, const std::string_view &queue, const std::string_view &routingkey, const Table &arguments) { return _implementation->unbindQueue(exchange, queue, routingkey, arguments); }
|
||||
Deferred &unbindQueue(const std::string_view &exchange, const std::string_view &queue, const std::string_view &routingkey) { return _implementation->unbindQueue(exchange, queue, routingkey, Table()); }
|
||||
|
||||
/**
|
||||
* Purge a queue
|
||||
|
|
@ -350,7 +350,7 @@ public:
|
|||
*
|
||||
* });
|
||||
*/
|
||||
DeferredDelete &purgeQueue(const std::string &name){ return _implementation->purgeQueue(name); }
|
||||
DeferredDelete &purgeQueue(const std::string_view &name){ return _implementation->purgeQueue(name); }
|
||||
|
||||
/**
|
||||
* Remove a queue
|
||||
|
|
@ -376,7 +376,7 @@ public:
|
|||
*
|
||||
* });
|
||||
*/
|
||||
DeferredDelete &removeQueue(const std::string &name, int flags = 0) { return _implementation->removeQueue(name, flags); }
|
||||
DeferredDelete &removeQueue(const std::string_view &name, int flags = 0) { return _implementation->removeQueue(name, flags); }
|
||||
|
||||
/**
|
||||
* Publish a message to an exchange
|
||||
|
|
@ -403,10 +403,10 @@ public:
|
|||
* @param size size of the message
|
||||
* @param flags optional flags
|
||||
*/
|
||||
bool publish(const std::string &exchange, const std::string &routingKey, const Envelope &envelope, int flags = 0) { return _implementation->publish(exchange, routingKey, envelope, flags); }
|
||||
bool publish(const std::string &exchange, const std::string &routingKey, const std::string &message, int flags = 0) { return _implementation->publish(exchange, routingKey, Envelope(message.data(), message.size()), flags); }
|
||||
bool publish(const std::string &exchange, const std::string &routingKey, const char *message, size_t size, int flags = 0) { return _implementation->publish(exchange, routingKey, Envelope(message, size), flags); }
|
||||
bool publish(const std::string &exchange, const std::string &routingKey, const char *message, int flags = 0) { return _implementation->publish(exchange, routingKey, Envelope(message, strlen(message)), flags); }
|
||||
bool publish(const std::string_view &exchange, const std::string_view &routingKey, const Envelope &envelope, int flags = 0) { return _implementation->publish(exchange, routingKey, envelope, flags); }
|
||||
bool publish(const std::string_view &exchange, const std::string_view &routingKey, const std::string &message, int flags = 0) { return _implementation->publish(exchange, routingKey, Envelope(message.data(), message.size()), flags); }
|
||||
bool publish(const std::string_view &exchange, const std::string_view &routingKey, const char *message, size_t size, int flags = 0) { return _implementation->publish(exchange, routingKey, Envelope(message, size), flags); }
|
||||
bool publish(const std::string_view &exchange, const std::string_view &routingKey, const char *message, int flags = 0) { return _implementation->publish(exchange, routingKey, Envelope(message, strlen(message)), flags); }
|
||||
|
||||
/**
|
||||
* Set the Quality of Service (QOS) for this channel
|
||||
|
|
@ -450,20 +450,20 @@ public:
|
|||
*
|
||||
* The onSuccess() callback that you can install should have the following signature:
|
||||
*
|
||||
* void myCallback(const std::string& tag);
|
||||
* void myCallback(const std::string_view& tag);
|
||||
*
|
||||
* For example: channel.consume("myqueue").onSuccess([](const std::string& tag) {
|
||||
* For example: channel.consume("myqueue").onSuccess([](const std::string_view& tag) {
|
||||
*
|
||||
* std::cout << "Started consuming under tag " << tag << std::endl;
|
||||
*
|
||||
* });
|
||||
*/
|
||||
DeferredConsumer &consume(const std::string &queue, const std::string &tag, int flags, const Table &arguments) { return _implementation->consume(queue, tag, flags, arguments); }
|
||||
DeferredConsumer &consume(const std::string &queue, const std::string &tag, int flags = 0) { return _implementation->consume(queue, tag, flags, Table()); }
|
||||
DeferredConsumer &consume(const std::string &queue, const std::string &tag, const Table &arguments) { return _implementation->consume(queue, tag, 0, arguments); }
|
||||
DeferredConsumer &consume(const std::string &queue, int flags, const Table &arguments) { return _implementation->consume(queue, std::string(), flags, arguments); }
|
||||
DeferredConsumer &consume(const std::string &queue, int flags = 0) { return _implementation->consume(queue, std::string(), flags, Table()); }
|
||||
DeferredConsumer &consume(const std::string &queue, const Table &arguments) { return _implementation->consume(queue, std::string(), 0, arguments); }
|
||||
DeferredConsumer &consume(const std::string_view &queue, const std::string_view &tag, int flags, const Table &arguments) { return _implementation->consume(queue, tag, flags, arguments); }
|
||||
DeferredConsumer &consume(const std::string_view &queue, const std::string_view &tag, int flags = 0) { return _implementation->consume(queue, tag, flags, Table()); }
|
||||
DeferredConsumer &consume(const std::string_view &queue, const std::string_view &tag, const Table &arguments) { return _implementation->consume(queue, tag, 0, arguments); }
|
||||
DeferredConsumer &consume(const std::string_view &queue, int flags, const Table &arguments) { return _implementation->consume(queue, std::string_view(), flags, arguments); }
|
||||
DeferredConsumer &consume(const std::string_view &queue, int flags = 0) { return _implementation->consume(queue, std::string_view(), flags, Table()); }
|
||||
DeferredConsumer &consume(const std::string_view &queue, const Table &arguments) { return _implementation->consume(queue, std::string_view(), 0, arguments); }
|
||||
|
||||
/**
|
||||
* Tell the messages that you are ready to recall/take back messages that messages thar are unroutable.
|
||||
|
|
@ -497,7 +497,7 @@ public:
|
|||
*
|
||||
* });
|
||||
*/
|
||||
DeferredCancel &cancel(const std::string &tag) { return _implementation->cancel(tag); }
|
||||
DeferredCancel &cancel(const std::string_view &tag) { return _implementation->cancel(tag); }
|
||||
|
||||
/**
|
||||
* Retrieve a single message from RabbitMQ
|
||||
|
|
@ -531,7 +531,7 @@ public:
|
|||
*
|
||||
* });
|
||||
*/
|
||||
DeferredGet &get(const std::string &queue, int flags = 0) { return _implementation->get(queue, flags); }
|
||||
DeferredGet &get(const std::string_view &queue, int flags = 0) { return _implementation->get(queue, flags); }
|
||||
|
||||
/**
|
||||
* Acknoldge a received message
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
* that has a private constructor so that it can not be used from outside
|
||||
* the AMQP library
|
||||
*
|
||||
* @copyright 2014 - 2022 Copernica BV
|
||||
* @copyright 2014 - 2023 Copernica BV
|
||||
*/
|
||||
|
||||
/**
|
||||
|
|
@ -308,7 +308,7 @@ public:
|
|||
* This function returns a deferred handler. Callbacks can be installed
|
||||
* using onSuccess(), onError() and onFinalize() methods.
|
||||
*/
|
||||
Deferred &declareExchange(const std::string &name, ExchangeType type, int flags, const Table &arguments);
|
||||
Deferred &declareExchange(const std::string_view &name, ExchangeType type, int flags, const Table &arguments);
|
||||
|
||||
/**
|
||||
* bind two exchanges
|
||||
|
|
@ -321,7 +321,7 @@ public:
|
|||
* This function returns a deferred handler. Callbacks can be installed
|
||||
* using onSuccess(), onError() and onFinalize() methods.
|
||||
*/
|
||||
Deferred &bindExchange(const std::string &source, const std::string &target, const std::string &routingkey, const Table &arguments);
|
||||
Deferred &bindExchange(const std::string_view &source, const std::string_view &target, const std::string_view &routingkey, const Table &arguments);
|
||||
|
||||
/**
|
||||
* unbind two exchanges
|
||||
|
|
@ -334,7 +334,7 @@ public:
|
|||
* This function returns a deferred handler. Callbacks can be installed
|
||||
* using onSuccess(), onError() and onFinalize() methods.
|
||||
*/
|
||||
Deferred &unbindExchange(const std::string &source, const std::string &target, const std::string &routingkey, const Table &arguments);
|
||||
Deferred &unbindExchange(const std::string_view &source, const std::string_view &target, const std::string_view &routingkey, const Table &arguments);
|
||||
|
||||
/**
|
||||
* remove an exchange
|
||||
|
|
@ -345,7 +345,7 @@ public:
|
|||
* This function returns a deferred handler. Callbacks can be installed
|
||||
* using onSuccess(), onError() and onFinalize() methods.
|
||||
*/
|
||||
Deferred &removeExchange(const std::string &name, int flags);
|
||||
Deferred &removeExchange(const std::string_view &name, int flags);
|
||||
|
||||
/**
|
||||
* declare a queue
|
||||
|
|
@ -356,7 +356,7 @@ public:
|
|||
* This function returns a deferred handler. Callbacks can be installed
|
||||
* using onSuccess(), onError() and onFinalize() methods.
|
||||
*/
|
||||
DeferredQueue &declareQueue(const std::string &name, int flags, const Table &arguments);
|
||||
DeferredQueue &declareQueue(const std::string_view &name, int flags, const Table &arguments);
|
||||
|
||||
/**
|
||||
* Bind a queue to an exchange
|
||||
|
|
@ -369,7 +369,7 @@ public:
|
|||
* This function returns a deferred handler. Callbacks can be installed
|
||||
* using onSuccess(), onError() and onFinalize() methods.
|
||||
*/
|
||||
Deferred &bindQueue(const std::string &exchangeName, const std::string &queueName, const std::string &routingkey, const Table &arguments);
|
||||
Deferred &bindQueue(const std::string_view &exchangeName, const std::string_view &queueName, const std::string_view &routingkey, const Table &arguments);
|
||||
|
||||
/**
|
||||
* Unbind a queue from an exchange
|
||||
|
|
@ -382,7 +382,7 @@ public:
|
|||
* This function returns a deferred handler. Callbacks can be installed
|
||||
* using onSuccess(), onError() and onFinalize() methods.
|
||||
*/
|
||||
Deferred &unbindQueue(const std::string &exchangeName, const std::string &queueName, const std::string &routingkey, const Table &arguments);
|
||||
Deferred &unbindQueue(const std::string_view &exchangeName, const std::string_view &queueName, const std::string_view &routingkey, const Table &arguments);
|
||||
|
||||
/**
|
||||
* Purge a queue
|
||||
|
|
@ -401,7 +401,7 @@ public:
|
|||
*
|
||||
* });
|
||||
*/
|
||||
DeferredDelete &purgeQueue(const std::string &name);
|
||||
DeferredDelete &purgeQueue(const std::string_view &name);
|
||||
|
||||
/**
|
||||
* Remove a queue
|
||||
|
|
@ -421,7 +421,7 @@ public:
|
|||
*
|
||||
* });
|
||||
*/
|
||||
DeferredDelete &removeQueue(const std::string &name, int flags);
|
||||
DeferredDelete &removeQueue(const std::string_view &name, int flags);
|
||||
|
||||
/**
|
||||
* Publish a message to an exchange
|
||||
|
|
@ -437,7 +437,7 @@ public:
|
|||
* @param flags optional flags
|
||||
* @return bool
|
||||
*/
|
||||
bool publish(const std::string &exchange, const std::string &routingKey, const Envelope &envelope, int flags);
|
||||
bool publish(const std::string_view &exchange, const std::string_view &routingKey, const Envelope &envelope, int flags);
|
||||
|
||||
/**
|
||||
* Set the Quality of Service (QOS) of the entire connection
|
||||
|
|
@ -471,7 +471,7 @@ public:
|
|||
*
|
||||
* });
|
||||
*/
|
||||
DeferredConsumer& consume(const std::string &queue, const std::string &tag, int flags, const Table &arguments);
|
||||
DeferredConsumer& consume(const std::string_view &queue, const std::string_view &tag, int flags, const Table &arguments);
|
||||
|
||||
/**
|
||||
* Tell that you are prepared to recall/take back messages that could not be
|
||||
|
|
@ -501,7 +501,7 @@ public:
|
|||
*
|
||||
* });
|
||||
*/
|
||||
DeferredCancel &cancel(const std::string &tag);
|
||||
DeferredCancel &cancel(const std::string_view &tag);
|
||||
|
||||
/**
|
||||
* Retrieve a single message from RabbitMQ
|
||||
|
|
@ -535,7 +535,7 @@ public:
|
|||
*
|
||||
* });
|
||||
*/
|
||||
DeferredGet &get(const std::string &queue, int flags = 0);
|
||||
DeferredGet &get(const std::string_view &queue, int flags = 0);
|
||||
|
||||
/**
|
||||
* Acknowledge a message
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
* String field types for amqp
|
||||
*
|
||||
* @copyright 2014 - 2020 Copernica BV
|
||||
* @copyright 2014 - 2023 Copernica BV
|
||||
*/
|
||||
|
||||
/**
|
||||
|
|
@ -47,6 +47,12 @@ public:
|
|||
*/
|
||||
StringField(const std::string &value) : _data(value) {}
|
||||
|
||||
/**
|
||||
* Construct based on a std::string
|
||||
* @param value string value
|
||||
*/
|
||||
StringField(const std::string_view &value) : _data(value) {}
|
||||
|
||||
/**
|
||||
* Construct based on a std::string
|
||||
* @param value string value
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
CPP = g++
|
||||
RM = rm -f
|
||||
CPPFLAGS = -Wall -c -I../include -std=c++11 -MD -Wno-class-conversion
|
||||
CPPFLAGS = -Wall -c -I../include -std=c++17 -MD -Wno-class-conversion
|
||||
LD = g++
|
||||
LD_FLAGS = -Wall -shared
|
||||
SHARED_LIB = lib$(LIBRARY_NAME).so.$(VERSION)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
* Class describing a basic cancel frame
|
||||
*
|
||||
* @copyright 2014 - 2022 Copernica BV
|
||||
* @copyright 2014 - 2023 Copernica BV
|
||||
*/
|
||||
|
||||
/**
|
||||
|
|
@ -58,7 +58,7 @@ public:
|
|||
* @param consumerTag consumertag specified by client of provided by server
|
||||
* @param noWait whether to wait for a response.
|
||||
*/
|
||||
BasicCancelFrame(uint16_t channel, const std::string& consumerTag, bool noWait = false) :
|
||||
BasicCancelFrame(uint16_t channel, const std::string_view &consumerTag, bool noWait = false) :
|
||||
BasicFrame(channel, (uint32_t)(consumerTag.size() + 2)), // 1 for extra string size, 1 for bool
|
||||
_consumerTag(consumerTag),
|
||||
_noWait(noWait) {}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
* Class describing a basic consume frame
|
||||
*
|
||||
* @copyright 2014 Copernica BV
|
||||
* @copyright 2014 - 2023 Copernica BV
|
||||
*/
|
||||
|
||||
/**
|
||||
|
|
@ -85,7 +85,7 @@ public:
|
|||
* @param noWait don't wait for a response
|
||||
* @param filter additional arguments
|
||||
*/
|
||||
BasicConsumeFrame(uint16_t channel, const std::string& queueName, const std::string& consumerTag, bool noLocal = false, bool noAck = false, bool exclusive = false, bool noWait = false, const Table& filter = {}) :
|
||||
BasicConsumeFrame(uint16_t channel, const std::string_view &queueName, const std::string_view &consumerTag, bool noLocal = false, bool noAck = false, bool exclusive = false, bool noWait = false, const Table& filter = {}) :
|
||||
BasicFrame(channel, (uint32_t)(queueName.length() + consumerTag.length() + 5 + filter.size())), // size of vars, +1 for each shortstring size, +1 for bools, +2 for deprecated value
|
||||
_queueName(queueName),
|
||||
_consumerTag(consumerTag),
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
* Class describing a basic get frame
|
||||
*
|
||||
* @copyright 2014 Copernica BV
|
||||
* @copyright 2014 - 2023 Copernica BV
|
||||
*/
|
||||
|
||||
/**
|
||||
|
|
@ -58,7 +58,7 @@ public:
|
|||
* @param queue name of the queue
|
||||
* @param noAck whether server expects acknowledgements for messages
|
||||
*/
|
||||
BasicGetFrame(uint16_t channel, const std::string& queue, bool noAck = false) :
|
||||
BasicGetFrame(uint16_t channel, const std::string_view &queue, bool noAck = false) :
|
||||
BasicFrame(channel, (uint32_t)(queue.length() + 4)), // 1 for bool, 1 for string size, 2 for deprecated field
|
||||
_queue(queue),
|
||||
_noAck(noAck)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
* Class describing a basic publish frame
|
||||
*
|
||||
* @copyright 2014 Copernica BV
|
||||
* @copyright 2014 - 2023 Copernica BV
|
||||
*/
|
||||
|
||||
/**
|
||||
|
|
@ -69,7 +69,7 @@ public:
|
|||
* @param mandatory indicate mandatory routing @default = false
|
||||
* @param immediate request immediate delivery @default = false
|
||||
*/
|
||||
BasicPublishFrame(uint16_t channel, const std::string& exchange = "", const std::string& routingKey = "", bool mandatory = false, bool immediate = false) :
|
||||
BasicPublishFrame(uint16_t channel, const std::string_view &exchange = "", const std::string_view &routingKey = "", bool mandatory = false, bool immediate = false) :
|
||||
BasicFrame(channel, (uint32_t)(exchange.length() + routingKey.length() + 5)), // 1 extra per string (for the size), 1 for bools, 2 for deprecated field
|
||||
_exchange(exchange),
|
||||
_routingKey(routingKey),
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* Implementation for a channel
|
||||
*
|
||||
* @copyright 2014 - 2022 Copernica BV
|
||||
* @copyright 2014 - 2023 Copernica BV
|
||||
*/
|
||||
#include "includes.h"
|
||||
#include "basicgetokframe.h"
|
||||
|
|
@ -279,7 +279,7 @@ Deferred &ChannelImpl::close()
|
|||
* This function returns a deferred handler. Callbacks can be installed
|
||||
* using onSuccess(), onError() and onFinalize() methods.
|
||||
*/
|
||||
Deferred &ChannelImpl::declareExchange(const std::string &name, ExchangeType type, int flags, const Table &arguments)
|
||||
Deferred &ChannelImpl::declareExchange(const std::string_view &name, ExchangeType type, int flags, const Table &arguments)
|
||||
{
|
||||
// convert exchange type
|
||||
const char *exchangeType = "";
|
||||
|
|
@ -314,7 +314,7 @@ Deferred &ChannelImpl::declareExchange(const std::string &name, ExchangeType typ
|
|||
* This function returns a deferred handler. Callbacks can be installed
|
||||
* using onSuccess(), onError() and onFinalize() methods.
|
||||
*/
|
||||
Deferred &ChannelImpl::bindExchange(const std::string &source, const std::string &target, const std::string &routingkey, const Table &arguments)
|
||||
Deferred &ChannelImpl::bindExchange(const std::string_view &source, const std::string_view &target, const std::string_view &routingkey, const Table &arguments)
|
||||
{
|
||||
// send exchange bind frame
|
||||
return push(ExchangeBindFrame(_id, target, source, routingkey, false, arguments));
|
||||
|
|
@ -331,7 +331,7 @@ Deferred &ChannelImpl::bindExchange(const std::string &source, const std::string
|
|||
* This function returns a deferred handler. Callbacks can be installed
|
||||
* using onSuccess(), onError() and onFinalize() methods.
|
||||
*/
|
||||
Deferred &ChannelImpl::unbindExchange(const std::string &source, const std::string &target, const std::string &routingkey, const Table &arguments)
|
||||
Deferred &ChannelImpl::unbindExchange(const std::string_view &source, const std::string_view &target, const std::string_view &routingkey, const Table &arguments)
|
||||
{
|
||||
// send exchange unbind frame
|
||||
return push(ExchangeUnbindFrame(_id, target, source, routingkey, false, arguments));
|
||||
|
|
@ -346,7 +346,7 @@ Deferred &ChannelImpl::unbindExchange(const std::string &source, const std::stri
|
|||
* This function returns a deferred handler. Callbacks can be installed
|
||||
* using onSuccess(), onError() and onFinalize() methods.
|
||||
*/
|
||||
Deferred &ChannelImpl::removeExchange(const std::string &name, int flags)
|
||||
Deferred &ChannelImpl::removeExchange(const std::string_view &name, int flags)
|
||||
{
|
||||
// send delete exchange frame
|
||||
return push(ExchangeDeleteFrame(_id, name, (flags & ifunused) != 0, false));
|
||||
|
|
@ -361,7 +361,7 @@ Deferred &ChannelImpl::removeExchange(const std::string &name, int flags)
|
|||
* This function returns a deferred handler. Callbacks can be installed
|
||||
* using onSuccess(), onError() and onFinalize() methods.
|
||||
*/
|
||||
DeferredQueue &ChannelImpl::declareQueue(const std::string &name, int flags, const Table &arguments)
|
||||
DeferredQueue &ChannelImpl::declareQueue(const std::string_view &name, int flags, const Table &arguments)
|
||||
{
|
||||
// the frame to send
|
||||
QueueDeclareFrame frame(_id, name, (flags & passive) != 0, (flags & durable) != 0, (flags & exclusive) != 0, (flags & autodelete) != 0, false, arguments);
|
||||
|
|
@ -387,7 +387,7 @@ DeferredQueue &ChannelImpl::declareQueue(const std::string &name, int flags, con
|
|||
* This function returns a deferred handler. Callbacks can be installed
|
||||
* using onSuccess(), onError() and onFinalize() methods.
|
||||
*/
|
||||
Deferred &ChannelImpl::bindQueue(const std::string &exchangeName, const std::string &queueName, const std::string &routingkey, const Table &arguments)
|
||||
Deferred &ChannelImpl::bindQueue(const std::string_view &exchangeName, const std::string_view &queueName, const std::string_view &routingkey, const Table &arguments)
|
||||
{
|
||||
// send the bind queue frame
|
||||
return push(QueueBindFrame(_id, queueName, exchangeName, routingkey, false, arguments));
|
||||
|
|
@ -404,7 +404,7 @@ Deferred &ChannelImpl::bindQueue(const std::string &exchangeName, const std::str
|
|||
* This function returns a deferred handler. Callbacks can be installed
|
||||
* using onSuccess(), onError() and onFinalize() methods.
|
||||
*/
|
||||
Deferred &ChannelImpl::unbindQueue(const std::string &exchange, const std::string &queue, const std::string &routingkey, const Table &arguments)
|
||||
Deferred &ChannelImpl::unbindQueue(const std::string_view &exchange, const std::string_view &queue, const std::string_view &routingkey, const Table &arguments)
|
||||
{
|
||||
// send the unbind queue frame
|
||||
return push(QueueUnbindFrame(_id, queue, exchange, routingkey, arguments));
|
||||
|
|
@ -427,7 +427,7 @@ Deferred &ChannelImpl::unbindQueue(const std::string &exchange, const std::strin
|
|||
*
|
||||
* });
|
||||
*/
|
||||
DeferredDelete &ChannelImpl::purgeQueue(const std::string &name)
|
||||
DeferredDelete &ChannelImpl::purgeQueue(const std::string_view &name)
|
||||
{
|
||||
// the frame to send
|
||||
QueuePurgeFrame frame(_id, name, false);
|
||||
|
|
@ -460,7 +460,7 @@ DeferredDelete &ChannelImpl::purgeQueue(const std::string &name)
|
|||
*
|
||||
* });
|
||||
*/
|
||||
DeferredDelete &ChannelImpl::removeQueue(const std::string &name, int flags)
|
||||
DeferredDelete &ChannelImpl::removeQueue(const std::string_view &name, int flags)
|
||||
{
|
||||
// the frame to send
|
||||
QueueDeleteFrame frame(_id, name, (flags & ifunused) != 0, (flags & ifempty) != 0, false);
|
||||
|
|
@ -486,7 +486,7 @@ DeferredDelete &ChannelImpl::removeQueue(const std::string &name, int flags)
|
|||
* @param flags
|
||||
* @return bool
|
||||
*/
|
||||
bool ChannelImpl::publish(const std::string &exchange, const std::string &routingKey, const Envelope &envelope, int flags)
|
||||
bool ChannelImpl::publish(const std::string_view &exchange, const std::string_view &routingKey, const Envelope &envelope, int flags)
|
||||
{
|
||||
// we are going to send out multiple frames, each one will trigger a call to the handler,
|
||||
// which in turn could destruct the channel object, we need to monitor that
|
||||
|
|
@ -574,7 +574,7 @@ Deferred &ChannelImpl::setQos(uint16_t prefetchCount, bool global)
|
|||
*
|
||||
* });
|
||||
*/
|
||||
DeferredConsumer& ChannelImpl::consume(const std::string &queue, const std::string &tag, int flags, const Table &arguments)
|
||||
DeferredConsumer& ChannelImpl::consume(const std::string_view &queue, const std::string_view &tag, int flags, const Table &arguments)
|
||||
{
|
||||
// the frame to send
|
||||
BasicConsumeFrame frame(_id, queue, tag, (flags & nolocal) != 0, (flags & noack) != 0, (flags & exclusive) != 0, false, arguments);
|
||||
|
|
@ -624,7 +624,7 @@ DeferredRecall &ChannelImpl::recall()
|
|||
*
|
||||
* });
|
||||
*/
|
||||
DeferredCancel &ChannelImpl::cancel(const std::string &tag)
|
||||
DeferredCancel &ChannelImpl::cancel(const std::string_view &tag)
|
||||
{
|
||||
// the cancel frame to send
|
||||
BasicCancelFrame frame(_id, tag, false);
|
||||
|
|
@ -671,7 +671,7 @@ DeferredCancel &ChannelImpl::cancel(const std::string &tag)
|
|||
*
|
||||
* });
|
||||
*/
|
||||
DeferredGet &ChannelImpl::get(const std::string &queue, int flags)
|
||||
DeferredGet &ChannelImpl::get(const std::string_view &queue, int flags)
|
||||
{
|
||||
// the get frame to send
|
||||
BasicGetFrame frame(_id, queue, (flags & noack) != 0);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
* Exchangebindframe.h
|
||||
*
|
||||
* @copyright 2014 Copernica BV
|
||||
* @copyright 2014 - 2023 Copernica BV
|
||||
*/
|
||||
|
||||
/**
|
||||
|
|
@ -94,7 +94,7 @@ public:
|
|||
* @param noWait
|
||||
* @param arguments
|
||||
*/
|
||||
ExchangeBindFrame(uint16_t channel, const std::string &destination, const std::string &source, const std::string &routingKey, bool noWait, const Table &arguments) :
|
||||
ExchangeBindFrame(uint16_t channel, const std::string_view &destination, const std::string_view &source, const std::string_view &routingKey, bool noWait, const Table &arguments) :
|
||||
ExchangeFrame(channel, (uint32_t)(destination.length() + source.length() + routingKey.length() + arguments.size() + 6)), // 1 for each string, 1 for booleanset, 2 for deprecated field
|
||||
_destination(destination),
|
||||
_source(source),
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
* Class describing an AMQP exchange declare frame
|
||||
*
|
||||
* @copyright 2014 - 2018 Copernica BV
|
||||
* @copyright 2014 - 2023 Copernica BV
|
||||
*/
|
||||
|
||||
/**
|
||||
|
|
@ -82,7 +82,7 @@ public:
|
|||
* @param noWait do not wait on response
|
||||
* @param arguments additional arguments
|
||||
*/
|
||||
ExchangeDeclareFrame(uint16_t channel, const std::string& name, const char *type, bool passive, bool durable, bool autodelete, bool internal, bool nowait, const Table& arguments) :
|
||||
ExchangeDeclareFrame(uint16_t channel, const std::string_view& name, const char *type, bool passive, bool durable, bool autodelete, bool internal, bool nowait, const Table& arguments) :
|
||||
ExchangeFrame(channel, (uint32_t)(name.length() + strlen(type) + arguments.size() + 5)), // size of name, type and arguments + 1 (all booleans are stored in 1 byte) + 2 (deprecated short) + 2 (string sizes)
|
||||
_name(name),
|
||||
_type(type),
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
* Class describing an AMQP exchange delete frame
|
||||
*
|
||||
* @copyright 2014 Copernica BV
|
||||
* @copyright 2014 - 2023 Copernica BV
|
||||
*/
|
||||
|
||||
/**
|
||||
|
|
@ -72,7 +72,7 @@ public:
|
|||
* @param bool ifUnused Delete only if frame is not used
|
||||
* @param bool noWait Do not wait for a response
|
||||
*/
|
||||
ExchangeDeleteFrame(uint16_t channel, const std::string& name, bool ifUnused = false, bool noWait = false) :
|
||||
ExchangeDeleteFrame(uint16_t channel, const std::string_view &name, bool ifUnused = false, bool noWait = false) :
|
||||
ExchangeFrame(channel, (uint32_t)(name.length() + 4)), // length of the name, 1 byte for encoding this length, 1 for bools, 2 for deprecated short
|
||||
_name(name),
|
||||
_bools(ifUnused, noWait)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
* Exchangeunbindframe.h
|
||||
*
|
||||
* @copyright 2014 Copernica BV
|
||||
* @copyright 2014 - 2023 Copernica BV
|
||||
*/
|
||||
|
||||
/**
|
||||
|
|
@ -94,7 +94,7 @@ public:
|
|||
* @param noWait
|
||||
* @param arguments
|
||||
*/
|
||||
ExchangeUnbindFrame(uint16_t channel, const std::string &destination, const std::string &source, const std::string &routingKey, bool noWait, const Table &arguments) :
|
||||
ExchangeUnbindFrame(uint16_t channel, const std::string_view &destination, const std::string_view &source, const std::string_view &routingKey, bool noWait, const Table &arguments) :
|
||||
ExchangeFrame(channel, (uint32_t)(destination.length() + source.length() + routingKey.length() + arguments.size() + 6)), // 1 for each string, 1 for booleanset, 2 for deprecated field
|
||||
_destination(destination),
|
||||
_source(source),
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
* Class describing an AMQP queue bind frame
|
||||
*
|
||||
* @copyright 2014 Copernica BV
|
||||
* @copyright 2014 - 2023 Copernica BV
|
||||
*/
|
||||
|
||||
/**
|
||||
|
|
@ -86,7 +86,7 @@ public:
|
|||
* @param Bool noWait do not wait for a response
|
||||
* @param Table arguments additional arguments
|
||||
*/
|
||||
QueueBindFrame(uint16_t channel, const std::string& name, const std::string& exchange, const std::string& routingKey = "", bool noWait = false, const Table& arguments = {}) :
|
||||
QueueBindFrame(uint16_t channel, const std::string_view &name, const std::string_view &exchange, const std::string_view &routingKey = "", bool noWait = false, const Table& arguments = {}) :
|
||||
QueueFrame(channel, (uint32_t)(name.length() + exchange.length() + routingKey.length() + arguments.size() + 6) ), // 3 extra per string, 1 for bools, 2 for deprecated field
|
||||
_name(name),
|
||||
_exchange(exchange),
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
* Class describing an AMQP queue declare frame
|
||||
*
|
||||
* @copyright 2014 Copernica BV
|
||||
* @copyright 2014 - 2023 Copernica BV
|
||||
*/
|
||||
|
||||
/**
|
||||
|
|
@ -79,7 +79,7 @@ public:
|
|||
* @param Bool noWait whether to wait for a return value
|
||||
* @param Table arguments additional arguments, implementation dependent
|
||||
*/
|
||||
QueueDeclareFrame(uint16_t channel, const std::string& name = "", bool passive = false, bool durable = false, bool exclusive = false, bool autoDelete = false, bool noWait = false, const Table& arguments = {}) :
|
||||
QueueDeclareFrame(uint16_t channel, const std::string_view &name = "", bool passive = false, bool durable = false, bool exclusive = false, bool autoDelete = false, bool noWait = false, const Table& arguments = {}) :
|
||||
QueueFrame(channel, (uint32_t)(name.length() + arguments.size() + 4 ) ), // 1 extra for string size, 1 for bools, 2 for deprecated value
|
||||
_name(name),
|
||||
_bools(passive, durable, exclusive, autoDelete, noWait),
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
* Class describing an AMQP queue delete frame
|
||||
*
|
||||
* @copyright 2014 Copernica BV
|
||||
* @copyright 2014 - 2023 Copernica BV
|
||||
*/
|
||||
|
||||
/**
|
||||
|
|
@ -68,7 +68,7 @@ public:
|
|||
* @param ifEmpty delete only if empty
|
||||
* @param noWait do not wait on response
|
||||
*/
|
||||
QueueDeleteFrame(uint16_t channel, const std::string& name, bool ifUnused = false, bool ifEmpty = false, bool noWait = false) :
|
||||
QueueDeleteFrame(uint16_t channel, const std::string_view &name, bool ifUnused = false, bool ifEmpty = false, bool noWait = false) :
|
||||
QueueFrame(channel, (uint32_t)(name.length() + 4)), // 1 for string length, 1 for bools, 2 for deprecated field
|
||||
_name(name),
|
||||
_bools(ifUnused, ifEmpty, noWait)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
* Class describing an AMQP queue purge frame
|
||||
*
|
||||
* @copyright 2014 Copernica BV
|
||||
* @copyright 2014 - 2023 Copernica BV
|
||||
*/
|
||||
|
||||
/**
|
||||
|
|
@ -64,7 +64,7 @@ public:
|
|||
*
|
||||
* @return newly created Queuepurgeframe
|
||||
*/
|
||||
QueuePurgeFrame(uint16_t channel, const std::string& name, bool noWait = false) :
|
||||
QueuePurgeFrame(uint16_t channel, const std::string_view &name, bool noWait = false) :
|
||||
QueueFrame(channel, (uint32_t)(name.length() + 4)), // 1 extra for string length, 1 for bool, 2 for deprecated field
|
||||
_name(name),
|
||||
_noWait(noWait)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
* Class describing an AMQP queue bind frame
|
||||
*
|
||||
* @copyright 2014 Copernica BV
|
||||
* @copyright 2014 - 2023 Copernica BV
|
||||
*/
|
||||
|
||||
/**
|
||||
|
|
@ -79,7 +79,7 @@ public:
|
|||
* @param routingKey the routingKey
|
||||
* @param arguments additional arguments, implementation dependant.
|
||||
*/
|
||||
QueueUnbindFrame(uint16_t channel, const std::string& name, const std::string& exchange, const std::string& routingKey = "", const Table& arguments = {} ) :
|
||||
QueueUnbindFrame(uint16_t channel, const std::string_view &name, const std::string_view &exchange, const std::string_view &routingKey = "", const Table& arguments = {} ) :
|
||||
QueueFrame(channel, (uint32_t)(name.length() + exchange.length() + routingKey.length() + arguments.size() + 5) ), // 1 per string, 2 for deprecated field
|
||||
_name(name),
|
||||
_exchange(exchange),
|
||||
|
|
|
|||
Loading…
Reference in New Issue