Skip to content

Commit

Permalink
added more constructors to AMQP::Envelope
Browse files Browse the repository at this point in the history
  • Loading branch information
EmielBruijntjes committed Mar 27, 2023
1 parent 31ded89 commit cdcdaf7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
11 changes: 11 additions & 0 deletions include/amqpcpp/envelope.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,18 @@ class Envelope : public MetaData
* @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
Expand Down
8 changes: 3 additions & 5 deletions include/amqpcpp/metadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/

/**
Expand Down Expand Up @@ -127,14 +127,12 @@ class MetaData
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
Expand Down

0 comments on commit cdcdaf7

Please sign in to comment.