added more constructors to AMQP::Envelope

This commit is contained in:
Emiel Bruijntjes 2023-03-27 14:12:37 +02:00
parent 31ded89de5
commit cdcdaf79a3
2 changed files with 14 additions and 5 deletions

View File

@ -53,7 +53,18 @@ public:
* @param size
*/
Envelope(const char *body, uint64_t size) : MetaData(), _body(body), _bodySize(size) {}
Envelope(const std::string_view &body) : Envelope(body.data(), body.size()) {}
Envelope(const char *body) : Envelope(body, strlen(body)) {}
/**
* Constructor that preserves meta-data, but installs different body
* @param metadata
* @param body
* @param size
*/
Envelope(const MetaData &metadata, const char *body, uint64_t size) : MetaData(metadata), _body(body), _bodySize(size) {}
Envelope(const MetaData &metadata, const std::string_view &body) : Envelope(metadata, body.data(), body.size()) {}
Envelope(const MetaData &metadata, const char *body) : Envelope(metadata, body, strlen(body)) {}
/**
* Read envelope frmo an input-buffer

View File

@ -4,7 +4,7 @@
* With every published message a set of meta data is passed to. This class
* holds all that meta data.
*
* @copyright 2014 - 2017 Copernica BV
* @copyright 2014 - 2023 Copernica BV
*/
/**
@ -127,14 +127,12 @@ protected:
ShortString _clusterID;
public:
/**
* Protected constructor to ensure that this class can only be constructed
* in a derived class
* Constructor for empty meta data. Can be useful when user-space wants to preserve all meta-data
*/
MetaData() {}
public:
/**
* Read incoming frame
* @param frame